Linux USB
 help / color / mirror / Atom feed
* [PATCH v2 0/3] usb: typec: report a current limit for non-PD Rp-def sources
@ 2026-10-04  3:40 Amit Sunil Dhamne via B4 Relay
  2026-10-04  3:40 ` [PATCH v2 1/3] usb: typec: tcpm: only call get_current_limit() for cc=Rp-def Amit Sunil Dhamne via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Amit Sunil Dhamne via B4 Relay @ 2026-10-04  3:40 UTC (permalink / raw)
  To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, André Draszik, RD Babiera, Kyle Tso,
	Amit Sunil Dhamne

As per Sec. 4.6.2.1 of the Type-C cable & connector spec when the
source advertises Rp-default, the current limit is set as per the
USB 2.0/USB 3.2 specification, BC1.2 specification as applicable or the
PD negotiation.

Reset value for the Input Current Limit register for the MAX77759
charger is 500 mA. Prior to the max77759_charger driver, the battery
would always charge at that limit since it wasn't re-programmed. Since
the driver was introduced, for any non-PD source advertising Rp-default,
the charger turns off as tcpm reports the current limit to be 0. The
max77759_charger driver reads POWER_SUPPLY_PROP_CURRENT_MAX from the
"tcpm-source" power supply that tcpm_set_current_limit() updates, and
programs its input current limit from it. The limit is 0 because the
tcpm doesn't have visibility on the USB data speed or BC1.2 detection.
As a workaround for the Rp-default case, let the Type-C stack report a
USB 2.0 current limit of 500 mA so that the behavior is at parity with
what was before. This is until we implement a conduit for USB core to
communicate with the Type-C stack.

Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
---
Changes in v2:
- Remove greedy initialization of `limit` variable in
  tcpm_get_current_limit(). (André Draszik)
- Link to v1: https://lore.kernel.org/r/20261001-max77759-icl-typec-v1-0-99ada1f65ced@google.com

---
Amit Sunil Dhamne (3):
      usb: typec: tcpm: only call get_current_limit() for cc=Rp-def
      usb: typec: tcpci: implement get_current_limit
      usb: typec: tcpci_maxim: implement get_current_limit

 drivers/usb/typec/tcpm/tcpci.c            | 14 ++++++++++++++
 drivers/usb/typec/tcpm/tcpci_maxim_core.c | 15 +++++++++++++++
 drivers/usb/typec/tcpm/tcpm.c             |  4 +++-
 include/linux/usb/tcpci.h                 |  6 ++++++
 4 files changed, 38 insertions(+), 1 deletion(-)
---
base-commit: 551c722f40809618230001baccf219193e22fc5a
change-id: 20260918-max77759-icl-typec-8dfb9f83d712

Best regards,
-- 
Amit Sunil Dhamne <amitsd@google.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/3] usb: typec: tcpm: only call get_current_limit() for cc=Rp-def
  2026-10-04  3:40 [PATCH v2 0/3] usb: typec: report a current limit for non-PD Rp-def sources Amit Sunil Dhamne via B4 Relay
@ 2026-10-04  3:40 ` Amit Sunil Dhamne via B4 Relay
  2026-10-09 11:33   ` Heikki Krogerus
  2026-10-04  3:41 ` [PATCH v2 2/3] usb: typec: tcpci: implement get_current_limit Amit Sunil Dhamne via B4 Relay
  2026-10-04  3:41 ` [PATCH v2 3/3] usb: typec: tcpci_maxim: " Amit Sunil Dhamne via B4 Relay
  2 siblings, 1 reply; 7+ messages in thread
From: Amit Sunil Dhamne via B4 Relay @ 2026-10-04  3:40 UTC (permalink / raw)
  To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, André Draszik, RD Babiera, Kyle Tso,
	Amit Sunil Dhamne

From: Amit Sunil Dhamne <amitsd@google.com>

tcpm_get_current_limit() folds the default label into the
TYPEC_CC_RP_DEF case, so tcpc_dev::get_current_limit() is also called
for CC states that do not advertise Rp, such as TYPEC_CC_OPEN,
TYPEC_CC_RA and TYPEC_CC_RD. Its kerneldoc has always scoped it to
cc=Rp-def:

  @get_current_limit:
          Optional; called by the tcpm core when configured as a snk
          and cc=Rp-def. This allows the tcpm to provide a fallback
          current-limit detection method for the cc=Rp-def case.

A chip driver has nothing to interpret in the other states. Therefore,
split the cases and report 0 when CC is not an Rp.

Assisted-by: LLM
Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 2d6b14aa2085..cb69d6a7ce5a 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -1279,12 +1279,14 @@ static u32 tcpm_get_current_limit(struct tcpm_port *port)
 		limit = 3000;
 		break;
 	case TYPEC_CC_RP_DEF:
-	default:
 		if (port->tcpc->get_current_limit)
 			limit = port->tcpc->get_current_limit(port->tcpc);
 		else
 			limit = 0;
 		break;
+	default:
+		limit = 0;
+		break;
 	}
 
 	return limit;

-- 
2.56.0.rc1.315.gc6ed9934b7-goog



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/3] usb: typec: tcpci: implement get_current_limit
  2026-10-04  3:40 [PATCH v2 0/3] usb: typec: report a current limit for non-PD Rp-def sources Amit Sunil Dhamne via B4 Relay
  2026-10-04  3:40 ` [PATCH v2 1/3] usb: typec: tcpm: only call get_current_limit() for cc=Rp-def Amit Sunil Dhamne via B4 Relay
