blob: e5fc9397934478482072de71240e1308301a3db7 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass4a56f102015-01-27 22:13:47 -07002/*
3 * Copyright (C) 2015, Google, Inc
Simon Glass4a56f102015-01-27 22:13:47 -07004 */
5
6#include <common.h>
Bin Meng74649a92017-06-16 06:31:46 -07007#include <dm.h>
Gabriel Huauf70353a2015-05-11 23:18:25 -07008#include <asm/gpio.h>
Bin Meng74649a92017-06-16 06:31:46 -07009#include <dm/device-internal.h>
10#include <dm/uclass-internal.h>
11
12#define GPIO_BANKE_NAME "gpioe"
Simon Glass4a56f102015-01-27 22:13:47 -070013
Bin Meng74649a92017-06-16 06:31:46 -070014int 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
Gabriel Huauf70353a2015-05-11 23:18:25 -070059 return 0;
60}