All of lore.kernel.org
 help / color / mirror / Atom feed
From: Doug Anderson <dianders@chromium.org>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: Heiko Stuebner <heiko@sntech.de>,
	Caesar Wang <caesar.wang@rock-chips.com>,
	Sonny Rao <sonnyrao@chromium.org>,
	Olof Johansson <olof@lixom.net>,
	Eddie Cai <eddie.cai@rock-chips.com>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	linux-pwm <linux-pwm@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/4] pwm: rockchip: Allow polarity invert on rk3288
Date: Tue, 19 Aug 2014 09:05:20 -0700	[thread overview]
Message-ID: <CAD=FV=Uvx3PMJRdnm4FKWWx4h3sN0Mn1yG6v245HnKur_3vgqQ@mail.gmail.com> (raw)
In-Reply-To: <20140819071857.GD12859@ulmo>

Thierry

On Tue, Aug 19, 2014 at 12:18 AM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> On Mon, Aug 18, 2014 at 10:09:07AM -0700, Doug Anderson wrote:
> [...]
>> diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c
>>  #define PWM_LP_DISABLE               (0 << 8)
>>
>> @@ -32,6 +34,7 @@ struct rockchip_pwm_chip {
>>       struct pwm_chip chip;
>>       struct clk *clk;
>>       const struct rockchip_pwm_data *data;
>> +     enum pwm_polarity polarity;
>
> Why do you need this field? struct pwm_device already has a copy of it.

OK, good point.


>> @@ -74,10 +78,14 @@ static void rockchip_pwm_set_enable_v2(struct pwm_chip *chip, bool enable)
>>  {
>>       struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip);
>>       u32 enable_conf = PWM_OUTPUT_LEFT | PWM_LP_DISABLE | PWM_ENABLE |
>> -                       PWM_CONTINUOUS | PWM_DUTY_POSITIVE |
>> -                       PWM_INACTIVE_NEGATIVE;
>> +                       PWM_CONTINUOUS;
>>       u32 val;
>>
>> +     if (pc->polarity == PWM_POLARITY_INVERSED)
>> +             enable_conf |= PWM_DUTY_NEGATIVE | PWM_INACTIVE_POSITIVE;
>> +     else
>> +             enable_conf |= PWM_DUTY_POSITIVE | PWM_INACTIVE_NEGATIVE;
>
> I have a feeling you're going to answer the above question with: "Because
> it's needed here". If so, my reply would be: "Then this function should
> take a struct pwm_device instead of struct pwm_chip."

OK.  I've chosen to have it take a pwm_device AND a pwm_chip.  It is a
little redundant because a pwm_device has a pointer to its pwm_chip,
but it follows the lead of all of the callbacks in "struct pwm_ops".
If you'd like me to spin it to take only a pwm_device I'm happy to.


>
>> @@ -173,6 +195,7 @@ static const struct rockchip_pwm_data pwm_data_v2 = {
>>               .ctrl = 0x0c,
>>       },
>>       .prescaler = 1,
>> +     .has_invert = 1,
>
> Since has_invert is a boolean, the proper value here would be "true".

Done.


>> @@ -228,6 +252,10 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
>>       pc->data = id->data;
>>       pc->chip.dev = &pdev->dev;
>>       pc->chip.ops = &rockchip_pwm_ops;
>> +     if (pc->data->has_invert) {
>> +             pc->chip.of_xlate = of_pwm_xlate_with_flags;
>> +             pc->chip.of_pwm_n_cells = 3;
>> +     }
>>       pc->chip.base = -1;
>>       pc->chip.npwm = 1;
>
> I suggest to rewrite the above as follows for readability:
>
>         pc->data = id->data;
>         pc->chip.dev = &pdev->dev;
>         pc->chip.ops = &rockchip_pwm_ops;
>         pc->chip.base = -1;
>         pc->chip.npwm = 1;

Done.


> +       if (pc->data->has_invert) {
> +               pc->chip.of_xlate = of_pwm_xlate_with_flags;
> +               pc->chip.of_pwm_n_cells = 3;
> +       }
>
> Thierry

WARNING: multiple messages have this Message-ID (diff)
From: dianders@chromium.org (Doug Anderson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/4] pwm: rockchip: Allow polarity invert on rk3288
Date: Tue, 19 Aug 2014 09:05:20 -0700	[thread overview]
Message-ID: <CAD=FV=Uvx3PMJRdnm4FKWWx4h3sN0Mn1yG6v245HnKur_3vgqQ@mail.gmail.com> (raw)
In-Reply-To: <20140819071857.GD12859@ulmo>

Thierry

On Tue, Aug 19, 2014 at 12:18 AM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> On Mon, Aug 18, 2014 at 10:09:07AM -0700, Doug Anderson wrote:
> [...]
>> diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c
>>  #define PWM_LP_DISABLE               (0 << 8)
>>
>> @@ -32,6 +34,7 @@ struct rockchip_pwm_chip {
>>       struct pwm_chip chip;
>>       struct clk *clk;
>>       const struct rockchip_pwm_data *data;
>> +     enum pwm_polarity polarity;
>
> Why do you need this field? struct pwm_device already has a copy of it.

OK, good point.


>> @@ -74,10 +78,14 @@ static void rockchip_pwm_set_enable_v2(struct pwm_chip *chip, bool enable)
>>  {
>>       struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip);
>>       u32 enable_conf = PWM_OUTPUT_LEFT | PWM_LP_DISABLE | PWM_ENABLE |
>> -                       PWM_CONTINUOUS | PWM_DUTY_POSITIVE |
>> -                       PWM_INACTIVE_NEGATIVE;
>> +                       PWM_CONTINUOUS;
>>       u32 val;
>>
>> +     if (pc->polarity == PWM_POLARITY_INVERSED)
>> +             enable_conf |= PWM_DUTY_NEGATIVE | PWM_INACTIVE_POSITIVE;
>> +     else
>> +             enable_conf |= PWM_DUTY_POSITIVE | PWM_INACTIVE_NEGATIVE;
>
> I have a feeling you're going to answer the above question with: "Because
> it's needed here". If so, my reply would be: "Then this function should
> take a struct pwm_device instead of struct pwm_chip."

OK.  I've chosen to have it take a pwm_device AND a pwm_chip.  It is a
little redundant because a pwm_device has a pointer to its pwm_chip,
but it follows the lead of all of the callbacks in "struct pwm_ops".
If you'd like me to spin it to take only a pwm_device I'm happy to.


>
>> @@ -173,6 +195,7 @@ static const struct rockchip_pwm_data pwm_data_v2 = {
>>               .ctrl = 0x0c,
>>       },
>>       .prescaler = 1,
>> +     .has_invert = 1,
>
> Since has_invert is a boolean, the proper value here would be "true".

Done.


>> @@ -228,6 +252,10 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
>>       pc->data = id->data;
>>       pc->chip.dev = &pdev->dev;
>>       pc->chip.ops = &rockchip_pwm_ops;
>> +     if (pc->data->has_invert) {
>> +             pc->chip.of_xlate = of_pwm_xlate_with_flags;
>> +             pc->chip.of_pwm_n_cells = 3;
>> +     }
>>       pc->chip.base = -1;
>>       pc->chip.npwm = 1;
>
> I suggest to rewrite the above as follows for readability:
>
>         pc->data = id->data;
>         pc->chip.dev = &pdev->dev;
>         pc->chip.ops = &rockchip_pwm_ops;
>         pc->chip.base = -1;
>         pc->chip.npwm = 1;

Done.


> +       if (pc->data->has_invert) {
> +               pc->chip.of_xlate = of_pwm_xlate_with_flags;
> +               pc->chip.of_pwm_n_cells = 3;
> +       }
>
> Thierry

  reply	other threads:[~2014-08-19 16:05 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-18 17:09 [PATCH 0/4] PWM changes for rk3288-evb Doug Anderson
2014-08-18 17:09 ` Doug Anderson
2014-08-18 17:09 ` [PATCH 1/4] ARM: rockchip: rk3288: Switch to use the proper PWM IP Doug Anderson
2014-08-18 17:09   ` Doug Anderson
2014-08-18 17:11   ` Sonny Rao
2014-08-18 17:11     ` Sonny Rao
2014-08-18 17:19     ` Doug Anderson
2014-08-18 17:19       ` Doug Anderson
2014-08-19  7:10   ` Thierry Reding
2014-08-19  7:10     ` Thierry Reding
2014-08-19 15:18     ` Doug Anderson
2014-08-19 15:18       ` Doug Anderson
2014-08-20  6:08       ` Thierry Reding
2014-08-20  6:08         ` Thierry Reding
2014-08-20 15:20         ` Doug Anderson
2014-08-20 15:20           ` Doug Anderson
2014-08-20 15:38           ` Thierry Reding
2014-08-20 15:38             ` Thierry Reding
2014-08-20 15:55             ` Doug Anderson
2014-08-20 15:55               ` Doug Anderson
2014-08-20 16:20               ` Heiko Stübner
2014-08-20 16:20                 ` Heiko Stübner
2014-08-20 16:27                 ` Doug Anderson
2014-08-20 16:27                   ` Doug Anderson
2014-08-20 18:03                   ` Heiko Stübner
2014-08-20 18:03                     ` Heiko Stübner
2014-08-20 20:49                     ` Doug Anderson
2014-08-20 20:49                       ` Doug Anderson
2014-08-21  6:36                 ` Thierry Reding
2014-08-21  6:36                   ` Thierry Reding
2014-08-21 15:38                   ` Doug Anderson
2014-08-21 15:38                     ` Doug Anderson
2014-08-21 15:49                     ` Tomasz Figa
2014-08-21 15:49                       ` Tomasz Figa
2014-08-21 16:49                       ` Thierry Reding
2014-08-21 16:49                         ` Thierry Reding
2014-08-21 16:47                     ` Thierry Reding
2014-08-21 16:47                       ` Thierry Reding
2014-08-25 23:40                       ` Doug Anderson
2014-08-25 23:40                         ` Doug Anderson
2014-08-26  7:31                         ` Thierry Reding
2014-08-26  7:31                           ` Thierry Reding
2014-08-21  6:24               ` Thierry Reding
2014-08-21  6:24                 ` Thierry Reding
2014-08-21 15:39                 ` Doug Anderson
2014-08-21 15:39                   ` Doug Anderson
2014-08-21 15:53                 ` Heiko Stübner
2014-08-21 15:53                   ` Heiko Stübner
2014-08-18 17:09 ` [PATCH 2/4] pwm: rockchip: Allow polarity invert on rk3288 Doug Anderson
2014-08-18 17:09   ` Doug Anderson
2014-08-18 17:09   ` Doug Anderson
2014-08-19  7:18   ` Thierry Reding
2014-08-19  7:18     ` Thierry Reding
2014-08-19 16:05     ` Doug Anderson [this message]
2014-08-19 16:05       ` Doug Anderson
2014-08-19 16:05       ` Doug Anderson
2014-08-20  6:09       ` Thierry Reding
2014-08-20  6:09         ` Thierry Reding
2014-08-20  6:09         ` Thierry Reding
2014-08-18 17:09 ` [PATCH 3/4] ARM: dts: Add main PWM info to rk3288 Doug Anderson
2014-08-18 17:09   ` Doug Anderson
2014-08-18 17:09 ` [PATCH 4/4] ARM: dts: Enable pwm backlight on rk3288-EVB Doug Anderson
2014-08-18 17:09   ` Doug Anderson
2014-08-19  7:22   ` Thierry Reding
2014-08-19  7:22     ` Thierry Reding
2014-08-19  7:22     ` Thierry Reding
2014-08-19 16:05     ` Doug Anderson
2014-08-19 16:05       ` Doug Anderson
2014-08-19 16:05       ` Doug Anderson

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='CAD=FV=Uvx3PMJRdnm4FKWWx4h3sN0Mn1yG6v245HnKur_3vgqQ@mail.gmail.com' \
    --to=dianders@chromium.org \
    --cc=caesar.wang@rock-chips.com \
    --cc=devicetree@vger.kernel.org \
    --cc=eddie.cai@rock-chips.com \
    --cc=galak@codeaurora.org \
    --cc=heiko@sntech.de \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=olof@lixom.net \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sonnyrao@chromium.org \
    --cc=thierry.reding@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.