From 2fbac538cc58c505753c9403b432c4a88c8d43bf Mon Sep 17 00:00:00 2001 From: Zhu Yingjiang Date: Thu, 18 Apr 2019 14:19:18 +0800 Subject: [PATCH 1/3] ASoC: SOF: Intel: hda: add the SSP Host Device memory space The DSP SSP device memory can be conditionally accessed by the host(depending on access policy). Add the SSP base memory offset of APL and CNL. Signed-off-by: Zhu Yingjiang --- sound/soc/sof/intel/hda.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index e49d9c92dd1c8b..e66a231578702a 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -339,6 +339,13 @@ #define HDA_ADSP_FW_STATUS_SKL HDA_ADSP_SRAM0_BASE_SKL #define HDA_ADSP_ERROR_CODE_SKL (HDA_ADSP_FW_STATUS_SKL + 0x4) +/* Host Device Memory Space */ +#define APL_SSP_BASE_OFFSET 0x2000 +#define CNL_SSP_BASE_OFFSET 0x10000 + +/* Host Device Memory Size of a Single SSP */ +#define SSP_DEV_MEM_SIZE 0x1000 + #define HDA_IDISP_CODEC(x) ((x) & BIT(2)) struct sof_intel_dsp_bdl { From 1ebc6197e9272b6527775f16206bd87d3d377322 Mon Sep 17 00:00:00 2001 From: Zhu Yingjiang Date: Thu, 18 Apr 2019 14:35:13 +0800 Subject: [PATCH 2/3] ASoC: SOF: Intel: hda: add SSP info to the chip info struct add SSP info of APL and CNL, to the sof_intel_dsp_desc structure. The max SSP count the platform support and the SSP base address. Signed-off-by: Zhu Yingjiang --- sound/soc/sof/intel/apl.c | 2 ++ sound/soc/sof/intel/cnl.c | 2 ++ sound/soc/sof/intel/hda.h | 4 ++++ sound/soc/sof/intel/shim.h | 2 ++ 4 files changed, 10 insertions(+) diff --git a/sound/soc/sof/intel/apl.c b/sound/soc/sof/intel/apl.c index 8c628260694467..026dde83962186 100644 --- a/sound/soc/sof/intel/apl.c +++ b/sound/soc/sof/intel/apl.c @@ -105,5 +105,7 @@ const struct sof_intel_dsp_desc apl_chip_info = { .ipc_ack_mask = HDA_DSP_REG_HIPCIE_DONE, .ipc_ctl = HDA_DSP_REG_HIPCCTL, .rom_init_timeout = 150, + .ssp_count = APL_SSP_COUNT, + .ssp_base_offset = APL_SSP_BASE_OFFSET, }; EXPORT_SYMBOL(apl_chip_info); diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c index 36ae9b88d0dc3d..3afd96d9c92575 100644 --- a/sound/soc/sof/intel/cnl.c +++ b/sound/soc/sof/intel/cnl.c @@ -246,5 +246,7 @@ const struct sof_intel_dsp_desc cnl_chip_info = { .ipc_ack_mask = CNL_DSP_REG_HIPCIDA_DONE, .ipc_ctl = CNL_DSP_REG_HIPCCTL, .rom_init_timeout = 300, + .ssp_count = CNL_SSP_COUNT, + .ssp_base_offset = CNL_SSP_BASE_OFFSET, }; EXPORT_SYMBOL(cnl_chip_info); diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index e66a231578702a..28e0fb10c85988 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -346,6 +346,10 @@ /* Host Device Memory Size of a Single SSP */ #define SSP_DEV_MEM_SIZE 0x1000 +/* SSP Count of the Platform */ +#define APL_SSP_COUNT 6 +#define CNL_SSP_COUNT 3 + #define HDA_IDISP_CODEC(x) ((x) & BIT(2)) struct sof_intel_dsp_bdl { diff --git a/sound/soc/sof/intel/shim.h b/sound/soc/sof/intel/shim.h index 11fd77cb4e6d0b..f7a3f62e45d44b 100644 --- a/sound/soc/sof/intel/shim.h +++ b/sound/soc/sof/intel/shim.h @@ -162,6 +162,8 @@ struct sof_intel_dsp_desc { int ipc_ack_mask; int ipc_ctl; int rom_init_timeout; + int ssp_count; /* ssp count of the platform */ + int ssp_base_offset; /* base address of the SSPs */ }; extern const struct snd_sof_dsp_ops sof_tng_ops; From c77ad74f50cf7eeef2e44079ffcb8a9a186a179a Mon Sep 17 00:00:00 2001 From: Zhu Yingjiang Date: Thu, 18 Apr 2019 14:42:26 +0800 Subject: [PATCH 3/3] ASoC: SOF: Intel: hda: set I2S slave before enabling DSP By default, the I2S ports are configured in master mode during DSP powerup sequences, the FS and BCLK lines will be driven on startup, even when the topology file explicitly requires the SSP to be slave. This may be problematic for external components configured in master mode who don't expect the Intel SOC/PCH to drive. Fix by configuring the SSP as slave before the SSP outputs are enabled to avoid this transient behavior. When the topology file configures the SSP as clock master, the initial slave configuration will be overridden. Signed-off-by: Zhu Yingjiang --- sound/soc/sof/intel/hda-loader.c | 11 +++++++++++ sound/soc/sof/intel/hda.h | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/sound/soc/sof/intel/hda-loader.c b/sound/soc/sof/intel/hda-loader.c index 6a44bc349e44ce..6427f0b3a2f113 100644 --- a/sound/soc/sof/intel/hda-loader.c +++ b/sound/soc/sof/intel/hda-loader.c @@ -84,6 +84,7 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, const void *fwdata, const struct sof_intel_dsp_desc *chip = hda->desc; unsigned int status; int ret; + int i; /* step 1: power up corex */ ret = hda_dsp_core_power_up(sdev, chip->cores_mask); @@ -92,6 +93,16 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, const void *fwdata, goto err; } + /* DSP is powered up, set all SSPs to slave mode */ + for (i = 0; i < chip->ssp_count; i++) { + snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, + chip->ssp_base_offset + + i * SSP_DEV_MEM_SIZE + + SSP_SSC1_OFFSET, + SSP_SET_SLAVE, + SSP_SET_SLAVE); + } + /* step 2: purge FW request */ snd_sof_dsp_write(sdev, HDA_DSP_BAR, chip->ipc_req, chip->ipc_req_mask | (HDA_DSP_IPC_PURGE_FW | diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 28e0fb10c85988..7d78110c65a609 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -350,6 +350,12 @@ #define APL_SSP_COUNT 6 #define CNL_SSP_COUNT 3 +/* SSP Registers */ +#define SSP_SSC1_OFFSET 0x4 +#define SSP_SET_SCLK_SLAVE BIT(25) +#define SSP_SET_SFRM_SLAVE BIT(24) +#define SSP_SET_SLAVE (SSP_SET_SCLK_SLAVE | SSP_SET_SFRM_SLAVE) + #define HDA_IDISP_CODEC(x) ((x) & BIT(2)) struct sof_intel_dsp_bdl {