lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 10 Oct 2018 09:33:24 +0000
From:   Vokáč Michal <Michal.Vokac@...ft.com>
To:     Thierry Reding <thierry.reding@...il.com>,
        Rob Herring <robh+dt@...nel.org>
CC:     Mark Rutland <mark.rutland@....com>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
        "linux-pwm@...r.kernel.org" <linux-pwm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Lukasz Majewski <l.majewski@...ess.pl>,
        Fabio Estevam <fabio.estevam@....com>,
        Lothar Waßmann <LW@...o-electronics.de>,
        Vokáč Michal <Michal.Vokac@...ft.com>
Subject: [RCF PATCH v2 0/2] pwm: imx: Configure output to GPIO in disabled state

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