Lines Matching refs:bdev
350 struct bam_device *bdev;
403 * @bdev: bam device
407 static inline void __iomem *bam_addr(struct bam_device *bdev, u32 pipe,
410 const struct reg_offset_data r = bdev->layout[reg];
412 return bdev->regs + r.base_offset +
415 r.ee_mult * bdev->ee;
426 struct bam_device *bdev = bchan->bdev;
431 writel_relaxed(1, bam_addr(bdev, bchan->id, BAM_P_RST));
432 writel_relaxed(0, bam_addr(bdev, bchan->id, BAM_P_RST));
451 struct bam_device *bdev = bchan->bdev;
462 bam_addr(bdev, bchan->id, BAM_P_DESC_FIFO_ADDR));
464 bam_addr(bdev, bchan->id, BAM_P_FIFO_SIZES));
468 bam_addr(bdev, bchan->id, BAM_P_IRQ_EN));
471 val = readl_relaxed(bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE));
473 writel_relaxed(val, bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE));
483 writel_relaxed(val, bam_addr(bdev, bchan->id, BAM_P_CTRL));
501 struct bam_device *bdev = bchan->bdev;
507 bchan->fifo_virt = dma_alloc_wc(bdev->dev, BAM_DESC_FIFO_SIZE,
511 dev_err(bdev->dev, "Failed to allocate desc fifo\n");
536 struct bam_device *bdev = bchan->bdev;
541 ret = bam_pm_runtime_get_sync(bdev->dev);
548 dev_err(bchan->bdev->dev, "Cannot free busy channel\n");
556 dma_free_wc(bdev->dev, BAM_DESC_FIFO_SIZE, bchan->fifo_virt,
561 val = readl_relaxed(bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE));
563 writel_relaxed(val, bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE));
566 writel_relaxed(0, bam_addr(bdev, bchan->id, BAM_P_IRQ_EN));
569 pm_runtime_mark_last_busy(bdev->dev);
570 pm_runtime_put_autosuspend(bdev->dev);
611 struct bam_device *bdev = bchan->bdev;
620 dev_err(bdev->dev, "invalid dma direction\n");
737 struct bam_device *bdev = bchan->bdev;
741 ret = bam_pm_runtime_get_sync(bdev->dev);
746 writel_relaxed(1, bam_addr(bdev, bchan->id, BAM_P_HALT));
749 pm_runtime_mark_last_busy(bdev->dev);
750 pm_runtime_put_autosuspend(bdev->dev);
763 struct bam_device *bdev = bchan->bdev;
767 ret = bam_pm_runtime_get_sync(bdev->dev);
772 writel_relaxed(0, bam_addr(bdev, bchan->id, BAM_P_HALT));
775 pm_runtime_mark_last_busy(bdev->dev);
776 pm_runtime_put_autosuspend(bdev->dev);
783 * @bdev: bam controller
788 static u32 process_channel_irqs(struct bam_device *bdev)
794 srcs = readl_relaxed(bam_addr(bdev, 0, BAM_IRQ_SRCS_EE));
800 for (i = 0; i < bdev->num_channels; i++) {
801 struct bam_chan *bchan = &bdev->channels[i];
807 pipe_stts = readl_relaxed(bam_addr(bdev, i, BAM_P_IRQ_STTS));
809 writel_relaxed(pipe_stts, bam_addr(bdev, i, BAM_P_IRQ_CLR));
813 offset = readl_relaxed(bam_addr(bdev, i, BAM_P_SW_OFSTS)) &
866 struct bam_device *bdev = data;
870 srcs |= process_channel_irqs(bdev);
874 tasklet_schedule(&bdev->task);
876 ret = bam_pm_runtime_get_sync(bdev->dev);
881 clr_mask = readl_relaxed(bam_addr(bdev, 0, BAM_IRQ_STTS));
889 writel_relaxed(clr_mask, bam_addr(bdev, 0, BAM_IRQ_CLR));
892 pm_runtime_mark_last_busy(bdev->dev);
893 pm_runtime_put_autosuspend(bdev->dev);
957 struct bam_device *bdev = bchan->bdev;
960 if (!bdev->controlled_remotely) {
967 bam_addr(bdev, 0, BAM_DESC_CNT_TRSHLD));
980 struct bam_device *bdev = bchan->bdev;
994 ret = bam_pm_runtime_get_sync(bdev->dev);
1065 bam_addr(bdev, bchan->id, BAM_P_EVNT_REG));
1067 pm_runtime_mark_last_busy(bdev->dev);
1068 pm_runtime_put_autosuspend(bdev->dev);
1079 struct bam_device *bdev = from_tasklet(bdev, t, task);
1085 for (i = 0; i < bdev->num_channels; i++) {
1086 bchan = &bdev->channels[i];
1132 struct bam_device *bdev = container_of(of->of_dma_data,
1140 if (request >= bdev->num_channels)
1143 return dma_get_slave_channel(&(bdev->channels[request].vc.chan));
1148 * @bdev: bam device
1152 static int bam_init(struct bam_device *bdev)
1157 if (!bdev->num_ees) {
1158 val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION));
1159 bdev->num_ees = (val >> NUM_EES_SHIFT) & NUM_EES_MASK;
1163 if (bdev->ee >= bdev->num_ees)
1166 if (!bdev->num_channels) {
1167 val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES));
1168 bdev->num_channels = val & BAM_NUM_PIPES_MASK;
1171 if (bdev->controlled_remotely)
1176 val = readl_relaxed(bam_addr(bdev, 0, BAM_CTRL));
1178 writel_relaxed(val, bam_addr(bdev, 0, BAM_CTRL));
1180 writel_relaxed(val, bam_addr(bdev, 0, BAM_CTRL));
1187 writel_relaxed(val, bam_addr(bdev, 0, BAM_CTRL));
1191 bam_addr(bdev, 0, BAM_DESC_CNT_TRSHLD));
1194 writel_relaxed(BAM_CNFG_BITS_DEFAULT, bam_addr(bdev, 0, BAM_CNFG_BITS));
1198 bam_addr(bdev, 0, BAM_IRQ_EN));
1201 writel_relaxed(BAM_IRQ_MSK, bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE));
1206 static void bam_channel_init(struct bam_device *bdev, struct bam_chan *bchan,
1210 bchan->bdev = bdev;
1212 vchan_init(&bchan->vc, &bdev->common);
1228 struct bam_device *bdev;
1233 bdev = devm_kzalloc(&pdev->dev, sizeof(*bdev), GFP_KERNEL);
1234 if (!bdev)
1237 bdev->dev = &pdev->dev;
1245 bdev->layout = match->data;
1248 bdev->regs = devm_ioremap_resource(&pdev->dev, iores);
1249 if (IS_ERR(bdev->regs))
1250 return PTR_ERR(bdev->regs);
1252 bdev->irq = platform_get_irq(pdev, 0);
1253 if (bdev->irq < 0)
1254 return bdev->irq;
1256 ret = of_property_read_u32(pdev->dev.of_node, "qcom,ee", &bdev->ee);
1258 dev_err(bdev->dev, "Execution environment unspecified\n");
1262 bdev->controlled_remotely = of_property_read_bool(pdev->dev.of_node,
1265 if (bdev->controlled_remotely) {
1267 &bdev->num_channels);
1269 dev_err(bdev->dev, "num-channels unspecified in dt\n");
1272 &bdev->num_ees);
1274 dev_err(bdev->dev, "num-ees unspecified in dt\n");
1277 bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk");
1278 if (IS_ERR(bdev->bamclk)) {
1279 if (!bdev->controlled_remotely)
1280 return PTR_ERR(bdev->bamclk);
1282 bdev->bamclk = NULL;
1285 ret = clk_prepare_enable(bdev->bamclk);
1287 dev_err(bdev->dev, "failed to prepare/enable clock\n");
1291 ret = bam_init(bdev);
1295 tasklet_setup(&bdev->task, dma_tasklet);
1297 bdev->channels = devm_kcalloc(bdev->dev, bdev->num_channels,
1298 sizeof(*bdev->channels), GFP_KERNEL);
1300 if (!bdev->channels) {
1306 INIT_LIST_HEAD(&bdev->common.channels);
1308 for (i = 0; i < bdev->num_channels; i++)
1309 bam_channel_init(bdev, &bdev->channels[i], i);
1311 ret = devm_request_irq(bdev->dev, bdev->irq, bam_dma_irq,
1312 IRQF_TRIGGER_HIGH, "bam_dma", bdev);
1317 bdev->common.dev = bdev->dev;
1318 ret = dma_set_max_seg_size(bdev->common.dev, BAM_FIFO_SIZE);
1320 dev_err(bdev->dev, "cannot set maximum segment size\n");
1324 platform_set_drvdata(pdev, bdev);
1327 dma_cap_zero(bdev->common.cap_mask);
1328 dma_cap_set(DMA_SLAVE, bdev->common.cap_mask);
1331 bdev->common.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
1332 bdev->common.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
1333 bdev->common.src_addr_widths = DMA_SLAVE_BUSWIDTH_4_BYTES;
1334 bdev->common.dst_addr_widths = DMA_SLAVE_BUSWIDTH_4_BYTES;
1335 bdev->common.device_alloc_chan_resources = bam_alloc_chan;
1336 bdev->common.device_free_chan_resources = bam_free_chan;
1337 bdev->common.device_prep_slave_sg = bam_prep_slave_sg;
1338 bdev->common.device_config = bam_slave_config;
1339 bdev->common.device_pause = bam_pause;
1340 bdev->common.device_resume = bam_resume;
1341 bdev->common.device_terminate_all = bam_dma_terminate_all;
1342 bdev->common.device_issue_pending = bam_issue_pending;
1343 bdev->common.device_tx_status = bam_tx_status;
1344 bdev->common.dev = bdev->dev;
1346 ret = dma_async_device_register(&bdev->common);
1348 dev_err(bdev->dev, "failed to register dma async device\n");
1353 &bdev->common);
1357 if (bdev->controlled_remotely) {
1372 dma_async_device_unregister(&bdev->common);
1374 for (i = 0; i < bdev->num_channels; i++)
1375 tasklet_kill(&bdev->channels[i].vc.task);
1377 tasklet_kill(&bdev->task);
1379 clk_disable_unprepare(bdev->bamclk);
1386 struct bam_device *bdev = platform_get_drvdata(pdev);
1392 dma_async_device_unregister(&bdev->common);
1395 writel_relaxed(0, bam_addr(bdev, 0, BAM_IRQ_SRCS_MSK_EE));
1397 devm_free_irq(bdev->dev, bdev->irq, bdev);
1399 for (i = 0; i < bdev->num_channels; i++) {
1400 bam_dma_terminate_all(&bdev->channels[i].vc.chan);
1401 tasklet_kill(&bdev->channels[i].vc.task);
1403 if (!bdev->channels[i].fifo_virt)
1406 dma_free_wc(bdev->dev, BAM_DESC_FIFO_SIZE,
1407 bdev->channels[i].fifo_virt,
1408 bdev->channels[i].fifo_phys);
1411 tasklet_kill(&bdev->task);
1413 clk_disable_unprepare(bdev->bamclk);
1420 struct bam_device *bdev = dev_get_drvdata(dev);
1422 clk_disable(bdev->bamclk);
1429 struct bam_device *bdev = dev_get_drvdata(dev);
1432 ret = clk_enable(bdev->bamclk);
1443 struct bam_device *bdev = dev_get_drvdata(dev);
1445 if (!bdev->controlled_remotely)
1448 clk_unprepare(bdev->bamclk);
1455 struct bam_device *bdev = dev_get_drvdata(dev);
1458 ret = clk_prepare(bdev->bamclk);
1462 if (!bdev->controlled_remotely)