i.MX6 PWM pin output state when disabled

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX6 PWM pin output state when disabled

2,787 Views
pavelstanek
Contributor II

Hi all,

I have i.MX6 Solo and using PWM for backlight, but with inverted logic. Low value of duty cycle means logic 1 for most time.

By POUTC bit I'm able to invert PWM's output levels.

Now in linux, when using PWM-backlight driver, when I set backlight to "0", then driver disables PWM and output is at logic 0 ( it seems that it's independent on POUTC bits) instead of full logic 1.

So is there some way how to set PWM to real "active-high" mode?When in disabled state the output pin is in high.

Thanks.

Labels (2)
0 Kudos
7 Replies

1,648 Views
fabio_estevam
NXP Employee
NXP Employee

I think you need to pass the PWM_POLARITY_INVERTED flag.

Take a look at this example in mainline kernel:

arch/arm/boot/dts/imx6q-tx6q-1010.dts:      pwms = <&pwm2 0 500000 PWM_POLARITY_INVERTED>;
0 Kudos

1,648 Views
fabio_estevam
NXP Employee
NXP Employee

Actually the PWM_POLARITY_INVERTED flag is also supported in 3.14.

More info about it at: Documentation/devicetree/bindings/pwm/pwm.txt

0 Kudos

1,648 Views
pavelstanek
Contributor II

I suppose that your information is not correct.

PWM_POLARITY_INVERTED is general flag which must be supported by hardware driver.

See drivers/pwm/pwm-imx.c, there must be function for set polarity.

KARO-electronics (dts which you mention) are using patch which adds this functionality. (you also needs to modify dts for pwm to pwm-cells=3

We also are using this code which controls POUTC bits, thats not the problem.

Main problem is that when PWM is disabled (EN bit=0), then output is allways on login 0, and it seems that there is no simple way to control it inside PWM block.

0 Kudos

1,647 Views
lategoodbye
Senior Contributor I

I also stumbled about this issue and the solution from KARO doesn't handle the pwm disable case.

So solved this by keep the EN bit in case of polarity inversion and clear PWMSAR in the enable handler.

0 Kudos

1,648 Views
pavelstanek
Contributor II
0 Kudos

1,648 Views
igorpadykov
NXP Employee
NXP Employee

Hi Pavel

when module disabled, all registers are reset and reset state of pwmo is logic 0.

Seems one can add in pwm driver pwm-imx.c [imx_pwm_set_enable()]

code disconnecting pwmo (POUTC=10) and enable pull-up.

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,648 Views
pavelstanek
Contributor II

Hi Igor, thank for reply

I tried proposed solution but it did not work.

Pad setting is Value at address 0x20E0610: 0xF048   (PKE=1, PUE=1, PUS=11 => 22K pull up)

When PWM is set to 4/256 duty cycle, control register is

Value at address 0x2080000: 0x01C60001

PWM work ok, on output there is mostly logic 1 with mall peaks to logic 0

When setting 0 as duty, then

Value at address 0x2080000: 0x01CA0001 (forced disconnect output, manually enabled PWM)

Value at address 0x2080000: 0x01CA0000 (forced disconnect output,normal setting by linux)

still produce logic 0 on output

I also test to force output disconnect during normal operation (duty 4/156) and output goes to logic 0

I found the only one way how to archive required functionality. Override disable function and keep PWM running with duty setting at 0.

0 Kudos