linux-kernel.vger.kernel.org archive mirror
 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: Thu, 8 Nov 2018 15:21:44 +0000	[thread overview]
Message-ID: <4fbb7307-df01-d7bd-f2e2-e05e6d17807d@ysoft.com> (raw)
In-Reply-To: <20181107150125.7cpd4v5t7yi2254c@pengutronix.de>

Hi Uwe,

On 7.11.2018 16:01, Uwe Kleine-König wrote:
>> Interesting idea. I just wonder why nobody else did not come up with such
>> a simple solution before.
> 
> I think I mentioned it already in this thread, but it went unnoticed :-)

I meant it like "How happened this was not invented years ago, when people
first noticed the issue with using inverted PWM for backlight on i.MX6."
In our project, this issue dates back to 2015 :(

> Then the patch isn't correct yet. The idea is always keep the hardware
> running and only disable it if it's uninverted.

OK, I got the point.

> In imx_pwm_probe it's not yet known what the polarity is supposed to be,
> right?

Not really. It can already be known but currently there is no way how to
pass the information to the probe function. I, as a creator of the device
(and author of a DTS file) know that the circuit needs inverted PWM signal.
And I know that the circuit needs to be disabled until I say it can be
enabled. How I say that can warry. It may be default brightness level > 0
in DTS file or from a userspace program using PWM sysfs interface.

> So the right thing to do there is to not touch the configuration
> of the pwm. I think all states that are problematic then are also
> problematic with the gpio/pinmux approach.

I think my use-case I already presented before is an example where
involving pinctrl solves the problem while the "leave PWM enabled
for inverted users" does not. That is all the time 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.
> 
> With the gpio/pinmux approach you don't know the intended polarity
> either and maybe enable the display, too.

You know it because the pinctrl solution is optional. So if you use it,
you use it on purpose to override the default PWM output level in PWM
disabled state. It is very useful in cases where you need inverted and
disabled PWM signal from power-up to userspace. Or until some kernel
driver (backlight, led, fan..) enables it. For this it is the only
solution I think.

It allows you to boot with disabled PWM that has normal polarity set
by default. Later on from your userspace program you configure the PWM
to desired period/duty, set PWM output to inversed and enable it.
Until this point the circuit is disabled with my solution.

> For both the solution is to let the bootloader enable the pwm with
> the right output level. Am I missing something?

Bootloader is only a small part of the whole solution I think. And I
suppose you meant: "enable the *GPIO* with the right output level".

  - Even if you use GPIO in bootloader to set the required level the
    time frame from imx_pwm_probe to imx_pwm_apply is not covered.

  - Currently there is no support in Linux pwm-imx driver to detect
    the PWM chip is already enabled at probe time. I actually send
    patches for this a month ago [1]. No response yet.

  - Inverted PWM does not work in U-Boot (on imx at least). And it
    does not seam like it can be fixed easily. I do not know what is
    the situation in other bootloaders.

So my current bootloader solution is one of:
  - Set the pin to the appropriate (HIGH) level using GPIO.
  - Do not touch the pin at all, it has 100k pull-up by default.

>> 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.
> 
> Isn't my change an improvement for all users? What state do you have in
> mind that make things worse than they are now?

Lets say that the user:
- Needs inverted PWM signal.
- Needs it to be disabled all the time unless he enable it.

Current situation:
H|____________________
L|                    \_________________________________________________
  +-------+------------+-----------------+-----------------+-------------+
  | reset | bootloader | default pinctrl | PWM enable 100% | PWM disable |

What you propose (for all users of inverted PWM):
H|____________________                                     _____________
L|                    \___________________________________/
  +-------+------------+-----------------+-----------------+-------------+
  | reset | bootloader | default pinctrl | PWM enable 100% | PWM disable |

My solution (for those who want it):
H|______________________________________                   _____________
L|                                      \_________________/
  +-------+------------+-----------------+-----------------+-------------+
  | reset | bootloader | default pinctrl | PWM enable 100% | PWM disable |

So your solution at least allows the user to really disable the circuit.
I can not really think of cases where this might not be good for current
users. Maybe that they simply expect that no matter what polarity is set,
the output in disabled state is always low. And they may have HW that
get already used to that and does not like the change :)

And it reminds me of something similar I have done for OLED display reset
recently [2]. I tried to fix active-low reset sequence that is hardcoded
in the driver. So you are supposed to use GPIO_ACTIVE_HIGH in DT to make
the active-low reset work. It was rejected. The reason was backward DTB
compatibility [3]. In other words: "Users of newer kernels expect that
the reset still work the same if they do not update DTBs on their boards".
I think this is kind of similar?

[1] http://patchwork.ozlabs.org/project/linux-pwm/list/?series=68445
[2] https://patchwork.kernel.org/project/linux-fbdev/list/?series=23775
[3] https://lkml.org/lkml/2018/10/9/135

Best regards,
Michal

  reply	other threads:[~2018-11-08 15:21 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
2018-11-07 15:01               ` Uwe Kleine-König
2018-11-08 15:21                 ` Vokáč Michal [this message]
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=4fbb7307-df01-d7bd-f2e2-e05e6d17807d@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 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).