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 <srinivas.kandagatla@linaro.org> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
This commit is contained in:
Родитель
d545afc907
Коммит
48d163b1aa
|
@ -393,6 +393,7 @@ struct bam_device {
|
||||||
struct device_dma_parameters dma_parms;
|
struct device_dma_parameters dma_parms;
|
||||||
struct bam_chan *channels;
|
struct bam_chan *channels;
|
||||||
u32 num_channels;
|
u32 num_channels;
|
||||||
|
u32 num_ees;
|
||||||
|
|
||||||
/* execution environment ID, from DT */
|
/* execution environment ID, from DT */
|
||||||
u32 ee;
|
u32 ee;
|
||||||
|
@ -1128,15 +1129,19 @@ static int bam_init(struct bam_device *bdev)
|
||||||
u32 val;
|
u32 val;
|
||||||
|
|
||||||
/* read revision and configuration information */
|
/* read revision and configuration information */
|
||||||
val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION)) >> NUM_EES_SHIFT;
|
if (!bdev->num_ees) {
|
||||||
val &= NUM_EES_MASK;
|
val = readl_relaxed(bam_addr(bdev, 0, BAM_REVISION));
|
||||||
|
bdev->num_ees = (val >> NUM_EES_SHIFT) & NUM_EES_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
/* check that configured EE is within range */
|
/* check that configured EE is within range */
|
||||||
if (bdev->ee >= val)
|
if (bdev->ee >= bdev->num_ees)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES));
|
if (!bdev->num_channels) {
|
||||||
bdev->num_channels = val & BAM_NUM_PIPES_MASK;
|
val = readl_relaxed(bam_addr(bdev, 0, BAM_NUM_PIPES));
|
||||||
|
bdev->num_channels = val & BAM_NUM_PIPES_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
if (bdev->controlled_remotely)
|
if (bdev->controlled_remotely)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1232,6 +1237,18 @@ static int bam_dma_probe(struct platform_device *pdev)
|
||||||
bdev->controlled_remotely = of_property_read_bool(pdev->dev.of_node,
|
bdev->controlled_remotely = of_property_read_bool(pdev->dev.of_node,
|
||||||
"qcom,controlled-remotely");
|
"qcom,controlled-remotely");
|
||||||
|
|
||||||
|
if (bdev->controlled_remotely) {
|
||||||
|
ret = of_property_read_u32(pdev->dev.of_node, "num-channels",
|
||||||
|
&bdev->num_channels);
|
||||||
|
if (ret)
|
||||||
|
dev_err(bdev->dev, "num-channels unspecified in dt\n");
|
||||||
|
|
||||||
|
ret = of_property_read_u32(pdev->dev.of_node, "qcom,num-ees",
|
||||||
|
&bdev->num_ees);
|
||||||
|
if (ret)
|
||||||
|
dev_err(bdev->dev, "num-ees unspecified in dt\n");
|
||||||
|
}
|
||||||
|
|
||||||
bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk");
|
bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk");
|
||||||
if (IS_ERR(bdev->bamclk)) {
|
if (IS_ERR(bdev->bamclk)) {
|
||||||
if (!bdev->controlled_remotely)
|
if (!bdev->controlled_remotely)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче