blob: 294f0ce60e816976a9580e3ef884f4a83b984f72 [file] [log] [blame]
Dave Frodinda2daef2014-06-09 12:33:24 -06001/*
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 Frodinda2daef2014-06-09 12:33:24 -060015 */
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'Callaghan85836c22014-07-09 20:26:25 +100027static void pnp_enter_conf_state(pnp_devfn_t dev)
Dave Frodinda2daef2014-06-09 12:33:24 -060028{
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'Callaghan85836c22014-07-09 20:26:25 +100035static void pnp_exit_conf_state(pnp_devfn_t dev)
Dave Frodinda2daef2014-06-09 12:33:24 -060036{
37 u16 port = dev >> 8;
38 outb(NUVOTON_EXIT_KEY, port);
39}
40
41/* Route UARTD to pins 41-48 */
Edward O'Callaghan85836c22014-07-09 20:26:25 +100042void nct5104d_enable_uartd(pnp_devfn_t dev)
Dave Frodinda2daef2014-06-09 12:33:24 -060043{
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}