Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936657AbcLTTT6 (ORCPT ); Tue, 20 Dec 2016 14:19:58 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:44969 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761842AbcLTTRJ (ORCPT ); Tue, 20 Dec 2016 14:17:09 -0500 Date: Tue, 20 Dec 2016 20:16:56 +0100 From: Maxime Ripard To: codekipper@gmail.com Cc: linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, lgirdwood@gmail.com, broonie@kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, be17068@iperbole.bo.it Subject: Re: [PATCH] ASoC: sun4i-i2s: Add quirks for newer SoCs Message-ID: <20161220191656.xrmovtlslwcofsts@lukather> References: <20161220145524.31047-1-codekipper@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6g6gikibm3dnmrwe" Content-Disposition: inline In-Reply-To: <20161220145524.31047-1-codekipper@gmail.com> User-Agent: Mutt/1.6.2-neo (2016-08-21) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5734 Lines: 177 --6g6gikibm3dnmrwe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Tue, Dec 20, 2016 at 03:55:24PM +0100, codekipper@gmail.com wrote: > From: Marcus Cooper >=20 > Newer SoCs have additional functionality so a quirks structure > has been added to handle them. So far we've seen the use of a > reset controller, a different address for the TXFIFO and varying > register changes. >=20 > This patch prepares the driver for these changes and adds the > reset specifier. >=20 > Signed-off-by: Marcus Cooper > --- > .../devicetree/bindings/sound/sun4i-i2s.txt | 2 + > sound/soc/sunxi/sun4i-i2s.c | 47 ++++++++++++++++= ++++-- > 2 files changed, 45 insertions(+), 4 deletions(-) >=20 > diff --git a/Documentation/devicetree/bindings/sound/sun4i-i2s.txt b/Docu= mentation/devicetree/bindings/sound/sun4i-i2s.txt > index 7a2c0945fd22..494a881ccd21 100644 > --- a/Documentation/devicetree/bindings/sound/sun4i-i2s.txt > +++ b/Documentation/devicetree/bindings/sound/sun4i-i2s.txt > @@ -18,6 +18,8 @@ Required properties: > - "apb" : clock for the I2S bus interface > - "mod" : module clock for the I2S controller > - #sound-dai-cells : Must be equal to 0 > +- resets: reset specifier for the ahb reset (A31 and newer only) > + > =20 > Example: > =20 > diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c > index f24d19526603..80fe4f1d6e3b 100644 > --- a/sound/soc/sunxi/sun4i-i2s.c > +++ b/sound/soc/sunxi/sun4i-i2s.c > @@ -14,9 +14,11 @@ > #include > #include > #include > +#include > #include > #include > #include > +#include > =20 > #include > #include > @@ -92,6 +94,7 @@ struct sun4i_i2s { > struct clk *bus_clk; > struct clk *mod_clk; > struct regmap *regmap; > + struct reset_control *rst; > =20 > unsigned int mclk_freq; > =20 > @@ -104,6 +107,13 @@ struct sun4i_i2s_clk_div { > u8 val; > }; > =20 > +struct sun4i_i2s_quirks { > + unsigned int reg_dac_txdata; /* TX FIFO offset for DMA config */ > + bool has_reset; > + const struct regmap_config *sun4i_i2s_regmap; > + const struct snd_soc_dai_ops *ops; > +}; > + This is quite hard to review without actual example of what you'll put in there. > static const struct sun4i_i2s_clk_div sun4i_i2s_bclk_div[] =3D { > { .div =3D 2, .val =3D 0 }, > { .div =3D 4, .val =3D 1 }, > @@ -541,7 +551,6 @@ static struct snd_soc_dai_driver sun4i_i2s_dai =3D { > .rates =3D SNDRV_PCM_RATE_8000_192000, > .formats =3D SNDRV_PCM_FMTBIT_S16_LE, > }, > - .ops =3D &sun4i_i2s_dai_ops, > .symmetric_rates =3D 1, > }; > =20 > @@ -655,6 +664,7 @@ static int sun4i_i2s_probe(struct platform_device *pd= ev) > { > struct sun4i_i2s *i2s; > struct resource *res; > + const struct sun4i_i2s_quirks *quirks; > void __iomem *regs; > int irq, ret; > =20 > @@ -680,8 +690,14 @@ static int sun4i_i2s_probe(struct platform_device *p= dev) > return PTR_ERR(i2s->bus_clk); > } > =20 > + quirks =3D of_device_get_match_data(&pdev->dev); > + if (quirks =3D=3D NULL) { > + dev_err(&pdev->dev, "Failed to determine the quirks to use\n"); > + return -ENODEV; > + } > + > i2s->regmap =3D devm_regmap_init_mmio(&pdev->dev, regs, > - &sun4i_i2s_regmap_config); > + quirks->sun4i_i2s_regmap); > if (IS_ERR(i2s->regmap)) { > dev_err(&pdev->dev, "Regmap initialisation failed\n"); > return PTR_ERR(i2s->regmap); > @@ -692,13 +708,25 @@ static int sun4i_i2s_probe(struct platform_device *= pdev) > dev_err(&pdev->dev, "Can't get our mod clock\n"); > return PTR_ERR(i2s->mod_clk); > } > + Spurious change? > =09 > - i2s->playback_dma_data.addr =3D res->start + SUN4I_I2S_FIFO_TX_REG; > + i2s->playback_dma_data.addr =3D res->start + quirks->reg_dac_txdata; > i2s->playback_dma_data.maxburst =3D 4; > =20 > i2s->capture_dma_data.addr =3D res->start + SUN4I_I2S_FIFO_RX_REG; > i2s->capture_dma_data.maxburst =3D 4; > =20 > + if (quirks->has_reset) { > + i2s->rst =3D devm_reset_control_get_optional(&pdev->dev, NULL); > + if (IS_ERR(i2s->rst) && PTR_ERR(i2s->rst) =3D=3D -EPROBE_DEFER) { > + ret =3D -EPROBE_DEFER; > + dev_err(&pdev->dev, "Failed to get reset: %d\n", ret); > + goto err_pm_disable; > + } > + if (!IS_ERR(i2s->rst)) > + reset_control_deassert(i2s->rst); > + } > + That reset line is not optional. The