linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RCF PATCH v2 0/2] pwm: imx: Configure output to GPIO in disabled state
@ 2018-10-10  9:33 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  9:33 ` [RCF PATCH v2 2/2] pwm: imx: Configure output to GPIO in disabled state Vokáč Michal
  0 siblings, 2 replies; 60+ messages in thread
From: Vokáč Michal @ 2018-10-10  9:33 UTC (permalink / raw)
  To: Thierry Reding, Rob Herring
  Cc: Mark Rutland, devicetree, linux-pwm, linux-kernel,
	Lukasz Majewski, Fabio Estevam, Lothar Waßmann,
	Vokáč Michal

This is an attempt to deal with i.MX SoC PWM HW limitation.
When a pad is configured as a PWM output the output level is always 0V
if the PWM block is disabled. This can cause problems when inverted PWM
signal is needed to drive the connected circuit. With inverted output
duty cycle = 0% corresponds to high output level and duty cycle = 100%
corresponds to low output level. This means that whenever the PWM block
is disabled the connected circuit is fed with 100% duty cycle.

This issue has been discussed in various threads about inverted PWM
support implementation. Finally this commit 326ed314fefe ("pwm: imx:
Add polarity inversion support to i.MX's PWMv2") from Lukasz was merged.

Later on Fabio came up with the same problem as I described.
His commit 1f6eefeb7cd4 ("pwm: imx: Let PWM be active during suspend")
solves the problem only in suspend state and not whenever PWM is disabled.

In the discussion Fabio also suggested a pinctrl solution though it was
still only for suspend [1].

I would like to bring attention to that pinctrl solution once again.
The code is basically a copy of the I2C recovery function [2].

This binding is totally optional and current users are not affected.

The idea is to use two new pinctrl states, "pwm" and "gpio", instead of
the "default" pinctrl state. The gpio state is selected  when PWM is
disabled and the pwm pinctrl state is selected when PWM is enabled. In the
gpio state level on the output is controlled by a new pwm-gpios signal.

Note that there is no conflict with the "default" pinctrl state. You can
actually define all the three states at the same time. The only effect is
that the pinctl driver will configure the pins to the default pinctrl
state as usual. Then when the imx-pwm driver gets control of the HW, it
configures the right pinctrl state according to the PWM state. So you may
end up with some additional level changes on the output during probe.

When switching the pinctrl states it is important to do it in the right
order. When disabling PWM, first set the GPIO output value, then change
the muxing and at last disable the PWM. And vice versa to enable the PWM
output. Otherwise you will get unwanted level changes on the output.

I would like to know your opinion on this, thanks.

Michal

[1] https://patchwork.ozlabs.org/patch/839834/#1819865
[2] https://elixir.bootlin.com/linux/latest/source/drivers/i2c/busses/i2c-imx.c#L989

Changes in v2:
 - Do not use the "default" pinctrl state for GPIO.
 - Use extra "pwm" and "gpio" pinctrl states.
 - Add a pwm-gpios signal to drive the output in "gpio" pinctrl state.
 - Select the right pinctrl state in probe.

Michal Vokáč (2):
  dt-bindings: pwm: imx: Allow switching PWM output between PWM and GPIO
  pwm: imx: Configure output to GPIO in disabled state

 Documentation/devicetree/bindings/pwm/imx-pwm.txt | 51 ++++++++++++++
 drivers/pwm/pwm-imx.c                             | 86 +++++++++++++++++++++++
 2 files changed, 137 insertions(+)

-- 
2.1.4


^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2018-11-26 15:51 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).