From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796392829; b=Hal5L0AqtXvFNRNzi2Kuos6/faDL6pzBcr0fcO+W/y+WBCjciV0gJ+Z2PCIQPOcttius Iuh6wu8KtpUmeAR64tdsbf4XEJZ+kk827Q0PrJnH4wmxira5Qg3FQj9y/57tk0BQeI9qI IFS9y/WE4iZr47U+ccj+v7WeD1DhRMBi8aVMRuE5Vzgs7XbIA9iwaaiEvW79l2XWasx8h K71wbkiKU4HFO3Q+H1a47V/1kowN1Khfda9L3qAXnkkkeBAOgqA+0/phuySwOpukS0t3U /LSOf1jkFDUaHZ3yNLx92vzPI8eVc9/hrq6qU792OmDk+xzT95ITY0dFu92OOKC3dqg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796392829; 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=0IH6Q1/lIZx+zD5BQRQvvX33TEnblsrV0bEFbAUCqe0=; b=mhj6AqKiNffikJY6pT5IKMoz56ebKTTa5dknTDMgZtAdK2dWGGswqRi1I9ai6khFu08w KDDQ27G08WuX4OgqVoCqErfTMCYzNsZA7jIlp4ncfwENgQsOvNKqdzpB1iLuGJ+Aty6a/ lkIBzqKsxSILNmtaKvKnjskf03gIX6PK5aJXLpMcfeu4+XzUYoURVvevP19jtv70S7xge 44iA44dykUlt27l/LGW4hH0auQ/BKKE9h2E6cFbKYCPzvvW79zPs7nA9Z3v57Kpw4Wy4w TksVyhFt6cVO7GUegN1GbX1DO5QIVLwCh3kkE8Eu4oBh1h25dSVUujlK1ya+K3f/NCA== 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=d+pRkEw1; arc=none smtp.remote-ip=198.175.65.18 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 3C768606A681 for ; Fri, 4 Dec 2026 14:00:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3C768606A681 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=d+pRkEw1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796392826; x=1827928826; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=0IH6Q1/lIZx+zD5BQRQvvX33TEnblsrV0bEFbAUCqe0=; b=d+pRkEw13qcIF8WO2m+1Erb1tyw9+K87HudqfEnVStcqRm//E0b1RhhF qxz0g0YYcN7Y2nizvlDJDohxUc9KMw67Ztq8aDuqHtbDqoCZKJNdiBali /3Cctc112tXy1gNCq+7MpL55F+EfnJCmVqImlonEQlj9sZjkyHCQut6AC qqFIIS0fOx2rHTrETaruB7eQkO48C3rrFzxPSJrNBcHUzXnRelFducmkb 0mQxoiSLr1a7hCazdjxeEULgFCa5QnBxqaOCzhyatOBF08DHhqz7w9BFe 4NQXvr89ckDv3hGMewqBbUX46Wy3uJ029k/8mgbBZvdtn/Qyh+x6CfZ/7 A==; X-CSE-ConnectionGUID: lLM0gwkgRPGjW1jNdLsiig== X-CSE-MsgGUID: VPvI8TlLTE29HH6TPTGu2w== X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="5391703" X-IronPort-AV: E=Sophos;i="6.29,78,1794902400"; d="scan'208";a="5391703" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 06:00:26 -0800 X-CSE-ConnectionGUID: Yz5gfgo/QYyCZXP1f+mTaQ== X-CSE-MsgGUID: RORl/zSnQUClnwpNp1+VFw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,78,1794902400"; d="scan'208";a="14139934" Received: from black.igk.intel.com ([10.91.253.5]) by fmviesa005.fm.intel.com with ESMTP; 04 Dec 2026 06:00:23 -0800 Received: by black.igk.intel.com (Postfix, from userid 1008) id 8CEA298; Fri, 04 Dec 2026 15:00:22 +0100 (CET) Date: Fri, 4 Dec 2026 15:00: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 v2] usb: typec: tcpm/tcpci_maxim: report BC1.2 current limit Message-ID: References: <20261204-tcpci-maxim-bc12-v2-1-3c8ccacc9bdd@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: <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 Acked-by: Heikki Krogerus > --- > 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 > #include > #include > #include > @@ -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 > -- heikki