blob: 59a53f289aa482d5a90ad3159d77afc015819a30 [file] [log] [blame]
Stefan Reinauereca92fb2006-08-23 14:28:37 +00001/*
Uwe Hermanna69d9782010-11-15 19:35:14 +00002 * This file is part of the coreboot project.
Stefan Reinauereca92fb2006-08-23 14:28:37 +00003 *
4 * Copyright (C) 2005 Digital Design Corporation
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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Stefan Reinauereca92fb2006-08-23 14:28:37 +000019 */
Ronald G. Minnich8a02b7d2006-08-17 20:31:09 +000020
Stefan Reinauer24d1d4b2013-03-21 11:51:41 -070021#include <arch/io.h>
Edward O'Callaghanc3e77fc2015-01-04 16:24:14 +110022#include <device/pnp.h>
23#include <stdint.h>
Ronald G. Minnich8a02b7d2006-08-17 20:31:09 +000024#include "lpc47m10x.h"
25
Edward O'Callaghan85836c22014-07-09 20:26:25 +100026static void pnp_enter_conf_state(pnp_devfn_t dev)
Zheng Bao9db833b2009-12-28 09:59:44 +000027{
Uwe Hermanna69d9782010-11-15 19:35:14 +000028 u16 port = dev >> 8;
Zheng Bao9db833b2009-12-28 09:59:44 +000029 outb(0x55, port);
Stefan Reinauereca92fb2006-08-23 14:28:37 +000030}
Ronald G. Minnich8a02b7d2006-08-17 20:31:09 +000031
Edward O'Callaghan85836c22014-07-09 20:26:25 +100032static void pnp_exit_conf_state(pnp_devfn_t dev)
Zheng Bao9db833b2009-12-28 09:59:44 +000033{
Uwe Hermanna69d9782010-11-15 19:35:14 +000034 u16 port = dev >> 8;
Zheng Bao9db833b2009-12-28 09:59:44 +000035 outb(0xaa, port);
Ronald G. Minnich8a02b7d2006-08-17 20:31:09 +000036}
37
Uwe Hermannb69cb5a2010-10-26 22:46:43 +000038/**
39 * Configure the base I/O port of the specified serial device and enable the
40 * serial device.
41 *
42 * @param dev High 8 bits = Super I/O port, low 8 bits = logical device number.
43 * @param iobase Processor I/O port address to assign to this serial device.
Zheng Bao9db833b2009-12-28 09:59:44 +000044 */
Edward O'Callaghanc3e77fc2015-01-04 16:24:14 +110045void lpc47m10x_enable_serial(pnp_devfn_t dev, u16 iobase)
Ronald G. Minnich8a02b7d2006-08-17 20:31:09 +000046{
47 pnp_enter_conf_state(dev);
48 pnp_set_logical_device(dev);
49 pnp_set_enable(dev, 0);
50 pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
51 pnp_set_enable(dev, 1);
52 pnp_exit_conf_state(dev);
53}