All of lore.kernel.org
 help / color / mirror / Atom feed
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 1/2] usb: typec: tcpci: add get_current_limit callback
Date: Mon, 30 Nov 2026 14:02:22 +0100	[thread overview]
Message-ID: <aw1z3tfD5Fnzb2Wr@black.igk.intel.com> (raw)
In-Reply-To: <20261125-tcpci-maxim-bc12-v1-1-656e01201efb@linaro.org>

On Wed, Nov 25, 2026 at 02:04:11PM +0000, André Draszik wrote:
> 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>

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

> ---
>  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
> 

-- 
heikki

  reply	other threads:[~2026-11-30 13:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-30 13:02   ` Heikki Krogerus [this message]
2026-11-25 14:04 ` [PATCH 2/2] usb: typec: tcpm/tcpci_maxim: report BC1.2 current limit André Draszik
2026-11-30 13:03   ` Heikki Krogerus
2026-11-25 14:10 ` [PATCH 0/2] usb: typec: tcpci: report BC1.2 current limit in tcpci_maxim 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=aw1z3tfD5Fnzb2Wr@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.