Re: [RFC PATCH 1/2] dt-bindings: pwm: imx: Allow switching PWM output between PWM and GPIO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Michal,

> On 23.8.2018 12:40, Lukasz Majewski wrote:
> 
> Hi Lukasz, thanks for the reply!
> > Hi Michal,
> >   
> >> Output of the PWM block of i.MX SoCs is always zero volts when the
> >> block is disabled. This can caue issues when inverted PWM polarity
> >> is needed. With inverted polarity a duty cycle = 0% corresponds to
> >> solid high level on the output. If the PWM is dissabled its output
> >> instantly goes to solid zero which corresponds to duty cycle =
> >> 100%.
> >>
> >> To have a trully inverted PWM output configure the PWM pad as a
> >> GPIO with pull-up. Then switch the pad to PWM output whenever
> >> non-zero duty cycle is needed.  
> > 
> > Just to ask - Is your display equipped with power supply
> > enable/disable pin?  
> 
> No it is not. The backlight on my display is just a bunch of serial-
> parallel connected LEDs with separate GND and VCC pins on a separate
> flex cable. And the display itself also does not have a reset or
> enable signal. It is a PITA to use it I must say..

Yes, it seems so. I must have had more luck than you with the HW....

>   
> > As fair as I remember the trick to avoid flickering the display
> > was to disable the display (enable-gpio property) and set the PWM
> > PIN as GPIO to high in u-boot.  
> 
> Yes, I know about that. I can not use this as the PWM output is the
> only signal I have to control the backlight. I mentioned that
> somewhere in the previous discussion with Lothar.

Yes, I've read it. I also find the PWM pinctrl as "default" state more
natural.

One more idea - though.

In iMX6Q it was possible to specify the pinctrl PIN setup as 0x80000000
- this means that it goes untouched to the IP block (configured by
  bootloader).

Maybe it would work to:

1. Setup the PWM output as GPIO in u-boot (high)

2. In PWM IMX probe configure PWM to be 100% duty cycle. And switch
iomux to PWM function of the pin

3. Then latter in the code PWM gets configured and we can control it in
"normal" way ?

Or am I missing some important point?

> 
> I also think this could be useful not only for backlight. Any circuit
> that requires truly inverted PWM signal can use it. I see it as an
> enhancement to what you with Lothar have already done ;)
>   
> >>
> >> Signed-off-by: Michal Vokáč <michal.vokac@xxxxxxxxx>
> >> ---
> >>   Documentation/devicetree/bindings/pwm/imx-pwm.txt | 44
> >> +++++++++++++++++++++++ 1 file changed, 44 insertions(+)
> >>
> >> diff --git a/Documentation/devicetree/bindings/pwm/imx-pwm.txt
> >> b/Documentation/devicetree/bindings/pwm/imx-pwm.txt index
> >> c61bdf8..3b1bc4c 100644 ---
> >> a/Documentation/devicetree/bindings/pwm/imx-pwm.txt +++
> >> b/Documentation/devicetree/bindings/pwm/imx-pwm.txt @@ -14,6 +14,12
> >> @@ See the clock consumer binding,
> >> Documentation/devicetree/bindings/clock/clock-bindings.txt
> >>   - interrupts: The interrupt for the pwm controller
> >>   
> >> +Optional properties:
> >> +- pinctrl: For i.MX27 and newer SoCs. Add extra pinctrl to
> >> configure the PWM
> >> +  pin to gpio function.  It allows control over the pin output
> >> level when the
> >> +  PWM block is disabled. This is meant to be used if inverted
> >> polarity of the
> >> +  PWM signal is required. See "Inverted PWM output" section
> >> bellow. +
> >>   Example:
> >>   
> >>   pwm1: pwm@53fb4000 {
> >> @@ -25,3 +31,41 @@ pwm1: pwm@53fb4000 {
> >>   	clock-names = "ipg", "per";
> >>   	interrupts = <61>;
> >>   };
> >> +
> >> +Inverted PWM output
> >> +-------------------
> >> +
> >> +The i.MX SoC has such limitation that whenever a pad is configured
> >> as a PWM +output, the output level is always zero volts when the
> >> PWM block is disabled. +The zero output level is actively driven
> >> by the output stage of the PWM block +and can not be overridden by
> >> pull-up. It also does not matter what PWM polarity +a PWM client
> >> (e.g. backlight) requested. +
> >> +To gain control of the PWM output level in disabled state two
> >> pinctrl states +can be used. The "default" state and the "pwm"
> >> state. In the default state the +PWM output is configured as a
> >> GPIO with pull-up. In the "pwm" state the output +is configured as
> >> a PWM output. This setup assures that the PWM output is at +the
> >> required level that corresponds to duty cycle = 0 when PWM is
> >> disabled. +E.g. at boot. +
> >> +Example:
> >> +
> >> +&pwm1 {
> >> +	pinctrl-names = "default", "pwm";
> >> +	pinctrl-0 = <&pinctrl_backlight_gpio>;
> >> +	pinctrl-1 = <&pinctrl_backlight_pwm>;
> >> +}
> >> +
> >> +pinctrl_backlight_gpio: pwm1grp-gpio {
> >> +	fsl,pins = <
> >> +		/* GPIO with 22kOhm pull-up */
> >> +		MX6QDL_PAD_GPIO_9__GPIO1_IO09	0xF008
> >> +	>;
> >> +};
> >> +
> >> +pinctrl_backlight_pwm: pwm1grp-pwm {
> >> +	fsl,pins = <
> >> +		/* PWM output */
> >> +		MX6QDL_PAD_GPIO_9__PWM1_OUT	0x8
> >> +	>;
> >> +};  




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@xxxxxxx

Attachment: pgpLdSClDHEsw.pgp
Description: OpenPGP digital signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux