Initial revision.
[coreboot.git] / src / superio / smsc / lpc47b272 / lpc47b272_early_serial.c
1 /*\r
2  * $Header$\r
3  *\r
4  * lpc47b272_early_serial.c: Pre-RAM driver for SMSC LPC47B272 Super I/O chip\r
5  *\r
6  * Copyright (C) 2005 Digital Design Corporation\r
7  *\r
8  * This program is free software; you can redistribute it and/or modify\r
9  * it under the terms of the GNU General Public License as published by\r
10  * the Free Software Foundation; either version 2 of the License, or\r
11  * (at your option) any later version.\r
12  *\r
13  * This program is distributed in the hope that it will be useful,\r
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
16  * GNU General Public License for more details.\r
17  *\r
18  * You should have received a copy of the GNU General Public License\r
19  * along with this program; if not, write to the Free Software\r
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
21  *\r
22  * $Log$\r
23  *\r
24  */\r
25
26 #include <arch/romcc_io.h>
27 #include "lpc47b272.h"
28
29 //----------------------------------------------------------------------------------\r
30 // Function:            pnp_enter_conf_state\r
31 // Parameters:          dev - high 8 bits = Super I/O port\r
32 // Return Value:        None\r
33 // Description:         Enable access to the LPC47B272's configuration registers.\r
34 //\r
35 static inline void pnp_enter_conf_state(device_t dev) {
36         unsigned port = dev>>8;
37     outb(0x55, port);
38 }\r
39
40 //----------------------------------------------------------------------------------\r
41 // Function:            pnp_exit_conf_state\r
42 // Parameters:          dev - high 8 bits = Super I/O port\r
43 // Return Value:        None\r
44 // Description:         Disable access to the LPC47B272's configuration registers.\r
45 //\r
46 static void pnp_exit_conf_state(device_t dev) {
47         unsigned port = dev>>8;
48     outb(0xaa, port);
49 }
50
51 //----------------------------------------------------------------------------------\r
52 // Function:            lpc47b272_enable_serial\r
53 // Parameters:          dev - high 8 bits = Super I/O port, \r
54 //                                                low 8 bits = logical device number (per lpc47b272.h)\r
55 //                                      iobase - processor I/O port address to assign to this serial device\r
56 // Return Value:        bool\r
57 // Description:         Configure the base I/O port of the specified serial device\r
58 //                                      and enable the serial device.\r
59 //\r
60 static void lpc47b272_enable_serial(device_t dev, unsigned iobase)
61 {
62         pnp_enter_conf_state(dev);
63         pnp_set_logical_device(dev);
64         pnp_set_enable(dev, 0);
65         pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
66         pnp_set_enable(dev, 1);
67         pnp_exit_conf_state(dev);
68 }