blob: a6bf9917f0506c43ac969975e3a188c8df84cca4 [file] [log] [blame]
Stefan Reinauereca92fb2006-08-23 14:28:37 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +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.
Stefan Reinauereca92fb2006-08-23 14:28:37 +000015 */
Steven J. Magnanie91619a2005-09-12 18:55:23 +000016
Uwe Hermannd82baa12006-12-05 14:13:10 +000017/* Pre-RAM driver for SMSC LPC47B272 Super I/O chip. */
18
Stefan Reinauer24d1d4b2013-03-21 11:51:41 -070019#include <arch/io.h>
Edward O'Callaghan117849e2015-01-04 16:34:03 +110020#include <device/pnp.h>
21#include <stdint.h>
Steven J. Magnanie91619a2005-09-12 18:55:23 +000022#include "lpc47b272.h"
23
Edward O'Callaghan85836c22014-07-09 20:26:25 +100024static void pnp_enter_conf_state(pnp_devfn_t dev)
Zheng Bao9db833b2009-12-28 09:59:44 +000025{
Uwe Hermanna69d9782010-11-15 19:35:14 +000026 u16 port = dev >> 8;
Zheng Bao9db833b2009-12-28 09:59:44 +000027 outb(0x55, port);
Stefan Reinauereca92fb2006-08-23 14:28:37 +000028}
Steven J. Magnanie91619a2005-09-12 18:55:23 +000029
Edward O'Callaghan85836c22014-07-09 20:26:25 +100030static void pnp_exit_conf_state(pnp_devfn_t dev)
Zheng Bao9db833b2009-12-28 09:59:44 +000031{
Uwe Hermanna69d9782010-11-15 19:35:14 +000032 u16 port = dev >> 8;
Zheng Bao9db833b2009-12-28 09:59:44 +000033 outb(0xaa, port);
Steven J. Magnanie91619a2005-09-12 18:55:23 +000034}
35
Uwe Hermannb69cb5a2010-10-26 22:46:43 +000036/**
37 * Configure the base I/O port of the specified serial device and enable the
38 * serial device.
39 *
40 * @param dev High 8 bits = Super I/O port, low 8 bits = logical device number.
41 * @param iobase Processor I/O port address to assign to this serial device.
Zheng Bao9db833b2009-12-28 09:59:44 +000042 */
Edward O'Callaghan117849e2015-01-04 16:34:03 +110043void lpc47b272_enable_serial(pnp_devfn_t dev, u16 iobase)
Steven J. Magnanie91619a2005-09-12 18:55:23 +000044{
45 pnp_enter_conf_state(dev);
46 pnp_set_logical_device(dev);
47 pnp_set_enable(dev, 0);
48 pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
49 pnp_set_enable(dev, 1);
50 pnp_exit_conf_state(dev);
51}