From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.8 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796043747; b=Qv9s2l5h6QKs7sWibNkODzAff+GezDx7ReWCKCH8Y5/hkzwIWs2uwwddZAOvjAaFPN0N oPXzq4K5/oUvwFz8r3G7FlwW0MPZDfMRROT64uSbqVaLpevAQIcrcvoTK7ReyLTXoAlik 9eekseUPsHNgSIGXoKDUJbeFuR3HxArjuj3gPh5pZYd9NsvKMyaDFaVYKo3ZUa77vHbjb 8IIthHzh/19kFJWVNCPtzlpnnO83aoN/L98t37sjZmdw5J1d1GQZ3M61sKQrijDYFeZNK nGXBt5tCYze2iSvlPxqovMg5nMyLmpQcFaWgHrW7kMttB7xV8gG/Ju9u0/co2eNXIxA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796043747; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Received:Date:From:To: Cc:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; bh=irEkbxYu6uiSkluTc0erVLFFqYWaRUr5pbPxpWQgAM0=; b=wqDhCVFbdbpnkR09/ZUT+ulTYKin6bfkHY36mvbYHMqcSWcoVrl7HVHc3H7bgLzZpmo4 mnsSxbICminXNhYxVP2EsTyi2v8cp/enZOmOAGItelV6M1JIhzyr8c05ncGCanJ2uBCS4 m2PgsToYYxQLvW/8CF53BQgySco34AMYFXcNEOaX15IAEWo1mh+8iJkdpNlKGktSoskpc RSJ4h6+S0qs+EXJ6C4KMVLdq685353FdTRXbIZsjz1MyufkZsqXJ2jSxmFpWcj1xf/aUf Ug3l1f0/PCZe10/o5hn7MRsxrLJLKMDbAyPkihAHJiCxZycBfv9C5l6VfsHxP2hf0Qg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=bNF1tV7Z; arc=none smtp.remote-ip=192.198.163.8 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1415606A320 for ; Mon, 30 Nov 2026 13:02:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A1415606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=bNF1tV7Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796043747; x=1827579747; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=irEkbxYu6uiSkluTc0erVLFFqYWaRUr5pbPxpWQgAM0=; b=bNF1tV7ZAOp3LrTIWakekEL4Gz+22aYgeZfQkQV606vz4KgXetPTMI5C nnxAQCggK7vonJTPkw6cN7VBRgztXuRCT6EDOhCuttHIyTTDaYMBPUS4H p+/Lt7iVZ48WvwRa5hK/l/hUgsotTnm/ML94qQXdDI+EISagmpBHDlJvo xCuBB5izlWyIRIkbyLoPMfFmFm0Bdu3Zw0S+uiHyg0YHxOcTH2kd13C89 pn49sGALb1SlicnSJMVg612bLnErJLLBh4A1/wfNuFJ3T3Bk5vG52I7m4 TOsbp3X30UkmlmqYkKDrimEtO0Xt4b5V2CiuE3oq1Qt7fmyAurdc3OGYn Q==; X-CSE-ConnectionGUID: fBFnGg9hSIutDPmonEPVyg== X-CSE-MsgGUID: blZ4GkpGTDKHDEcCI+pKAQ== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4753940" X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="4753940" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 05:02:26 -0800 X-CSE-ConnectionGUID: 5SESBGheRfON+plMiVqODw== X-CSE-MsgGUID: UnlANsS0Tr+1X69r9K+txg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="12804753" Received: from black.igk.intel.com ([10.91.253.5]) by orviesa004.jf.intel.com with ESMTP; 30 Nov 2026 05:02:24 -0800 Received: by black.igk.intel.com (Postfix, from userid 1008) id 5F9C199; Mon, 30 Nov 2026 14:02:22 +0100 (CET) Date: Mon, 30 Nov 2026 14:02:22 +0100 From: Heikki Krogerus To: =?iso-8859-1?Q?Andr=E9?= Draszik Cc: Badhri Jagan Sridharan , Greg Kroah-Hartman , Peter Griffin , Tudor Ambarus , Juan Yescas , Amit Sunil Dhamne , kernel-team@android.com, linux-usb@vger.kernel.org Subject: Re: [PATCH 1/2] usb: typec: tcpci: add get_current_limit callback Message-ID: References: <20261125-tcpci-maxim-bc12-v1-0-656e01201efb@linaro.org> <20261125-tcpci-maxim-bc12-v1-1-656e01201efb@linaro.org> X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 Acked-by: Heikki Krogerus > --- > 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