From: Arun Iyengar Date: Thu, 12 Nov 2026 08:23:34 +0000 Subject: [PATCH v2 2/2] usb: typec: fusb302: Toggle with the default Rp current MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261112-tcpm-attach-reboot-v2-2-b4bc6ca83490@gmail.com> References: <20261112-tcpm-attach-reboot-v2-0-b4bc6ca83490@gmail.com> In-Reply-To: <20261112-tcpm-attach-reboot-v2-0-b4bc6ca83490@gmail.com> To: Badhri Jagan Sridharan , Heikki Krogerus , Greg Kroah-Hartman , Guenter Roeck , Heiko Stuebner Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, Arun Iyengar X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1794471812; l=3585; i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id; bh=tD7FYH82nlIArIvaQxvwuexRhWGTOTfnEzwgYwR8d8U=; b=spjM5HPPpWe+lrfW7WRU681uie2NR8dc4+wxVo2n+3xwGB6vSqQ1bU1/Os7tSe3znFz4XI8W2 2ONr7RyGZJ1CXPtw6TxihfctXruTMpLrgQehwYMr6XuEBm3iocDr10+ X-Developer-Key: i=aiyengar1990@gmail.com; a=ed25519; pk=zXpRgUTrhaFe6jLyPqbBy3ccfkj04w0g2690Wv3mg+0= X-Endpoint-Received: by B4 Relay for aiyengar1990@gmail.com/20261110 with auth_id=1480 List-Id: B4 Relay Submissions tcpm_start_toggling() programs the Rp current that tcpm asks for, which is the current of the source PDO (Rp 3.0A on boards that can source 3A) when the port starts toggling from Unattached.SRC, and the default current when it starts from Unattached.SNK after a detach. A Genesys Logic based USB-C to DisplayPort cable connected to the Orange Pi 5 is often not detected after a warm reboot: the FUSB302 toggle state machine raises no interrupt with it while it drives the high Rp current, but finds it within seconds once toggling restarts with the default current after another device was detached. Toggle with the default current, and switch to the requested one when toggling stops on a sink, before tcpm is told about the attach, so the sink sees the configured level from the start of the connection as before. tcpm does not set it again after attach on every path (not on ports without PD, for instance). The Rd detection threshold used for unplug detection follows the restored current. The FUSB302B datasheet sets the toggle up the same way: under "Toggle Functionality" the processor writes HOST_CUR for the default current before it sets TOGGLE, and a HOST_CUR change after attach is applied to the CC line immediately ("HOST_CUR Changed After Attach"). Fixes: c034a43e72dd ("staging: typec: Fairchild FUSB302 Type-c chip driver") Signed-off-by: Arun Iyengar --- drivers/usb/typec/tcpm/fusb302.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c index 3319f6a2b0c9..44aa05fd4ba2 100644 --- a/drivers/usb/typec/tcpm/fusb302.c +++ b/drivers/usb/typec/tcpm/fusb302.c @@ -97,6 +97,7 @@ struct fusb302_chip { /* chip status */ enum toggling_mode toggling_mode; enum src_current_status src_current_status; + enum src_current_status toggling_src_current; bool intr_togdone; bool intr_bc_lvl; bool intr_comp_chng; @@ -942,10 +943,19 @@ static int tcpm_start_toggling(struct tcpc_dev *dev, } mutex_lock(&chip->lock); - ret = fusb302_set_src_current(chip, cc_src_current[cc]); + /* + * Look for a partner with the default USB current advertisement. + * Some sinks (seen with a Genesys Logic based USB-C to DisplayPort + * cable) present an Rd that the FUSB302 toggle state machine does + * not detect while it drives the high (3.0 A) Rp current, so they + * are only found when toggling starts from the sink side. The + * requested current is restored when toggling finds a sink. + */ + chip->toggling_src_current = cc_src_current[cc]; + ret = fusb302_set_src_current(chip, SRC_CURRENT_DEFAULT); if (ret < 0) { fusb302_log(chip, "unable to set src current %s, ret=%d", - typec_cc_status_name[cc], ret); + typec_cc_status_name[TYPEC_CC_RP_DEF], ret); goto done; } ret = fusb302_set_toggling(chip, mode); @@ -1357,6 +1367,13 @@ static int fusb302_handle_togdone_src(struct fusb302_chip *chip, typec_cc_status_name[cc2]); return fusb302_set_toggling(chip, toggling_mode); } + /* advertise the requested Rp current now that a sink is attached */ + ret = fusb302_set_src_current(chip, chip->toggling_src_current); + if (ret < 0) { + fusb302_log(chip, "cannot set src current, ret=%d", ret); + return ret; + } + rd_mda = rd_mda_value[chip->src_current_status]; /* set polarity and pull_up, pull_down */ ret = fusb302_set_cc_polarity_and_pull(chip, cc_polarity, true, false); if (ret < 0) { -- 2.55.0