aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinod Koul <vinod.koul@intel.com>2018-04-09 23:25:37 -0400
committerVinod Koul <vinod.koul@intel.com>2018-04-09 23:25:37 -0400
commit185a6cdb78ddf2dc60e2c700c68f8a53c91ede99 (patch)
tree61f4c797534bf35ac2d9e61f68e8ebd5969e356f
parentf18b46190c62858fe04414e8ee9efea26f759e91 (diff)
parent5b4a68952a89e7decf4ff5e86406975cc730575d (diff)
Merge branch 'topic/qcom' into for-linus
-rw-r--r--Documentation/devicetree/bindings/dma/qcom_bam_dma.txt4
-rw-r--r--drivers/dma/qcom/bam_dma.c59
2 files changed, 49 insertions, 14 deletions
diff --git a/Documentation/devicetree/bindings/dma/qcom_bam_dma.txt b/Documentation/devicetree/bindings/dma/qcom_bam_dma.txt
index 9cbf5d9df8fd..cf5b9e44432c 100644
--- a/Documentation/devicetree/bindings/dma/qcom_bam_dma.txt
+++ b/Documentation/devicetree/bindings/dma/qcom_bam_dma.txt
@@ -15,6 +15,10 @@ Required properties:
15 the secure world. 15 the secure world.
16- qcom,controlled-remotely : optional, indicates that the bam is controlled by 16- qcom,controlled-remotely : optional, indicates that the bam is controlled by
17 remote proccessor i.e. execution environment. 17 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.
18 22
19Example: 23Example:
20 24
diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index d076940e0c69..d29275b97e84 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -393,6 +393,7 @@ struct bam_device {
393 struct device_dma_parameters dma_parms; 393 struct device_dma_parameters dma_parms;
394 struct bam_chan *channels; 394 struct bam_chan *channels;
395 u32 num_channels; 395 u32 num_channels;
396 u32 num_ees;
396 397
397 /* execution environment ID, from DT */ 398 /* execution environment ID, from DT */
398 u32 ee; 399 u32 ee;
@@ -934,12 +935,15 @@ static void bam_apply_new_config(struct bam_chan *bchan,
934 struct bam_device *bdev = bchan->bdev; 935 struct bam_device *bdev = bchan->bdev;
935 u32 maxburst; 936 u32 maxburst;
936 937
937 if (dir == DMA_DEV_TO_MEM) 938 if (!bdev->controlled_remotely) {
938 maxburst = bchan->slave.src_maxburst; 939 if (dir == DMA_DEV_TO_MEM)
939 else 940 maxburst = bchan->slave.src_maxburst;
940 maxburst = bchan->slave.dst_maxburst; 941 else
942 maxburst = bchan->slave.dst_maxburst;
941 943
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 }
943 947
944 bchan->reconfigure = 0; 948 bchan->reconfigure = 0;
945} 949}
@@ -1128,15 +1132,19 @@ static int bam_init(struct bam_device *bdev)
1128 u32 val; 1132 u32 val;
1129 1133
1130 /* read revision and configuration information */ 1134 /* read revision and configuration information */
1131 val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION)) >> NUM_EES_SHIFT; 1135 if (!bdev->num_ees) {
1132 val &= NUM_EES_MASK; 1136 val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION));
1137 bdev->num_ees = (val >> NUM_EES_SHIFT) & NUM_EES_MASK;
1138 }
1133 1139
1134 /* check that configured EE is within range */ 1140 /* check that configured EE is within range */
1135 if (bdev->ee >= val) 1141 if (bdev->ee >= bdev->num_ees)
1136 return -EINVAL; 1142 return -EINVAL;
1137 1143
1138 val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES)); 1144 if (!bdev->num_channels) {
1139 bdev->num_channels = val & BAM_NUM_PIPES_MASK; 1145 val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES));
1146 bdev->num_channels = val & BAM_NUM_PIPES_MASK;
1147 }
1140 1148
1141 if (bdev->controlled_remotely) 1149 if (bdev->controlled_remotely)
1142 return 0; 1150 return 0;
@@ -1232,9 +1240,25 @@ static int bam_dma_probe(struct platform_device *pdev)
1232 bdev->controlled_remotely = of_property_read_bool(pdev->dev.of_node, 1240 bdev->controlled_remotely = of_property_read_bool(pdev->dev.of_node,
1233 "qcom,controlled-remotely"); 1241 "qcom,controlled-remotely");
1234 1242
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
1235 bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk"); 1255 bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk");
1236 if (IS_ERR(bdev->bamclk)) 1256 if (IS_ERR(bdev->bamclk)) {
1237 return PTR_ERR(bdev->bamclk); 1257 if (!bdev->controlled_remotely)
1258 return PTR_ERR(bdev->bamclk);
1259
1260 bdev->bamclk = NULL;
1261 }
1238 1262
1239 ret = clk_prepare_enable(bdev->bamclk); 1263 ret = clk_prepare_enable(bdev->bamclk);
1240 if (ret) { 1264 if (ret) {
@@ -1309,6 +1333,11 @@ static int bam_dma_probe(struct platform_device *pdev)
1309 if (ret) 1333 if (ret)
1310 goto err_unregister_dma; 1334 goto err_unregister_dma;
1311 1335
1336 if (bdev->controlled_remotely) {
1337 pm_runtime_disable(&pdev->dev);
1338 return 0;
1339 }
1340
1312 pm_runtime_irq_safe(&pdev->dev); 1341 pm_runtime_irq_safe(&pdev->dev);
1313 pm_runtime_set_autosuspend_delay(&pdev->dev, BAM_DMA_AUTOSUSPEND_DELAY); 1342 pm_runtime_set_autosuspend_delay(&pdev->dev, BAM_DMA_AUTOSUSPEND_DELAY);
1314 pm_runtime_use_autosuspend(&pdev->dev); 1343 pm_runtime_use_autosuspend(&pdev->dev);
@@ -1392,7 +1421,8 @@ static int __maybe_unused bam_dma_suspend(struct device *dev)
1392{ 1421{
1393 struct bam_device *bdev = dev_get_drvdata(dev); 1422 struct bam_device *bdev = dev_get_drvdata(dev);
1394 1423
1395 pm_runtime_force_suspend(dev); 1424 if (!bdev->controlled_remotely)
1425 pm_runtime_force_suspend(dev);
1396 1426
1397 clk_unprepare(bdev->bamclk); 1427 clk_unprepare(bdev->bamclk);
1398 1428
@@ -1408,7 +1438,8 @@ static int __maybe_unused bam_dma_resume(struct device *dev)
1408 if (ret) 1438 if (ret)
1409 return ret; 1439 return ret;
1410 1440
1411 pm_runtime_force_resume(dev); 1441 if (!bdev->controlled_remotely)
1442 pm_runtime_force_resume(dev);
1412 1443
1413 return 0; 1444 return 0;
1414} 1445}