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