devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Icenowy Zheng <icenowy-ymACFijhrKM@public.gmane.org>
To: wens-jdAy2FN1RRM@public.gmane.org
Cc: Thierry Reding
	<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Maxime Ripard
	<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Russell King <linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org>,
	linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree <devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-kernel
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-sunxi <linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: [PATCH 2/5] pwm: sun4i: Add support for PWM controller on sun6i SoCs
Date: Wed, 12 Oct 2016 16:10:03 +0800	[thread overview]
Message-ID: <1476259803.2317.2.camel@Nokia-N900> (raw)
In-Reply-To: <CAGb2v65P7SQyEv+b0mU_FA=CQxy7qX9h7HE4NivqjZ-ZBh94ww-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Hi,

----- 原件 -----
> Hi,
> 
> On Wed, Oct 12, 2016 at 12:20 PM, Icenowy Zheng <icenowy-ymACFijhrKM@public.gmane.org> wrote:
> > The PWM controller in A31 is different with other Allwinner SoCs, with
> > a control register per channel (in other SoCs the control register is
> > shared), and each channel are allocated 16 bytes of address (but only 8
> > bytes are used.). The register map in one channel is just like a
> > single-channel A10 PWM controller, however, A31 have a different
> > prescaler table than other SoCs.
> > 
> > In order to use the driver for all 4 channels, device nodes should be
> > created per channel.
> 
> I think Maxime wants you to support the different register offsets
> in this driver, and have all 4 channels in the same device (node).

I think that will make the code much more complex...
And in hardware there may also be 4 controllers... as the register is aligned at 0x10.

