2 * This file is part of the coreboot project.
4 * Copyright (C) 2010 Wang Qing Pei <wangqingpei@gmail.com>
5 * Copyright (C) 2010 Advanced Micro Devices, Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <console/console.h>
22 #include <device/device.h>
23 #include <device/pci.h>
25 #include <boot/tables.h>
26 #include <cpu/x86/msr.h>
27 #include <cpu/amd/mtrr.h>
28 #include <device/pci_def.h>
29 #include <southbridge/amd/sb700/sb700.h>
32 #define SMBUS_IO_BASE 0x6000
34 uint64_t uma_memory_base, uma_memory_size;
36 void set_pcie_dereset(void);
37 void set_pcie_reset(void);
38 u8 is_dev3_present(void);
40 * ma78gm-us2h uses GPIO 6 as PCIe slot reset, GPIO4 as GFX slot reset. We need to
41 * pull it up before training the slot.
43 void set_pcie_dereset()
47 /* GPIO 6 reset PCIe slot, GPIO 4 reset GFX PCIe */
48 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
50 word = pci_read_config16(sm_dev, 0xA8);
51 word |= (1 << 0) | (1 << 2); /* Set Gpio6,4 as output */
52 word &= ~((1 << 8) | (1 << 10));
53 pci_write_config16(sm_dev, 0xA8, word);
60 /* GPIO 6 reset PCIe slot, GPIO 4 reset GFX PCIe */
61 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
63 word = pci_read_config16(sm_dev, 0xA8);
64 word &= ~((1 << 0) | (1 << 2)); /* Set Gpio6,4 as output */
65 word &= ~((1 << 8) | (1 << 10));
66 pci_write_config16(sm_dev, 0xA8, word);
70 u8 is_dev3_present(void)
75 /*************************************************
76 * enable the dedicated function in board.
77 * This function called early than rs780_enable.
78 *************************************************/
79 static void ma78gm_enable(device_t dev)
81 printk(BIOS_INFO, "Mainboard MA78GM-US2H Enable. dev=0x%p\n", dev);
83 #if (CONFIG_GFXUMA == 1)
86 /* TOP_MEM: the top of DRAM below 4G */
89 (BIOS_INFO, "%s, TOP MEM: msr.lo = 0x%08x, msr.hi = 0x%08x\n",
90 __func__, msr.lo, msr.hi);
92 /* TOP_MEM2: the top of DRAM above 4G */
93 msr2 = rdmsr(TOP_MEM2);
95 (BIOS_INFO, "%s, TOP MEM2: msr2.lo = 0x%08x, msr2.hi = 0x%08x\n",
96 __func__, msr2.lo, msr2.hi);
98 /* refer to UMA Size Consideration in 780 BDG. */
100 case 0x10000000: /* 256M system memory */
101 uma_memory_size = 0x4000000; /* 64M recommended UMA */
104 case 0x20000000: /* 512M system memory */
105 uma_memory_size = 0x8000000; /* 128M recommended UMA */
108 default: /* 1GB and above system memory */
109 uma_memory_size = 0x10000000; /* 256M recommended UMA */
113 uma_memory_base = msr.lo - uma_memory_size; /* TOP_MEM1 */
114 printk(BIOS_INFO, "%s: uma size 0x%08llx, memory start 0x%08llx\n",
115 __func__, uma_memory_size, uma_memory_base);
119 uma_memory_size = 0x8000000; /* 128M recommended UMA */
120 uma_memory_base = 0x38000000; /* 1GB system memory supposed */
124 /* get_ide_dma66(); */
127 int add_mainboard_resources(struct lb_memory *mem)
129 /* UMA is removed from system memory in the northbridge code, but
130 * in some circumstances we want the memory mentioned as reserved.
132 #if (CONFIG_GFXUMA == 1)
133 printk(BIOS_INFO, "uma_memory_start=0x%llx, uma_memory_size=0x%llx \n",
134 uma_memory_base, uma_memory_size);
135 lb_add_memory_range(mem, LB_MEM_RESERVED, uma_memory_base,
141 struct chip_operations mainboard_ops = {
142 CHIP_NAME("GIGABYTE MA78GM-US2H")
143 .enable_dev = ma78gm_enable,