Re: [PATCH v2 2/8] ASoC: SOF: imx8: use common imx chip interface

From: Frank Li
Date: Thu Feb 06 2025 - 11:11:22 EST


On Wed, Feb 05, 2025 at 03:30:16PM -0500, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@xxxxxxx>
>
> The common interface for imx chips (defined in imx-common.c) contains the
> definitions for a lot of functions required by the SOF core. As such, the
> platform driver can just use the common definitions instead of duplicating
> code by re-defining aforementioned functions.
>
> Make the transition to the new common interface. This consists of:
>
> 1) Removing unneeded functions, which are already defined in the
> common interface.
>
> 2) Defining some chip-specific operations/structures required by the
> interface to work.
>
> 3) Dropping structure definitions that are no longer needed.
>
> 4) Adapting some existing functions to the new interface.
>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@xxxxxxx>
> ---
> sound/soc/sof/imx/imx8.c | 522 +++++----------------------------------
> 1 file changed, 65 insertions(+), 457 deletions(-)
>
> diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c
> index 1e7bf00d7c46..25e3296a1e5e 100644
> --- a/sound/soc/sof/imx/imx8.c
> +++ b/sound/soc/sof/imx/imx8.c
> @@ -1,6 +1,6 @@

...
> static int imx8x_run(struct snd_sof_dev *sdev)
> {
> - struct imx8_priv *dsp_priv = sdev->pdata->hw_pdata;
> int ret;
>
> - ret = imx_sc_misc_set_control(dsp_priv->sc_ipc, IMX_SC_R_DSP,
> + ret = imx_sc_misc_set_control(get_chip_pdata(sdev), IMX_SC_R_DSP,
> IMX_SC_C_OFS_SEL, 1);
> if (ret < 0) {
> dev_err(sdev->dev, "Error system address offset source select\n");
> return ret;
> }
>
> - ret = imx_sc_misc_set_control(dsp_priv->sc_ipc, IMX_SC_R_DSP,
> + ret = imx_sc_misc_set_control(get_chip_pdata(sdev), IMX_SC_R_DSP,
> IMX_SC_C_OFS_AUDIO, 0x80);
> if (ret < 0) {
> dev_err(sdev->dev, "Error system address offset of AUDIO\n");
> return ret;
> }
>
> - ret = imx_sc_misc_set_control(dsp_priv->sc_ipc, IMX_SC_R_DSP,
> + ret = imx_sc_misc_set_control(get_chip_pdata(sdev), IMX_SC_R_DSP,
> IMX_SC_C_OFS_PERIPH, 0x5A);

Not related with patch change, Can you define such magic number 0x5A,
0x80, 0x51? You can improve it later.

Reviewed-by: Frank Li <Frank.Li@xxxxxxx>

> if (ret < 0) {
> dev_err(sdev->dev, "Error system address offset of PERIPH %d\n",
> @@ -142,14 +70,14 @@ static int imx8x_run(struct snd_sof_dev *sdev)
> return ret;
> }
>
...
> .ipc_supported_mask = BIT(SOF_IPC_TYPE_3),
> .ipc_default = SOF_IPC_TYPE_3,
> .default_fw_path = {
> @@ -666,6 +273,7 @@ static struct sof_dev_desc sof_of_imx8qm_desc = {
> },
> .nocodec_tplg_filename = "sof-imx8-nocodec.tplg",
> .ops = &sof_imx8_ops,
> + .ops_init = imx8_ops_init,
> };
>
> static const struct of_device_id sof_of_imx8_ids[] = {
> --
> 2.34.1
>