1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Copyright (C) 2015, Google, Inc 4 */ 5 6 #include <common.h> 7 #include <dm.h> 8 #include <asm/gpio.h> 9 #include <dm/device-internal.h> 10 #include <dm/uclass-internal.h> 11 12 #define GPIO_BANKE_NAME "gpioe" 13 14 int misc_init_r(void) 15 { 16 struct udevice *dev; 17 struct gpio_desc desc; 18 int ret; 19 20 /* 21 * Turn on USB VBUS for the two USB ports on the board. 22 * Each port's VBUS is controlled by a GPIO pin. 23 */ 24 25 ret = uclass_find_device_by_name(UCLASS_GPIO, GPIO_BANKE_NAME, &dev); 26 if (ret) { 27 debug("%s: GPIO %s device cannot be not found (ret=%d)\n", 28 __func__, GPIO_BANKE_NAME, ret); 29 return ret; 30 } 31 32 ret = device_probe(dev); 33 if (ret) { 34 debug("%s: GPIO %s device probe failed (ret=%d)\n", 35 __func__, GPIO_BANKE_NAME, ret); 36 return ret; 37 } 38 39 desc.dev = dev; 40 desc.flags = GPIOD_IS_OUT; 41 42 /* GPIO E8 controls the bottom port */ 43 desc.offset = 8; 44 45 ret = dm_gpio_request(&desc, "usb_host_en0"); 46 if (ret) 47 return ret; 48 dm_gpio_set_value(&desc, 1); 49 50 /* GPIO E9 controls the upper port */ 51 desc.offset = 9; 52 53 ret = dm_gpio_request(&desc, "usb_host_en1"); 54 if (ret) 55 return ret; 56 57 dm_gpio_set_value(&desc, 1); 58 59 return 0; 60 } 61