]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
x86: minnowmax: Configure GPIO pins to turn on USB ports VBUS
authorBin Meng <bmeng.cn@gmail.com>
Fri, 16 Jun 2017 13:31:46 +0000 (06:31 -0700)
committerBin Meng <bmeng.cn@gmail.com>
Thu, 22 Jun 2017 06:58:10 +0000 (14:58 +0800)
GPIO bank E pin 8 & 9 are used to control the on-board two USB ports
VBUS on/off. Let's configure them in the misc_init_r().

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
board/intel/minnowmax/minnowmax.c
include/configs/minnowmax.h

index 94b22edd57fd10b6466b7849fc1f839001c3d233..99aed5310063bb22a76ea98928032b946f5eefe7 100644 (file)
@@ -5,9 +5,62 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <asm/gpio.h>
+#include <dm/device-internal.h>
+#include <dm/uclass-internal.h>
+
+#define GPIO_BANKE_NAME                "gpioe"
 
 int arch_early_init_r(void)
 {
        return 0;
 }
+
+int misc_init_r(void)
+{
+       struct udevice *dev;
+       struct gpio_desc desc;
+       int ret;
+
+       /*
+        * Turn on USB VBUS for the two USB ports on the board.
+        * Each port's VBUS is controlled by a GPIO pin.
+        */
+
+       ret = uclass_find_device_by_name(UCLASS_GPIO, GPIO_BANKE_NAME, &dev);
+       if (ret) {
+               debug("%s: GPIO %s device cannot be not found (ret=%d)\n",
+                     __func__, GPIO_BANKE_NAME, ret);
+               return ret;
+       }
+
+       ret = device_probe(dev);
+       if (ret) {
+               debug("%s: GPIO %s device probe failed (ret=%d)\n",
+                     __func__, GPIO_BANKE_NAME, ret);
+               return ret;
+       }
+
+       desc.dev = dev;
+       desc.flags = GPIOD_IS_OUT;
+
+       /* GPIO E8 controls the bottom port */
+       desc.offset = 8;
+
+       ret = dm_gpio_request(&desc, "usb_host_en0");
+       if (ret)
+               return ret;
+       dm_gpio_set_value(&desc, 1);
+
+       /* GPIO E9 controls the upper port */
+       desc.offset = 9;
+
+       ret = dm_gpio_request(&desc, "usb_host_en1");
+       if (ret)
+               return ret;
+
+       dm_gpio_set_value(&desc, 1);
+
+       return 0;
+}
index 7b9f90c08d832f715477fd4e33d8c8224e0a62e1..3744811d96a5fafcb35d8a1f970ef521e3103951 100644 (file)
@@ -16,6 +16,7 @@
 #define CONFIG_SYS_MONITOR_LEN         (1 << 20)
 
 #define CONFIG_SMSC_LPC47M
+#define CONFIG_MISC_INIT_R
 
 #define CONFIG_STD_DEVICES_SETTINGS    "stdin=usbkbd,serial\0" \
                                        "stdout=vidconsole,serial\0" \