summaryrefslogtreecommitdiff
path: root/sound/soc/fsl/fsl_dsp.c
diff options
context:
space:
mode:
authorWeiguang Kong <weiguang.kong@nxp.com>2018-05-11 12:34:10 +0800
committerDong Aisheng <aisheng.dong@nxp.com>2019-11-25 15:51:52 +0800
commitdc9756fa77434d5a3c85ce44a82565c2fe6b89ab (patch)
treecc6b3b2fdc1b1bd4c35d0dcab828c7557f90d5c5 /sound/soc/fsl/fsl_dsp.c
parent6b034c90fbccceebf4a009b4334d4450c8a161cc (diff)
MLK-18279: ASoC: fsl_dsp: get the information of reserved memory from dts
The reserved memory for dsp is defined in dts file, however, the dsp driver has also defined the address and size of this reserved memory, which is repeated and inflexible. So by cancelling the definition in dsp driver and use system API to get the information of reserved memory from dts dynamically to fix this problem. Signed-off-by: Weiguang Kong <weiguang.kong@nxp.com>
Diffstat (limited to 'sound/soc/fsl/fsl_dsp.c')
-rw-r--r--sound/soc/fsl/fsl_dsp.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/sound/soc/fsl/fsl_dsp.c b/sound/soc/fsl/fsl_dsp.c
index ea95c87507c4..593fb80ba48b 100644
--- a/sound/soc/fsl/fsl_dsp.c
+++ b/sound/soc/fsl/fsl_dsp.c
@@ -739,6 +739,8 @@ static const struct file_operations dsp_fops = {
static int fsl_dsp_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
+ struct device_node *reserved_node;
+ struct resource reserved_res;
struct fsl_dsp *dsp_priv;
const char *fw_name;
struct resource *res;
@@ -820,14 +822,32 @@ static int fsl_dsp_probe(struct platform_device *pdev)
return ret;
}
- dsp_priv->sdram_phys_addr = SDRAM_BASE_ADDR;
+ reserved_node = of_parse_phandle(np, "reserved-region", 0);
+ if (!reserved_node) {
+ dev_err(&pdev->dev, "failed to get reserved region node\n");
+ return -ENODEV;
+ }
+
+ if (of_address_to_resource(reserved_node, 0, &reserved_res)) {
+ dev_err(&pdev->dev, "failed to get reserved region address\n");
+ return -EINVAL;
+ }
+
+ dsp_priv->sdram_phys_addr = reserved_res.start;
+ dsp_priv->sdram_reserved_size = (reserved_res.end - reserved_res.start)
+ + 1;
+ if (dsp_priv->sdram_reserved_size <= 0) {
+ dev_err(&pdev->dev, "invalid value of reserved region size\n");
+ return -EINVAL;
+ }
+
dsp_priv->sdram_vir_addr = ioremap_wc(dsp_priv->sdram_phys_addr,
- SDRAM_BASE_SIZE);
+ dsp_priv->sdram_reserved_size);
if (!dsp_priv->sdram_vir_addr) {
dev_err(&pdev->dev, "failed to remap sdram space for dsp firmware\n");
return -ENXIO;
}
- memset_io(dsp_priv->sdram_vir_addr, 0, SDRAM_BASE_SIZE);
+ memset_io(dsp_priv->sdram_vir_addr, 0, dsp_priv->sdram_reserved_size);
size = MSG_BUF_SIZE + DSP_CONFIG_SIZE;
@@ -848,12 +868,16 @@ static int fsl_dsp_probe(struct platform_device *pdev)
dsp_priv->dsp_config_phys = buf_phys + offset;
dsp_priv->dsp_config_size = DSP_CONFIG_SIZE;
- /* scratch memory for dsp framework */
+ /* scratch memory for dsp framework. The sdram reserved memory
+ * is split into two equal parts currently. The front part is
+ * used to keep the dsp firmware, the other part is considered
+ * as scratch memory for dsp framework.
+ */
dsp_priv->scratch_buf_virt = dsp_priv->sdram_vir_addr +
- SDRAM_CODEC_LIB_OFFSET;
+ dsp_priv->sdram_reserved_size / 2;
dsp_priv->scratch_buf_phys = dsp_priv->sdram_phys_addr +
- SDRAM_CODEC_LIB_OFFSET;
- dsp_priv->scratch_buf_size = SDRAM_BASE_SIZE - SDRAM_CODEC_LIB_OFFSET;
+ dsp_priv->sdram_reserved_size / 2;
+ dsp_priv->scratch_buf_size = dsp_priv->sdram_reserved_size / 2;
/* initialize the reference counter for dsp_priv
* structure