usb: dwc_otg_310: support vbus controlled by both gpio and pmic
authorWilliam Wu <wulf@rock-chips.com>
Fri, 14 Apr 2017 09:51:27 +0000 (17:51 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 17 Apr 2017 00:54:22 +0000 (08:54 +0800)
On some rockchip platforms (e.g. rk3368), usb vbus 5v is controlled
by both gpio and pmic at the same time. So we need to set gpio and
pmic when enable/disable usb vbus power.

Change-Id: I327a87f16662026eaab1b6577d0b0116c4b2671f
Signed-off-by: William Wu <wulf@rock-chips.com>
drivers/usb/dwc_otg_310/usbdev_rk3036.c
drivers/usb/dwc_otg_310/usbdev_rk3126.c
drivers/usb/dwc_otg_310/usbdev_rk32.c
drivers/usb/dwc_otg_310/usbdev_rk3368.c

index e599618..02dec70 100755 (executable)
@@ -185,13 +185,14 @@ static void usb20otg_power_enable(int enable)
                /* disable otg_drv power */
                if (gpio_is_valid(control_usb->otg_gpios->gpio))
                        gpio_set_value(control_usb->otg_gpios->gpio, 0);
-               else if (usb20otg_get_status(USB_STATUS_BVABLID))
-                       rk_battery_charger_detect_cb(USB_OTG_POWER_OFF);
+
+               rk_battery_charger_detect_cb(USB_OTG_POWER_OFF);
        } else if (1 == enable) {
                /* enable otg_drv power */
                if (gpio_is_valid(control_usb->otg_gpios->gpio))
                        gpio_set_value(control_usb->otg_gpios->gpio, 1);
-               else if (!usb20otg_get_status(USB_STATUS_BVABLID))
+
+               if (!usb20otg_get_status(USB_STATUS_BVABLID))
                        rk_battery_charger_detect_cb(USB_OTG_POWER_ON);
        }
 }
index bd39911..2cf9c5a 100755 (executable)
@@ -194,13 +194,14 @@ static void usb20otg_power_enable(int enable)
                /* disable otg_drv power */
                if (gpio_is_valid(control_usb->otg_gpios->gpio))
                        gpio_set_value(control_usb->otg_gpios->gpio, 0);
-               else if (usb20otg_get_status(USB_STATUS_BVABLID))
-                       rk_battery_charger_detect_cb(USB_OTG_POWER_OFF);
+
+               rk_battery_charger_detect_cb(USB_OTG_POWER_OFF);
        } else if (1 == enable) {
                /* enable otg_drv power */
                if (gpio_is_valid(control_usb->otg_gpios->gpio))
                        gpio_set_value(control_usb->otg_gpios->gpio, 1);
-               else if (!usb20otg_get_status(USB_STATUS_BVABLID))
+
+               if (!usb20otg_get_status(USB_STATUS_BVABLID))
                        rk_battery_charger_detect_cb(USB_OTG_POWER_ON);
        }
 }
index 53e14de..5f38390 100644 (file)
@@ -183,13 +183,14 @@ static void usb20otg_power_enable(int enable)
                /* disable otg_drv power */
                if (gpio_is_valid(control_usb->otg_gpios->gpio))
                        gpio_set_value(control_usb->otg_gpios->gpio, 0);
-               else if (usb20otg_get_status(USB_STATUS_BVABLID))
-                       rk_battery_charger_detect_cb(USB_OTG_POWER_OFF);
+
+               rk_battery_charger_detect_cb(USB_OTG_POWER_OFF);
        } else if (1 == enable) {
                /* enable otg_drv power */
                if (gpio_is_valid(control_usb->otg_gpios->gpio))
                        gpio_set_value(control_usb->otg_gpios->gpio, 1);
-               else if (!usb20otg_get_status(USB_STATUS_BVABLID))
+
+               if (!usb20otg_get_status(USB_STATUS_BVABLID))
                        rk_battery_charger_detect_cb(USB_OTG_POWER_ON);
        }
 }
index 833671c..3272e4e 100644 (file)
@@ -189,13 +189,14 @@ static void usb20otg_power_enable(int enable)
                /* disable otg_drv power */
                if (gpio_is_valid(control_usb->otg_gpios->gpio))
                        gpio_set_value(control_usb->otg_gpios->gpio, 0);
-               else if (usb20otg_get_status(USB_STATUS_BVABLID))
-                       rk_battery_charger_detect_cb(USB_OTG_POWER_OFF);
+
+               rk_battery_charger_detect_cb(USB_OTG_POWER_OFF);
        } else if (1 == enable) {
                /* enable otg_drv power */
                if (gpio_is_valid(control_usb->otg_gpios->gpio))
                        gpio_set_value(control_usb->otg_gpios->gpio, 1);
-               else if (!usb20otg_get_status(USB_STATUS_BVABLID))
+
+               if (!usb20otg_get_status(USB_STATUS_BVABLID))
                        rk_battery_charger_detect_cb(USB_OTG_POWER_ON);
        }
 }