Felix Held | 3f3eca9 | 2020-01-23 17:12:32 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Dave Frodin | da2daef | 2014-06-09 12:33:24 -0600 | [diff] [blame] | 2 | |
| 3 | #include <arch/io.h> |
| 4 | #include <device/pnp.h> |
| 5 | #include <stdint.h> |
| 6 | #include "nct5104d.h" |
| 7 | |
| 8 | #define NUVOTON_ENTRY_KEY 0x87 |
| 9 | #define NUVOTON_EXIT_KEY 0xAA |
| 10 | |
| 11 | /* Enable configuration: pass entry key '0x87' into index port dev |
| 12 | * two times. */ |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 13 | static void pnp_enter_conf_state(pnp_devfn_t dev) |
Dave Frodin | da2daef | 2014-06-09 12:33:24 -0600 | [diff] [blame] | 14 | { |
| 15 | u16 port = dev >> 8; |
| 16 | outb(NUVOTON_ENTRY_KEY, port); |
| 17 | outb(NUVOTON_ENTRY_KEY, port); |
| 18 | } |
| 19 | |
| 20 | /* Disable configuration: pass exit key '0xAA' into index port dev. */ |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 21 | static void pnp_exit_conf_state(pnp_devfn_t dev) |
Dave Frodin | da2daef | 2014-06-09 12:33:24 -0600 | [diff] [blame] | 22 | { |
| 23 | u16 port = dev >> 8; |
| 24 | outb(NUVOTON_EXIT_KEY, port); |
| 25 | } |
| 26 | |
| 27 | /* Route UARTD to pins 41-48 */ |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 28 | void nct5104d_enable_uartd(pnp_devfn_t dev) |
Dave Frodin | da2daef | 2014-06-09 12:33:24 -0600 | [diff] [blame] | 29 | { |
| 30 | u8 tmp; |
| 31 | u16 port = dev >> 8; |
| 32 | pnp_enter_conf_state(dev); |
| 33 | outb(0x1c, port); |
| 34 | tmp = inb(port + 1); |
| 35 | tmp |= 0x04; |
| 36 | outb(tmp, port + 1); |
| 37 | pnp_exit_conf_state(dev); |
| 38 | } |