Lines Matching refs:bdev
350 struct bam_device *bdev; member
409 static inline void __iomem *bam_addr(struct bam_device *bdev, u32 pipe, in bam_addr() argument
412 const struct reg_offset_data r = bdev->layout[reg]; in bam_addr()
414 return bdev->regs + r.base_offset + in bam_addr()
417 r.ee_mult * bdev->ee; in bam_addr()
424 static void bam_reset(struct bam_device *bdev) in bam_reset() argument
430 val = readl_relaxed(bam_addr(bdev, 0, BAM_CTRL)); in bam_reset()
432 writel_relaxed(val, bam_addr(bdev, 0, BAM_CTRL)); in bam_reset()
434 writel_relaxed(val, bam_addr(bdev, 0, BAM_CTRL)); in bam_reset()
441 writel_relaxed(val, bam_addr(bdev, 0, BAM_CTRL)); in bam_reset()
445 bam_addr(bdev, 0, BAM_DESC_CNT_TRSHLD)); in bam_reset()
448 writel_relaxed(BAM_CNFG_BITS_DEFAULT, bam_addr(bdev, 0, BAM_CNFG_BITS)); in bam_reset()
452 bam_addr(bdev, 0, BAM_IRQ_EN)); in bam_reset()
455 writel_relaxed(BAM_IRQ_MSK, bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE)); in bam_reset()
466 struct bam_device *bdev = bchan->bdev; in bam_reset_channel() local
471 writel_relaxed(1, bam_addr(bdev, bchan->id, BAM_P_RST)); in bam_reset_channel()
472 writel_relaxed(0, bam_addr(bdev, bchan->id, BAM_P_RST)); in bam_reset_channel()
491 struct bam_device *bdev = bchan->bdev; in bam_chan_init_hw() local
502 bam_addr(bdev, bchan->id, BAM_P_DESC_FIFO_ADDR)); in bam_chan_init_hw()
504 bam_addr(bdev, bchan->id, BAM_P_FIFO_SIZES)); in bam_chan_init_hw()
508 bam_addr(bdev, bchan->id, BAM_P_IRQ_EN)); in bam_chan_init_hw()
511 val = readl_relaxed(bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE)); in bam_chan_init_hw()
513 writel_relaxed(val, bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE)); in bam_chan_init_hw()
523 writel_relaxed(val, bam_addr(bdev, bchan->id, BAM_P_CTRL)); in bam_chan_init_hw()
541 struct bam_device *bdev = bchan->bdev; in bam_alloc_chan() local
547 bchan->fifo_virt = dma_alloc_wc(bdev->dev, BAM_DESC_FIFO_SIZE, in bam_alloc_chan()
551 dev_err(bdev->dev, "Failed to allocate desc fifo\n"); in bam_alloc_chan()
555 if (bdev->active_channels++ == 0 && bdev->powered_remotely) in bam_alloc_chan()
556 bam_reset(bdev); in bam_alloc_chan()
579 struct bam_device *bdev = bchan->bdev; in bam_free_chan() local
584 ret = bam_pm_runtime_get_sync(bdev->dev); in bam_free_chan()
591 dev_err(bchan->bdev->dev, "Cannot free busy channel\n"); in bam_free_chan()
599 dma_free_wc(bdev->dev, BAM_DESC_FIFO_SIZE, bchan->fifo_virt, in bam_free_chan()
604 val = readl_relaxed(bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE)); in bam_free_chan()
606 writel_relaxed(val, bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE)); in bam_free_chan()
609 writel_relaxed(0, bam_addr(bdev, bchan->id, BAM_P_IRQ_EN)); in bam_free_chan()
611 if (--bdev->active_channels == 0 && bdev->powered_remotely) { in bam_free_chan()
613 val = readl_relaxed(bam_addr(bdev, 0, BAM_CTRL)); in bam_free_chan()
615 writel_relaxed(val, bam_addr(bdev, 0, BAM_CTRL)); in bam_free_chan()
619 pm_runtime_mark_last_busy(bdev->dev); in bam_free_chan()
620 pm_runtime_put_autosuspend(bdev->dev); in bam_free_chan()
661 struct bam_device *bdev = bchan->bdev; in bam_prep_slave_sg() local
670 dev_err(bdev->dev, "invalid dma direction\n"); in bam_prep_slave_sg()
783 struct bam_device *bdev = bchan->bdev; in bam_pause() local
787 ret = bam_pm_runtime_get_sync(bdev->dev); in bam_pause()
792 writel_relaxed(1, bam_addr(bdev, bchan->id, BAM_P_HALT)); in bam_pause()
795 pm_runtime_mark_last_busy(bdev->dev); in bam_pause()
796 pm_runtime_put_autosuspend(bdev->dev); in bam_pause()
809 struct bam_device *bdev = bchan->bdev; in bam_resume() local
813 ret = bam_pm_runtime_get_sync(bdev->dev); in bam_resume()
818 writel_relaxed(0, bam_addr(bdev, bchan->id, BAM_P_HALT)); in bam_resume()
821 pm_runtime_mark_last_busy(bdev->dev); in bam_resume()
822 pm_runtime_put_autosuspend(bdev->dev); in bam_resume()
834 static u32 process_channel_irqs(struct bam_device *bdev) in process_channel_irqs() argument
840 srcs = readl_relaxed(bam_addr(bdev, 0, BAM_IRQ_SRCS_EE)); in process_channel_irqs()
846 for (i = 0; i < bdev->num_channels; i++) { in process_channel_irqs()
847 struct bam_chan *bchan = &bdev->channels[i]; in process_channel_irqs()
853 pipe_stts = readl_relaxed(bam_addr(bdev, i, BAM_P_IRQ_STTS)); in process_channel_irqs()
855 writel_relaxed(pipe_stts, bam_addr(bdev, i, BAM_P_IRQ_CLR)); in process_channel_irqs()
859 offset = readl_relaxed(bam_addr(bdev, i, BAM_P_SW_OFSTS)) & in process_channel_irqs()
912 struct bam_device *bdev = data; in bam_dma_irq() local
916 srcs |= process_channel_irqs(bdev); in bam_dma_irq()
920 tasklet_schedule(&bdev->task); in bam_dma_irq()
922 ret = bam_pm_runtime_get_sync(bdev->dev); in bam_dma_irq()
927 clr_mask = readl_relaxed(bam_addr(bdev, 0, BAM_IRQ_STTS)); in bam_dma_irq()
935 writel_relaxed(clr_mask, bam_addr(bdev, 0, BAM_IRQ_CLR)); in bam_dma_irq()
938 pm_runtime_mark_last_busy(bdev->dev); in bam_dma_irq()
939 pm_runtime_put_autosuspend(bdev->dev); in bam_dma_irq()
1003 struct bam_device *bdev = bchan->bdev; in bam_apply_new_config() local
1006 if (!bdev->controlled_remotely) { in bam_apply_new_config()
1013 bam_addr(bdev, 0, BAM_DESC_CNT_TRSHLD)); in bam_apply_new_config()
1026 struct bam_device *bdev = bchan->bdev; in bam_start_dma() local
1040 ret = bam_pm_runtime_get_sync(bdev->dev); in bam_start_dma()
1111 bam_addr(bdev, bchan->id, BAM_P_EVNT_REG)); in bam_start_dma()
1113 pm_runtime_mark_last_busy(bdev->dev); in bam_start_dma()
1114 pm_runtime_put_autosuspend(bdev->dev); in bam_start_dma()
1125 struct bam_device *bdev = from_tasklet(bdev, t, task); in dma_tasklet() local
1131 for (i = 0; i < bdev->num_channels; i++) { in dma_tasklet()
1132 bchan = &bdev->channels[i]; in dma_tasklet()
1178 struct bam_device *bdev = container_of(of->of_dma_data, in bam_dma_xlate() local
1186 if (request >= bdev->num_channels) in bam_dma_xlate()
1189 return dma_get_slave_channel(&(bdev->channels[request].vc.chan)); in bam_dma_xlate()
1198 static int bam_init(struct bam_device *bdev) in bam_init() argument
1203 if (!bdev->num_ees) { in bam_init()
1204 val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION)); in bam_init()
1205 bdev->num_ees = (val >> NUM_EES_SHIFT) & NUM_EES_MASK; in bam_init()
1209 if (bdev->ee >= bdev->num_ees) in bam_init()
1212 if (!bdev->num_channels) { in bam_init()
1213 val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES)); in bam_init()
1214 bdev->num_channels = val & BAM_NUM_PIPES_MASK; in bam_init()
1218 if (!bdev->controlled_remotely && !bdev->powered_remotely) in bam_init()
1219 bam_reset(bdev); in bam_init()
1224 static void bam_channel_init(struct bam_device *bdev, struct bam_chan *bchan, in bam_channel_init() argument
1228 bchan->bdev = bdev; in bam_channel_init()
1230 vchan_init(&bchan->vc, &bdev->common); in bam_channel_init()
1246 struct bam_device *bdev; in bam_dma_probe() local
1251 bdev = devm_kzalloc(&pdev->dev, sizeof(*bdev), GFP_KERNEL); in bam_dma_probe()
1252 if (!bdev) in bam_dma_probe()
1255 bdev->dev = &pdev->dev; in bam_dma_probe()
1263 bdev->layout = match->data; in bam_dma_probe()
1266 bdev->regs = devm_ioremap_resource(&pdev->dev, iores); in bam_dma_probe()
1267 if (IS_ERR(bdev->regs)) in bam_dma_probe()
1268 return PTR_ERR(bdev->regs); in bam_dma_probe()
1270 bdev->irq = platform_get_irq(pdev, 0); in bam_dma_probe()
1271 if (bdev->irq < 0) in bam_dma_probe()
1272 return bdev->irq; in bam_dma_probe()
1274 ret = of_property_read_u32(pdev->dev.of_node, "qcom,ee", &bdev->ee); in bam_dma_probe()
1276 dev_err(bdev->dev, "Execution environment unspecified\n"); in bam_dma_probe()
1280 bdev->controlled_remotely = of_property_read_bool(pdev->dev.of_node, in bam_dma_probe()
1282 bdev->powered_remotely = of_property_read_bool(pdev->dev.of_node, in bam_dma_probe()
1285 if (bdev->controlled_remotely || bdev->powered_remotely) { in bam_dma_probe()
1287 &bdev->num_channels); in bam_dma_probe()
1289 dev_err(bdev->dev, "num-channels unspecified in dt\n"); in bam_dma_probe()
1292 &bdev->num_ees); in bam_dma_probe()
1294 dev_err(bdev->dev, "num-ees unspecified in dt\n"); in bam_dma_probe()
1297 if (bdev->controlled_remotely || bdev->powered_remotely) in bam_dma_probe()
1298 bdev->bamclk = devm_clk_get_optional(bdev->dev, "bam_clk"); in bam_dma_probe()
1300 bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk"); in bam_dma_probe()
1302 if (IS_ERR(bdev->bamclk)) in bam_dma_probe()
1303 return PTR_ERR(bdev->bamclk); in bam_dma_probe()
1305 ret = clk_prepare_enable(bdev->bamclk); in bam_dma_probe()
1307 dev_err(bdev->dev, "failed to prepare/enable clock\n"); in bam_dma_probe()
1311 ret = bam_init(bdev); in bam_dma_probe()
1315 tasklet_setup(&bdev->task, dma_tasklet); in bam_dma_probe()
1317 bdev->channels = devm_kcalloc(bdev->dev, bdev->num_channels, in bam_dma_probe()
1318 sizeof(*bdev->channels), GFP_KERNEL); in bam_dma_probe()
1320 if (!bdev->channels) { in bam_dma_probe()
1326 INIT_LIST_HEAD(&bdev->common.channels); in bam_dma_probe()
1328 for (i = 0; i < bdev->num_channels; i++) in bam_dma_probe()
1329 bam_channel_init(bdev, &bdev->channels[i], i); in bam_dma_probe()
1331 ret = devm_request_irq(bdev->dev, bdev->irq, bam_dma_irq, in bam_dma_probe()
1332 IRQF_TRIGGER_HIGH, "bam_dma", bdev); in bam_dma_probe()
1337 bdev->common.dev = bdev->dev; in bam_dma_probe()
1338 ret = dma_set_max_seg_size(bdev->common.dev, BAM_FIFO_SIZE); in bam_dma_probe()
1340 dev_err(bdev->dev, "cannot set maximum segment size\n"); in bam_dma_probe()
1344 platform_set_drvdata(pdev, bdev); in bam_dma_probe()
1347 dma_cap_zero(bdev->common.cap_mask); in bam_dma_probe()
1348 dma_cap_set(DMA_SLAVE, bdev->common.cap_mask); in bam_dma_probe()
1351 bdev->common.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); in bam_dma_probe()
1352 bdev->common.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; in bam_dma_probe()
1353 bdev->common.src_addr_widths = DMA_SLAVE_BUSWIDTH_4_BYTES; in bam_dma_probe()
1354 bdev->common.dst_addr_widths = DMA_SLAVE_BUSWIDTH_4_BYTES; in bam_dma_probe()
1355 bdev->common.device_alloc_chan_resources = bam_alloc_chan; in bam_dma_probe()
1356 bdev->common.device_free_chan_resources = bam_free_chan; in bam_dma_probe()
1357 bdev->common.device_prep_slave_sg = bam_prep_slave_sg; in bam_dma_probe()
1358 bdev->common.device_config = bam_slave_config; in bam_dma_probe()
1359 bdev->common.device_pause = bam_pause; in bam_dma_probe()
1360 bdev->common.device_resume = bam_resume; in bam_dma_probe()
1361 bdev->common.device_terminate_all = bam_dma_terminate_all; in bam_dma_probe()
1362 bdev->common.device_issue_pending = bam_issue_pending; in bam_dma_probe()
1363 bdev->common.device_tx_status = bam_tx_status; in bam_dma_probe()
1364 bdev->common.dev = bdev->dev; in bam_dma_probe()
1366 ret = dma_async_device_register(&bdev->common); in bam_dma_probe()
1368 dev_err(bdev->dev, "failed to register dma async device\n"); in bam_dma_probe()
1373 &bdev->common); in bam_dma_probe()
1377 if (!bdev->bamclk) { in bam_dma_probe()
1392 dma_async_device_unregister(&bdev->common); in bam_dma_probe()
1394 for (i = 0; i < bdev->num_channels; i++) in bam_dma_probe()
1395 tasklet_kill(&bdev->channels[i].vc.task); in bam_dma_probe()
1397 tasklet_kill(&bdev->task); in bam_dma_probe()
1399 clk_disable_unprepare(bdev->bamclk); in bam_dma_probe()
1406 struct bam_device *bdev = platform_get_drvdata(pdev); in bam_dma_remove() local
1412 dma_async_device_unregister(&bdev->common); in bam_dma_remove()
1415 writel_relaxed(0, bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE)); in bam_dma_remove()
1417 devm_free_irq(bdev->dev, bdev->irq, bdev); in bam_dma_remove()
1419 for (i = 0; i < bdev->num_channels; i++) { in bam_dma_remove()
1420 bam_dma_terminate_all(&bdev->channels[i].vc.chan); in bam_dma_remove()
1421 tasklet_kill(&bdev->channels[i].vc.task); in bam_dma_remove()
1423 if (!bdev->channels[i].fifo_virt) in bam_dma_remove()
1426 dma_free_wc(bdev->dev, BAM_DESC_FIFO_SIZE, in bam_dma_remove()
1427 bdev->channels[i].fifo_virt, in bam_dma_remove()
1428 bdev->channels[i].fifo_phys); in bam_dma_remove()
1431 tasklet_kill(&bdev->task); in bam_dma_remove()
1433 clk_disable_unprepare(bdev->bamclk); in bam_dma_remove()
1440 struct bam_device *bdev = dev_get_drvdata(dev); in bam_dma_runtime_suspend() local
1442 clk_disable(bdev->bamclk); in bam_dma_runtime_suspend()
1449 struct bam_device *bdev = dev_get_drvdata(dev); in bam_dma_runtime_resume() local
1452 ret = clk_enable(bdev->bamclk); in bam_dma_runtime_resume()
1463 struct bam_device *bdev = dev_get_drvdata(dev); in bam_dma_suspend() local
1465 if (bdev->bamclk) { in bam_dma_suspend()
1467 clk_unprepare(bdev->bamclk); in bam_dma_suspend()
1475 struct bam_device *bdev = dev_get_drvdata(dev); in bam_dma_resume() local
1478 if (bdev->bamclk) { in bam_dma_resume()
1479 ret = clk_prepare(bdev->bamclk); in bam_dma_resume()