summaryrefslogtreecommitdiff
path: root/sound/soc
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
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')
-rw-r--r--sound/soc/fsl/fsl_dsp.c38
-rw-r--r--sound/soc/fsl/fsl_dsp.h22
-rw-r--r--sound/soc/fsl/fsl_dsp_proxy.c6
3 files changed, 35 insertions, 31 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
diff --git a/sound/soc/fsl/fsl_dsp.h b/sound/soc/fsl/fsl_dsp.h
index 3824641c2f93..02eca8ef5c80 100644
--- a/sound/soc/fsl/fsl_dsp.h
+++ b/sound/soc/fsl/fsl_dsp.h
@@ -67,6 +67,7 @@ struct fsl_dsp {
unsigned long sram;
void *sdram_vir_addr;
unsigned long sdram_phys_addr;
+ int sdram_reserved_size;
void *msg_buf_virt;
dma_addr_t msg_buf_phys;
int msg_buf_size;
@@ -107,27 +108,6 @@ struct fsl_dsp {
#define OUTPUT_BUF_SIZE 16384
#define DSP_CONFIG_SIZE 4096
-/*external buffer
- * ----------------------------------------------------------------------
- * | name | size | description |
- * -----------------------------------------------------------------------
- * | scratch buffer for malloc | 0xffffff | For MEM_scratch_malloc()
- * ------------------------------------------------------------------------
- * | global structure | 4096 | For store dsp config structure
- * ------------------------------------------------------------------------
- */
-
-#define MEMORY_REMAP_OFFSET 0x39000000
-
-/* reserved memory for dsp firmware and core libs to
- * save their instruction/data section in SDRAM, the physical
- * address range is 0x8e000000 ~ 0x8fffffff (32M bytes).
- */
-#define SDRAM_BASE_ADDR 0x8e000000
-#define SDRAM_BASE_SIZE 0x1ffffff
-#define SDRAM_CODEC_LIB_OFFSET 0x1000000
-#define SDRAM_SCRATCH_BUF_SIZE 0xffffff
-
#define SC_C_OFS_SEL 39
#define SC_C_OFS_AUDIO 40
#define SC_C_OFS_PERIPH 41
diff --git a/sound/soc/fsl/fsl_dsp_proxy.c b/sound/soc/fsl/fsl_dsp_proxy.c
index f9a226d1f577..0eb0605018c8 100644
--- a/sound/soc/fsl/fsl_dsp_proxy.c
+++ b/sound/soc/fsl/fsl_dsp_proxy.c
@@ -281,7 +281,7 @@ irqreturn_t fsl_dsp_mu_isr(int irq, void *dev_id)
/* ...NULL-address specification */
#define XF_PROXY_NULL (~0U)
-#define XF_PROXY_BADADDR SDRAM_SCRATCH_BUF_SIZE
+#define XF_PROXY_BADADDR (dsp_priv->scratch_buf_size)
/* ...shared memory translation - kernel virtual address to shared address */
u32 xf_proxy_b2a(struct xf_proxy *proxy, void *b)
@@ -292,7 +292,7 @@ u32 xf_proxy_b2a(struct xf_proxy *proxy, void *b)
if (b == NULL)
return XF_PROXY_NULL;
else if ((u32)(b - dsp_priv->scratch_buf_virt) <
- SDRAM_SCRATCH_BUF_SIZE)
+ dsp_priv->scratch_buf_size)
return (u32)(b - dsp_priv->scratch_buf_virt);
else
return XF_PROXY_BADADDR;
@@ -304,7 +304,7 @@ void *xf_proxy_a2b(struct xf_proxy *proxy, u32 address)
struct fsl_dsp *dsp_priv = container_of(proxy,
struct fsl_dsp, proxy);
- if (address < SDRAM_SCRATCH_BUF_SIZE)
+ if (address < dsp_priv->scratch_buf_size)
return dsp_priv->scratch_buf_virt + address;
else if (address == XF_PROXY_NULL)
return NULL;