Re: [RFC PATCH v3 2/2] pwm: imx: Configure output to GPIO in disabled state

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

 



On 12.12.2018 09:01, Uwe Kleine-König wrote:
> On Thu, Dec 06, 2018 at 01:41:31PM +0000, Vokáč Michal wrote:
>> Normally the PWM output is held LOW when PWM is disabled. This can cause
>> problems when inverted PWM signal polarity is needed. With this behavior
>> the connected circuit is fed by 100% duty cycle instead of being shut-off.
>>
>> Allow users to define a "pwm" and a "gpio" pinctrl states. The pwm pinctrl
>> state is selected when PWM is enabled and the gpio pinctrl state is
>> selected when PWM is disabled. In the gpio state the new pwm-gpios GPIO is
>> configured as input and the internal pull-up resistor is used to pull the
>> output level high.
>>
>> If all the pinctrl states and the pwm-gpios GPIO are not correctly
>> specified in DT the PWM work as usual.
>>
>> As an example, with this patch a PWM controlled backlight with inversed
>> signal polarity can be used in full brightness range. Without this patch
>> the backlight can not be turned off as brightness = 0 disables the PWM
>> and that in turn set PWM output LOW, that is full brightness.
>>
>> Inverted output of the PWM with "default" and with "pwm"+"gpio" pinctrl:
>>
>> +--------------+------------+---------------+----------- +-------------+
>> | After reset  | Bootloader |   PWM probe   |     PWM    |     PWM     |
>> | 100k pull-up |            |               | enable 30% |   disable   |
>> +--------------+------------+---------------+------------+-------------+
>> | pinctrl      |    none    |    default    |   default  |   default   |
>> | out H   __________________                   __   __                 |
>> | out L                     \_________________/  \_/  \_/\____________ |
>> |                                           ^    ^    ^                |
>> +--------------+------------+---------------+------------+-------------+
>> | pinctrl      |    none    |      gpio     |     pwm    |     gpio    |
>> | out H   __________________________________   __   __   _____________ |
>> | out L                                     \_/  \_/  \_/              |
>> |                                           ^    ^    ^                |
>> +----------------------------------------------------------------------+
>>
>> Signed-off-by: Michal Vokáč <michal.vokac@xxxxxxxxx>
>> ---
>> Changes in v3:
>>   - Commit message update.
>>   - Minor fix in code comment (Uwe)
>>   - Align function arguments to the opening parentheses. (Uwe)
>>   - Do not test devm_pinctrl_get for NULL. (Thierry)
>>   - Convert all messages to dev_dbg() (Thierry)
>>   - Do not actively drive the pin in gpio state. Configure it as input
>>     and rely solely on the internal pull-up. (Thierry)
>>
>> Changes in v2:
>>   - Utilize the "pwm" and "gpio" pinctrl states.
>>   - Use the pwm-gpios signal to drive the output in "gpio" pinctrl state.
>>   - Select the right pinctrl state in probe.
>>
>>   drivers/pwm/pwm-imx.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 77 insertions(+)
>>

[ snip ]

> On thing I noticed while looking at the rcar driver is: This doesn't
> wait for the current period to end. Is this supposed to happen? Also for
> the enable case the hardware is configured for the desired duty cycle
> and only then the pinctrl is switched to pwm. Both might result in a
> spike that is not desired.

The behavior should not change from how imx-pwm was working before.
When PWM is disabled the output is immediately gated off (put into
the idle state) independently on the period. I measured this.

For the enable case you would certainly not get any additional spikes.
The worst thing that may happen is that the first period will be
slightly shorter depending on how long it takes to test the pinctrl
and switch the muxing. And this is unavoidable, it would happen even
if you wait for the start of a period. The test + muxing still takes
some time.

Michal




[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