a52b852786ec6d585fb3cee7f7e22a4683dab542
[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,
25                             u8 value)
26 {
27         outb(0x07, port);
28         outb(ldn, port + 1);
29         outb(index, port);
30         outb(value, port + 1);
31 }
32
33 static void i3100_enable_serial(u8 port, u8 ldn, u16 iobase)
34 {
35         /* Enter configuration state */
36         outb(0x80, port);
37         outb(0x86, port);
38
39         /* Enable serial port */
40         i3100_sio_write(port, ldn, 0x30, 0x01);
41
42         /* Set serial port IO region */
43         i3100_sio_write(port, ldn, 0x60, (iobase >> 8) & 0xff);
44         i3100_sio_write(port, ldn, 0x61, iobase & 0xff);
45
46         /* Enable device interrupts, set UART_CLK predivide to 26 */
47         i3100_sio_write(port, 0x00, 0x29, 0x0b);
48
49         /* Exit configuration state */
50         outb(0x68, port);
51         outb(0x08, port);
52 }