All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vokáč Michal" <Michal.Vokac@ysoft.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: "Thierry Reding" <thierry.reding@gmail.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-pwm@vger.kernel.org" <linux-pwm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Lukasz Majewski" <l.majewski@majess.pl>,
	"Fabio Estevam" <fabio.estevam@nxp.com>,
	"Lothar Waßmann" <LW@karo-electronics.de>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>
Subject: Re: [RCF PATCH,v2,2/2] pwm: imx: Configure output to GPIO in disabled state
Date: Wed, 7 Nov 2018 13:32:10 +0000	[thread overview]
Message-ID: <eb4e7a42-bd5c-3ae2-ccb7-d1a73d5ae99c@ysoft.com> (raw)
In-Reply-To: <20181107093355.e4n3irrnkybqsjvc@pengutronix.de>

Hi Uwe,

On 7.11.2018 10:33, Uwe Kleine-König wrote:
> Hello Michal,
> 
> just to state it more explicitly, I think the following patch (not even
> compile tested) is much preferable over your approach:

Interesting idea. I just wonder why nobody else did not come up with such
a simple solution before.

> diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
> index 1d5242c9cde0..af88644b5efb 100644
> --- a/drivers/pwm/pwm-imx.c
> +++ b/drivers/pwm/pwm-imx.c
> @@ -216,7 +216,14 @@ static int imx_pwm_apply_v2(struct pwm_chip *chip, struct pwm_device *pwm,
>   			cr |= MX3_PWMCR_POUTC;
>   
>   		writel(cr, imx->mmio_base + MX3_PWMCR);
> -	} else if (cstate.enabled) {
> +	} else if (cstate.enabled && state->polarity == PWM_POLARITY_NORMAL) {
> +		/*
> +		 * When disabled in hardware the output pin goes to 0
> +		 * independant of the polarity setting. The expectation of some
> +		 * people however is that after disabling the pin goes to the
> +		 * inactive level which isn't given for an inversed pwm, so
> +		 * only disable for normal polarity.
> +		 */
>   		writel(0, imx->mmio_base + MX3_PWMCR);
>   
>   		clk_disable_unprepare(imx->clk_per);

I tested your patch. It does not work as you expected.

In v4.20-rc1 the pwm-backlight driver has been converted to atomic API.
So the pwm_apply_v2 function is called only once to set new period/duty
and state. With your patch that means that "echo 0 > brightness" has no
visible effect. It leaves the PWM chip enabled with period/duty set to
however it was. But the core thinks it was reconfigured:

# cat /sys/class/backlight/backight/brightness
0

# cat /sys/kernel/debug/pwm
platform/2080000.pwm, 1 PWM device
  pwm-0   (backlight           ): requested period: 500000 ns duty: 0 ns polarity: inverse

> I think it solves most if not all problems you want to address with the
> pinctrl stuff.

Unfortunately not. I also tested your patch on v4.19. It works as you
probably intended - it is possible to disable backlight without the PWM
chip being disabled. But it does not solve the time frame between
imx_pwm_probe() and imx_pwm_apply_v2().

In probe you do not have any users yet. So you do not know the requested
output polarity. With "default" pinctrl the PWM output would be muxed to
the selected pin and since the PWM chip is most probably disabled
(unless you enabled it in bootloader) you would get low level on the pin.
That means your backlight is fully enabled until the first call to
imx_pwm_apply_v2(). On my system this is 2 seconds.

It might not be a big issue for backlight but for motor control it is
not the right thing to do.

The other thing is I would prefer to make the change optional. With your
approach you are changing the behavior for all current users of inverted
PWM. I do not think all imx6 users are aware of the problem so they might
not be OK with the sudden change in the behavior.

I agree it would be nice if such a simple change as you proposed would
solve the problem. Still, I do not see any other solution than pinctrl
to deal with all the problems I would like to address.

Anyway, thank you for the idea!

All the best,
Michal

  reply	other threads:[~2018-11-07 13:32 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-10  9:33 [RCF PATCH v2 0/2] pwm: imx: Configure output to GPIO in disabled state Vokáč Michal
2018-10-10  9:33 ` [RCF PATCH v2 1/2] dt-bindings: pwm: imx: Allow switching PWM output between PWM and GPIO Vokáč Michal
2018-10-10 13:39   ` Thierry Reding
2018-10-29 15:52     ` Vokáč Michal
2018-10-10  9:33 ` [RCF PATCH v2 2/2] pwm: imx: Configure output to GPIO in disabled state Vokáč Michal
2018-10-12  8:57   ` [RCF PATCH,v2,2/2] " Uwe Kleine-König
2018-10-12 15:04     ` Vokáč Michal
2018-10-12 15:54       ` Thierry Reding
2018-10-12 16:08       ` Uwe Kleine-König
2018-10-14 20:24         ` Uwe Kleine-König
2018-10-15  8:45           ` Thierry Reding
2018-10-29 15:55             ` Vokáč Michal
2018-10-29 15:54         ` Vokáč Michal
2018-11-07  9:33           ` Uwe Kleine-König
2018-11-07 13:32             ` Vokáč Michal [this message]
2018-11-07 15:01               ` Uwe Kleine-König
2018-11-08 15:21                 ` Vokáč Michal
2018-11-08 19:18                   ` Uwe Kleine-König
2018-11-09 14:24                     ` Vokáč Michal
2018-11-09 16:55                       ` Uwe Kleine-König
2018-11-14  9:09                         ` Uwe Kleine-König
2018-11-14 11:34                         ` Thierry Reding
2018-11-14 21:51                           ` Uwe Kleine-König
2018-11-15 15:25                             ` Thierry Reding
2018-11-15 20:37                               ` Uwe Kleine-König
2018-11-16  7:34                                 ` Lothar Waßmann
2018-11-16  8:25                                   ` Uwe Kleine-König
2018-11-22 15:42                                     ` Vokáč Michal
2018-11-22 16:23                                       ` Uwe Kleine-König
2018-11-22 16:46                                         ` Vokáč Michal
2018-11-22 19:03                                           ` Uwe Kleine-König
2018-11-23 15:15                                             ` Vokáč Michal
2018-11-25 20:56                                               ` Uwe Kleine-König
2018-11-26  9:11                                                 ` Lothar Waßmann
2018-11-26  9:18                                                   ` Uwe Kleine-König
2018-11-26 10:03                                                     ` Lothar Waßmann
2018-11-26 11:51                                               ` Thierry Reding
2018-11-26 12:23                                                 ` Lothar Waßmann
2018-11-26 13:34                                                   ` Thierry Reding
2018-11-26 15:50                                                     ` Vokáč Michal
2018-11-16  9:51                                 ` Thierry Reding
2018-11-16 10:39                                   ` Uwe Kleine-König
2018-11-16 11:56                                     ` Lothar Waßmann
2018-11-18 11:30                                       ` Uwe Kleine-König
2018-11-16 12:24                                     ` Thierry Reding
2018-11-18 20:08                                       ` Uwe Kleine-König
2018-11-19  8:48                                         ` Uwe Kleine-König
2018-11-22 15:03                                         ` Thierry Reding
2018-11-22 16:17                                           ` Uwe Kleine-König
2018-11-20 13:14                                   ` Vokáč Michal
2018-11-20 16:54                                     ` Uwe Kleine-König
2018-11-22 14:23                                       ` Vokáč Michal
2018-11-19  7:44                             ` Linus Walleij
2018-11-19  8:32                               ` Uwe Kleine-König
2018-11-20  8:35                                 ` Linus Walleij
2018-11-20  9:16                                   ` Viresh Kumar
2018-11-20  9:53                                   ` Uwe Kleine-König
2018-11-14 11:14                   ` Thierry Reding
2018-10-12 16:00   ` [RCF PATCH v2 2/2] " Thierry Reding
2018-10-29 15:53     ` Vokáč Michal

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=eb4e7a42-bd5c-3ae2-ccb7-d1a73d5ae99c@ysoft.com \
    --to=michal.vokac@ysoft.com \
    --cc=LW@karo-electronics.de \
    --cc=devicetree@vger.kernel.org \
    --cc=fabio.estevam@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=l.majewski@majess.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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.