AMD SB800: Drop component prefix from filenames.
[coreboot.git] / src / southbridge / amd / cimx_wrapper / sb800 / bootblock.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2010 Advanced Micro Devices, 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; 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
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19
20 #include <arch/io.h>
21 #include <arch/romcc_io.h>
22
23 #if CONFIG_SERIAL_POST == 1
24
25 /* Data */
26 #define UART_RBR 0x00
27 #define UART_TBR 0x00
28
29 /* Control */
30 #define UART_IER 0x01
31 #define UART_IIR 0x02
32 #define UART_FCR 0x02
33 #define UART_LCR 0x03
34 #define UART_MCR 0x04
35 #define UART_DLL 0x00
36 #define UART_DLM 0x01
37
38 /* Status */
39 #define UART_LSR 0x05
40 #define UART_MSR 0x06
41 #define UART_SCR 0x07
42
43 #ifndef CONFIG_TTYS0_DIV
44 #if ((115200%CONFIG_TTYS0_BAUD) != 0)
45 #error Bad ttys0 baud rate
46 #endif
47 #define CONFIG_TTYS0_DIV        (115200/CONFIG_TTYS0_BAUD)
48 #endif // CONFIG_TTYS0_DIV
49
50 #define UART_LCS        CONFIG_TTYS0_LCS
51
52 #endif // CONFIG_SERIAL_POST == 1
53
54 static void sb800_enable_rom(void)
55 {
56   u32 word;
57   u32 dword;
58   device_t dev;
59
60   dev = PCI_DEV(0, 0x14, 0x03);
61   /* SB800 LPC Bridge 0:20:3:44h.
62    * BIT6: Port Enable for serial port 0x3f8-0x3ff
63    * BIT29: Port Enable for KBC port 0x60 and 0x64
64    * BIT30: Port Enable for ACPI Micro-Controller port 0x66 and 0x62
65    */
66   dword = pci_io_read_config32(dev, 0x44);
67   //dword |= (1<<6) | (1<<29) | (1<<30) ;
68   /*Turn on all of LPC IO Port decode enable */
69   dword = 0xffffffff;
70   pci_io_write_config32(dev, 0x44, dword);
71
72   /* SB800 LPC Bridge 0:20:3:48h.
73    * BIT0: Port Enable for SuperIO 0x2E-0x2F
74    * BIT1: Port Enable for SuperIO 0x4E-0x4F
75    * BIT4: Port Enable for LPC ROM Address Arrage2 (0x68-0x6C)
76    * BIT6: Port Enable for RTC IO 0x70-0x73
77    * BIT21: Port Enable for Port 0x80
78    */
79   dword = pci_io_read_config32(dev, 0x48);
80   dword |= (1<<0) | (1<<1) | (1<<4) | (1<<6) | (1<<21) ;
81   pci_io_write_config32(dev, 0x48, dword);
82
83   /* Enable 2MB rom access at 0xFFE00000 - 0xFFFFFFFF */
84   /* Set the 2MB enable bits */
85   word = pci_io_read_config16(dev, 0x6c);
86   word = 0xFFE0;
87   pci_io_write_config16(dev, 0x6c, word);
88 }
89
90 static void uart_init(void)
91 {
92 #if CONFIG_SERIAL_POST == 1
93   /* disable interrupts */
94   outb(0x0, CONFIG_TTYS0_BASE + UART_IER);
95   /* enable fifo's */
96   outb(0x01, CONFIG_TTYS0_BASE + UART_FCR);
97   /* Set Baud Rate Divisor to 12 ==> 115200 Baud */
98   outb(0x80 | UART_LCS, CONFIG_TTYS0_BASE + UART_LCR);
99   outb(CONFIG_TTYS0_DIV & 0xFF,   CONFIG_TTYS0_BASE + UART_DLL);
100   outb((CONFIG_TTYS0_DIV >> 8) & 0xFF,    CONFIG_TTYS0_BASE + UART_DLM);
101   outb(UART_LCS, CONFIG_TTYS0_BASE + UART_LCR);
102 #endif // CONFIG_SERIAL_POST == 1
103 }
104
105 static void bootblock_southbridge_init(void)
106 {
107   /* Setup the rom access for 2M */
108   sb800_enable_rom();
109   uart_init();
110 }