@ 2026-10-04  3:41 ` Amit Sunil Dhamne via B4 Relay
  2026-10-09 11:33   ` Heikki Krogerus
  2026-10-04  3:41 ` [PATCH v2 3/3] usb: typec: tcpci_maxim: " Amit Sunil Dhamne via B4 Relay
  2 siblings, 1 reply; 7+ messages in thread
From: Amit Sunil Dhamne via B4 Relay @ 2026-10-04  3:41 UTC (permalink / raw)
  To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, André Draszik, RD Babiera, Kyle Tso,
	Amit Sunil Dhamne

From: Amit Sunil Dhamne <amitsd@google.com>

Implement a callback for tcpc_dev::get_current_limit. This acts like a
conduit to relay the current limit information from chip level tcpc
drivers.

This does not introduce any functional changes for chip level drivers
that do not implement tcpci_data::get_current_limit.

Assisted-by: LLM
Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>
---
 drivers/usb/typec/tcpm/tcpci.c | 14 ++++++++++++++
 include/linux/usb/tcpci.h      |  6 ++++++
 2 files changed, 20 insertions(+)

diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index 6717ac914c6a..f1bc1ac0a556 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -250,6 +250,19 @@ static int tcpci_get_cc(struct tcpc_dev *tcpc,
 	return 0;
 }
 
+static int tcpci_get_current_limit(struct tcpc_dev *tcpc)
+{
+	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
+	int ret;
+
+	if (!tcpci->data->get_current_limit)
+		return 0;
+
+	ret = tcpci->data->get_current_limit(tcpci, tcpci->data);
+
+	return ret < 0 ? 0 : ret;
+}
+
 static int tcpci_set_polarity(struct tcpc_dev *tcpc,
 			      enum typec_cc_polarity polarity)
 {
@@ -861,6 +874,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
 	tcpci->tcpc.set_cc = tcpci_set_cc;
 	tcpci->tcpc.apply_rc = tcpci_apply_rc;
 	tcpci->tcpc.get_cc = tcpci_get_cc;
+	tcpci->tcpc.get_current_limit = tcpci_get_current_limit;
 	tcpci->tcpc.set_polarity = tcpci_set_polarity;
 	tcpci->tcpc.set_vconn = tcpci_set_vconn;
 	tcpci->tcpc.start_toggling = tcpci_start_toggling;
diff --git a/include/linux/usb/tcpci.h b/include/linux/usb/tcpci.h
index 9b46a6bc762c..580fbdac7ede 100644
--- a/include/linux/usb/tcpci.h
+++ b/include/linux/usb/tcpci.h
@@ -205,6 +205,11 @@ struct tcpci;
  *		swap following Discover Identity on SOP' occurs.
  *		Return true when the TCPM is allowed to request a Vconn swap
  *		after Discovery Identity on SOP.
+ * @get_current_limit:
+ *		Optional; Called when the port is a sink and CC=Rp-def to obtain
+ *		the current limit. Chip level drivers can implement their own
+ *		detection and return the limit in mA, or 0 when it cannot be
+ *		determined.
  * @set_orientation:
  *		Optional; Enable setting the connector orientation
  *		CONFIG_STANDARD_OUTPUT (0x18) bit0.
@@ -228,6 +233,7 @@ struct tcpci_data {
 					     bool capable);
 	void (*check_contaminant)(struct tcpci *tcpci, struct tcpci_data *data);
 	bool (*attempt_vconn_swap_discovery)(struct tcpci *tcpci, struct tcpci_data *data);
+	int (*get_current_limit)(struct tcpci *tcpci, struct tcpci_data *data);
 };
 
 struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data);

-- 
2.56.0.rc1.315.gc6ed9934b7-goog



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/3] usb: typec: tcpci_maxim: implement get_current_limit
  2026-10-04  3:40 [PATCH v2 0/3] usb: typec: report a current limit for non-PD Rp-def sources Amit Sunil Dhamne via B4 Relay
  2026-10-04  3:40 ` [PATCH v2 1/3] usb: typec: tcpm: only call get_current_limit() for cc=Rp-def Amit Sunil Dhamne via B4 Relay
  2026-10-04  3:41 ` [PATCH v2 2/3] usb: typec: tcpci: implement get_current_limit Amit Sunil Dhamne via B4 Relay
@ 2026-10-04  3:41 ` Amit Sunil Dhamne via B4 Relay
  2026-10-09 11:34   ` Heikki Krogerus
  2 siblings, 1 reply; 7+ messages in thread
From: Amit Sunil Dhamne via B4 Relay @ 2026-10-04  3:41 UTC (permalink / raw)
  To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, André Draszik, RD Babiera, Kyle Tso,
	Amit Sunil Dhamne

From: Amit Sunil Dhamne <amitsd@google.com>

Implement tcpci_data::get_current_limit for tcpci_maxim driver to report
a value of 500 mA unconditionally. This is the max current a configured
USB 2.0 device may draw per the USB Type-C Cable and Connector
Specification r2.2, Sec. 4.6.2.1. This helps set a current limit and
thus enable charging for the cases when a port is connected to a non-PD
Type-C port partner advertising Rp-def. This is until a mechanism for
USB core to communicate the current limit to the TCPC driver is
implemented.

Assisted-by: LLM
Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>
---
 drivers/usb/typec/tcpm/tcpci_maxim_core.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
index 998693a61839..e6f825931ba0 100644
--- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c
+++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
@@ -482,6 +482,20 @@ 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)
+{
+	return 500;
+}
+
 static void max_tcpci_unregister_tcpci_port(void *tcpci)
 {
 	tcpci_unregister_port(tcpci);
@@ -523,6 +537,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.0.rc1.315.gc6ed9934b7-goog



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] usb: typec: tcpm: only call get_current_limit() for cc=Rp-def
  2026-10-04  3:40 ` [PATCH v2 1/3] usb: typec: tcpm: only call get_current_limit() for cc=Rp-def Amit Sunil Dhamne via B4 Relay
