Linux Power Management development
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Herman van Hazendonk <github.com@herrie.org>
Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
	 linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] dt-bindings: power: supply: maxim,max8903: add DC and USB input current-limit controls
Date: Fri, 5 Jun 2026 00:43:16 +0200	[thread overview]
Message-ID: <aiH9IOUWjmpkpko_@venus> (raw)
In-Reply-To: <20260603071519.807604-2-github.com@herrie.org>

[-- Attachment #1: Type: text/plain, Size: 4600 bytes --]

Hi,

On Wed, Jun 03, 2026 at 09:15:18AM +0200, Herman van Hazendonk wrote:
> Add four optional properties to the MAX8903 charger binding to
> describe board-level GPIO control of the DC and USB input current
> limits:
> 
> DC input (TA / DOK pin):
>   - dc-current-limit-gpios (1..4 GPIOs): mux control lines feeding
>     the MAX8903 IDC resistor mux;
>   - dc-current-limit-mapping (uint32-matrix of {microamps,
>     gpio_bit_pattern} pairs): the available current levels and the
>     GPIO bit pattern that selects each level.
> 
> USB input (USB / UOK pin):
>   - usb-current-limit-gpios: a single GPIO driving the IUSB
>     tri-state pin (low / high);
>   - usb-current-limit-values: the two microamp values that the IUSB
>     pin selects.
>
> These let userspace clamp the input draw via the standard
> POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT power_supply attribute. The HP
> TouchPad uses both: two TLMM lines select between 0.5 A, 1.0 A,
> 1.5 A and 2.0 A DC input current limits behind the MAX8903B
> charger, and a third TLMM line picks the IUSB 100 mA / 500 mA
> limit.
> 
> These are purely additive; existing platforms remain unaffected.
> 
> Signed-off-by: Herman van Hazendonk <github.com@herrie.org>
> ---
>  .../bindings/power/supply/maxim,max8903.yaml  | 58 +++++++++++++++++++
>  1 file changed, 58 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max8903.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max8903.yaml
> index 86af38378999..5e970ebc08df 100644
> --- a/Documentation/devicetree/bindings/power/supply/maxim,max8903.yaml
> +++ b/Documentation/devicetree/bindings/power/supply/maxim,max8903.yaml
> @@ -44,6 +44,41 @@ properties:
>      maxItems: 1
>      description: USB suspend pin (active high, output)
>  
> +  dc-current-limit-gpios:
> +    minItems: 1
> +    maxItems: 4
> +    description:
> +      GPIOs controlling DC input current limit via resistor mux.
> +      Used with dc-current-limit-mapping to select charging current.
> +
> +  dc-current-limit-mapping:
> +    $ref: /schemas/types.yaml#/definitions/uint32-matrix
> +    minItems: 2
> +    maxItems: 16
> +    description: |
> +      Array of (current_microamps, gpio_bit_pattern) pairs defining available
> +      DC current limits. The gpio_bit_pattern is applied to dc-current-limit-gpios
> +      to select that current level.
> +    items:
> +      items:
> +        - description: Current limit in microamps
> +        - description: GPIO bit pattern value
> +
> +  usb-current-limit-gpios:
> +    maxItems: 1
> +    description:
> +      GPIO controlling USB input current limit.
> +      Low = usb-current-limit-values[0], High = usb-current-limit-values[1].
> +
> +  usb-current-limit-values:
> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> +    minItems: 2
> +    maxItems: 2
> +    default: [100000, 500000]
> +    description:
> +      USB current limits in microamps for GPIO low and high states.
> +      Default is 100mA (low) and 500mA (high) per USB specification.

The IUSB pin always selects between 100mA and 500mA for the MAX8903
according to the datasheet, so why is there a DT property?

Greetings,

-- Sebastian

> +
>  required:
>    - compatible
>  
> @@ -65,3 +100,26 @@ examples:
>        chg-gpios = <&gpio3 15 GPIO_ACTIVE_LOW>;
>        cen-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
>      };
> +  - |
> +    /* Example with DC and USB current limit control */
> +    #include <dt-bindings/gpio/gpio.h>
> +    charger-with-current-limit {
> +      compatible = "maxim,max8903";
> +      dok-gpios = <&gpio2 3 GPIO_ACTIVE_LOW>;
> +      flt-gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
> +      chg-gpios = <&gpio3 15 GPIO_ACTIVE_LOW>;
> +      cen-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
> +      dcm-gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>;
> +
> +      /* DC input current limit via IDC resistor mux */
> +      dc-current-limit-gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>,
> +                               <&gpio1 1 GPIO_ACTIVE_HIGH>;
> +      dc-current-limit-mapping = <750000 0>,  /* GPIO[1:0]=0b00 */
> +                                 <900000 1>,  /* GPIO[1:0]=0b01 */
> +                                 <1400000 3>, /* GPIO[1:0]=0b11 */
> +                                 <2000000 2>; /* GPIO[1:0]=0b10 */
> +
> +      /* USB current control */
> +      usb-current-limit-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
> +      usb-current-limit-values = <100000 500000>; /* 100mA / 500mA */
> +    };
> -- 
> 2.43.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-06-04 22:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03  7:15 [PATCH 0/2] power: supply: max8903: add GPIO-controlled input current-limit Herman van Hazendonk
2026-06-03  7:15 ` [PATCH 1/2] dt-bindings: power: supply: maxim,max8903: add DC and USB input current-limit controls Herman van Hazendonk
2026-06-04 22:43   ` Sebastian Reichel [this message]
2026-06-03  7:15 ` [PATCH 2/2] power: supply: max8903: add DC and USB input current-limit GPIO controls Herman van Hazendonk

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=aiH9IOUWjmpkpko_@venus \
    --to=sebastian.reichel@collabora.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=github.com@herrie.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=robh@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox