Stefan Reinauer | aeba92a | 2009-04-17 08:37:18 +0000 | [diff] [blame] | 1 | /* |
| 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 Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 17 | * Foundation, Inc. |
Stefan Reinauer | aeba92a | 2009-04-17 08:37:18 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | /* |
| 21 | * Enable the serial devices on the VIA CX700 |
| 22 | */ |
| 23 | |
Stefan Reinauer | 24d1d4b | 2013-03-21 11:51:41 -0700 | [diff] [blame] | 24 | #include <arch/io.h> |
Stefan Reinauer | aeba92a | 2009-04-17 08:37:18 +0000 | [diff] [blame] | 25 | |
| 26 | static void cx700_writepnpaddr(u8 val) |
| 27 | { |
| 28 | outb(val, 0x2e); |
| 29 | outb(val, 0xeb); |
| 30 | } |
| 31 | |
| 32 | static void cx700_writepnpdata(u8 val) |
| 33 | { |
| 34 | outb(val, 0x2f); |
| 35 | outb(val, 0xeb); |
| 36 | } |
| 37 | |
| 38 | static void cx700_writesiobyte(u16 reg, u8 val) |
| 39 | { |
| 40 | outb(val, reg); |
| 41 | } |
| 42 | |
| 43 | static void cx700_writesioword(u16 reg, u16 val) |
| 44 | { |
| 45 | outw(val, reg); |
| 46 | } |
| 47 | |
| 48 | static void enable_cx700_serial(void) |
| 49 | { |
Alexandru Gagniuc | 5005bb06 | 2011-04-11 20:17:22 +0000 | [diff] [blame] | 50 | post_code(0x06); |
Stefan Reinauer | aeba92a | 2009-04-17 08:37:18 +0000 | [diff] [blame] | 51 | |
| 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 Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 64 | // now go ahead and set up com1. |
Stefan Reinauer | aeba92a | 2009-04-17 08:37:18 +0000 | [diff] [blame] | 65 | // 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 Reinauer | 85b0fa1 | 2010-12-17 00:08:21 +0000 | [diff] [blame] | 84 | // src/lib/uart8250.c:uart_init |
Stefan Reinauer | aeba92a | 2009-04-17 08:37:18 +0000 | [diff] [blame] | 85 | |
| 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 Gagniuc | 5005bb06 | 2011-04-11 20:17:22 +0000 | [diff] [blame] | 101 | post_code(0x07); |
Stefan Reinauer | aeba92a | 2009-04-17 08:37:18 +0000 | [diff] [blame] | 102 | } |