@ 2026-10-09 11:33   ` Heikki Krogerus
  0 siblings, 0 replies; 7+ messages in thread
From: Heikki Krogerus @ 2026-10-09 11:33 UTC (permalink / raw)
  To: amitsd
  Cc: Badhri Jagan Sridharan, Greg Kroah-Hartman, linux-usb,
	linux-kernel, André Draszik, RD Babiera, Kyle Tso

On Sun, Oct 04, 2026 at 03:40:59AM +0000, Amit Sunil Dhamne via B4 Relay wrote:
> From: Amit Sunil Dhamne <amitsd@google.com>
> 
> tcpm_get_current_limit() folds the default label into the
> TYPEC_CC_RP_DEF case, so tcpc_dev::get_current_limit() is also called
> for CC states that do not advertise Rp, such as TYPEC_CC_OPEN,
> TYPEC_CC_RA and TYPEC_CC_RD. Its kerneldoc has always scoped it to
> cc=Rp-def:
> 
>   @get_current_limit:
>           Optional; called by the tcpm core when configured as a snk
>           and cc=Rp-def. This allows the tcpm to provide a fallback
>           current-limit detection method for the cc=Rp-def case.
> 
> A chip driver has nothing to interpret in the other states. Therefore,
> split the cases and report 0 when CC is not an Rp.
> 
> Assisted-by: LLM
> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
> Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 2d6b14aa2085..cb69d6a7ce5a 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -1279,12 +1279,14 @@ static u32 tcpm_get_current_limit(struct tcpm_port *port)
>  		limit = 3000;
>  		break;
>  	case TYPEC_CC_RP_DEF:
> -	default:
>  		if (port->tcpc->get_current_limit)
>  			limit = port->tcpc->get_current_limit(port->tcpc);
>  		else
>  			limit = 0;
>  		break;
> +	default:
> +		limit = 0;
> +		break;
>  	}
>  
>  	return limit;
> 
> -- 
> 2.56.0.rc1.315.gc6ed9934b7-goog
> 

-- 
heikki

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/3] usb: typec: tcpci: implement get_current_limit
  2026-10-04  3:41 ` [PATCH v2 2/3] usb: typec: tcpci: implement get_current_limit Amit Sunil Dhamne via B4 Relay
