Initial AMD Barcelona support for rev Bx.
[coreboot.git] / src / northbridge / amd / amdht / ht_wrapper.c
1 /*
2  * This file is part of the LinuxBIOS project.
3  *
4  * Copyright (C) 2007 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 /*----------------------------------------------------------------------------
22  *                      TYPEDEFS, DEFINITIONS AND MACROS
23  *
24  *----------------------------------------------------------------------------
25  */
26
27 /* Single CPU system? */
28 #if (CONFIG_MAX_PHYSICAL_CPUS == 1)
29         #define HT_BUILD_NC_ONLY 1
30 #endif
31
32 /* Debugging Options */
33 #define AMD_DEBUG 1
34 //#define AMD_DEBUG_ERROR_STOP 1
35
36 /*----------------------------------------------------------------------------
37  *                              MODULES USED
38  *
39  *----------------------------------------------------------------------------
40  */
41
42 #undef FILECODE
43 #define FILECODE 0xFF01
44 #include "comlib.h"
45 #include "h3gtopo.h"
46 #include "h3finit.h"
47
48 /* include the main HT source file */
49 #include "h3finit.c"
50
51
52 /*----------------------------------------------------------------------------
53  *                      LOCAL FUNCTIONS
54  *
55  *----------------------------------------------------------------------------
56  */
57
58 /* FIXME: Find a better place for these pre-ram functions. */
59 #define NODE_HT(x) NODE_PCI(x,0)
60 #define NODE_MP(x) NODE_PCI(x,1)
61 #define NODE_MC(x) NODE_PCI(x,3)
62 #define NODE_LC(x) NODE_PCI(x,4)
63 static  u32 get_nodes(void)
64 {
65         device_t dev;
66         u32 nodes;
67
68         dev = PCI_DEV(CBB, CDB, 0);
69         nodes = ((pci_read_config32(dev, 0x60)>>4) & 7) ;
70 #if CONFIG_MAX_PHYSICAL_CPUS > 8
71         nodes += (((pci_read_config32(dev, 0x160)>>4) & 7)<<3);
72 #endif
73         nodes++;
74
75         return nodes;
76 }
77
78 static void enable_apic_ext_id(u32 node)
79 {
80         u32 val;
81         val = pci_read_config32(NODE_HT(node), 0x68);
82         val |= (HTTC_APIC_EXT_SPUR | HTTC_APIC_EXT_ID | HTTC_APIC_EXT_BRD_CST);
83         pci_write_config32(NODE_HT(node), 0x68, val);
84 }
85
86
87 static void setup_link_trans_cntrl()
88 {
89         /* FIXME: Not sure that this belongs here but it is HT related */
90         u32 val;
91         val = pci_read_config32(NODE_HT(0), 0x68);
92         val |= 0x00206800;      // DSNpReqLimit, LimitCldtCfg, BufRefPri, RespPassPW per BKDG;
93         pci_write_config32(NODE_HT(0), 0x68, val);
94 }
95
96
97
98
99 /**
100  * void AMD_CB_EventNotify (u8 evtClass, u16 event, const u8 *pEventData0)
101  *
102  *  Needs to be fixed to output the debug structures.
103  *
104  */
105 void AMD_CB_EventNotify (u8 evtClass, u16 event, const u8 *pEventData0)
106 {
107         printk_debug("AMD_CB_EventNotify()\n");
108         printk_debug("event class: %02x event: %04x\n", evtClass, event);
109
110 }
111
112 /**
113  * void getAmdTopolist(u8 ***p)
114  *
115  *  point to the stock topo list array
116  *
117  */
118 void getAmdTopolist(u8 ***p)
119 {
120         *p = (u8 **)amd_topo_list;
121 }
122
123
124 /**
125  * void amd_ht_init(struct sys_info *sysinfo)
126  *
127  *  AMD HT init LinuxBIOS wrapper
128  *
129  */
130 void amd_ht_init(struct sys_info *sysinfo)
131 {
132         AMD_HTBLOCK ht_wrapper = {
133                 NULL,   // u8 **topolist;
134                 0,      // u8 AutoBusStart;
135                 32,     // u8 AutoBusMax;
136                 6,      // u8 AutoBusIncrement;
137                 NULL,   // BOOL (*AMD_CB_IgnoreLink)();
138                 NULL,   // BOOL (*AMD_CB_OverrideBusNumbers)();
139                 NULL,   // BOOL (*AMD_CB_ManualBUIDSwapList)();
140                 NULL,   // void (*AMD_CB_DeviceCapOverride)();
141                 NULL,   // void (*AMD_CB_Cpu2CpuPCBLimits)();
142                 NULL,   // void (*AMD_CB_IOPCBLimits)();
143                 NULL,   // BOOL (*AMD_CB_SkipRegang)();
144                 NULL,   // BOOL (*AMD_CB_CustomizeTrafficDistribution)();
145                 NULL,   // BOOL (*AMD_CB_CustomizeBuffers)();
146                 NULL,   // void (*AMD_CB_OverrideDevicePort)();
147                 NULL,   // void (*AMD_CB_OverrideCpuPort)();
148                 AMD_CB_EventNotify      // void (*AMD_CB_EventNotify) ();
149         };
150
151         printk_debug("Enter amd_ht_init()\n");
152         amdHtInitialize(&ht_wrapper);
153         printk_debug("Exit amd_ht_init()\n");
154
155
156 }
157
158
159
160