linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: thierry.reding@gmail.com (Thierry Reding)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/4] pwm: rockchip: Allow polarity invert on rk3288
Date: Tue, 19 Aug 2014 09:18:58 +0200	[thread overview]
Message-ID: <20140819071857.GD12859@ulmo> (raw)
In-Reply-To: <1408381749-14156-3-git-send-email-dianders@chromium.org>

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.

> @@ -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."

> @@ -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".

> @@ -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;
+
+	if (pc->data->has_invert) {
+		pc->chip.of_xlate = of_pwm_xlate_with_flags;
+		pc->chip.of_pwm_n_cells = 3;
+	}

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140819/51892853/attachment.sig>

  reply	other threads:[~2014-08-19  7:18 UTC|newest]

Thread overview: 32+ 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 ` [PATCH 1/4] ARM: rockchip: rk3288: Switch to use the proper PWM IP Doug Anderson
2014-08-18 17:11   ` Sonny Rao
2014-08-18 17:19     ` Doug Anderson
2014-08-19  7:10   ` Thierry Reding
2014-08-19 15:18     ` Doug Anderson
2014-08-20  6:08       ` Thierry Reding
2014-08-20 15:20         ` Doug Anderson
2014-08-20 15:38           ` Thierry Reding
2014-08-20 15:55             ` Doug Anderson
2014-08-20 16:20               ` Heiko Stübner
2014-08-20 16:27                 ` Doug Anderson
2014-08-20 18:03                   ` Heiko Stübner
2014-08-20 20:49                     ` Doug Anderson
2014-08-21  6:36                 ` Thierry Reding
2014-08-21 15:38                   ` Doug Anderson
2014-08-21 15:49                     ` Tomasz Figa
2014-08-21 16:49                       ` Thierry Reding
2014-08-21 16:47                     ` Thierry Reding
2014-08-25 23:40                       ` Doug Anderson
2014-08-26  7:31                         ` Thierry Reding
2014-08-21  6:24               ` Thierry Reding
2014-08-21 15:39                 ` Doug Anderson
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-19  7:18   ` Thierry Reding [this message]
2014-08-19 16:05     ` Doug Anderson
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 ` [PATCH 4/4] ARM: dts: Enable pwm backlight on rk3288-EVB Doug Anderson
2014-08-19  7:22   ` Thierry Reding
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=20140819071857.GD12859@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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).