82d80f08a8b7ca942be71a69759dac1a3640b4f4
[coreboot.git] / src / southbridge / amd / 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 <stdint.h>
21 #include <arch/io.h>
22 #include <arch/romcc_io.h>
23 #include <device/pci_ids.h>
24
25 /*
26  * Enable 4MB (LPC) ROM access at 0xFFC00000 - 0xFFFFFFFF.
27  *
28  * Hardware should enable LPC ROM by pin straps. This function does not
29  * handle the theoretically possible PCI ROM, FWH, or SPI ROM configurations.
30  *
31  * The SB800 power-on default is to map 512K ROM space.
32  *
33  */
34 static void sb800_enable_rom(void)
35 {
36         u8 reg8;
37         device_t dev;
38
39         dev = PCI_DEV(0, 0x14, 3);
40
41         /* Decode variable LPC ROM address ranges 1 and 2. */
42         reg8 = pci_read_config8(dev, 0x48);
43         reg8 |= (1 << 3) | (1 << 4);
44         pci_write_config8(dev, 0x48, reg8);
45
46         /* LPC ROM address range 1: */
47         /* Enable LPC ROM range mirroring start at 0x000e(0000). */
48         pci_write_config16(dev, 0x68, 0x000e);
49         /* Enable LPC ROM range mirroring end at 0x000f(ffff). */
50         pci_write_config16(dev, 0x6a, 0x000f);
51
52         /* LPC ROM address range 2: */
53         /*
54          * Enable LPC ROM range start at:
55          * 0xfff8(0000): 512KB
56          * 0xfff0(0000): 1MB
57          * 0xffe0(0000): 2MB
58          * 0xffc0(0000): 4MB
59          */
60         pci_write_config16(dev, 0x6c, 0xffc0); /* 4 MB */
61         /* Enable LPC ROM range end at 0xffff(ffff). */
62         pci_write_config16(dev, 0x6e, 0xffff);
63 }
64
65 static void bootblock_southbridge_init(void)
66 {
67         sb800_enable_rom();
68 }