@@ -393,6 +393,7 @@ struct bam_device {
393
393
struct device_dma_parameters dma_parms ;
394
394
struct bam_chan * channels ;
395
395
u32 num_channels ;
396
+ u32 num_ees ;
396
397
397
398
/* execution environment ID, from DT */
398
399
u32 ee ;
@@ -934,12 +935,15 @@ static void bam_apply_new_config(struct bam_chan *bchan,
934
935
struct bam_device * bdev = bchan -> bdev ;
935
936
u32 maxburst ;
936
937
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 ;
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
948
bchan -> reconfigure = 0 ;
945
949
}
@@ -1128,15 +1132,19 @@ static int bam_init(struct bam_device *bdev)
1128
1132
u32 val ;
1129
1133
1130
1134
/* 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
+ }
1133
1139
1134
1140
/* check that configured EE is within range */
1135
- if (bdev -> ee >= val )
1141
+ if (bdev -> ee >= bdev -> num_ees )
1136
1142
return - EINVAL ;
1137
1143
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
+ }
1140
1148
1141
1149
if (bdev -> controlled_remotely )
1142
1150
return 0 ;
@@ -1232,9 +1240,25 @@ static int bam_dma_probe(struct platform_device *pdev)
1232
1240
bdev -> controlled_remotely = of_property_read_bool (pdev -> dev .of_node ,
1233
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
1255
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
+ }
1238
1262
1239
1263
ret = clk_prepare_enable (bdev -> bamclk );
1240
1264
if (ret ) {
@@ -1309,6 +1333,11 @@ static int bam_dma_probe(struct platform_device *pdev)
1309
1333
if (ret )
1310
1334
goto err_unregister_dma ;
1311
1335
1336
+ if (bdev -> controlled_remotely ) {
1337
+ pm_runtime_disable (& pdev -> dev );
1338
+ return 0 ;
1339
+ }
1340
+
1312
1341
pm_runtime_irq_safe (& pdev -> dev );
1313
1342
pm_runtime_set_autosuspend_delay (& pdev -> dev , BAM_DMA_AUTOSUSPEND_DELAY );
1314
1343
pm_runtime_use_autosuspend (& pdev -> dev );
@@ -1392,7 +1421,8 @@ static int __maybe_unused bam_dma_suspend(struct device *dev)
1392
1421
{
1393
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
1427
clk_unprepare (bdev -> bamclk );
1398
1428
@@ -1408,7 +1438,8 @@ static int __maybe_unused bam_dma_resume(struct device *dev)
1408
1438
if (ret )
1409
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
1444
return 0 ;
1414
1445
}
0 commit comments