summaryrefslogtreecommitdiff
path: root/src/superio/intel/i3100/i3100_early_serial.c
blob: 74c20c537caa836de45341d44c75e72c69c0b987 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2008 Arastra, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

#include <arch/romcc_io.h>
#include "i3100.h"

static void i3100_sio_write(u8 port, u8 ldn, u8 index, u8 value)
{
	outb(0x07, port);
	outb(ldn, port + 1);
	outb(index, port);
	outb(value, port + 1);
}

static void i3100_enable_serial(u8 port, u8 ldn, u16 iobase)
{
	/* Enter configuration state. */
	outb(0x80, port);
	outb(0x86, port);

	/* Enable serial port. */
	i3100_sio_write(port, ldn, 0x30, 0x01);

	/* Set serial port I/O region. */
	i3100_sio_write(port, ldn, 0x60, (iobase >> 8) & 0xff);
	i3100_sio_write(port, ldn, 0x61, iobase & 0xff);

	/* Enable device interrupts, set UART_CLK predivide to 26. */
	i3100_sio_write(port, 0x00, 0x29, 0x0b);

	/* Exit configuration state. */
	outb(0x68, port);
	outb(0x08, port);
}