Lines Matching full:sdc
1236 struct sun6i_dma_dev *sdc; in sun6i_dma_probe() local
1240 sdc = devm_kzalloc(&pdev->dev, sizeof(*sdc), GFP_KERNEL); in sun6i_dma_probe()
1241 if (!sdc) in sun6i_dma_probe()
1244 sdc->cfg = of_device_get_match_data(&pdev->dev); in sun6i_dma_probe()
1245 if (!sdc->cfg) in sun6i_dma_probe()
1249 sdc->base = devm_ioremap_resource(&pdev->dev, res); in sun6i_dma_probe()
1250 if (IS_ERR(sdc->base)) in sun6i_dma_probe()
1251 return PTR_ERR(sdc->base); in sun6i_dma_probe()
1253 sdc->irq = platform_get_irq(pdev, 0); in sun6i_dma_probe()
1254 if (sdc->irq < 0) in sun6i_dma_probe()
1255 return sdc->irq; in sun6i_dma_probe()
1257 sdc->clk = devm_clk_get(&pdev->dev, NULL); in sun6i_dma_probe()
1258 if (IS_ERR(sdc->clk)) { in sun6i_dma_probe()
1260 return PTR_ERR(sdc->clk); in sun6i_dma_probe()
1263 if (sdc->cfg->has_mbus_clk) { in sun6i_dma_probe()
1264 sdc->clk_mbus = devm_clk_get(&pdev->dev, "mbus"); in sun6i_dma_probe()
1265 if (IS_ERR(sdc->clk_mbus)) { in sun6i_dma_probe()
1267 return PTR_ERR(sdc->clk_mbus); in sun6i_dma_probe()
1271 sdc->rstc = devm_reset_control_get(&pdev->dev, NULL); in sun6i_dma_probe()
1272 if (IS_ERR(sdc->rstc)) { in sun6i_dma_probe()
1274 return PTR_ERR(sdc->rstc); in sun6i_dma_probe()
1277 sdc->pool = dmam_pool_create(dev_name(&pdev->dev), &pdev->dev, in sun6i_dma_probe()
1279 if (!sdc->pool) { in sun6i_dma_probe()
1284 platform_set_drvdata(pdev, sdc); in sun6i_dma_probe()
1285 INIT_LIST_HEAD(&sdc->pending); in sun6i_dma_probe()
1286 spin_lock_init(&sdc->lock); in sun6i_dma_probe()
1288 dma_cap_set(DMA_PRIVATE, sdc->slave.cap_mask); in sun6i_dma_probe()
1289 dma_cap_set(DMA_MEMCPY, sdc->slave.cap_mask); in sun6i_dma_probe()
1290 dma_cap_set(DMA_SLAVE, sdc->slave.cap_mask); in sun6i_dma_probe()
1291 dma_cap_set(DMA_CYCLIC, sdc->slave.cap_mask); in sun6i_dma_probe()
1293 INIT_LIST_HEAD(&sdc->slave.channels); in sun6i_dma_probe()
1294 sdc->slave.device_free_chan_resources = sun6i_dma_free_chan_resources; in sun6i_dma_probe()
1295 sdc->slave.device_tx_status = sun6i_dma_tx_status; in sun6i_dma_probe()
1296 sdc->slave.device_issue_pending = sun6i_dma_issue_pending; in sun6i_dma_probe()
1297 sdc->slave.device_prep_slave_sg = sun6i_dma_prep_slave_sg; in sun6i_dma_probe()
1298 sdc->slave.device_prep_dma_memcpy = sun6i_dma_prep_dma_memcpy; in sun6i_dma_probe()
1299 sdc->slave.device_prep_dma_cyclic = sun6i_dma_prep_dma_cyclic; in sun6i_dma_probe()
1300 sdc->slave.copy_align = DMAENGINE_ALIGN_4_BYTES; in sun6i_dma_probe()
1301 sdc->slave.device_config = sun6i_dma_config; in sun6i_dma_probe()
1302 sdc->slave.device_pause = sun6i_dma_pause; in sun6i_dma_probe()
1303 sdc->slave.device_resume = sun6i_dma_resume; in sun6i_dma_probe()
1304 sdc->slave.device_terminate_all = sun6i_dma_terminate_all; in sun6i_dma_probe()
1305 sdc->slave.src_addr_widths = sdc->cfg->src_addr_widths; in sun6i_dma_probe()
1306 sdc->slave.dst_addr_widths = sdc->cfg->dst_addr_widths; in sun6i_dma_probe()
1307 sdc->slave.directions = BIT(DMA_DEV_TO_MEM) | in sun6i_dma_probe()
1309 sdc->slave.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; in sun6i_dma_probe()
1310 sdc->slave.dev = &pdev->dev; in sun6i_dma_probe()
1312 sdc->num_pchans = sdc->cfg->nr_max_channels; in sun6i_dma_probe()
1313 sdc->num_vchans = sdc->cfg->nr_max_vchans; in sun6i_dma_probe()
1314 sdc->max_request = sdc->cfg->nr_max_requests; in sun6i_dma_probe()
1316 ret = of_property_read_u32(np, "dma-channels", &sdc->num_pchans); in sun6i_dma_probe()
1317 if (ret && !sdc->num_pchans) { in sun6i_dma_probe()
1322 ret = of_property_read_u32(np, "dma-requests", &sdc->max_request); in sun6i_dma_probe()
1323 if (ret && !sdc->max_request) { in sun6i_dma_probe()
1326 sdc->max_request = DMA_CHAN_MAX_DRQ_A31; in sun6i_dma_probe()
1333 if (!sdc->num_vchans) in sun6i_dma_probe()
1334 sdc->num_vchans = 2 * (sdc->max_request + 1); in sun6i_dma_probe()
1336 sdc->pchans = devm_kcalloc(&pdev->dev, sdc->num_pchans, in sun6i_dma_probe()
1338 if (!sdc->pchans) in sun6i_dma_probe()
1341 sdc->vchans = devm_kcalloc(&pdev->dev, sdc->num_vchans, in sun6i_dma_probe()
1343 if (!sdc->vchans) in sun6i_dma_probe()
1346 tasklet_setup(&sdc->task, sun6i_dma_tasklet); in sun6i_dma_probe()
1348 for (i = 0; i < sdc->num_pchans; i++) { in sun6i_dma_probe()
1349 struct sun6i_pchan *pchan = &sdc->pchans[i]; in sun6i_dma_probe()
1352 pchan->base = sdc->base + 0x100 + i * 0x40; in sun6i_dma_probe()
1355 for (i = 0; i < sdc->num_vchans; i++) { in sun6i_dma_probe()
1356 struct sun6i_vchan *vchan = &sdc->vchans[i]; in sun6i_dma_probe()
1360 vchan_init(&vchan->vc, &sdc->slave); in sun6i_dma_probe()
1363 ret = reset_control_deassert(sdc->rstc); in sun6i_dma_probe()
1369 ret = clk_prepare_enable(sdc->clk); in sun6i_dma_probe()
1375 if (sdc->cfg->has_mbus_clk) { in sun6i_dma_probe()
1376 ret = clk_prepare_enable(sdc->clk_mbus); in sun6i_dma_probe()
1383 ret = devm_request_irq(&pdev->dev, sdc->irq, sun6i_dma_interrupt, 0, in sun6i_dma_probe()
1384 dev_name(&pdev->dev), sdc); in sun6i_dma_probe()
1390 ret = dma_async_device_register(&sdc->slave); in sun6i_dma_probe()
1397 sdc); in sun6i_dma_probe()
1403 if (sdc->cfg->clock_autogate_enable) in sun6i_dma_probe()
1404 sdc->cfg->clock_autogate_enable(sdc); in sun6i_dma_probe()
1409 dma_async_device_unregister(&sdc->slave); in sun6i_dma_probe()
1411 sun6i_kill_tasklet(sdc); in sun6i_dma_probe()
1413 clk_disable_unprepare(sdc->clk_mbus); in sun6i_dma_probe()
1415 clk_disable_unprepare(sdc->clk); in sun6i_dma_probe()
1417 reset_control_assert(sdc->rstc); in sun6i_dma_probe()
1419 sun6i_dma_free(sdc); in sun6i_dma_probe()
1425 struct sun6i_dma_dev *sdc = platform_get_drvdata(pdev); in sun6i_dma_remove() local
1428 dma_async_device_unregister(&sdc->slave); in sun6i_dma_remove()
1430 sun6i_kill_tasklet(sdc); in sun6i_dma_remove()
1432 clk_disable_unprepare(sdc->clk_mbus); in sun6i_dma_remove()
1433 clk_disable_unprepare(sdc->clk); in sun6i_dma_remove()
1434 reset_control_assert(sdc->rstc); in sun6i_dma_remove()
1436 sun6i_dma_free(sdc); in sun6i_dma_remove()