From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933108AbdBHIzJ (ORCPT ); Wed, 8 Feb 2017 03:55:09 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:38194 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933154AbdBHIh7 (ORCPT ); Wed, 8 Feb 2017 03:37:59 -0500 Date: Wed, 8 Feb 2017 08:53:27 +0100 From: Maxime Ripard To: lis8215@gmail.com Cc: linux-sunxi@googlegroups.com, thierry.reding@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, wens@csie.org, linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/4] ARM: pwm: sun6i: add support the Allwinner A31 PWM. Message-ID: <20170208075327.vv4p4svukxh7frvn@lukather> References: <1486489846-662-1-git-send-email-lis8215@gmail.com> <1486489846-662-4-git-send-email-lis8215@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="seq76nlc3mleerbw" Content-Disposition: inline In-Reply-To: <1486489846-662-4-git-send-email-lis8215@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 --seq76nlc3mleerbw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 07, 2017 at 08:50:45PM +0300, lis8215@gmail.com wrote: > From: Siarhei Volkau >=20 > This patch introduce the sun6i PWM driver itself: > - sun6i register operations, > - sun6i prescaler table, > - DT bindings for A31 SoC, > - documentation update. >=20 > Signed-off-by: Siarhei Volkau > --- > .../devicetree/bindings/pwm/pwm-sun4i.txt | 3 +- > drivers/pwm/pwm-sun4i.c | 71 ++++++++++++++++= ++++++ > 2 files changed, 73 insertions(+), 1 deletion(-) >=20 > diff --git a/Documentation/devicetree/bindings/pwm/pwm-sun4i.txt b/Docume= ntation/devicetree/bindings/pwm/pwm-sun4i.txt > index f1cbeef..b737934 100644 > --- a/Documentation/devicetree/bindings/pwm/pwm-sun4i.txt > +++ b/Documentation/devicetree/bindings/pwm/pwm-sun4i.txt > @@ -1,10 +1,11 @@ > -Allwinner sun4i and sun7i SoC PWM controller > +Allwinner sun4i, sun6i and sun7i SoC PWM controller > =20 > Required properties: > - compatible: should be one of: > - "allwinner,sun4i-a10-pwm" > - "allwinner,sun5i-a10s-pwm" > - "allwinner,sun5i-a13-pwm" > + - "allwinner,sun6i-a31-pwm" > - "allwinner,sun7i-a20-pwm" > - "allwinner,sun8i-h3-pwm" > - reg: physical base address and length of the controller's registers > diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c > index 39912fc..0c1c372 100644 > --- a/drivers/pwm/pwm-sun4i.c > +++ b/drivers/pwm/pwm-sun4i.c > @@ -47,6 +47,12 @@ > =20 > #define BIT_CH(bit, chan) ((bit) << ((chan) * PWMCH_OFFSET)) > =20 > +#define SUN6I_PWM_RDY_BIT PWM_RDY_BASE > +#define SUN6I_PWM_CTL_OFFS 0x0 > +#define SUN6I_PWM_PRD_OFFS 0x4 > +#define SUN6I_PWM_CH_CTL(ch) (0x10 * (ch) + SUN6I_PWM_CTL_OFFS) > +#define SUN6I_PWM_CH_PRD(ch) (0x10 * (ch) + SUN6I_PWM_PRD_OFFS) > + > struct sun4i_pwm_chip; > =20 > static const u32 sun4i_prescaler_table[] =3D { > @@ -68,6 +74,25 @@ static const u32 sun4i_prescaler_table[] =3D { > 0, /* Actually 1 but tested separately */ > }; > =20 > +static const u32 sun6i_prescaler_table[] =3D { > + 1, > + 2, > + 4, > + 8, > + 16, > + 32, > + 64, > + 0, > + 0, > + 0, > + 0, > + 0, > + 0, > + 0, > + 0, > + 0, > +}; > + > struct sunxi_reg_ops { > int (*ctl_rdy)(struct sun4i_pwm_chip *chip, int npwm); > u32 (*ctl_read)(struct sun4i_pwm_chip *chip, int npwm); > @@ -140,6 +165,33 @@ static void sun4i_reg_prd_write(struct sun4i_pwm_chi= p *chip, int npwm, u32 val) > sun4i_pwm_writel(chip, val, PWM_CH_PRD(npwm)); > } > =20 > +static int sun6i_reg_ctl_rdy(struct sun4i_pwm_chip *chip, int npwm) > +{ > + u32 val =3D sun4i_pwm_readl(chip, SUN6I_PWM_CH_CTL(npwm)); > + > + return val & BIT(SUN6I_PWM_RDY_BIT); > +} > + > +static u32 sun6i_reg_ctl_read(struct sun4i_pwm_chip *chip, int npwm) > +{ > + return sun4i_pwm_readl(chip, SUN6I_PWM_CH_CTL(npwm)); > +} > + > +static void sun6i_reg_ctl_write(struct sun4i_pwm_chip *chip, int npwm, u= 32 val) > +{ > + return sun4i_pwm_writel(chip, val, SUN6I_PWM_CH_CTL(npwm)); > +} > + > +static u32 sun6i_reg_prd_read(struct sun4i_pwm_chip *chip, int npwm) > +{ > + return sun4i_pwm_readl(chip, SUN6I_PWM_CH_PRD(npwm)); > +} > + > +static void sun6i_reg_prd_write(struct sun4i_pwm_chip *chip, int npwm, u= 32 val) > +{ > + return sun4i_pwm_writel(chip, val, SUN6I_PWM_CH_PRD(npwm)); > +} > + > static int sun4i_pwm_config(struct pwm_chip *chip, struct pwm_device *pw= m, > int duty_ns, int period_ns) > { > @@ -306,6 +358,14 @@ static const struct sunxi_reg_ops sun4i_reg_ops =3D { > .prd_write =3D sun4i_reg_prd_write, > }; > =20 > +static const struct sunxi_reg_ops sun6i_reg_ops =3D { > + .ctl_rdy =3D sun6i_reg_ctl_rdy, > + .ctl_read =3D sun6i_reg_ctl_read, > + .ctl_write =3D sun6i_reg_ctl_write, > + .prd_read =3D sun6i_reg_prd_read, > + .prd_write =3D sun6i_reg_prd_write, > +}; > + =2E.. And use regmap's reg_field to deal with the different offsets in that case ? Looks quite good otherwise, thanks! Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --seq76nlc3mleerbw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJYms53AAoJEBx+YmzsjxAgY34P/0vUNACYQmBtupVauCruCeh3 XD14kH9sKjfE4jjCEJNtkbhTT8hQsrUZbCJmZNoAjffkJLesyR0v/jodP06duCmn AhxBWa5MDyOhYdG6b4XqWMIEJVTDYbCGug5OyB6llpxdwc3Ogmy7kzYsjFUkqxPy Q/0uPHMLpTCsZCM/ajp+U/54wp6JsdN7tzkrOM3UvYcBMaZX4fxfsGTxY6IvwYF9 XNaDxv53uwnRm2vAvK7jO6P8eSyoJx3Yoq36Cnwv14wfhJcXERlwBt7eJL+KLZvU V81XkgMk97QbqmBniJq0qcdW7d8zVrW+g3FizfJhP2tOZOIxmFL1eLSKn8kVzWrX qzqFpXJ7imQ/FBnNGbNnIDcFK9L0Zrbh64gtF1rEx0WkFnbCnYUp+SE8UCgG9z1D AtPjNxW++fqtuDDIQ2iV24fQ1b+niBJ8r2bTD/5ezv4kFWucYBZm0kJbnNCcOsQp HerXxJmy8SFpIWIh4aJp8/+MjyWDMEbZOZQCwHNPeHem1bT0iv0cMgezEWWNTt8b 9ONxkK2NvigTJLsWw4OdehiiYsiubHx5lGvIto6Txe5GAGKNTpFSIEYxoMM+jiA8 ZymX7qfSvivu2aHDPJ47fvOE7uUME7CcfQT7rQRCNL18R3zQfK+dRInJ7R2gQGKU X86rnCubDF/Y7LZQnRqc =FEAb -----END PGP SIGNATURE----- --seq76nlc3mleerbw--