From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Mark Gross <markgross@kernel.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
Linus Walleij <linus.walleij@linaro.org>,
Daniel Scally <djrscally@gmail.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
platform-driver-x86@vger.kernel.org, linux-gpio@vger.kernel.org,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Kate Hsuan <hpa@redhat.com>,
linux-media@vger.kernel.org
Subject: Re: [PATCH 1/5] gpio: tps68470: Fix tps68470_gpio_get() reading from the wrong register
Date: Tue, 29 Nov 2022 14:34:03 +0200 [thread overview]
Message-ID: <Y4X8O382eP+DKNA+@smile.fi.intel.com> (raw)
In-Reply-To: <1eb61f7a-3b93-32a1-21bf-6929bbb40d36@redhat.com>
On Tue, Nov 29, 2022 at 01:19:57PM +0100, Hans de Goede wrote:
> On 11/29/22 12:56, Andy Shevchenko wrote:
> > On Tue, Nov 29, 2022 at 1:27 PM Hans de Goede <hdegoede@redhat.com> wrote:
> >> On 11/29/22 11:22, Andy Shevchenko wrote:
> >>> On Mon, Nov 28, 2022 at 11:44 PM Hans de Goede <hdegoede@redhat.com> wrote:
> >>>>
> >>>> For the regular GPIO pins the value should be read from TPS68470_REG_GPDI,
> >>>> so that the actual value of the pin is read, rather then the value the pin
> >>>
> >>> than
> >>
> >> Ack.
> >>
> >>>> would output when put in output mode.
> >>>
> >>> I don't see it here and haven't checked the context, but the idea is
> >>> to check the direction and return either input (if pin is in input
> >>> mode) or [cached] output.If it's the case, the patch looks good to me.
> >>
> >> No the idea is to always actually use the input register when reading
> >> the pins, independent of the input/output mode. Instead of always
> >> reading the [cached] output register value.
> >
> > But why? This makes a little sense to me.
>
> I don't understand what your problem is with this patch ?
>
> This is standard behavior for GPIO drivers, the get() callback
> always reads the actual pin values when there is a registers
> to get the actual pin-values. AFAIK this is no different from what
> countless other GPIO drivers do ?
If the GPIO is requested is output and the pin in the HiZ mode, what value
should you return?
> >> The input buffer will still work when the device is in output mode
> >
> > Does this hardware support HiZ?
>
> Yes the 7 standard GPIO pins can be put in input mode, aka HiZ mode.
No, input and HiZ are two different states. If the hardware doesn't
support the latter, then your patch doesn't make any difference indeed, except
involving "in" buffer for "out" value. Which I consider an unneeded
step instead of reading [cached] "out" value.
[cached] here is used in a broader sense: either SW cache, or read back value
from the GPIO out register (not all hardware support that).
> >> and if somehow an external force is pushing the pin low/high against
> >> the output value then the input buffer will correctly reflect this
> >> (assuming the output is current limited and thus the magic smoke
> >> stays inside the chip).
> >
> > Exactly, when smoke comes out, the hardware is broken and code,
> > whatever is it, makes no difference at all.
>
> The GPIO part of the TPS68470 supports open-drain outputs, to correctly
> get the actual value on the pin from the get() callback, the GPDI
> register must be used. And being able to detect some outside chip
> forcing the line low in open-drain mode is important to be able to
> e.g. implement a software I2C master.
Right, but for push-pull mode this is not needed, correct?
> As I mentioned above actually using the input buffer value in
> the get() method is standard behavior for GPIO drivers, exactly
> for reasons like allowing a sw I2C master implementation to
> detect clock stretching or conflicts (in the multi master case).
> I really don't understand what is so controversial about this
> patch?
There are couple of remarks above:
1) what to read at the real HiZ mode ("in" and "out" buffers are disconnected
from the pin) in case hardware supports it;
2) why to read "out" value via "in" buffer in case of push-pull mode.
> Note the datasheet describes the GPDO / GPDI bit 0 values as:
>
> GPDO bit 0: "Control of the GPIO0 output"
> GPDI bit 0: "State of the GPIO0 input"
>
> So clearly GPDI is the correct register to use for the get()
> callback, which is what this patch is doing.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2022-11-29 12:34 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-28 21:44 [PATCH 0/5] gpio/media/int3472: Add support for tps68470 privacy-LED output Hans de Goede
2022-11-28 21:44 ` [PATCH 1/5] gpio: tps68470: Fix tps68470_gpio_get() reading from the wrong register Hans de Goede
2022-11-29 10:22 ` Andy Shevchenko
2022-11-29 11:27 ` Hans de Goede
2022-11-29 11:56 ` Andy Shevchenko
2022-11-29 12:19 ` Hans de Goede
2022-11-29 12:34 ` Andy Shevchenko [this message]
2022-11-29 12:59 ` Hans de Goede
2022-11-30 15:16 ` Dan Scally
2022-11-28 21:44 ` [PATCH 2/5] gpio: tps68470: Make tps68470_gpio_output() always set the initial value Hans de Goede
2022-11-29 10:24 ` Andy Shevchenko
2022-11-29 11:33 ` Hans de Goede
2022-11-30 16:04 ` Dan Scally
2022-11-28 21:44 ` [PATCH 3/5] gpio: tps68470: Add support for the indicator LED outputs Hans de Goede
2022-11-29 10:28 ` Andy Shevchenko
2022-11-29 11:32 ` Hans de Goede
2022-11-29 11:59 ` Andy Shevchenko
2022-11-29 12:20 ` Hans de Goede
2022-11-29 12:35 ` Andy Shevchenko
2022-11-28 21:44 ` [PATCH 4/5] media: ov8865: Add support for a privacy-led GPIO Hans de Goede
2022-11-28 21:44 ` [PATCH 5/5] platform/x86: int3472: Add support for the back privacy LED on Surface Go models Hans de Goede
2022-12-03 9:32 ` [PATCH 0/5] gpio/media/int3472: Add support for tps68470 privacy-LED output Linus Walleij
2022-12-03 12:28 ` Hans de Goede
2022-12-05 15:01 ` Hans de Goede
2022-12-05 21:26 ` Laurent Pinchart
2022-12-05 21:37 ` Hans de Goede
2022-12-07 0:25 ` Linus Walleij
2022-12-07 17:37 ` Hans de Goede
2022-12-05 9:18 ` Sakari Ailus
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=Y4X8O382eP+DKNA+@smile.fi.intel.com \
--to=andy.shevchenko@gmail.com \
--cc=bgolaszewski@baylibre.com \
--cc=djrscally@gmail.com \
--cc=hdegoede@redhat.com \
--cc=hpa@redhat.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=sakari.ailus@linux.intel.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