blob: 87506a77a17e5b274ae18c13c01dbc0eb36dc81f [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
Tom Riniabb9a042024-05-18 20:20:43 -06006#include <common.h>
Simon Glassa7b51302019-11-14 12:57:46 -07007#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -06008#include <log.h>
Stefan Roese312dc932016-08-15 13:50:49 +02009#include <nuvoton_nct6102d.h>
10#include <asm/gpio.h>
11#include <asm/ibmpc.h>
12#include <asm/pnp_def.h>
Simon Glassdbd79542020-05-10 11:40:11 -060013#include <linux/delay.h>
Stefan Roese312dc932016-08-15 13:50:49 +020014
15int 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}
Stefan Roese0700bba2017-07-18 14:10:49 +020033
34int 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}