blob: 74dea2d993ecd2cd77d25f303cd9e09029219bf4 [file] [log] [blame]
Stefan Reinaueraeba92a2009-04-17 08:37:18 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
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; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
Patrick Georgib890a122015-03-26 15:17:45 +010017 * Foundation, Inc.
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000018 */
19
20/*
21 * Enable the serial devices on the VIA CX700
22 */
23
Stefan Reinauer24d1d4b2013-03-21 11:51:41 -070024#include <arch/io.h>
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000025
26static void cx700_writepnpaddr(u8 val)
27{
28 outb(val, 0x2e);
29 outb(val, 0xeb);
30}
31
32static void cx700_writepnpdata(u8 val)
33{
34 outb(val, 0x2f);
35 outb(val, 0xeb);
36}
37
38static void cx700_writesiobyte(u16 reg, u8 val)
39{
40 outb(val, reg);
41}
42
43static void cx700_writesioword(u16 reg, u16 val)
44{
45 outw(val, reg);
46}
47
48static void enable_cx700_serial(void)
49{
Alexandru Gagniuc5005bb062011-04-11 20:17:22 +000050 post_code(0x06);
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000051
52 // WTH?
53 outb(0x03, 0x22);
54
55 // Set UART1 I/O Base Address
56 pci_write_config8(PCI_DEV(0, 17, 0), 0xb4, 0x7e);
57
58 // UART1 Enable
59 pci_write_config8(PCI_DEV(0, 17, 0), 0xb0, 0x10);
60
61 // turn on pnp
62 cx700_writepnpaddr(0x87);
63 cx700_writepnpaddr(0x87);
Stefan Reinauer14e22772010-04-27 06:56:47 +000064 // now go ahead and set up com1.
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000065 // set address
66 cx700_writepnpaddr(0x7);
67 cx700_writepnpdata(0x2);
68 // enable serial out
69 cx700_writepnpaddr(0x30);
70 cx700_writepnpdata(0x1);
71 // serial port 1 base address (FEh)
72 cx700_writepnpaddr(0x60);
73 cx700_writepnpdata(0xfe);
74 // serial port 1 IRQ (04h)
75 cx700_writepnpaddr(0x70);
76 cx700_writepnpdata(0x4);
77 // serial port 1 control
78 cx700_writepnpaddr(0xf0);
79 cx700_writepnpdata(0x2);
80 // turn of pnp
81 cx700_writepnpaddr(0xaa);
82
83 // XXX This part should be fully taken care of by
Stefan Reinauer85b0fa12010-12-17 00:08:21 +000084 // src/lib/uart8250.c:uart_init
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000085
86 // set up reg to set baud rate.
87 cx700_writesiobyte(0x3fb, 0x80);
88 // Set 115 kb
89 cx700_writesioword(0x3f8, 1);
90 // Set 9.6 kb
91 // cx700_writesioword(0x3f8, 12)
92 // now set no parity, one stop, 8 bits
93 cx700_writesiobyte(0x3fb, 3);
94 // now turn on RTS, DRT
95 cx700_writesiobyte(0x3fc, 3);
96 // Enable interrupts
97 cx700_writesiobyte(0x3f9, 0xf);
98 // should be done. Dump a char for fun.
99 cx700_writesiobyte(0x3f8, 48);
100
Alexandru Gagniuc5005bb062011-04-11 20:17:22 +0000101 post_code(0x07);
Stefan Reinaueraeba92a2009-04-17 08:37:18 +0000102}