@ 2026-10-09 11:33   ` Heikki Krogerus
  0 siblings, 0 replies; 7+ messages in thread
From: Heikki Krogerus @ 2026-10-09 11:33 UTC (permalink / raw)
  To: amitsd
  Cc: Badhri Jagan Sridharan, Greg Kroah-Hartman, linux-usb,
	linux-kernel, André Draszik, RD Babiera, Kyle Tso

On Sun, Oct 04, 2026 at 03:41:00AM +0000, Amit Sunil Dhamne via B4 Relay wrote:
> From: Amit Sunil Dhamne <amitsd@google.com>
> 
> Implement a callback for tcpc_dev::get_current_limit. This acts like a
> conduit to relay the current limit information from chip level tcpc
> drivers.
> 
> This does not introduce any functional changes for chip level drivers
> that do not implement tcpci_data::get_current_limit.
> 
> Assisted-by: LLM
> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
> Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tcpm/tcpci.c | 14 ++++++++++++++
>  include/linux/usb/tcpci.h      |  6 ++++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index 6717ac914c6a..f1bc1ac0a556 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -250,6 +250,19 @@ static int tcpci_get_cc(struct tcpc_dev *tcpc,
>  	return 0;
>  }
>  
> +static int tcpci_get_current_limit(struct tcpc_dev *tcpc)
> +{
> +	struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
> +	int ret;
> +
> +	if (!tcpci->data->get_current_limit)
> +		return 0;
> +
> +	ret = tcpci->data->get_current_limit(tcpci, tcpci->data);
> +
> +	return ret < 0 ? 0 : ret;
> +}
> +
>  static int tcpci_set_polarity(struct tcpc_dev *tcpc,
>  			      enum typec_cc_polarity polarity)
>  {
> @@ -861,6 +874,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
>  	tcpci->tcpc.set_cc = tcpci_set_cc;
>  	tcpci->tcpc.apply_rc = tcpci_apply_rc;
>  	tcpci->tcpc.get_cc = tcpci_get_cc;
> +	tcpci->tcpc.get_current_limit = tcpci_get_current_limit;
>  	tcpci->tcpc.set_polarity = tcpci_set_polarity;
>  	tcpci->tcpc.set_vconn = tcpci_set_vconn;
>  	tcpci->tcpc.start_toggling = tcpci_start_toggling;
> diff --git a/include/linux/usb/tcpci.h b/include/linux/usb/tcpci.h
> index 9b46a6bc762c..580fbdac7ede 100644
> --- a/include/linux/usb/tcpci.h
> +++ b/include/linux/usb/tcpci.h
> @@ -205,6 +205,11 @@ struct tcpci;
>   *		swap following Discover Identity on SOP' occurs.
>   *		Return true when the TCPM is allowed to request a Vconn swap
>   *		after Discovery Identity on SOP.
> + * @get_current_limit:
> + *		Optional; Called when the port is a sink and CC=Rp-def to obtain
> + *		the current limit. Chip level drivers can implement their own
> + *		detection and return the limit in mA, or 0 when it cannot be
> + *		determined.
>   * @set_orientation:
>   *		Optional; Enable setting the connector orientation
>   *		CONFIG_STANDARD_OUTPUT (0x18) bit0.
> @@ -228,6 +233,7 @@ struct tcpci_data {
>  					     bool capable);
>  	void (*check_contaminant)(struct tcpci *tcpci, struct tcpci_data *data);
>  	bool (*attempt_vconn_swap_discovery)(struct tcpci *tcpci, struct tcpci_data *data);
> +	int (*get_current_limit)(struct tcpci *tcpci, struct tcpci_data *data);
>  };
>  
>  struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data);
> 
> -- 
> 2.56.0.rc1.315.gc6ed9934b7-goog
> 

-- 
heikki

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 3/3] usb: typec: tcpci_maxim: implement get_current_limit
  2026-10-04  3:41 ` [PATCH v2 3/3] usb: typec: tcpci_maxim: " Amit Sunil Dhamne via B4 Relay
