[alsa-devel] [PATCH 0/5] ASoC: Intel: Enable BDW/HSW SRAM power gating
Hi Mark,
Here is the patch series for enable Intel Broadwell/Haswell ADSP SRAM power gating feature.
Patches 0001~0003 implement FW module persistent area allocate during FW parse; Patch 0004 add dummy read to workaround SRAM write missing bytes issue; Patch 0005 will make SRAM start with all memory banks disabled, and enabled required banks during boot procedure.
thanks, Keyon
Jie Yang (5): ASoC: Intel: Add persistent area alloc ASoC: Intel: Merge wild cat point ADSP DRAM regions ASoC: Intel: Use a table for ADSP SRAM shift ASoC: Intel: Add dummy read for SRAM block enable ASoC: Intel: Start with all memory banks disabled
sound/soc/intel/sst-dsp-priv.h | 2 ++ sound/soc/intel/sst-firmware.c | 52 ++++++++++++++++++++++++++++++ sound/soc/intel/sst-haswell-dsp.c | 68 ++++++++++++++++++++++++++++++--------- 3 files changed, 106 insertions(+), 16 deletions(-)
Allocate persistent SRAM blocks for each firmware module.
Signed-off-by: Jie Yang yang.jie@intel.com --- sound/soc/intel/sst-dsp-priv.h | 2 ++ sound/soc/intel/sst-firmware.c | 52 +++++++++++++++++++++++++++++++++++++++ sound/soc/intel/sst-haswell-dsp.c | 7 +++++- 3 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/sound/soc/intel/sst-dsp-priv.h b/sound/soc/intel/sst-dsp-priv.h index 3c0cbba..f96c1c5 100644 --- a/sound/soc/intel/sst-dsp-priv.h +++ b/sound/soc/intel/sst-dsp-priv.h @@ -301,6 +301,8 @@ struct sst_module *sst_module_get_from_id(struct sst_dsp *dsp, u32 id); struct sst_module *sst_mem_block_alloc_scratch(struct sst_dsp *dsp); void sst_mem_block_free_scratch(struct sst_dsp *dsp, struct sst_module *scratch); +int sst_module_alloc_persistent(struct sst_dsp *dsp, struct sst_module *module); +void sst_module_free_persistent(struct sst_dsp *dsp, struct sst_module *module); int sst_block_module_remove(struct sst_module *module);
/* Register the DSPs memory blocks - would be nice to read from ACPI */ diff --git a/sound/soc/intel/sst-firmware.c b/sound/soc/intel/sst-firmware.c index 8349df5..8ab5ce8 100644 --- a/sound/soc/intel/sst-firmware.c +++ b/sound/soc/intel/sst-firmware.c @@ -845,6 +845,58 @@ void sst_mem_block_free_scratch(struct sst_dsp *dsp, } EXPORT_SYMBOL_GPL(sst_mem_block_free_scratch);
+/* allocate persistent buffer blocks for given module + creates new sst_module to represent persistent memory alocation of requestor. +*/ +int sst_module_alloc_persistent(struct sst_dsp *dsp, struct sst_module *module) +{ + int ret = 0; + struct sst_module_data *persistent = &module->p; + + mutex_lock(&dsp->mutex); + + dev_dbg(dsp->dev, "persistent buffer required for mod id %d is %d bytes\n", + module->id, persistent->size); + + ret = block_alloc(module, persistent); + + if (ret < 0) { + dev_err(dsp->dev, "error: can't alloc persistent blocks for mod id %d\n", + module->id); + goto out; + } + dev_dbg(dsp->dev, "module %d persistent area allocated %dB at 0x%x\n", + module->id, persistent->size, persistent->offset); + + /* prepare DSP blocks for persistent module usage */ + ret = block_module_prepare(module); + if (ret < 0) { + dev_err(dsp->dev, "error: persistent module prepare failed\n"); + goto out; + } + +out: + mutex_unlock(&dsp->mutex); + return ret; +} +EXPORT_SYMBOL_GPL(sst_module_alloc_persistent); + +void sst_module_free_persistent(struct sst_dsp *dsp, struct sst_module *persistent) +{ + struct sst_mem_block *block, *tmp; + + dev_dbg(dsp->dev, "module %d persistent released", persistent->id); + + mutex_lock(&dsp->mutex); + + list_for_each_entry_safe(block, tmp, &persistent->block_list, module_list) + list_del(&block->module_list); + + mutex_unlock(&dsp->mutex); + +} +EXPORT_SYMBOL_GPL(sst_module_free_persistent); + /* get a module from it's unique ID */ struct sst_module *sst_module_get_from_id(struct sst_dsp *dsp, u32 id) { diff --git a/sound/soc/intel/sst-haswell-dsp.c b/sound/soc/intel/sst-haswell-dsp.c index 535f517..48ddff3 100644 --- a/sound/soc/intel/sst-haswell-dsp.c +++ b/sound/soc/intel/sst-haswell-dsp.c @@ -168,6 +168,11 @@ static int hsw_parse_module(struct sst_dsp *dsp, struct sst_fw *fw,
block = (void *)block + sizeof(*block) + block->size; } + + /*allocate persistent memory if needed*/ + if (mod->p.size > 0) + return sst_module_alloc_persistent(dsp, mod); + return 0; }
@@ -207,7 +212,7 @@ static int hsw_parse_fw_image(struct sst_fw *sst_fw) module = (void *)module + sizeof(*module) + module->mod_size; }
- /* allocate persistent/scratch mem regions */ + /* allocate scratch mem regions */ scratch = sst_mem_block_alloc_scratch(dsp); if (scratch == NULL) return -ENOMEM;
Merge D-SRAM0 D-SRAM1 D-SRAM2 to D-SRAM, for wild cat point ADSP mem regions.
Signed-off-by: Jie Yang yang.jie@intel.com --- sound/soc/intel/sst-haswell-dsp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/sound/soc/intel/sst-haswell-dsp.c b/sound/soc/intel/sst-haswell-dsp.c index 48ddff3..1b96344 100644 --- a/sound/soc/intel/sst-haswell-dsp.c +++ b/sound/soc/intel/sst-haswell-dsp.c @@ -318,9 +318,7 @@ static const struct sst_adsp_memregion lp_region[] = {
/* wild cat point ADSP mem regions */ static const struct sst_adsp_memregion wpt_region[] = { - {0x00000, 0x40000, 8, SST_MEM_DRAM}, /* D-SRAM0 - 8 * 32kB */ - {0x40000, 0x80000, 8, SST_MEM_DRAM}, /* D-SRAM1 - 8 * 32kB */ - {0x80000, 0xA0000, 4, SST_MEM_DRAM}, /* D-SRAM2 - 4 * 32kB */ + {0x00000, 0xA0000, 20, SST_MEM_DRAM}, /* D-SRAM0,D-SRAM1,D-SRAM2 - 20 * 32kB */ {0xA0000, 0xF0000, 10, SST_MEM_IRAM}, /* I-SRAM - 10 * 32kB */ };
Use a table for ADSP IRAM/DRAM bit shift.
Signed-off-by: Jie Yang yang.jie@intel.com --- sound/soc/intel/sst-haswell-dsp.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-)
diff --git a/sound/soc/intel/sst-haswell-dsp.c b/sound/soc/intel/sst-haswell-dsp.c index 1b96344..f4276fb 100644 --- a/sound/soc/intel/sst-haswell-dsp.c +++ b/sound/soc/intel/sst-haswell-dsp.c @@ -342,21 +342,40 @@ static int hsw_acpi_resource_map(struct sst_dsp *sst, struct sst_pdata *pdata) return 0; }
+struct sst_sram_shift { + u32 dev_id; /* SST Device IDs */ + u32 iram_shift; + u32 dram_shift; +}; + +static const struct sst_sram_shift sram_shift[] = { + {SST_DEV_ID_LYNX_POINT, 6, 16}, /* lp */ + {SST_DEV_ID_WILDCAT_POINT, 2, 12}, /* wpt */ +}; static u32 hsw_block_get_bit(struct sst_mem_block *block) { - u32 bit = 0, shift = 0; + u32 bit = 0, shift = 0, index; + struct sst_dsp *sst = block->dsp;
- switch (block->type) { - case SST_MEM_DRAM: - shift = 16; - break; - case SST_MEM_IRAM: - shift = 6; - break; - default: - return 0; + for (index = 0; index < ARRAY_SIZE(sram_shift); index++) { + if (sram_shift[index].dev_id == sst->id) + break; }
+ if (index < ARRAY_SIZE(sram_shift)) { + switch (block->type) { + case SST_MEM_DRAM: + shift = sram_shift[index].dram_shift; + break; + case SST_MEM_IRAM: + shift = sram_shift[index].iram_shift; + break; + default: + shift = 0; + } + } else + shift = 0; + bit = 1 << (block->index + shift);
return bit;
Add dummy read after each block enable, to workaround SRAM write missing bytes issue.
Signed-off-by: Jie Yang yang.jie@intel.com --- sound/soc/intel/sst-haswell-dsp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/sound/soc/intel/sst-haswell-dsp.c b/sound/soc/intel/sst-haswell-dsp.c index f4276fb..cc58b31 100644 --- a/sound/soc/intel/sst-haswell-dsp.c +++ b/sound/soc/intel/sst-haswell-dsp.c @@ -381,6 +381,17 @@ static u32 hsw_block_get_bit(struct sst_mem_block *block) return bit; }
+/*dummy read a SRAM block.*/ +static void sst_mem_block_dummy_read(struct sst_mem_block *block) +{ + u32 size; + u8 tmp_buf[4]; + struct sst_dsp *sst = block->dsp; + + size = block->size > 4 ? 4 : block->size; + memcpy_fromio(tmp_buf, sst->addr.lpe + block->offset, size); +} + /* enable 32kB memory block - locks held by caller */ static int hsw_block_enable(struct sst_mem_block *block) { @@ -400,6 +411,8 @@ static int hsw_block_enable(struct sst_mem_block *block) /* wait 18 DSP clock ticks */ udelay(10);
+ /*add a dummy read before the SRAM block is written, otherwise the writing may miss bytes sometimes.*/ + sst_mem_block_dummy_read(block); return 0; }
All required banks are enabled during boot procedure.
Signed-off-by: Jie Yang yang.jie@intel.com --- sound/soc/intel/sst-haswell-dsp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sound/soc/intel/sst-haswell-dsp.c b/sound/soc/intel/sst-haswell-dsp.c index cc58b31..59c85a8 100644 --- a/sound/soc/intel/sst-haswell-dsp.c +++ b/sound/soc/intel/sst-haswell-dsp.c @@ -523,8 +523,9 @@ static int hsw_init(struct sst_dsp *sst, struct sst_pdata *pdata) } }
- /* set default power gating mask */ - writel(0x0, sst->addr.pci_cfg + SST_VDRTCTL0); + /* set default power gating control, enable power gating control for all blocks. that is, + can't be accessed, please enable each block before accessing. */ + writel(0xffffffff, sst->addr.pci_cfg + SST_VDRTCTL0);
return 0; }
participants (1)
-
Jie Yang