Angel Pons | 210a008 | 2020-04-02 23:48:24 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Duncan Laurie | ea98b40 | 2018-10-15 13:45:29 -0700 | [diff] [blame] | 2 | |
| 3 | #include <arch/io.h> |
Kyösti Mälkki | 3695593 | 2019-03-03 17:43:29 +0200 | [diff] [blame] | 4 | #include <endian.h> |
Kyösti Mälkki | 3855c01 | 2019-03-03 08:45:19 +0200 | [diff] [blame] | 5 | #include <device/pnp_ops.h> |
Duncan Laurie | ea98b40 | 2018-10-15 13:45:29 -0700 | [diff] [blame] | 6 | #include <device/pnp_def.h> |
Duncan Laurie | ea98b40 | 2018-10-15 13:45:29 -0700 | [diff] [blame] | 7 | |
| 8 | #include "bootblock.h" |
| 9 | |
| 10 | #define PNP_CFG_IDX 0x2e |
| 11 | #define PNP_LDN_SERIAL 0x0d |
| 12 | |
| 13 | static void pnp_enter_conf_state(pnp_devfn_t dev) |
| 14 | { |
| 15 | outb(0x55, PNP_CFG_IDX); |
| 16 | outb(0x55, PNP_CFG_IDX); |
| 17 | } |
| 18 | |
| 19 | static void pnp_exit_conf_state(pnp_devfn_t dev) |
| 20 | { |
| 21 | outb(0xaa, PNP_CFG_IDX); |
| 22 | } |
| 23 | |
| 24 | static void wilco_ec_serial_init(void) |
| 25 | { |
| 26 | pnp_devfn_t dev = PNP_DEV(PNP_CFG_IDX, PNP_LDN_SERIAL); |
| 27 | |
| 28 | pnp_enter_conf_state(dev); |
| 29 | pnp_set_logical_device(dev); |
| 30 | pnp_set_enable(dev, 1); |
| 31 | pnp_set_iobase(dev, PNP_IDX_IO1, cpu_to_be16(CONFIG_TTYS0_BASE)); |
| 32 | pnp_write_config(dev, PNP_IDX_IO0, 1); |
| 33 | pnp_exit_conf_state(dev); |
| 34 | } |
| 35 | |
| 36 | void wilco_ec_early_init(void) |
| 37 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 38 | if (CONFIG(DRIVERS_UART_8250IO)) |
Duncan Laurie | ea98b40 | 2018-10-15 13:45:29 -0700 | [diff] [blame] | 39 | wilco_ec_serial_init(); |
| 40 | } |