From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.12 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796043820; b=4jAx7wfOuz65f3Ccx8beRsV9EjGs3Tju7FzIb1USFLw1k5eYc1W2dTJGw4Izyhu9rziC u2s0bwtxi5jvNQN1Ro9ZjE8b7BV2q5t3qx3c7BJlLE6gDEIVOkhwi/zHXby8mFdJTt32u m98AFhXpsqG41dOCLUOvZadiLNrcYgx7mFqmBn1faEDSlIjte+1YLuPhCEsyWIpex6Jhj gc0glNWMwBzt2fmxY0mmLiGt2nWCJ4Xjlhk8tTud40Iimd7hLku/L/2OQ4D2eitDcB3/U yBeQYBmU9jJW97MgOccfYVBGZ5muQqV1xKkwbYXV9JBWGxlbJhy6DNGGknYJ0w+zISw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796043820; 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=+SHkO0PBwHzRlJtbNuazDhH2ALhEh9+JO4PR1rFCSEA=; b=40F9s5RwsPug8jzszTS9aMI3+auaBNygL4M18IYDCiz776tse+AH5S8luUeJDSYhvrup xaRznVkhObEYGL1YKqPi/aiFt6lTERiXqalRcS+JYwLn6o9p1wAm3oHEaeHahR9OsyFDY vCMeluwPn2VfyE2amGvGuxCOOQDYLcU+RWumkF8JiZINhkqzkEyGtpDrmUkImWpxxRf3M 8OPs7e/xJD1TTTwYt2a1DDE9l0kPxH5wHrLO462FuJmfzTCP7/PNzxzvhaMlGH/gX+olR 1fsPv87e/ET9fwU7nXoAllDIfBEOX2RrzdLMCi9gkgZEFDHnJzhiJv2fYK3HYWj9afg== 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=MeSOC1jw; arc=none smtp.remote-ip=192.198.163.12 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 B087B606A32C for ; Mon, 30 Nov 2026 13:03:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B087B606A32C 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=MeSOC1jw DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796043820; x=1827579820; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=+SHkO0PBwHzRlJtbNuazDhH2ALhEh9+JO4PR1rFCSEA=; b=MeSOC1jw2hwZBB/uEWv249cdKv+PTmxzG7o0BGoY9I+MHV7qwxkqQeMv 8i6gBHwSxzdzBB8WnGAKBc7Z+JGI+AhC+mZ8X3c9BKK7hHGFBtK1QZIK+ sYxjUhqY4DsJ0lPL1c88RgH6x+8mZWnUjPApr2TTusTCB0oKDIjqK9k4x Z0nwf5yT4GtQRuyjviWB7tFldn0jEiiF6roCacu6OqpR00vy19Sq9a+R5 kFWMCOUWIIPiQxJm88/kWy06A4odXwkrbaEzscklynOu+0ryK3hIMD92I gnIm508R6sqsBPWB1q9AsQM3HiDYJOoOojNBjCzclhq6Ihp5UejdcefqI g==; X-CSE-ConnectionGUID: gkk/WWU3R0C2Abv3P5uZuQ== X-CSE-MsgGUID: 07XBahLGT+OS7QGJthIiDg== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4771937" X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="4771937" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 05:03:39 -0800 X-CSE-ConnectionGUID: dI05SD9MQOmVWbqYvTnlfQ== X-CSE-MsgGUID: bQlhVempQtCOmRqDMfkNzg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="12710749" Received: from black.igk.intel.com ([10.91.253.5]) by orviesa008.jf.intel.com with ESMTP; 30 Nov 2026 05:03:37 -0800 Received: by black.igk.intel.com (Postfix, from userid 1008) id C64D399; Mon, 30 Nov 2026 14:03:35 +0100 (CET) Date: Mon, 30 Nov 2026 14:03:35 +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 2/2] usb: typec: tcpm/tcpci_maxim: report BC1.2 current limit Message-ID: References: <20261125-tcpci-maxim-bc12-v1-0-656e01201efb@linaro.org> <20261125-tcpci-maxim-bc12-v1-2-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-2-656e01201efb@linaro.org> On Wed, Nov 25, 2026 at 02:04:12PM +0000, André Draszik wrote: > 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 Acked-by: Heikki Krogerus > --- > 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 > #include > #include > #include > @@ -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 > -- heikki