From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: "André Draszik" <andre.draszik@linaro.org>
Cc: Badhri Jagan Sridharan <badhri@google.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Peter Griffin <peter.griffin@linaro.org>,
Tudor Ambarus <tudor.ambarus@linaro.org>,
Juan Yescas <jyescas@google.com>,
Amit Sunil Dhamne <amitsd@google.com>,
kernel-team@android.com, linux-usb@vger.kernel.org
Subject: Re: [PATCH v2] usb: typec: tcpm/tcpci_maxim: report BC1.2 current limit
Date: Fri, 4 Dec 2026 15:00:22 +0100 [thread overview]
Message-ID: <axLHdq8ErINjDJ-6@black.igk.intel.com> (raw)
In-Reply-To: <20261204-tcpci-maxim-bc12-v2-1-3c8ccacc9bdd@linaro.org>
On Fri, Dec 04, 2026 at 11:00:13AM +0000, André Draszik wrote:
> Maxim TCPCI (MAX33359/MAX77759) ports attached to a non-PD source
> advertising Rp-default always report a 500 mA current limit, even when
> connected to a CDP or DCP source that can supply 1500 mA, and still
> report 500 mA when no charging source is detected.
>
> Commit 9d44cf247e7d ("usb: typec: tcpci_maxim: implement
> get_current_limit") returns a hardcoded 500 mA workaround instead of
> reading the hardware BC1.2 charger detection result in CHGTYP[1:0] of
> vendor register BC_STATUS1 (0x87). On MAX77759, BC1.2 detection is
> enabled by reset default (ChgDetEn in BC_CTRL1 0x8f resets to 1); on
> Pixel 6 attached to a CDP host, BC_CTRL1 reads 0x81 and BC_STATUS1
> reads 0x02 (CDP).
>
> Replace the hardcoded 500 mA return in max_tcpci_get_current_limit()
> with a read of TCPC_VENDOR_BC_STATUS1, returning 500 mA for SDP,
> 1500 mA for CDP and DCP, and 0 otherwise or on read error (matching the
> tcpci_data::get_current_limit kerneldoc). Note that compared to the
> hardcoded workaround, boards where firmware explicitly disables BC1.2
> detection (or where detection has not completed yet) now receive 0 mA
> instead of 500 mA.
>
> Drop the broad workaround comment above max_tcpci_get_current_limit():
> BC1.2 detection comes from the TCPC itself (as documented for
> tcpc_dev::get_current_limit), not the USB stack, so only the SDP case
> depends on USB enumeration. Keep a focused comment on CHGTYP_SDP and
> return 500 mA (matching fusb302) because TCPM queries
> get_current_limit() on entering SNK_DISCOVERY and SNK_READY and has no
> conduit from the USB stack to report enumerated limits later.
>
> Tested on Pixel 6 (MAX77759) with SDP (BC_STATUS1=0x01, 500 mA), CDP
> (0x02, 1500 mA), and DCP (0x3b, 1500 mA) attach and hot-plug.
>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> Rebased onto gregkh-usb/usb-testing (d6ed2c3c5bb6) as a single patch
> now that tcpci_data::get_current_limit and the initial tcpci_maxim
> 500 mA stub have landed there.
> ---
> Changes in v2:
> - Rebased onto gregkh-usb/usb-testing (d6ed2c3c5bb6).
> - Dropped v1 patch 1/2 ("usb: typec: tcpci: add get_current_limit
> callback"), superseded by commit 29bef51f3cf0 ("usb: typec: tcpci:
> implement get_current_limit").
> - Updated v1 patch 2/2 (now the sole patch) to replace the hardcoded
> 500 mA workaround added by commit 9d44cf247e7d ("usb: typec:
> tcpci_maxim: implement get_current_limit") in place, keeping the
> 0 mA return on CHGTYP_NOT_ATTACHED or read error, and updated the
> commit message accordingly.
> - Dropped Heikki's Acked-by from v1 due to the changed baseline and
> commit message.
> - Link to v1: https://lore.kernel.org/r/20261125-tcpci-maxim-bc12-v1-0-656e01201efb@linaro.org
> ---
> drivers/usb/typec/tcpm/tcpci_maxim.h | 8 +++++++
> drivers/usb/typec/tcpm/tcpci_maxim_core.c | 36 +++++++++++++++++++++----------
> 2 files changed, 33 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpci_maxim.h b/drivers/usb/typec/tcpm/tcpci_maxim.h
> index b314606eb0f6..8290201f8ae3 100644
> --- a/drivers/usb/typec/tcpm/tcpci_maxim.h
> +++ b/drivers/usb/typec/tcpm/tcpci_maxim.h
> @@ -10,6 +10,14 @@
> #define VENDOR_CC_STATUS2 0x85
> #define CC1_VUFP_RD0P5 BIT(1)
> #define CC2_VUFP_RD0P5 BIT(5)
> +
> +#define TCPC_VENDOR_BC_STATUS1 0x87
> +#define CHGTYP GENMASK(1, 0)
> +#define CHGTYP_NOT_ATTACHED 0
> +#define CHGTYP_SDP 1
> +#define CHGTYP_CDP 2
> +#define CHGTYP_DCP 3
> +
> #define TCPC_VENDOR_FLADC_STATUS 0x89
>
> #define TCPC_VENDOR_CC_CTRL1 0x8c
> diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> index d6a4fce3c80d..6d966a6fc3cf 100644
> --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> @@ -5,6 +5,7 @@
> * MAXIM TCPCI based TCPC driver
> */
>
> +#include <linux/bitfield.h>
> #include <linux/interrupt.h>
> #include <linux/i2c.h>
> #include <linux/kernel.h>
> @@ -485,18 +486,31 @@ static bool max_tcpci_attempt_vconn_swap_discovery(struct tcpci *tcpci, struct t
> return true;
> }
>
> -/*
> - * This callback is used by the TCPM to determine the current limit to set when
> - * Rp-def is advertised on the CC pins. The actual current limit comes from
> - * other subsystems such as the USB gadget/host stack (USB 2.0/USB 3.2) and
> - * BC1.2. As a workaround, report the USB 2.0 current limit of 500 mA to enable
> - * charging when the device is connected to a non-PD source advertising Rp-def.
> - * This can be removed once a mechanism for the USB core to communicate the
> - * current limit to this driver is implemented.
> - */
> -static int max_tcpci_get_current_limit(struct tcpci *tcpci, struct tcpci_data *tdata)
> +static int max_tcpci_get_current_limit(struct tcpci *tcpci,
> + struct tcpci_data *tdata)
> {
> - return 500;
> + struct max_tcpci_chip *chip = tdata_to_max_tcpci(tdata);
> + u8 status;
> + int ret;
> +
> + /* Returns 0 if BC1.2 detection is disabled or has not finished yet. */
> + ret = max_tcpci_read8(chip, TCPC_VENDOR_BC_STATUS1, &status);
> + if (ret < 0)
> + return 0;
> +
> + switch (FIELD_GET(CHGTYP, status)) {
> + case CHGTYP_SDP:
> + /*
> + * Assume a configured USB 2.0 device until the USB stack can
> + * report enumerated SDP limits to TCPM.
> + */
> + return 500;
> + case CHGTYP_CDP:
> + case CHGTYP_DCP:
> + return 1500;
> + default:
> + return 0;
> + }
> }
>
> static void max_tcpci_unregister_tcpci_port(void *tcpci)
>
> ---
> base-commit: d6ed2c3c5bb60dc173b2edf38044695b6aefedd2
> change-id: 20261125-tcpci-maxim-bc12-49a0ffb71d26
>
> Best regards,
> --
> André Draszik <andre.draszik@linaro.org>
>
--
heikki
prev parent reply other threads:[~2026-12-04 14:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 11:00 [PATCH v2] usb: typec: tcpm/tcpci_maxim: report BC1.2 current limit André Draszik
2026-12-04 11:15 ` sashiko-bot
2026-12-04 13:14 ` André Draszik
2026-12-04 14:00 ` Heikki Krogerus [this message]
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=axLHdq8ErINjDJ-6@black.igk.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=amitsd@google.com \
--cc=andre.draszik@linaro.org \
--cc=badhri@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=jyescas@google.com \
--cc=kernel-team@android.com \
--cc=linux-usb@vger.kernel.org \
--cc=peter.griffin@linaro.org \
--cc=tudor.ambarus@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox