This patch unifies the use of config options in v2 to all start with CONFIG_
[coreboot.git] / src / northbridge / amd / amdfam10 / get_pci1234.c
1 /*
2  * This file is part of the coreboot 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 #include <console/console.h>
21 #include <device/pci.h>
22 #include <device/pci_ids.h>
23 #include <string.h>
24 #include <stdint.h>
25
26 #include <cpu/amd/amdfam10_sysconf.h>
27
28
29 /* Need pci1234 array
30  * pci1234[0] will record sblink and bus range
31  * pci1234[i] will record ht chain i.
32  * It will keep the sequence when some ht io card is not installed.
33  *
34  *      1n: 8
35  *      2n: 7x2
36  *      3n: 6x3
37  *      4n: 5x4
38  *      5n: 4x5
39  *      6n: 3x6
40  *      7n: 2x7
41  *      8n: 1x8
42  *
43  *      8n(4x2): 8x4
44  *      16n(4x4): 16*2
45  *      20n(4x5): 20x1
46  *      32n(4x4+4x4): 16x1
47  *
48  * Total: xxx: I just want to use 32 instead, If you have more, you may need to
49  * reset HC_POSSIBLE_NUM and update ssdt.dsl (hcdn, hclk)
50  *
51  * Put all the possible ht node/link to the list tp pci1234[] in  get_bus_conf.c
52  * on MB dir. Also, don't forget to increase the CONFIG_ACPI_SSDTX_NUM etc if you have
53  * too much SSDT. How about co-processor on socket 1 on 2 way system.
54  * or socket 2, and socket3 on 4 way system? treat that as one hc too!
55  *
56  */
57
58
59 void get_pci1234(void)
60 {
61
62         int i,j;
63         u32 dword;
64
65         dword = sysconf.sblk<<8;
66         dword |= 1;
67         sysconf.pci1234[0] = dword; // sblink
68         sysconf.hcid[0] = 0;
69
70         /* about hardcode numbering for HT_IO support
71           set the node_id and link_id that could have ht chain in the one array,
72           then check if is enabled.... then update final value
73         */
74
75         //here we need to set hcdn
76         //1. hypertransport.c need to record hcdn_reg together with 0xe0, 0xe4, 0xe8, 0xec when are set
77         //2. so at the same time we need update hsdn with hcdn_reg here
78 //      printk_debug("sysconf.ht_c_num = %02d\n", sysconf.ht_c_num);
79
80         for(j=0;j<sysconf.ht_c_num;j++) {
81                 u32 dwordx;
82                 dwordx = sysconf.ht_c_conf_bus[j];
83 //              printk_debug("sysconf.ht_c_conf_bus[%02d] = %08x\n", j, sysconf.ht_c_conf_bus[j]);
84                 dwordx &=0xfffffffd; //keep bus num, node_id, link_num, enable bits
85                 if((dwordx & 0x7fd) == dword) { //SBLINK
86                         sysconf.pci1234[0] = dwordx;
87                         sysconf.hcdn[0] = sysconf.hcdn_reg[j];
88                         continue;
89                 }
90                 if((dwordx & 1)) {
91                         // We need to find out the number of HC
92                         // for exact match
93                         for(i=1;i<sysconf.hc_possible_num;i++) {
94                                 if((dwordx & 0x7fc) == (sysconf.pci1234[i] & 0x7fc)) { // same node and same linkn
95                                         sysconf.pci1234[i] = dwordx;
96                                         sysconf.hcdn[i] = sysconf.hcdn_reg[j];
97                                         break;
98                                 }
99                         }
100                         // for 0xffc match or same node
101                         for(i=1;i<sysconf.hc_possible_num;i++) {
102                                 if((dwordx & 0x7fc) == (dwordx & sysconf.pci1234[i] & 0x7fc)) {
103                                         sysconf.pci1234[i] = dwordx;
104                                         sysconf.hcdn[i] = sysconf.hcdn_reg[j];
105                                         break;
106                                 }
107                         }
108                 }
109         }
110
111         for(i=1;i<sysconf.hc_possible_num;i++) {
112                 if(!(sysconf.pci1234[i] & 1)) {
113                         sysconf.pci1234[i] = 0;
114                         sysconf.hcdn[i] = 0x20202020;
115                 }
116                 sysconf.hcid[i] = 0;
117         }
118 }