* [PATCH 0/2] usb: typec: tcpci: report BC1.2 current limit in tcpci_maxim
@ 2026-11-25 14:04 André Draszik
2026-11-25 14:04 ` [PATCH 1/2] usb: typec: tcpci: add get_current_limit callback André Draszik
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: André Draszik @ 2026-11-25 14:04 UTC (permalink / raw)
To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman
Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
kernel-team, linux-usb, André Draszik
Hi,
These two patches allow Maxim TCPCI (MAX33359 / MAX77759) ports to
report their BC1.2 current limit when attached to a non-PD Rp-default
source:
- Add an optional get_current_limit callback to struct tcpci_data.
- Report the Maxim TCPCI BC1.2 current limit from vendor register
BC_STATUS1.
Tested on Pixel 6 (Oriole) with SDP, CDP, and DCP attach and hot-plug
as well as USB-C PD.
Cheers
Andre'
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
André Draszik (2):
usb: typec: tcpci: add get_current_limit callback
usb: typec: tcpm/tcpci_maxim: report BC1.2 current limit
drivers/usb/typec/tcpm/tcpci.c | 12 ++++++++++++
drivers/usb/typec/tcpm/tcpci_maxim.h | 8 ++++++++
drivers/usb/typec/tcpm/tcpci_maxim_core.c | 25 +++++++++++++++++++++++++
include/linux/usb/tcpci.h | 5 +++++
4 files changed, 50 insertions(+)
---
base-commit: 3191063649dbf7c0d0b768e1f3655e4c5fc6edb5
change-id: 20261125-tcpci-maxim-bc12-49a0ffb71d26
Best regards,
--
André Draszik <andre.draszik@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] usb: typec: tcpci: add get_current_limit callback
2026-11-25 14:04 [PATCH 0/2] usb: typec: tcpci: report BC1.2 current limit in tcpci_maxim André Draszik
@ 2026-11-25 14:04 ` André Draszik
2026-11-25 14:04 ` [PATCH 2/2] usb: typec: tcpm/tcpci_maxim: report BC1.2 current limit André Draszik
2026-11-25 14:10 ` [PATCH 0/2] usb: typec: tcpci: report BC1.2 current limit in tcpci_maxim sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: André Draszik @ 2026-11-25 14:04 UTC (permalink / raw)
To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman
Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
kernel-team, linux-usb, André Draszik
TCPCI-based ports attached to a source advertising Rp-default report a
0 mA current limit to consumers such as charger drivers, preventing
non-PD charging on hosts that rely on BC1.2 detection.
tcpm_get_current_limit() falls back to 0 mA for TYPEC_CC_RP_DEF unless
tcpc->get_current_limit is populated, and tcpci_register_port() provides
no way for chip-level TCPCI drivers to supply that callback.
Add an optional get_current_limit callback to struct tcpci_data and wire
it into tcpc.get_current_limit when provided, clamping any negative
return value to 0 because tcpm stores the result as unsigned.
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
drivers/usb/typec/tcpm/tcpci.c | 12 ++++++++++++
include/linux/usb/tcpci.h | 5 +++++
2 files changed, 17 insertions(+)
diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index 7cca97bd772b..3f2c87d475c7 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -498,6 +498,15 @@ static int tcpci_set_pd_rx(struct tcpc_dev *tcpc, bool enable)
return 0;
}
+static int tcpci_get_current_limit(struct tcpc_dev *tcpc)
+{
+ struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
+ int ret;
+
+ ret = tcpci->data->get_current_limit(tcpci, tcpci->data);
+ return ret < 0 ? 0 : ret;
+}
+
static int tcpci_get_vbus(struct tcpc_dev *tcpc)
{
struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
@@ -892,6 +901,9 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
if (tcpci->data->check_contaminant)
tcpci->tcpc.check_contaminant = tcpci_check_contaminant;
+ if (tcpci->data->get_current_limit)
+ tcpci->tcpc.get_current_limit = tcpci_get_current_limit;
+
if (tcpci->data->auto_discharge_disconnect) {
tcpci->tcpc.enable_auto_vbus_discharge = tcpci_enable_auto_vbus_discharge;
tcpci->tcpc.set_auto_vbus_discharge_threshold =
diff --git a/include/linux/usb/tcpci.h b/include/linux/usb/tcpci.h
index 9b46a6bc762c..1e316190dc8c 100644
--- a/include/linux/usb/tcpci.h
+++ b/include/linux/usb/tcpci.h
@@ -208,6 +208,10 @@ struct tcpci;
* @set_orientation:
* Optional; Enable setting the connector orientation
* CONFIG_STANDARD_OUTPUT (0x18) bit0.
+ * @get_current_limit:
+ * Optional; Returns the current in mA the port may draw as a sink
+ * when the partner advertises Rp-default, e.g. from BC1.2
+ * detection in the TCPC. Must not return a negative value.
*/
struct tcpci_data {
struct regmap *regmap;
@@ -223,6 +227,7 @@ struct tcpci_data {
int (*start_drp_toggling)(struct tcpci *tcpci, struct tcpci_data *data,
enum typec_cc_status cc);
int (*set_vbus)(struct tcpci *tcpci, struct tcpci_data *data, bool source, bool sink);
+ int (*get_current_limit)(struct tcpci *tcpci, struct tcpci_data *data);
void (*frs_sourcing_vbus)(struct tcpci *tcpci, struct tcpci_data *data);
void (*set_partner_usb_comm_capable)(struct tcpci *tcpci, struct tcpci_data *data,
bool capable);
--
2.56.1.831.g720f3f5937-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] usb: typec: tcpm/tcpci_maxim: report BC1.2 current limit
2026-11-25 14:04 [PATCH 0/2] usb: typec: tcpci: report BC1.2 current limit in tcpci_maxim André Draszik
2026-11-25 14:04 ` [PATCH 1/2] usb: typec: tcpci: add get_current_limit callback André Draszik
@ 2026-11-25 14:04 ` André Draszik
2026-11-25 14:10 ` [PATCH 0/2] usb: typec: tcpci: report BC1.2 current limit in tcpci_maxim sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: André Draszik @ 2026-11-25 14:04 UTC (permalink / raw)
To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman
Cc: Peter Griffin, Tudor Ambarus, Juan Yescas, Amit Sunil Dhamne,
kernel-team, linux-usb, André Draszik
Maxim TCPCI (MAX33359/MAX77759) ports attached to a non-PD source
advertising Rp-default report a 0 mA current limit, so charger drivers
such as max77759-charger disable charging even when hardware BC1.2
detection has identified a charging port.
For TYPEC_CC_RP_DEF, tcpm_get_current_limit() returns 0 mA unless the
TCPC reports a limit. The Maxim TCPC exposes its BC1.2 charger detection
result in CHGTYP[1:0] of vendor register BC_STATUS1 (0x87), which
tcpci_maxim does not read; on Pixel 6 (MAX77759) attached to a CDP host,
BC_STATUS1 reads 0x02 (CDP) with BC_CTRL1 (0x8f) reading 0x81
(CHGDETEN set).
Implement the new tcpci_data get_current_limit callback to read
BC_STATUS1 and return 500 mA for SDP and 1500 mA for CDP/DCP (and 0
otherwise or on read error). Return 500 mA for SDP (matching fusb302)
because TCPM queries get_current_limit() on entering SNK_DISCOVERY and
SNK_READY and has no USB enumeration hook to raise a 100 mA limit 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>
---
drivers/usb/typec/tcpm/tcpci_maxim.h | 8 ++++++++
drivers/usb/typec/tcpm/tcpci_maxim_core.c | 25 +++++++++++++++++++++++++
2 files changed, 33 insertions(+)
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 a19f52515429..fb22a0dfb963 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>
@@ -57,6 +58,29 @@ static struct max_tcpci_chip *tdata_to_max_tcpci(struct tcpci_data *tdata)
return container_of(tdata, struct max_tcpci_chip, data);
}
+static int max_tcpci_get_current_limit(struct tcpci *tcpci,
+ struct tcpci_data *tdata)
+{
+ struct max_tcpci_chip *chip = tdata_to_max_tcpci(tdata);
+ u8 status;
+ int ret;
+
+ /* Relies on CHGDETEN being set; returns 0 until detection finishes. */
+ ret = max_tcpci_read8(chip, TCPC_VENDOR_BC_STATUS1, &status);
+ if (ret < 0)
+ return 0;
+
+ switch (FIELD_GET(CHGTYP, status)) {
+ case CHGTYP_SDP:
+ return 500;
+ case CHGTYP_CDP:
+ case CHGTYP_DCP:
+ return 1500;
+ default:
+ return 0;
+ }
+}
+
static void max_tcpci_init_regs(struct max_tcpci_chip *chip)
{
u16 alert_mask = 0;
@@ -523,6 +547,7 @@ static int max_tcpci_probe(struct i2c_client *client)
chip->data.check_contaminant = max_tcpci_check_contaminant;
chip->data.cable_comm_capable = true;
chip->data.attempt_vconn_swap_discovery = max_tcpci_attempt_vconn_swap_discovery;
+ chip->data.get_current_limit = max_tcpci_get_current_limit;
max_tcpci_init_regs(chip);
chip->tcpci = tcpci_register_port(chip->dev, &chip->data);
--
2.56.1.831.g720f3f5937-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] usb: typec: tcpci: report BC1.2 current limit in tcpci_maxim
2026-11-25 14:04 [PATCH 0/2] usb: typec: tcpci: report BC1.2 current limit in tcpci_maxim André Draszik
2026-11-25 14:04 ` [PATCH 1/2] usb: typec: tcpci: add get_current_limit callback André Draszik
2026-11-25 14:04 ` [PATCH 2/2] usb: typec: tcpm/tcpci_maxim: report BC1.2 current limit André Draszik
@ 2026-11-25 14:10 ` sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-25 14:10 UTC (permalink / raw)
To: André Draszik; +Cc: linux-usb
Sashiko has reviewed this 2-patch series and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-tcpci-maxim-bc12-v1-0-656e01201efb@linaro.org
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-25 14:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 14:04 [PATCH 0/2] usb: typec: tcpci: report BC1.2 current limit in tcpci_maxim André Draszik
2026-11-25 14:04 ` [PATCH 1/2] usb: typec: tcpci: add get_current_limit callback André Draszik
2026-11-25 14:04 ` [PATCH 2/2] usb: typec: tcpm/tcpci_maxim: report BC1.2 current limit André Draszik
2026-11-25 14:10 ` [PATCH 0/2] usb: typec: tcpci: report BC1.2 current limit in tcpci_maxim sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox