[alsa-devel] [PATCH 3/3] ASoC: fsl_sai: add i.MX8M support

Lucas Stach l.stach at pengutronix.de
Wed Jul 17 16:33:47 CEST 2019


Hi Daniel,

Am Mittwoch, den 17.07.2019, 17:16 +0300 schrieb Daniel Baluta:
> > On Wed, Jul 17, 2019 at 1:59 PM Lucas Stach <l.stach at pengutronix.de> wrote:
> > 
> > The SAI block on the i.MX8M moved the register layout, as 2 version
> > registers were added at the start of the register map. We deal with
> > this by moving the start of the regmap, so both register layouts
> > look the same to accesses going through the regmap.
> > 
> > Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
> 
> This is a little bit tricky. We need the verid register in order
> to differentiate IPs which can support 1:1 ratio for bclk:mclk

And this patch doesn't prevent this usage. If needed we can just read
the verid via a plain readl on the base mapping in the probe function
and cache it in struct fsl_sai. This seems way less intrusive than
carrying a register offset through all of the regmap accessors and
validation functions. I simply haven't implemented it in this patch, as
I had no need for it right now.

Regards,
Lucas

> I am working now for upstreaming all SAI patches that we have
> in our internal tree.
> 
> > ---
> >  .../devicetree/bindings/sound/fsl-sai.txt     |  2 +-
> >  sound/soc/fsl/fsl_sai.c                       | 19 +++++++++++++++++++
> >  sound/soc/fsl/fsl_sai.h                       |  1 +
> >  3 files changed, 21 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/sound/fsl-sai.txt b/Documentation/devicetree/bindings/sound/fsl-sai.txt
> > index 2e726b983845..037871d2f505 100644
> > --- a/Documentation/devicetree/bindings/sound/fsl-sai.txt
> > +++ b/Documentation/devicetree/bindings/sound/fsl-sai.txt
> > @@ -8,7 +8,7 @@ codec/DSP interfaces.
> >  Required properties:
> > 
> >    - compatible         : Compatible list, contains "fsl,vf610-sai",
> > -                         "fsl,imx6sx-sai" or "fsl,imx6ul-sai"
> > +                         "fsl,imx6sx-sai", "fsl,imx6ul-sai" or "fsl,imx8mq-sai"
> > 
> >    - reg                        : Offset and length of the register set for the device.
> > 
> > diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
> > index b3cd055a61c7..a10201078e40 100644
> > --- a/sound/soc/fsl/fsl_sai.c
> > +++ b/sound/soc/fsl/fsl_sai.c
> > @@ -808,6 +808,16 @@ static int fsl_sai_probe(struct platform_device *pdev)
> >         if (IS_ERR(base))
> >                 return PTR_ERR(base);
> > 
> > +       /*
> > +        * New versions of the SAI have 2 32bit version registers added at the
> > +        * start of the register map. To avoid dealing with this shift all over
> > +        * the driver, we move the start of the regmap to make both register
> > +        * layouts look the same to the regmap. This means we can't read the
> > +        * version registers through the regmap, but this is small price to pay.
> > +        */
> > +       if (sai->soc_data->has_version_registers)
> > +               base += 8;
> > +
> >         sai->regmap = devm_regmap_init_mmio_clk(&pdev->dev,
> >                         "bus", base, &fsl_sai_regmap_config);
> > 
> > @@ -923,18 +933,27 @@ static int fsl_sai_remove(struct platform_device *pdev)
> > 
> >  static const struct fsl_sai_soc_data fsl_sai_vf610_data = {
> >         .use_imx_pcm = false,
> > +       .has_version_registers = false,
> >         .fifo_depth = 32,
> >  };
> > 
> >  static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = {
> >         .use_imx_pcm = true,
> > +       .has_version_registers = false,
> >         .fifo_depth = 32,
> >  };
> > 
> > +static const struct fsl_sai_soc_data fsl_sai_imx8m_data = {
> > +       .use_imx_pcm = true,
> > +       .has_version_registers = true,
> > +       .fifo_depth = 128,
> > +};
> > +
> >  static const struct of_device_id fsl_sai_ids[] = {
> >         { .compatible = "fsl,vf610-sai", .data = &fsl_sai_vf610_data },
> >         { .compatible = "fsl,imx6sx-sai", .data = &fsl_sai_imx6sx_data },
> >         { .compatible = "fsl,imx6ul-sai", .data = &fsl_sai_imx6sx_data },
> > +       { .compatible = "fsl,imx8mq-sai", .data = &fsl_sai_imx8m_data },
> >         { /* sentinel */ }
> >  };
> >  MODULE_DEVICE_TABLE(of, fsl_sai_ids);
> > diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h
> > index 7c1ef671da28..b6a9053ed400 100644
> > --- a/sound/soc/fsl/fsl_sai.h
> > +++ b/sound/soc/fsl/fsl_sai.h
> > @@ -128,6 +128,7 @@
> > 
> >  struct fsl_sai_soc_data {
> >         bool use_imx_pcm;
> > +       bool has_version_registers;
> >         unsigned int fifo_depth;
> >  };
> > 
> > --
> > 2.20.1
> > 
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel at alsa-project.org
> > https://mailman.alsa-project.org/mailman/listinfo/alsa-devel


More information about the Alsa-devel mailing list