Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: typec: wcove: Remove dependency on HW FSM

The USB Type-C PHY in Intel WhiskeyCove PMIC has build-in
USB Type-C state machine which we were relying on to
configure the CC lines correctly. This patch removes that
dependency and configures the CC line according to commands
from the port manager (tcpm.c) in wcove_set_cc().

This fixes an issue where USB devices attached to the USB
Type-C port do not get enumerated. When acting as
source/host, the HW FSM sometimes fails to configure the PHY
correctly.

Fixes: 3c4fb9f16921 ("usb: typec: wcove: start using tcpm for USB PD support")
Cc: stable@vger.kernel.org
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Heikki Krogerus and committed by
Greg Kroah-Hartman
05826ff1 cb296846

+28 -2
+28 -2
drivers/usb/typec/typec_wcove.c
··· 202 202 struct wcove_typec *wcove = tcpc_to_wcove(tcpc); 203 203 int ret; 204 204 205 + ret = regmap_write(wcove->regmap, USBC_CONTROL1, 0); 206 + if (ret) 207 + return ret; 208 + 205 209 /* Unmask everything */ 206 210 ret = regmap_write(wcove->regmap, USBC_IRQMASK1, 0); 207 211 if (ret) ··· 289 285 290 286 static int wcove_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc) 291 287 { 292 - /* XXX: Relying on the HW FSM to configure things correctly for now */ 293 - return 0; 288 + struct wcove_typec *wcove = tcpc_to_wcove(tcpc); 289 + unsigned int ctrl; 290 + 291 + switch (cc) { 292 + case TYPEC_CC_RD: 293 + ctrl = USBC_CONTROL1_MODE_SNK; 294 + break; 295 + case TYPEC_CC_RP_DEF: 296 + ctrl = USBC_CONTROL1_CURSRC_UA_80 | USBC_CONTROL1_MODE_SRC; 297 + break; 298 + case TYPEC_CC_RP_1_5: 299 + ctrl = USBC_CONTROL1_CURSRC_UA_180 | USBC_CONTROL1_MODE_SRC; 300 + break; 301 + case TYPEC_CC_RP_3_0: 302 + ctrl = USBC_CONTROL1_CURSRC_UA_330 | USBC_CONTROL1_MODE_SRC; 303 + break; 304 + case TYPEC_CC_OPEN: 305 + ctrl = 0; 306 + break; 307 + default: 308 + return -EINVAL; 309 + } 310 + 311 + return regmap_write(wcove->regmap, USBC_CONTROL1, ctrl); 294 312 } 295 313 296 314 static int wcove_set_polarity(struct tcpc_dev *tcpc, enum typec_cc_polarity pol)