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