mfd: fusb302: correct extcon cable state when enable vbus
authorWu Liang feng <wulf@rock-chips.com>
Sat, 15 Oct 2016 03:49:18 +0000 (11:49 +0800)
committerWu Liang feng <wulf@rock-chips.com>
Sun, 16 Oct 2016 06:39:59 +0000 (14:39 +0800)
Set extcon cable state to EXTCON_USB_VBUS_EN instead of
EXTCON_USB_HOST when enable vbus 5v. Because EXTCON_USB_HOST
state means that fusb302 has detected Type-C mode and the
orientation. However, enable vbus is prior to Type-C mode
and orientation detection. If we set EXTCON_USB_HOST state
when power on vbus, it may cause usb controller driver to
receive the state prematurely, and do tcphy orientation init
improperly.

Change-Id: Id65072dc8235693db44667ee5d2ceac74dc94920
Signed-off-by: Wu Liang feng <wulf@rock-chips.com>
drivers/mfd/fusb302.c

index 7bf2a65aa99f9c661fb9db17c37aefc714539060..effa6968d1a1f06beb8dd68ea29ea48dad164160 100644 (file)
@@ -214,6 +214,8 @@ static void platform_set_vbus_lvl_enable(struct fusb30x_chip *chip, int vbus_5v,
 {
        if (chip->gpio_vbus_5v) {
                gpiod_set_raw_value(chip->gpio_vbus_5v, vbus_5v);
+               /* Only set state here, don't sync notifier to PMIC */
+               extcon_set_state(chip->extcon, EXTCON_USB_VBUS_EN, vbus_5v);
        } else {
                extcon_set_state(chip->extcon, EXTCON_USB_VBUS_EN, vbus_5v);
                extcon_sync(chip->extcon, EXTCON_USB_VBUS_EN);
@@ -1323,7 +1325,6 @@ static void fusb_state_attach_wait_source(struct fusb30x_chip *chip, int evt)
 static void fusb_state_attached_source(struct fusb30x_chip *chip, int evt)
 {
        tcpm_set_polarity(chip, !(chip->cc_state & 0x01));
-       extcon_set_state(chip->extcon, EXTCON_USB_HOST, 1);
        platform_set_vbus_lvl_enable(chip, 1, 0);
        tcpm_set_vconn(chip, 1);