Skip to content

Commit 48d163b

Browse files
Srinivas-KandagatlaVinod Koul
authored andcommitted
dmaengine: qcom: bam_dma: get num-channels and num-ees from dt
When Linux is master of BAM, it can directly read registers to know number of supported channels, however when its remotely controlled reading these registers would trigger a crash if the BAM is not yet initialized or powered up on the remote side. This patch allows driver to read num-channels and num-ees from Device Tree for remotely controlled BAM. Signed-off-by: Srinivas Kandagatla <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
1 parent d545afc commit 48d163b

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

drivers/dma/qcom/bam_dma.c

Lines changed: 22 additions & 5 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;
@@ -1128,15 +1129,19 @@ static int bam_init(struct bam_device *bdev)
11281129
u32 val;
11291130

11301131
/* read revision and configuration information */
1131-
val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION)) >> NUM_EES_SHIFT;
1132-
val &= NUM_EES_MASK;
1132+
if (!bdev->num_ees) {
1133+
val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION));
1134+
bdev->num_ees = (val >> NUM_EES_SHIFT) & NUM_EES_MASK;
1135+
}
11331136

11341137
/* check that configured EE is within range */
1135-
if (bdev->ee >= val)
1138+
if (bdev->ee >= bdev->num_ees)
11361139
return -EINVAL;
11371140

1138-
val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES));
1139-
bdev->num_channels = val & BAM_NUM_PIPES_MASK;
1141+
if (!bdev->num_channels) {
1142+
val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES));
1143+
bdev->num_channels = val & BAM_NUM_PIPES_MASK;
1144+
}
11401145

11411146
if (bdev->controlled_remotely)
11421147
return 0;
@@ -1232,6 +1237,18 @@ static int bam_dma_probe(struct platform_device *pdev)
12321237
bdev->controlled_remotely = of_property_read_bool(pdev->dev.of_node,
12331238
"qcom,controlled-remotely");
12341239

1240+
if (bdev->controlled_remotely) {
1241+
ret = of_property_read_u32(pdev->dev.of_node, "num-channels",
1242+
&bdev->num_channels);
1243+
if (ret)
1244+
dev_err(bdev->dev, "num-channels unspecified in dt\n");
1245+
1246+
ret = of_property_read_u32(pdev->dev.of_node, "qcom,num-ees",
1247+
&bdev->num_ees);
1248+
if (ret)
1249+
dev_err(bdev->dev, "num-ees unspecified in dt\n");
1250+
}
1251+
12351252
bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk");
12361253
if (IS_ERR(bdev->bamclk)) {
12371254
if (!bdev->controlled_remotely)

0 commit comments

Comments
 (0)