mfd: fusb302: Add EXTCON_USB_VBUS_EN for fusb302
authorBin Yang <yangbin@rock-chips.com>
Fri, 23 Sep 2016 07:22:34 +0000 (15:22 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Sun, 9 Oct 2016 10:20:05 +0000 (18:20 +0800)
Some rk3399 board(rk3399 MID or rk3399 VR) is use rk81x generated vbus.
So need fusb302 send a extcon to notify rk818 when OTG or DP cable plugin.

If use EXTCON_USB_HOST, the extcon will notify dwc3 and rk818_charger at
the same time,so need to add a new extcon EXTCON_USB_VBUS_EN.

Change-Id: Ib019ed7c2d4343c50dcef739ab3076f592979ea0
Signed-off-by: Bin Yang <yangbin@rock-chips.com>
drivers/mfd/fusb302.c

index ca0eb20c0014f466e170f48e5b9f9ed48ff2ca46..3baaa6c21f65667f0e8e2369b4c06e76bb0f6b66 100644 (file)
@@ -103,6 +103,7 @@ static void dump_notify_info(struct fusb30x_chip *chip)
 static const unsigned int fusb302_cable[] = {
        EXTCON_USB,
        EXTCON_USB_HOST,
+       EXTCON_USB_VBUS_EN,
        EXTCON_CHG_USB_SDP,
        EXTCON_CHG_USB_CDP,
        EXTCON_CHG_USB_DCP,
@@ -199,8 +200,13 @@ static void fusb_timer_start(struct hrtimer *timer, int ms)
 static void platform_set_vbus_lvl_enable(struct fusb30x_chip *chip, int vbus_5v,
                                         int vbus_other)
 {
-       if (chip->gpio_vbus_5v)
+       if (chip->gpio_vbus_5v) {
                gpiod_set_raw_value(chip->gpio_vbus_5v, vbus_5v);
+       } else {
+               extcon_set_state(chip->extcon, EXTCON_USB_VBUS_EN, vbus_5v);
+               extcon_sync(chip->extcon, EXTCON_USB_VBUS_EN);
+               dev_info(chip->dev, "fusb302 send extcon to enable vbus 5v\n");
+       }
 
        if (chip->gpio_vbus_other)
                gpiod_set_raw_value(chip->gpio_vbus_5v, vbus_other);