Dave Frodin | da2daef | 2014-06-09 12:33:24 -0600 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2014 Sage Electronic Engineering, LLC |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Dave Frodin | da2daef | 2014-06-09 12:33:24 -0600 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <arch/io.h> |
| 18 | #include <device/pnp.h> |
| 19 | #include <stdint.h> |
| 20 | #include "nct5104d.h" |
| 21 | |
| 22 | #define NUVOTON_ENTRY_KEY 0x87 |
| 23 | #define NUVOTON_EXIT_KEY 0xAA |
| 24 | |
| 25 | /* Enable configuration: pass entry key '0x87' into index port dev |
| 26 | * two times. */ |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 27 | static void pnp_enter_conf_state(pnp_devfn_t dev) |
Dave Frodin | da2daef | 2014-06-09 12:33:24 -0600 | [diff] [blame] | 28 | { |
| 29 | u16 port = dev >> 8; |
| 30 | outb(NUVOTON_ENTRY_KEY, port); |
| 31 | outb(NUVOTON_ENTRY_KEY, port); |
| 32 | } |
| 33 | |
| 34 | /* Disable configuration: pass exit key '0xAA' into index port dev. */ |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 35 | static void pnp_exit_conf_state(pnp_devfn_t dev) |
Dave Frodin | da2daef | 2014-06-09 12:33:24 -0600 | [diff] [blame] | 36 | { |
| 37 | u16 port = dev >> 8; |
| 38 | outb(NUVOTON_EXIT_KEY, port); |
| 39 | } |
| 40 | |
| 41 | /* Route UARTD to pins 41-48 */ |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 42 | void nct5104d_enable_uartd(pnp_devfn_t dev) |
Dave Frodin | da2daef | 2014-06-09 12:33:24 -0600 | [diff] [blame] | 43 | { |
| 44 | u8 tmp; |
| 45 | u16 port = dev >> 8; |
| 46 | pnp_enter_conf_state(dev); |
| 47 | outb(0x1c, port); |
| 48 | tmp = inb(port + 1); |
| 49 | tmp |= 0x04; |
| 50 | outb(tmp, port + 1); |
| 51 | pnp_exit_conf_state(dev); |
| 52 | } |