Fintek and Intel i3100 Super I/O cleanups.
[coreboot.git] / src / superio / intel / i3100 / i3100_early_serial.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008 Arastra, Inc.
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
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 #include <arch/romcc_io.h>
22 #include "i3100.h"
23
24 static void i3100_sio_write(u8 port, u8 ldn, u8 index, u8 value)
25 {
26         outb(0x07, port);
27         outb(ldn, port + 1);
28         outb(index, port);
29         outb(value, port + 1);
30 }
31
32 static void i3100_enable_serial(u8 port, u8 ldn, u16 iobase)
33 {
34         /* Enter configuration state. */
35         outb(0x80, port);
36         outb(0x86, port);
37
38         /* Enable serial port. */
39         i3100_sio_write(port, ldn, 0x30, 0x01);
40
41         /* Set serial port I/O region. */
42         i3100_sio_write(port, ldn, 0x60, (iobase >> 8) & 0xff);
43         i3100_sio_write(port, ldn, 0x61, iobase & 0xff);
44
45         /* Enable device interrupts, set UART_CLK predivide to 26. */
46         i3100_sio_write(port, 0x00, 0x29, 0x0b);
47
48         /* Exit configuration state. */
49         outb(0x68, port);
50         outb(0x08, port);
51 }