@ 2026-10-09 11:34   ` Heikki Krogerus
  0 siblings, 0 replies; 7+ messages in thread
From: Heikki Krogerus @ 2026-10-09 11:34 UTC (permalink / raw)
  To: amitsd
  Cc: Badhri Jagan Sridharan, Greg Kroah-Hartman, linux-usb,
	linux-kernel, André Draszik, RD Babiera, Kyle Tso

On Sun, Oct 04, 2026 at 03:41:01AM +0000, Amit Sunil Dhamne via B4 Relay wrote:
> From: Amit Sunil Dhamne <amitsd@google.com>
> 
> Implement tcpci_data::get_current_limit for tcpci_maxim driver to report
> a value of 500 mA unconditionally. This is the max current a configured
> USB 2.0 device may draw per the USB Type-C Cable and Connector
> Specification r2.2, Sec. 4.6.2.1. This helps set a current limit and
> thus enable charging for the cases when a port is connected to a non-PD
> Type-C port partner advertising Rp-def. This is until a mechanism for
> USB core to communicate the current limit to the TCPC driver is
> implemented.
> 
> Assisted-by: LLM
> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
> Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tcpm/tcpci_maxim_core.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> index 998693a61839..e6f825931ba0 100644
> --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> @@ -482,6 +482,20 @@ 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)
> +{
> +	return 500;
> +}
> +
>  static void max_tcpci_unregister_tcpci_port(void *tcpci)
>  {
>  	tcpci_unregister_port(tcpci);
> @@ -523,6 +537,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.0.rc1.315.gc6ed9934b7-goog
> 

-- 
heikki

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-09 11:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-04  3:40 [PATCH v2 0/3] usb: typec: report a current limit for non-PD Rp-def sources Amit Sunil Dhamne via B4 Relay
2026-10-04  3:40 ` [PATCH v2 1/3] usb: typec: tcpm: only call get_current_limit() for cc=Rp-def Amit Sunil Dhamne via B4 Relay
2026-10-09 11:33   ` Heikki Krogerus
2026-10-04  3:41 ` [PATCH v2 2/3] usb: typec: tcpci: implement get_current_limit Amit Sunil Dhamne via B4 Relay
2026-10-09 11:33   ` Heikki Krogerus
2026-10-04  3:41 ` [PATCH v2 3/3] usb: typec: tcpci_maxim: " Amit Sunil Dhamne via B4 Relay
2026-10-09 11:34   ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox