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> |
Simon Glass | 5255932 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 7 | #include <init.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Stefan Roese | b1ad6c6 | 2016-08-15 13:50:49 +0200 | [diff] [blame] | 9 | #include <nuvoton_nct6102d.h> |
| 10 | #include <asm/gpio.h> |
| 11 | #include <asm/ibmpc.h> |
| 12 | #include <asm/pnp_def.h> |
Simon Glass | c05ed00 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 13 | #include <linux/delay.h> |
Stefan Roese | b1ad6c6 | 2016-08-15 13:50:49 +0200 | [diff] [blame] | 14 | |
| 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 | } |
Stefan Roese | 1f4e257 | 2017-07-18 14:10:49 +0200 | [diff] [blame] | 33 | |
| 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 | } |