linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michal Vokáč" <michal.vokac@ysoft.com>
To: Thierry Reding <thierry.reding@gmail.com>,
	Rob Herring <robh+dt@kernel.org>
Cc: "Mark Rutland" <mark.rutland@arm.com>,
	devicetree@vger.kernel.org, linux-pwm@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>,
	"Michal Vokáč" <michal.vokac@ysoft.com>
Subject: [RFC PATCH 0/2] pwm: imx: Configure output to GPIO in disabled state
Date: Tue, 21 Aug 2018 16:38:51 +0200	[thread overview]
Message-ID: <1534862333-27950-1-git-send-email-michal.vokac@ysoft.com> (raw)

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

The binding is totally optional and current users are not affected.
The idea is to use the "default" pinctrl state to set the pin to a safe
state. That is a GPIO function with pull-up. Then when a PWM signal is
needed on the output, select the "pwm" state.

Using the GPIO function as a default state assures that the pad is in
a safe state all the time from power-up and is switched to PWM only when
it is really needed.

It is also important to first change the muxing and then disable the PWM.
Otherwise you will get unwanted level changes on the output. And vice
versa when PWM output needs to be enabled. Enable PWM first, then change
the muxing.

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


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

 Documentation/devicetree/bindings/pwm/imx-pwm.txt | 44 ++++++++++++++++++
 drivers/pwm/pwm-imx.c                             | 56 +++++++++++++++++++++++
 2 files changed, 100 insertions(+)

-- 
2.1.4


             reply	other threads:[~2018-08-21 14:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-21 14:38 Michal Vokáč [this message]
2018-08-21 14:38 ` [RFC PATCH 1/2] dt-bindings: pwm: imx: Allow switching PWM output between PWM and GPIO Michal Vokáč
2018-08-22  6:14   ` Lothar Waßmann
2018-08-22  7:01     ` Michal Vokáč
2018-08-22 11:17       ` Lothar Waßmann
2018-08-22 13:20         ` Michal Vokáč
2018-08-22 14:10           ` Lothar Waßmann
2018-08-23  9:13             ` Michal Vokáč
2018-08-23 11:18               ` Lothar Waßmann
2018-08-23 12:38                 ` Michal Vokáč
2018-08-23 10:40   ` Lukasz Majewski
2018-08-23 11:19     ` Lothar Waßmann
2018-08-23 11:21     ` Michal Vokáč
2018-08-23 12:36       ` Lukasz Majewski
2018-10-09 11:03         ` Vokáč Michal
2018-08-31 12:18   ` Rob Herring
2018-08-31 12:45     ` Lothar Waßmann
2018-08-31 13:17       ` Michal Vokáč
2018-08-31 13:30         ` Lothar Waßmann
2018-10-09 10:30           ` Vokáč Michal
2018-08-21 14:38 ` [RFC PATCH 2/2] pmw: imx: Configure output to GPIO in disabled state Michal Vokáč

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=1534862333-27950-1-git-send-email-michal.vokac@ysoft.com \
    --to=michal.vokac@ysoft.com \
    --cc=LW@karo-electronics.de \
    --cc=devicetree@vger.kernel.org \
    --cc=fabio.estevam@nxp.com \
    --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 \
    /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).