e04cec0e04351105bc06d8a0d436fe3eeef1cf2e
[coreboot.git] / src / southbridge / amd / cimx / sb900 / bootblock.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2011 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
21 #include <arch/io.h>
22 #include <arch/romcc_io.h>
23
24
25 #if CONFIG_CONSOLE_POST == 1
26
27 /* Data */
28 #define UART_RBR 0x00
29 #define UART_TBR 0x00
30
31 /* Control */
32 #define UART_IER 0x01
33 #define UART_IIR 0x02
34 #define UART_FCR 0x02
35 #define UART_LCR 0x03
36 #define UART_MCR 0x04
37 #define UART_DLL 0x00
38 #define UART_DLM 0x01
39
40 /* Status */
41 #define UART_LSR 0x05
42 #define UART_MSR 0x06
43 #define UART_SCR 0x07
44
45 #ifndef CONFIG_TTYS0_DIV
46 #if ((115200%CONFIG_TTYS0_BAUD) != 0)
47 #error Bad ttys0 baud rate
48 #endif
49 #define CONFIG_TTYS0_DIV        (115200/CONFIG_TTYS0_BAUD)
50 #endif // CONFIG_TTYS0_DIV
51
52 #define UART_LCS        CONFIG_TTYS0_LCS
53
54 #endif // CONFIG_CONSOLE_POST == 1
55
56
57 static void sb900_enable_rom(void)
58 {
59   u32 word;
60   u32 dword;
61   device_t dev;
62
63   dev = PCI_DEV(0, 0x14, 0x03);
64   /* SB900 LPC Bridge 0:20:3:44h.
65    * BIT6: Port Enable for serial port 0x3f8-0x3ff
66    * BIT29: Port Enable for KBC port 0x60 and 0x64
67    * BIT30: Port Enable for ACPI Micro-Controller port 0x66 and 0x62
68    */
69   dword = pci_io_read_config32(dev, 0x44);
70   //dword |= (1<<6) | (1<<29) | (1<<30) ;
71   /*Turn on all of LPC IO Port decode enable */
72   dword = 0xffffffff;
73   pci_io_write_config32(dev, 0x44, dword);
74
75   /* SB900 LPC Bridge 0:20:3:48h.
76    * BIT0: Port Enable for SuperIO 0x2E-0x2F 
77    * BIT1: Port Enable for SuperIO 0x4E-0x4F 
78    * BIT4: Port Enable for LPC ROM Address Arrage2 (0x68-0x6C)
79    * BIT6: Port Enable for RTC IO 0x70-0x73
80    * BIT21: Port Enable for Port 0x80
81    */
82   dword = pci_io_read_config32(dev, 0x48);
83   dword |= (1<<0) | (1<<1) | (1<<4) | (1<<6) | (1<<21) ;
84   pci_io_write_config32(dev, 0x48, dword);
85
86   /* Enable 4MB rom access at 0xFFE00000 - 0xFFFFFFFF */
87   /* Set the 4MB enable bits */
88   word = pci_io_read_config16(dev, 0x6c);
89   word = 0xFFC0; 
90   pci_io_write_config16(dev, 0x6c, word);
91 }
92
93 static void bootblock_southbridge_init(void)
94 {
95   /* Setup the rom access for 2M */
96   sb900_enable_rom();
97 }