diff --git a/src/drivers/intel/ssp/ssp.c b/src/drivers/intel/ssp/ssp.c index adfa35ae2..acb992e8b 100644 --- a/src/drivers/intel/ssp/ssp.c +++ b/src/drivers/intel/ssp/ssp.c @@ -719,6 +719,8 @@ static int ssp_set_config(struct dai *dai, struct ipc_config_dai *common_config, if (ret < 0) goto out; + ssp->clk_active |= SSP_CLK_MCLK_ES_REQ; + dai_info(dai, "ssp_set_config(): hw_params stage: enabled MCLK clocks for SSP%d...", dai->index); } @@ -733,6 +735,8 @@ static int ssp_set_config(struct dai *dai, struct ipc_config_dai *common_config, if (ret < 0) goto out; + ssp->clk_active |= SSP_CLK_BCLK_ES_REQ; + if (enable_sse) { /* enable TRSE/RSRE before SSE */ @@ -764,11 +768,13 @@ static int ssp_set_config(struct dai *dai, struct ipc_config_dai *common_config, dai_info(dai, "ssp_set_config(): SSE clear for SSP%d", dai->index); } ssp_bclk_disable_unprepare(dai); + ssp->clk_active &= ~SSP_CLK_BCLK_ES_REQ; } if (ssp->params.clks_control & SOF_DAI_INTEL_SSP_CLKCTRL_MCLK_ES) { dai_info(dai, "ssp_set_config: hw_free stage: releasing MCLK clocks for SSP%d...", dai->index); ssp_mclk_disable_unprepare(dai); + ssp->clk_active &= ~SSP_CLK_MCLK_ES_REQ; } break; default: @@ -797,16 +803,14 @@ static int ssp_pre_start(struct dai *dai) * We will test if mclk/bclk is configured in * ssp_mclk/bclk_prepare_enable/disable functions */ - if (!(ssp->params.clks_control & - SOF_DAI_INTEL_SSP_CLKCTRL_MCLK_ES)) { + if (!(ssp->clk_active & SSP_CLK_MCLK_ES_REQ)) { /* MCLK config */ ret = ssp_mclk_prepare_enable(dai); if (ret < 0) return ret; } - if (!(ssp->params.clks_control & - SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_ES)) + if (!(ssp->clk_active & SSP_CLK_BCLK_ES_REQ)) ret = ssp_bclk_prepare_enable(dai); return ret; @@ -824,14 +828,12 @@ static void ssp_post_stop(struct dai *dai) /* release clocks if SSP is inactive */ if (ssp->state[SOF_IPC_STREAM_PLAYBACK] != COMP_STATE_ACTIVE && ssp->state[SOF_IPC_STREAM_CAPTURE] != COMP_STATE_ACTIVE) { - if (!(ssp->params.clks_control & - SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_ES)) { + if (!(ssp->clk_active & SSP_CLK_BCLK_ES_REQ)) { dai_info(dai, "ssp_post_stop releasing BCLK clocks for SSP%d...", dai->index); ssp_bclk_disable_unprepare(dai); } - if (!(ssp->params.clks_control & - SOF_DAI_INTEL_SSP_CLKCTRL_MCLK_ES)) { + if (!(ssp->clk_active & SSP_CLK_MCLK_ES_REQ)) { dai_info(dai, "ssp_post_stop releasing MCLK clocks for SSP%d...", dai->index); ssp_mclk_disable_unprepare(dai); @@ -881,9 +883,7 @@ static void ssp_start(struct dai *dai, int direction) /* request mclk/bclk */ ssp_pre_start(dai); - if (!(ssp->params.clks_control & - SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_ES)) { - + if (!(ssp->clk_active & SSP_CLK_BCLK_ES_REQ)) { /* enable TRSE/RSRE before SSE */ ssp_update_bits(dai, SSCR1, SSCR1_TSRE | SSCR1_RSRE, @@ -948,9 +948,7 @@ static void ssp_stop(struct dai *dai, int direction) /* disable SSP port if no users */ if (ssp->state[SOF_IPC_STREAM_CAPTURE] == COMP_STATE_PREPARE && ssp->state[SOF_IPC_STREAM_PLAYBACK] == COMP_STATE_PREPARE) { - if (!(ssp->params.clks_control & - SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_ES)) { - + if (!(ssp->clk_active & SSP_CLK_BCLK_ES_REQ)) { /* clear TRSE/RSRE before SSE */ ssp_update_bits(dai, SSCR1, SSCR1_TSRE | SSCR1_RSRE, diff --git a/src/include/sof/drivers/ssp.h b/src/include/sof/drivers/ssp.h index d672159ca..94787fe25 100644 --- a/src/include/sof/drivers/ssp.h +++ b/src/include/sof/drivers/ssp.h @@ -224,8 +224,10 @@ extern const struct dai_driver ssp_driver; #define ssp_irq(ssp) \ ssp->plat_data.irq -#define SSP_CLK_MCLK_ACTIVE BIT(0) -#define SSP_CLK_BCLK_ACTIVE BIT(1) +#define SSP_CLK_MCLK_ES_REQ BIT(0) +#define SSP_CLK_MCLK_ACTIVE BIT(1) +#define SSP_CLK_BCLK_ES_REQ BIT(2) +#define SSP_CLK_BCLK_ACTIVE BIT(3) /* SSP private data */ struct ssp_pdata {