[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20230321220825.GA1685482-robh@kernel.org>
Date: Tue, 21 Mar 2023 17:08:25 -0500
From: Rob Herring <robh@...nel.org>
To: Stephan Gerhold <stephan@...hold.net>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
"Lin, Meng-Bo" <linmengbo0689@...tonmail.com>,
linux-kernel@...r.kernel.org, Pavel Machek <pavel@....cz>,
Lee Jones <lee@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Nikita Travkin <nikita@...n.ru>, linux-leds@...r.kernel.org,
devicetree@...r.kernel.org, ~postmarketos/upstreaming@...ts.sr.ht
Subject: Re: [PATCH v2 1/2] dt-bindings: leds: aw2013: Document vddio-supply
On Tue, Mar 21, 2023 at 09:21:36PM +0100, Stephan Gerhold wrote:
> On Tue, Mar 21, 2023 at 07:42:37AM +0100, Krzysztof Kozlowski wrote:
> > On 20/03/2023 19:59, Stephan Gerhold wrote:
> > > On Mon, Mar 20, 2023 at 07:04:22PM +0100, Krzysztof Kozlowski wrote:
> > >> On 20/03/2023 18:55, Lin, Meng-Bo wrote:
> > >>> Some LEDs controllers are used with external pull-up for the interrupt
> > >>> line and the I2C lines, so we might need to enable a regulator to bring
> > >>> the lines into usable state.
> > >>
> > >> Not a property of this device.
> > >>
> > >>> Otherwise, this might cause spurious
> > >>> interrupts and reading from I2C will fail.
> > >>>
> > >>> Document support for "vddio-supply" that is enabled by the aw2013 driver
> > >>> so that the regulator gets enabled when needed.
> > >>>
> > >>> Signed-off-by: Lin, Meng-Bo <linmengbo0689@...tonmail.com>
> > >>> ---
> > >>> Documentation/devicetree/bindings/leds/leds-aw2013.yaml | 5 +++++
> > >>> 1 file changed, 5 insertions(+)
> > >>>
> > >>> diff --git a/Documentation/devicetree/bindings/leds/leds-aw2013.yaml b/Documentation/devicetree/bindings/leds/leds-aw2013.yaml
> > >>> index 08f3e1cfc1b1..79b69cf1d1fe 100644
> > >>> --- a/Documentation/devicetree/bindings/leds/leds-aw2013.yaml
> > >>> +++ b/Documentation/devicetree/bindings/leds/leds-aw2013.yaml
> > >>> @@ -23,6 +23,11 @@ properties:
> > >>> vcc-supply:
> > >>> description: Regulator providing power to the "VCC" pin.
> > >>>
> > >>> + vddio-supply:
> > >>> + description: |
> > >>> + Optional regulator that provides digital I/O voltage,
> > >>
> > >> NAK. I responded to your patch and you just send a v2 without explanation.
> > >>
> > >> The device does not have VDDIO pin, either.
> > >>
> > >
> > > The power supply Lin is trying to add here is basically the "VIO1"
> > > example in "Figure 1 AW2013 Typical Application Circuit" on page 1 of
> > > the AW2013 datasheet [1]. The I2C pins and the interrupt output are both
> > > open-drain and therefore require external pull-up resistors, connected
> > > to a power supply that might not be always on.
> > >
> > > Because of the open-drain pins AW2013 does indeed not have a dedicated
> > > input pin for the I/O supply voltage. However, it is still necessary to
> > > describe the power supply _somewhere_, to ensure that it is enabled when
> > > needed.
> > >
> > > It is hard to model this properly but it's generally easiest to handle
> > > this inside the peripheral driver since it knows exactly when I2C and/or
> > > interrupt lines are currently needed or not. This situation is fairly
> > > common for I2C devices so there are several precedents, e.g.:
> > >
> > > 1. cypress,tm2-touchkey.yaml: "vddio-supply"
> > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3e730ec11d51283ad62a98436967c01b718132ab
> > > 2. goodix,gt7375p.yaml: "mainboard-vddio-supply"
> > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1d18c1f3b7d938bdefc44289d137b4e6c7a3d502
> >
> > Both are mistaken. How can you enumerate or autodetect a device if its
> > regulator pulling up I2C are not on?
>
> You don't. By design I2C does not support enumeration or autodetection.
> Nothing we implement in software can change that.
>
> I2C devices have all sorts of requirements before they show up on the
> bus at all (power supplies, enable GPIOs, clocks, ...). All these are
> currently modelled as part of the consumer IC.
>
> > What's more, on I2C lines you could have more devices, so you expect
> > each of them having the supply?
>
> Yes, I don't think this is a problem since it's typical for regulators
> to be shared. If at least one of the I2C devices is active, the bus will
> be active as well.
>
> > These are properties of I2C controller, not the consumer. I2C controller
> > should enable any regulators necessary for the IO pins.
>
> In general I agree with you here. But as I mentioned already there is
> usually more than just the I2C I/O lines. For AW2013 there is at least
> also the open-drain interrupt line. On other ICs there could also be
> arbitrary GPIO lines that are used in open-drain mode. Those are
> completely unrelated to the I2C controller.
>
> Do you have any suggestions how to handle the power supply for those?
>
> IMO for interrupts lines the pull-up I/O supply is hardly a property of
> the interrupt controller. It just cares that a line switches from high
> to low. It's not exactly a property of the consumer IC either. However,
> since operating the interrupt line in open-drain mode is part of the
> consumer IC specification I would say that the I/O supply for interrupt
> lines is better described on the consumer side.
>
> For sake of completeness we could additionally describe the supply for
> the I2C lines on the I2C controller, but then we still need this patch
> or something else for the interrupt lines.
I think a supply on the device side is fine here. Just be clear in the
description about its purpose. We have much worse abuses than this
(random bus clocks added to SoC devices).
Rob
Powered by blists - more mailing lists