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