2 * This file is part of the coreboot project.
4 * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
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.
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.
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
20 #include <cpu/x86/msr.h>
21 #include <console/console.h>
22 #include <northbridge/amd/amdfam10/amdfam10.h>
24 /*----------------------------------------------------------------------------
25 * TYPEDEFS, DEFINITIONS AND MACROS
27 *----------------------------------------------------------------------------
30 /* Single CPU system? */
31 #if (CONFIG_MAX_PHYSICAL_CPUS == 1)
32 #define HT_BUILD_NC_ONLY 1
35 /* Debugging Options */
37 //#define AMD_DEBUG_ERROR_STOP 1
39 /*----------------------------------------------------------------------------
42 *----------------------------------------------------------------------------
46 #define FILECODE 0xFF01
51 /* include the main HT source file */
55 /*----------------------------------------------------------------------------
58 *----------------------------------------------------------------------------
61 /* FIXME: Find a better place for these pre-ram functions. */
62 #define NODE_HT(x) NODE_PCI(x,0)
63 #define NODE_MP(x) NODE_PCI(x,1)
64 #define NODE_MC(x) NODE_PCI(x,3)
65 #define NODE_LC(x) NODE_PCI(x,4)
67 static u32 get_nodes(void)
72 dev = PCI_DEV(CONFIG_CBB, CONFIG_CDB, 0);
73 nodes = ((pci_read_config32(dev, 0x60)>>4) & 7) ;
74 #if CONFIG_MAX_PHYSICAL_CPUS > 8
75 nodes += (((pci_read_config32(dev, 0x160)>>4) & 7)<<3);
84 * void AMD_CB_EventNotify (u8 evtClass, u16 event, const u8 *pEventData0)
86 static void AMD_CB_EventNotify (u8 evtClass, u16 event, const u8 *pEventData0)
90 printk(BIOS_DEBUG, "AMD_CB_EventNotify()\n");
91 printk(BIOS_DEBUG, " event class: %02x\n event: %04x\n data: ", evtClass, event);
93 for (i = 0; i < *pEventData0; i++) {
94 printk(BIOS_DEBUG, " %02x ", *(pEventData0 + i));
96 printk(BIOS_DEBUG, "\n");
102 * BOOL AMD_CB_ManualBUIDSwapList(u8 Node, u8 Link, u8 **List)
104 * This routine is called every time a non-coherent chain is processed.
105 * BUID assignment may be controlled explicitly on a non-coherent chain. Provide a
106 * swap list. The first part of the list controls the BUID assignment and the
107 * second part of the list provides the device to device linking. Device orientation
108 * can be detected automatically, or explicitly. See documentation for more details.
110 * Automatic non-coherent init assigns BUIDs starting at 1 and incrementing sequentially
111 * based on each device's unit count.
114 * @param[in] u8 node = The node on which this chain is located
115 * @param[in] u8 link = The link on the host for this chain
116 * @param[out] u8** list = supply a pointer to a list
117 * @param[out] BOOL result = true to use a manual list
118 * false to initialize the link automatically
120 static BOOL AMD_CB_ManualBUIDSwapList (u8 node, u8 link, u8 **List)
122 static u8 swaplist[] = { 0xFF, CONFIG_HT_CHAIN_UNITID_BASE, CONFIG_HT_CHAIN_END_UNITID_BASE, 0xFF };
123 /* If the BUID was adjusted in early_ht we need to do the manual override */
124 if ((CONFIG_HT_CHAIN_UNITID_BASE != 0) && (CONFIG_HT_CHAIN_END_UNITID_BASE != 0)) {
125 printk(BIOS_DEBUG, "AMD_CB_ManualBUIDSwapList()\n");
126 if ((node == 0) && (link == 0)) { /* BSP SB link */
137 * void getAmdTopolist(u8 ***p)
139 * point to the stock topo list array
142 void getAmdTopolist(u8 ***p)
144 *p = (u8 **)amd_topo_list;
149 * void amd_ht_init(struct sys_info *sysinfo)
151 * AMD HT init coreboot wrapper
154 static void amd_ht_init(struct sys_info *sysinfo)
157 AMD_HTBLOCK ht_wrapper = {
158 NULL, // u8 **topolist;
159 0, // u8 AutoBusStart;
160 32, // u8 AutoBusMax;
161 6, // u8 AutoBusIncrement;
162 NULL, // BOOL (*AMD_CB_IgnoreLink)();
163 NULL, // BOOL (*AMD_CB_OverrideBusNumbers)();
164 AMD_CB_ManualBUIDSwapList, // BOOL (*AMD_CB_ManualBUIDSwapList)();
165 NULL, // void (*AMD_CB_DeviceCapOverride)();
166 NULL, // void (*AMD_CB_Cpu2CpuPCBLimits)();
167 NULL, // void (*AMD_CB_IOPCBLimits)();
168 NULL, // BOOL (*AMD_CB_SkipRegang)();
169 NULL, // BOOL (*AMD_CB_CustomizeTrafficDistribution)();
170 NULL, // BOOL (*AMD_CB_CustomizeBuffers)();
171 NULL, // void (*AMD_CB_OverrideDevicePort)();
172 NULL, // void (*AMD_CB_OverrideCpuPort)();
173 AMD_CB_EventNotify // void (*AMD_CB_EventNotify) ();
176 printk(BIOS_DEBUG, "Enter amd_ht_init()\n");
177 amdHtInitialize(&ht_wrapper);
178 printk(BIOS_DEBUG, "Exit amd_ht_init()\n");