Devicetree
 help / color / mirror / Atom feed
From: Herman van Hazendonk <github.com@herrie.org>
To: sre@kernel.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,
	Herman van Hazendonk <github.com@herrie.org>
Subject: [PATCH 0/2] power: supply: max8903: add GPIO-controlled input current-limit
Date: Wed,  3 Jun 2026 09:15:17 +0200	[thread overview]
Message-ID: <20260603071519.807604-1-github.com@herrie.org> (raw)

The MAX8903 charger exposes two hardware pins for input current control:
IDC (DC path, pin 11) and IUSB (USB path, pin 7). On many boards these
are driven by GPIO lines to a resistor mux or logic selector, letting
software select the input current limit. The driver currently has no
mechanism to set POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT at all.

This series adds that capability via two optional DT property groups:

  DC path: "dc-current-limit-gpios" + "dc-current-limit-mapping"
  A 1..4-GPIO array drives a resistor mux connected to the MAX8903 IDC
  pin. The IDC pin programs the step-down DC input current limit from
  0.5 A to 2 A (R_IDC = 6000V/I_DC_MAX) when the DCM mode pin is
  logic-high. The mapping table (uint32-matrix of {microamps,
  gpio_bit_pattern} pairs) lists every step the board supports. The
  driver picks the largest step at or below the requested limit.

  USB path: "usb-current-limit-gpios" + "usb-current-limit-values"
  A single GPIO drives the MAX8903 IUSB pin. Logic-low selects 100 mA,
  logic-high selects 500 mA per the MAX8903 spec. The two microamp
  values are described in DT so boards with non-standard IUSB thresholds
  can override them. Requests below the lower value are rejected with
  -EINVAL rather than silently programming a higher-than-requested limit.

The dispatch between the two paths is guarded by a new mutex (source_lock)
that is also taken in the IRQ handlers that update the "source online"
flags, preventing a race between set_property and a concurrent DOK/UOK
IRQ flip. The IRQs are already requested IRQF_ONESHOT so the sleepable
mutex is the appropriate primitive.

Motivation: the HP TouchPad carries a MAX8903B charger with two TLMM GPIO
lines feeding a four-step IDC resistor mux (500 mA, 1 A, 1.5 A, 2 A DC
input current limit) and a third TLMM line driving IUSB for the 100 mA /
500 mA USB limit. Without this series, the charger always draws its
hardware-default current irrespective of what the USB host negotiated.

Both patches are purely additive; platforms that don't provide the new DT
properties continue to behave exactly as before.

Herman van Hazendonk (2):
  dt-bindings: power: supply: maxim,max8903: add DC and USB input
    current-limit controls
  power: supply: max8903: add DC and USB input current-limit GPIO
    controls

 .../bindings/power/supply/maxim,max8903.yaml  |  58 +++
 drivers/power/supply/max8903_charger.c        | 369 +++++++++++++++++-
 2 files changed, 416 insertions(+), 11 deletions(-)

-- 
2.43.0


             reply	other threads:[~2026-06-03  7:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03  7:15 Herman van Hazendonk [this message]
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-03  7:22   ` sashiko-bot
2026-06-03  7:15 ` [PATCH 2/2] power: supply: max8903: add DC and USB input current-limit GPIO controls Herman van Hazendonk
2026-06-03  7:33   ` sashiko-bot

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=20260603071519.807604-1-github.com@herrie.org \
    --to=github.com@herrie.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sre@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