All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vokáč Michal" <Michal.Vokac@ysoft.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: "Lothar Waßmann" <LW@KARO-electronics.de>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-pwm@vger.kernel.org" <linux-pwm@vger.kernel.org>,
	"Lukasz Majewski" <l.majewski@majess.pl>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Rob Herring" <robh+dt@kernel.org>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"Fabio Estevam" <fabio.estevam@nxp.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"viresh kumar" <viresh.kumar@linaro.org>
Subject: Re: [RCF PATCH,v2,2/2] pwm: imx: Configure output to GPIO in disabled state
Date: Fri, 23 Nov 2018 15:15:11 +0000	[thread overview]
Message-ID: <9da8c6d9-d97c-200c-d8e4-2eb9f73eedc5@ysoft.com> (raw)
In-Reply-To: <20181122190321.ktqegs7kpvhcemvi@pengutronix.de>

On 22.11.2018 20:03, Uwe Kleine-König wrote:
> On Thu, Nov 22, 2018 at 04:46:39PM +0000, Vokáč Michal wrote:
>> On 22.11.2018 17:23, Uwe Kleine-König wrote:
>>> On Thu, Nov 22, 2018 at 03:42:14PM +0000, Vokáč Michal wrote:
>>>> On 16.11.2018 09:25, Uwe Kleine-König wrote:
>>>>> On Fri, Nov 16, 2018 at 08:34:30AM +0100, Lothar Waßmann wrote:
>>>>>> No. You can disable the output driver via pinctrl, so that only the
>>>>>> selected pull-up/down is relevant. The pin function and GPIO register
>>>>>> settings don't matter at all in this case.
>>>>
>>>> Lothar, please can you be more specific how would you do that? IFAIK the
>>>> pull-up/down internal resistors have effect only if the pin is configured
>>>> as GPIO *input* (on i.MX6 at least). See the TRM, 29.4.2.2 Output driver:
>>>>
>>>>     "Internal pull-up, pull-down resistors, and pad keeper are disabled in
>>>>      output mode."
> 
> This would mean you'd have to rely on an external pull up for your use
> case. I wouldn't be surprised however if DSE=0 wouldn't count as "output
> mode". Given the reliability of NXP documentation I wouldn't bet neither
> on one nor the other possibility.

Yeah, the NXP documentation sometimes does not really match reality.
My use case is based on the fact that I configure the pin as input in
the driver. Then it works just fine.

>>> So I'd expect this to really work on i.MX6 but not the earlier SoCs
>>> without a gpio specifier.
>>
>> Maybe you would expect it to work but I already tested and measured
>> that weeks ago ;) It did not work.
> 
> Which pin/gpio do we talk about? Which i.MX6 variant did you test this
> on? (Assuming i.MX6D or i.MX6Q and PAD_DISP0_DATA09, did you try setting
> 
> 	IOMUXC_SW_MUX_CTL_PAD_DISP0_DATA09 (0x020E0194) = 0x00000005
> 	IOMUXC_SW_PAD_CTL_PAD_DISP0_DATA09 (0x020E04A8) = 0x0000b080
> 
> and then play with GPIO 4.30 direction and output value?)

My test setup is as follows:
- SoC is i.MX6DL or i.MX6S - I have three board variants in total.
- Pin used for PWM/GPIO is PAD_GPIO9.
- The pin is not connected to any circuit. Just a test point.
- pinctrl setup in DT:
   - for "pwm":
     - fsl,pins = <MX6QDL_PAD_GPIO_9__PWM1_OUT 0x8>
     - IOMUXC_SW_MUX_CTL_PAD_GPIO09 = 0x00000004
     - IOMUXC_SW_PAD_CTL_PAD_GPIO09 = 0x00000008

   - for "gpio":
    - fsl,pins = <MX6QDL_PAD_GPIO_9__GPIO1_IO09 0xb000>
    - IOMUXC_SW_MUX_CTL_PAD_GPIO09 = 0x00000005
    - IOMUXC_SW_PAD_CTL_PAD_GPIO09 = 0x0000b000

Test scenario:

- In bootloader configure the pin as GPIO output, set it LOW (0V).
   I set it LOW to start in the oposite state than I want to end up in.
- Boot Linux
- Use sysfs to configure the PWM to produce some signal.
- In the PWM driver select the "pwm" pinctrl state.
- Measure the output - expected waveform on the scope.
- Use sysfs to stop the PWM "echo 0 > /sys/class/pwm/pwmchip0/pwm0/enable°
- In the PWM driver select the "gpio" pinctrl state.
- Then in the PWM driver:

a) non-working variant
- Do not request the GPIO - so do not touch its pad control reg.
   It is set as output from the bootloader, data register = 0.
- Measure voltage on the output
   - against GND = 0V
   - against VCC = 0V
- Measure resistance against VCC: Hi-Z

The pin is in Hi-Z mode. That is fine but that does not satisfy any
logic level.

b) working variant
- Request the GPIO, configure it as input.
- Measure voltage on the output
   - against GND = VCC (3.3V)
   - against VCC = 0V
- Measure resistance against VCC = 91.1kOhm

The pull-up is active.

I can repeat the results on both i.MX6DL and i.MX6S on pwm1 and pwm4.
All pull-up and pull-down combinations gave me the expected results
only if the pin is configured as input. So if I repeat the test and
do not touch the pin in bootloader at all, it works as well even if
I do not request/configure the GPIO in the PWM driver.

But we can not rely on the fact that the pin is correctly configured
from bootloader or that it is in the after-reset state. It should
just work regardless of what state it was left in.

Best regards,
Michal

  reply	other threads:[~2018-11-23 15:15 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-10  9:33 [RCF PATCH v2 0/2] pwm: imx: Configure output to GPIO in disabled state Vokáč Michal
2018-10-10  9:33 ` [RCF PATCH v2 1/2] dt-bindings: pwm: imx: Allow switching PWM output between PWM and GPIO Vokáč Michal
2018-10-10 13:39   ` Thierry Reding
2018-10-29 15:52     ` Vokáč Michal
2018-10-10  9:33 ` [RCF PATCH v2 2/2] pwm: imx: Configure output to GPIO in disabled state Vokáč Michal
2018-10-12  8:57   ` [RCF PATCH,v2,2/2] " Uwe Kleine-König
2018-10-12 15:04     ` Vokáč Michal
2018-10-12 15:54       ` Thierry Reding
2018-10-12 16:08       ` Uwe Kleine-König
2018-10-14 20:24         ` Uwe Kleine-König
2018-10-15  8:45           ` Thierry Reding
2018-10-29 15:55             ` Vokáč Michal
2018-10-29 15:54         ` Vokáč Michal
2018-11-07  9:33           ` Uwe Kleine-König
2018-11-07 13:32             ` Vokáč Michal
2018-11-07 15:01               ` Uwe Kleine-König
2018-11-08 15:21                 ` Vokáč Michal
2018-11-08 19:18                   ` Uwe Kleine-König
2018-11-09 14:24                     ` Vokáč Michal
2018-11-09 16:55                       ` Uwe Kleine-König
2018-11-14  9:09                         ` Uwe Kleine-König
2018-11-14 11:34                         ` Thierry Reding
2018-11-14 21:51                           ` Uwe Kleine-König
2018-11-15 15:25                             ` Thierry Reding
2018-11-15 20:37                               ` Uwe Kleine-König
2018-11-16  7:34                                 ` Lothar Waßmann
2018-11-16  8:25                                   ` Uwe Kleine-König
2018-11-22 15:42                                     ` Vokáč Michal
2018-11-22 16:23                                       ` Uwe Kleine-König
2018-11-22 16:46                                         ` Vokáč Michal
2018-11-22 19:03                                           ` Uwe Kleine-König
2018-11-23 15:15                                             ` Vokáč Michal [this message]
2018-11-25 20:56                                               ` Uwe Kleine-König
2018-11-26  9:11                                                 ` Lothar Waßmann
2018-11-26  9:18                                                   ` Uwe Kleine-König
2018-11-26 10:03                                                     ` Lothar Waßmann
2018-11-26 11:51                                               ` Thierry Reding
2018-11-26 12:23                                                 ` Lothar Waßmann
2018-11-26 13:34                                                   ` Thierry Reding
2018-11-26 15:50                                                     ` Vokáč Michal
2018-11-16  9:51                                 ` Thierry Reding
2018-11-16 10:39                                   ` Uwe Kleine-König
2018-11-16 11:56                                     ` Lothar Waßmann
2018-11-18 11:30                                       ` Uwe Kleine-König
2018-11-16 12:24                                     ` Thierry Reding
2018-11-18 20:08                                       ` Uwe Kleine-König
2018-11-19  8:48                                         ` Uwe Kleine-König
2018-11-22 15:03                                         ` Thierry Reding
2018-11-22 16:17                                           ` Uwe Kleine-König
2018-11-20 13:14                                   ` Vokáč Michal
2018-11-20 16:54                                     ` Uwe Kleine-König
2018-11-22 14:23                                       ` Vokáč Michal
2018-11-19  7:44                             ` Linus Walleij
2018-11-19  8:32                               ` Uwe Kleine-König
2018-11-20  8:35                                 ` Linus Walleij
2018-11-20  9:16                                   ` Viresh Kumar
2018-11-20  9:53                                   ` Uwe Kleine-König
2018-11-14 11:14                   ` Thierry Reding
2018-10-12 16:00   ` [RCF PATCH v2 2/2] " Thierry Reding
2018-10-29 15:53     ` Vokáč Michal

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=9da8c6d9-d97c-200c-d8e4-2eb9f73eedc5@ysoft.com \
    --to=michal.vokac@ysoft.com \
    --cc=LW@KARO-electronics.de \
    --cc=devicetree@vger.kernel.org \
    --cc=fabio.estevam@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=l.majewski@majess.pl \
    --cc=linus.walleij@linaro.org \
    --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 \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=viresh.kumar@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.