The error I made in my previous patch set is making
a dedicatded pwm-sun6i driver. So I reworked this.
(This also why I do not call the current patchset PATCH v2 -- it's a new patchset)

Icenowy Zheng

> 
> ChenYu
> 
> 
> > Signed-off-by: Icenowy Zheng <icenowy-ymACFijhrKM@public.gmane.org>
> > ---
> > drivers/pwm/pwm-sun4i.c | 37 ++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 36 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
> > index 03a99a5..3e93bdf 100644
> > --- a/drivers/pwm/pwm-sun4i.c
> > +++ b/drivers/pwm/pwm-sun4i.c
> > @@ -46,7 +46,7 @@
> > 
> > #define BIT_CH(bit, chan)           ((bit) << ((chan) * PWMCH_OFFSET))
> > 
> > -static const u32 prescaler_table[] = {
> > +static const u32 prescaler_table_a10[] = {
> > 120,
> > 180,
> > 240,
> > @@ -65,10 +65,30 @@ static const u32 prescaler_table[] = {
> > 0, /* Actually 1 but tested separately */
> > };
> > 
> > +static const u32 prescaler_table_a31[] = {
> > +             1,
> > +             2,
> > +             4,
> > +             8,
> > +             16,
> > +             32,
> > +             64,
> > +             0,
> > +             0,
> > +             0,
> > +             0,
> > +             0,
> > +             0,
> > +             0,
> > +             0,
> > +             0,
> > +};
> > +
> > struct sun4i_pwm_data {
> > bool has_prescaler_bypass;
> > bool has_rdy;
> > unsigned int npwm;
> > +             const u32 *prescaler_table;
> > };
> > 
> > struct sun4i_pwm_chip {
> > @@ -100,6 +120,7 @@ static int sun4i_pwm_config(struct pwm_chip *chip,
> > struct pwm_device *pwm, int duty_ns, int period_ns)
> > {
> > struct sun4i_pwm_chip *sun4i_pwm = to_sun4i_pwm_chip(chip);
> > +             const u32 *prescaler_table = sun4i_pwm->data->prescaler_table;
> > u32 prd, dty, val, clk_gate;
> > u64 clk_rate, div = 0;
> > unsigned int prescaler = 0;
> > @@ -264,24 +285,35 @@ static const struct sun4i_pwm_data
> > sun4i_pwm_data_a10 = { .has_prescaler_bypass = false,
> > .has_rdy = false,
> > .npwm = 2,
> > +             .prescaler_table = prescaler_table_a10,
> > };
> > 
> > static const struct sun4i_pwm_data sun4i_pwm_data_a10s = {
> > .has_prescaler_bypass = true,
> > .has_rdy = true,
> > .npwm = 2,
> > +             .prescaler_table = prescaler_table_a10,
> > };
> > 
> > static const struct sun4i_pwm_data sun4i_pwm_data_a13 = {
> > .has_prescaler_bypass = true,
> > .has_rdy = true,
> > .npwm = 1,
> > +             .prescaler_table = prescaler_table_a10,
> > };
> > 
> > static const struct sun4i_pwm_data sun4i_pwm_data_a20 = {
> > .has_prescaler_bypass = true,
> > .has_rdy = true,
> > .npwm = 2,
> > +             .prescaler_table = prescaler_table_a10,
> > +};
> > +
> > +static const struct sun4i_pwm_data sun4i_pwm_data_a31 = {
> > +             .has_prescaler_bypass = false,
> > +             .has_rdy = true,
> > +             .npwm = 1,
> > +             .prescaler_table = prescaler_table_a31,
> > };
> > 
> > static const struct of_device_id sun4i_pwm_dt_ids[] = {
> > @@ -298,6 +330,9 @@ static const struct of_device_id
> > sun4i_pwm_dt_ids[] = { .compatible = "allwinner,sun7i-a20-pwm",
> > .data = &sun4i_pwm_data_a20,
> > }, {
> > +                             .compatible = "allwinner,sun6i-a31-pwm",
> > +                             .data = &sun4i_pwm_data_a31
> > +             }, {
> > /* sentinel */
> > },
> > };
> > --
> > 2.10.1
> > 
> > --
> > You received this message because you are subscribed to the Google
> > Groups "linux-sunxi" group. To unsubscribe from this group and stop
> > receiving emails from it, send an email to
> > linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit
> > https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "linux-sunxi" group. To unsubscribe from this group and stop
> receiving emails from it, send an email to
> linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit
> https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

  parent reply	other threads:[~2016-10-12  8:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-12  4:20 [PATCH 1/5] dt-bindings: add binding for Allwinner A31 SoC PWM controller Icenowy Zheng
     [not found] ` <20161012042059.40015-1-icenowy-ymACFijhrKM@public.gmane.org>
2016-10-12  4:20   ` [PATCH 2/5] pwm: sun4i: Add support for PWM controller on sun6i SoCs Icenowy Zheng
     [not found]     ` <20161012042059.40015-2-icenowy-ymACFijhrKM@public.gmane.org>
2016-10-12  7:30       ` Chen-Yu Tsai
     [not found]         ` <CAGb2v65P7SQyEv+b0mU_FA=CQxy7qX9h7HE4NivqjZ-ZBh94ww-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-12  8:10           ` Icenowy Zheng [this message]
2016-10-14 12:57             ` Maxime Ripard
2016-10-16 14:29               ` Icenowy Zheng
     [not found]                 ` <4823581476628157-Lmo0JfpuFbtxpj1cXAZ9Bg@public.gmane.org>
2016-10-17 20:08                   ` Maxime Ripard
2016-10-14 12:55           ` Maxime Ripard
2016-10-12  4:20   ` [PATCH 3/5] ARM: dts: sun6i: add PWM controller Icenowy Zheng
2016-10-12  4:20   ` [PATCH 4/5] ARM: dts: sun6i: add pinmux for PWM0 Icenowy Zheng
     [not found]     ` <20161012042059.40015-4-icenowy-ymACFijhrKM@public.gmane.org>
2016-10-12  7:27       ` Chen-Yu Tsai
2016-10-12  4:20   ` [PATCH 5/5] ARM: dts: sun6i: add pwm backlight for reference design tablet Icenowy Zheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1476259803.2317.2.camel@Nokia-N900 \
    --to=icenowy-ymacfijhrkm@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=wens-jdAy2FN1RRM@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).