1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
4 */
5
6 #include <common.h>
7 #include <init.h>
8 #include <log.h>
9 #include <nuvoton_nct6102d.h>
10 #include <asm/gpio.h>
11 #include <asm/ibmpc.h>
12 #include <asm/pnp_def.h>
13 #include <linux/delay.h>
14
board_early_init_f(void)15 int board_early_init_f(void)
16 {
17 #ifdef CONFIG_INTERNAL_UART
18 /* Disable the legacy UART which is enabled per default */
19 nct6102d_uarta_disable();
20 #else
21 /*
22 * The FSP enables the BayTrail internal legacy UART (again).
23 * Disable it again, so that the Nuvoton one can be used.
24 */
25 setup_internal_uart(0);
26 #endif
27
28 /* Disable the watchdog which is enabled per default */
29 nct6102d_wdt_disable();
30
31 return 0;
32 }
33
board_late_init(void)34 int board_late_init(void)
35 {
36 struct gpio_desc desc;
37 int ret;
38
39 ret = dm_gpio_lookup_name("F10", &desc);
40 if (ret)
41 debug("gpio ret=%d\n", ret);
42 ret = dm_gpio_request(&desc, "xhci_hub_reset");
43 if (ret)
44 debug("gpio_request ret=%d\n", ret);
45 ret = dm_gpio_set_dir_flags(&desc, GPIOD_IS_OUT);
46 if (ret)
47 debug("gpio dir ret=%d\n", ret);
48
49 /* Pull xHCI hub reset to low (active low) */
50 dm_gpio_set_value(&desc, 0);
51
52 /* Wait at least 5 ms, so lets choose 10 to be safe */
53 mdelay(10);
54
55 /* Pull xHCI hub reset to high (active low) */
56 dm_gpio_set_value(&desc, 1);
57
58 return 0;
59 }
60