]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
sunxi: musb: Support checking VBUS using AXP221 PMIC
authorChen-Yu Tsai <wens@csie.org>
Mon, 9 Mar 2015 07:44:16 +0000 (15:44 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 1 Sep 2015 12:28:32 +0000 (14:28 +0200)
This enables the musb glue layer to use the AXP221's VBUS detection
function to check for VBUS. This fixes otg support on the A23 q8h
tablets.

Note that u-boot never calls musb_shutdown(), so once VBUS is enabled,
it is never disabled until the system is powered off, or the OS does
so. This can be used to our advantage to keep VBUS powered into the
OS, where support for AXP221 is not available yet.

Fixes: 52defe8f6570 ("sunxi: musb: Check Vbus-det before enabling otg port power")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/usb/musb-new/sunxi.c

index fe45db1e064fc1e5398e5ea824e612531eee40f8..4d8c15a5e0b6e4abf44da0c3e770f29a597680ac 100644 (file)
 #include <asm-generic/gpio.h>
 #include "linux-compat.h"
 #include "musb_core.h"
+#ifdef CONFIG_AXP152_POWER
+#include <axp152.h>
+#endif
+#ifdef CONFIG_AXP209_POWER
+#include <axp209.h>
+#endif
+#ifdef CONFIG_AXP221_POWER
+#include <axp221.h>
+#endif
 
 /******************************************************************************
  ******************************************************************************
@@ -228,29 +237,44 @@ static int sunxi_musb_init(struct musb *musb)
 
        if (is_host_enabled(musb)) {
                int vbus_det = sunxi_name_to_gpio(CONFIG_USB0_VBUS_DET);
-               if (vbus_det == -1) {
-                       eprintf("Error invalid Vusb-det pin\n");
-                       return -EINVAL;
-               }
 
-               err = gpio_request(vbus_det, "vbus0_det");
-               if (err)
-                       return err;
+#ifdef AXP_VBUS_DETECT
+               if (!strcmp(CONFIG_USB0_VBUS_DET, "axp_vbus_detect")) {
+                       err = axp_get_vbus();
+                       if (err < 0)
+                               return err;
+               } else {
+#endif
+                       if (vbus_det == -1) {
+                               eprintf("Error invalid Vusb-det pin\n");
+                               return -EINVAL;
+                       }
+
+                       err = gpio_request(vbus_det, "vbus0_det");
+                       if (err)
+                               return err;
+
+                       err = gpio_direction_input(vbus_det);
+                       if (err) {
+                               gpio_free(vbus_det);
+                               return err;
+                       }
+
+                       err = gpio_get_value(vbus_det);
+                       if (err) {
+                               gpio_free(vbus_det);
+                               return -EIO;
+                       }
 
-               err = gpio_direction_input(vbus_det);
-               if (err) {
                        gpio_free(vbus_det);
-                       return err;
+#ifdef AXP_VBUS_DETECT
                }
+#endif
 
-               err = gpio_get_value(vbus_det);
                if (err) {
                        eprintf("Error: A charger is plugged into the OTG\n");
-                       gpio_free(vbus_det);
                        return -EIO;
                }
-
-               gpio_free(vbus_det);
        }
 
        err = sunxi_usbc_request_resources(0);