Skip to content

Commit 185a6cd

Browse files
author
Vinod Koul
committed
Merge branch 'topic/qcom' into for-linus
2 parents f18b461 + 5b4a689 commit 185a6cd

File tree

2 files changed

+49
-14
lines changed

2 files changed

+49
-14
lines changed

Documentation/devicetree/bindings/dma/qcom_bam_dma.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ Required properties:
1515
the secure world.
1616
- qcom,controlled-remotely : optional, indicates that the bam is controlled by
1717
remote proccessor i.e. execution environment.
18+
- num-channels : optional, indicates supported number of DMA channels in a
19+
remotely controlled bam.
20+
- qcom,num-ees : optional, indicates supported number of Execution Environments
21+
in a remotely controlled bam.
1822

1923
Example:
2024

drivers/dma/qcom/bam_dma.c

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ struct bam_device {
393393
struct device_dma_parameters dma_parms;
394394
struct bam_chan *channels;
395395
u32 num_channels;
396+
u32 num_ees;
396397

397398
/* execution environment ID, from DT */
398399
u32 ee;
@@ -934,12 +935,15 @@ static void bam_apply_new_config(struct bam_chan *bchan,
934935
struct bam_device *bdev = bchan->bdev;
935936
u32 maxburst;
936937

937-
if (dir == DMA_DEV_TO_MEM)
938-
maxburst = bchan->slave.src_maxburst;
939-
else
940-
maxburst = bchan->slave.dst_maxburst;
938+
if (!bdev->controlled_remotely) {
939+
if (dir == DMA_DEV_TO_MEM)
940+
maxburst = bchan->slave.src_maxburst;
941+
else
942+
maxburst = bchan->slave.dst_maxburst;
941943

942-
writel_relaxed(maxburst, bam_addr(bdev, 0, BAM_DESC_CNT_TRSHLD));
944+
writel_relaxed(maxburst,
945+
bam_addr(bdev, 0, BAM_DESC_CNT_TRSHLD));
946+
}
943947

944948
bchan->reconfigure = 0;
945949
}
@@ -1128,15 +1132,19 @@ static int bam_init(struct bam_device *bdev)
11281132
u32 val;
11291133

11301134
/* read revision and configuration information */
1131-
val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION)) >> NUM_EES_SHIFT;
1132-
val &= NUM_EES_MASK;
1135+
if (!bdev->num_ees) {
1136+
val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION));
1137+
bdev->num_ees = (val >> NUM_EES_SHIFT) & NUM_EES_MASK;
1138+
}
11331139

11341140
/* check that configured EE is within range */
1135-
if (bdev->ee >= val)
1141+
if (bdev->ee >= bdev->num_ees)
11361142
return -EINVAL;
11371143

1138-
val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES));
1139-
bdev->num_channels = val & BAM_NUM_PIPES_MASK;
1144+
if (!bdev->num_channels) {
1145+
val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES));
1146+
bdev->num_channels = val & BAM_NUM_PIPES_MASK;
1147+
}
11401148

11411149
if (bdev->controlled_remotely)
11421150
return 0;
@@ -1232,9 +1240,25 @@ static int bam_dma_probe(struct platform_device *pdev)
12321240
bdev->controlled_remotely = of_property_read_bool(pdev->dev.of_node,
12331241
"qcom,controlled-remotely");
12341242

1243+
if (bdev->controlled_remotely) {
1244+
ret = of_property_read_u32(pdev->dev.of_node, "num-channels",
1245+
&bdev->num_channels);
1246+
if (ret)
1247+
dev_err(bdev->dev, "num-channels unspecified in dt\n");
1248+
1249+
ret = of_property_read_u32(pdev->dev.of_node, "qcom,num-ees",
1250+
&bdev->num_ees);
1251+
if (ret)
1252+
dev_err(bdev->dev, "num-ees unspecified in dt\n");
1253+
}
1254+
12351255
bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk");
1236-
if (IS_ERR(bdev->bamclk))
1237-
return PTR_ERR(bdev->bamclk);
1256+
if (IS_ERR(bdev->bamclk)) {
1257+
if (!bdev->controlled_remotely)
1258+
return PTR_ERR(bdev->bamclk);
1259+
1260+
bdev->bamclk = NULL;
1261+
}
12381262

12391263
ret = clk_prepare_enable(bdev->bamclk);
12401264
if (ret) {
@@ -1309,6 +1333,11 @@ static int bam_dma_probe(struct platform_device *pdev)
13091333
if (ret)
13101334
goto err_unregister_dma;
13111335

1336+
if (bdev->controlled_remotely) {
1337+
pm_runtime_disable(&pdev->dev);
1338+
return 0;
1339+
}
1340+
13121341
pm_runtime_irq_safe(&pdev->dev);
13131342
pm_runtime_set_autosuspend_delay(&pdev->dev, BAM_DMA_AUTOSUSPEND_DELAY);
13141343
pm_runtime_use_autosuspend(&pdev->dev);
@@ -1392,7 +1421,8 @@ static int __maybe_unused bam_dma_suspend(struct device *dev)
13921421
{
13931422
struct bam_device *bdev = dev_get_drvdata(dev);
13941423

1395-
pm_runtime_force_suspend(dev);
1424+
if (!bdev->controlled_remotely)
1425+
pm_runtime_force_suspend(dev);
13961426

13971427
clk_unprepare(bdev->bamclk);
13981428

@@ -1408,7 +1438,8 @@ static int __maybe_unused bam_dma_resume(struct device *dev)
14081438
if (ret)
14091439
return ret;
14101440

1411-
pm_runtime_force_resume(dev);
1441+
if (!bdev->controlled_remotely)
1442+
pm_runtime_force_resume(dev);
14121443

14131444
return 0;
14141445
}

0 commit comments

Comments
 (0)