2 * This file is part of the coreboot project.
4 * Copyright (C) 2007 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 #if defined(__PRE_RAM__)
21 typedef struct sys_info sys_info_conf_t;
23 typedef struct amdfam10_sysconf_t sys_info_conf_t;
26 struct dram_base_mask_t {
27 u32 base; //[47:27] at [28:8]
28 u32 mask; //[47:27] at [28:8] and enable at bit 0
31 static struct dram_base_mask_t get_dram_base_mask(u32 nodeid)
34 struct dram_base_mask_t d;
35 #if defined(__PRE_RAM__)
36 dev = PCI_DEV(CONFIG_CBB, CONFIG_CDB, 1);
41 #if CONFIG_EXT_CONF_SUPPORT == 1
42 // I will use ext space only for simple
43 pci_write_config32(dev, 0x110, nodeid | (1<<28)); // [47:27] at [28:8]
44 d.mask = pci_read_config32(dev, 0x114); // enable is bit 0
45 pci_write_config32(dev, 0x110, nodeid | (0<<28));
46 d.base = pci_read_config32(dev, 0x114) & 0x1fffff00; //[47:27] at [28:8];
49 temp = pci_read_config32(dev, 0x44 + (nodeid << 3)); //[39:24] at [31:16]
50 d.mask = ((temp & 0xfff80000)>>(8+3)); // mask out DramMask [26:24] too
51 temp = pci_read_config32(dev, 0x144 + (nodeid <<3)) & 0xff; //[47:40] at [7:0]
54 temp = pci_read_config32(dev, 0x40 + (nodeid << 3)); //[39:24] at [31:16]
55 d.mask |= (temp & 1); // enable bit
57 d.base = ((temp & 0xfff80000)>>(8+3)); // mask out DramBase [26:24) too
58 temp = pci_read_config32(dev, 0x140 + (nodeid <<3)) & 0xff; //[47:40] at [7:0]
64 static void set_dram_base_mask(u32 nodeid, struct dram_base_mask_t d, u32 nodes)
68 #if CONFIG_EXT_CONF_SUPPORT == 1
69 // I will use ext space only for simple
70 u32 d_base_i, d_base_d, d_mask_i, d_mask_d;
71 d_base_i = nodeid | (0<<28);
72 d_base_d = d.base | nodeid; //[47:27] at [28:8];
73 d_mask_i = nodeid | (1<<28); // [47:27] at [28:8]
74 d_mask_d = d.mask; // enable is bit 0
77 u32 d_base_lo, d_base_hi, d_mask_lo, d_mask_hi;
78 u32 d_base_lo_reg, d_base_hi_reg, d_mask_lo_reg, d_mask_hi_reg;
79 d_mask_lo = (((d.mask<<(8+3))|(0x07<<16)) & 0xffff0000)|nodeid; // need to fill DramMask[26:24] with ones
80 d_mask_hi = (d.mask>>21) & 0xff;
81 d_base_lo = ((d.base<<(8+3)) & 0xffff0000);
82 if(d.mask & 1) d_base_lo |= 3;
83 d_base_hi = (d.base>>21) & 0xff;
84 d_mask_lo_reg = 0x44+(nodeid<<3);
85 d_mask_hi_reg = 0x144+(nodeid<<3);
86 d_base_lo_reg = 0x40+(nodeid<<3);
87 d_base_hi_reg = 0x140+(nodeid<<3);
90 for(i=0;i<nodes;i++) {
91 #if defined(__PRE_RAM__)
97 #if CONFIG_EXT_CONF_SUPPORT == 1
98 // I will use ext space only for simple
99 pci_write_config32(dev, 0x110, d_base_i);
100 pci_write_config32(dev, 0x114, d_base_d); //[47:27] at [28:8];
101 pci_write_config32(dev, 0x110, d_mask_i); // [47:27] at [28:8]
102 pci_write_config32(dev, 0x114, d_mask_d); // enable is bit 0
104 pci_write_config32(dev, d_mask_lo_reg, d_mask_lo); // need to fill DramMask[26:24] with ones
105 pci_write_config32(dev, d_mask_hi_reg, d_mask_hi);
106 pci_write_config32(dev, d_base_lo_reg, d_base_lo);
107 pci_write_config32(dev, d_base_hi_reg, d_base_hi);
111 #if defined(__PRE_RAM__)
112 dev = NODE_PCI(nodeid, 1);
114 dev = __f1_dev[nodeid];
116 pci_write_config32(dev, 0x120, d.base>>8);
117 pci_write_config32(dev, 0x124, d.mask>>8);
122 static void set_DctSelBaseAddr(u32 i, u32 sel_m)
125 #if defined(__PRE_RAM__)
126 dev = NODE_PCI(i, 2);
131 dcs_lo = pci_read_config32(dev, DRAM_CTRL_SEL_LOW);
132 dcs_lo &= ~(DCSL_DctSelBaseAddr_47_27_MASK<<DCSL_DctSelBaseAddr_47_27_SHIFT);
133 dcs_lo |= (sel_m<<(20+DCSL_DctSelBaseAddr_47_27_SHIFT-27));
134 pci_write_config32(dev, DRAM_CTRL_SEL_LOW, dcs_lo);
139 static u32 get_DctSelBaseAddr(u32 i)
142 #if defined(__PRE_RAM__)
143 dev = NODE_PCI(i, 2);
149 dcs_lo = pci_read_config32(dev, DRAM_CTRL_SEL_LOW);
150 dcs_lo &= DCSL_DctSelBaseAddr_47_27_MASK<<DCSL_DctSelBaseAddr_47_27_SHIFT;
151 sel_m = dcs_lo>>(20+DCSL_DctSelBaseAddr_47_27_SHIFT-27);
156 static void set_DctSelHiEn(u32 i, u32 val)
159 #if defined(__PRE_RAM__)
160 dev = NODE_PCI(i, 2);
165 dcs_lo = pci_read_config32(dev, DRAM_CTRL_SEL_LOW);
168 pci_write_config32(dev, DRAM_CTRL_SEL_LOW, dcs_lo);
172 static u32 get_DctSelHiEn(u32 i)
175 #if defined(__PRE_RAM__)
176 dev = NODE_PCI(i, 2);
181 dcs_lo = pci_read_config32(dev, DRAM_CTRL_SEL_LOW);
187 static void set_DctSelBaseOffset(u32 i, u32 sel_off_m)
190 #if defined(__PRE_RAM__)
191 dev = NODE_PCI(i, 2);
196 dcs_hi = pci_read_config32(dev, DRAM_CTRL_SEL_HIGH);
197 dcs_hi &= ~(DCSH_DctSelBaseOffset_47_26_MASK<<DCSH_DctSelBaseOffset_47_26_SHIFT);
198 dcs_hi |= sel_off_m<<(20+DCSH_DctSelBaseOffset_47_26_SHIFT-26);
199 pci_write_config32(dev, DRAM_CTRL_SEL_HIGH, dcs_hi);
203 static u32 get_DctSelBaseOffset(u32 i)
206 #if defined(__PRE_RAM__)
207 dev = NODE_PCI(i, 2);
213 dcs_hi = pci_read_config32(dev, DRAM_CTRL_SEL_HIGH);
214 dcs_hi &= DCSH_DctSelBaseOffset_47_26_MASK<<DCSH_DctSelBaseOffset_47_26_SHIFT;
215 sel_off_m = dcs_hi>>(20+DCSH_DctSelBaseOffset_47_26_SHIFT-26);
218 #if CONFIG_AMDMCT == 0
220 static u32 get_one_DCT(struct mem_info *meminfo)
223 if(meminfo->is_Width128) {
226 u32 dimm_mask = meminfo->dimm_mask;
227 if((dimm_mask >> DIMM_SOCKETS) && (dimm_mask & ((1<<DIMM_SOCKETS)-1))) {
235 #if CONFIG_HW_MEM_HOLE_SIZEK != 0
237 static u32 hoist_memory(u32 hole_startk, u32 i, u32 one_DCT, u32 nodes)
242 struct dram_base_mask_t d;
248 carry_over = (4*1024*1024) - hole_startk;
250 for(ii=nodes - 1;ii>i;ii--) {
251 d = get_dram_base_mask(ii);
252 if(!(d.mask & 1)) continue;
253 d.base += (carry_over>>9);
254 d.mask += (carry_over>>9);
255 set_dram_base_mask(ii, d, nodes);
257 if(get_DctSelHiEn(ii) & 1) {
258 sel_m = get_DctSelBaseAddr(ii);
259 sel_m += carry_over>>10;
260 set_DctSelBaseAddr(ii, sel_m);
264 d = get_dram_base_mask(i);
265 d.mask += (carry_over>>9);
266 set_dram_base_mask(i,d, nodes);
267 #if defined(__PRE_RAM__)
268 dev = NODE_PCI(i, 1);
272 sel_hi_en = get_DctSelHiEn(i);
274 sel_m = get_DctSelBaseAddr(i);
276 if(d.base == (hole_startk>>9)) {
277 //don't need set memhole here, because hole off set will be 0, overflow
278 //so need to change base reg instead, new basek will be 4*1024*1024
279 d.base = (4*1024*1024)>>9;
280 set_dram_base_mask(i, d, nodes);
283 sel_m += carry_over>>10;
284 set_DctSelBaseAddr(i, sel_m);
287 hoist = /* hole start address */
288 ((hole_startk << 10) & 0xff000000) +
291 if(one_DCT||(sel_m>=(hole_startk>>10))) { //one DCT or hole in DCT0
293 /* hole address to memory controller address */
294 ((((d.base<<9) + carry_over) >> 6) & 0x0000ff00) ;
297 sel_m += (carry_over>>10);
298 set_DctSelBaseAddr(i, sel_m);
299 set_DctSelBaseOffset(i, sel_m);
301 } else { // hole in DCT1 range
303 /* hole address to memory controller address */
304 ((((sel_m<<10) + carry_over) >> 6) & 0x0000ff00) ;
305 // don't need to update DctSelBaseAddr
307 set_DctSelBaseOffset(i, sel_m);
310 pci_write_config32(dev, 0xf0, hoist);
319 #if CONFIG_EXT_CONF_SUPPORT
320 static void set_addr_map_reg_4_6_in_one_node(u32 nodeid, u32 cfg_map_dest,
321 u32 busn_min, u32 busn_max,
327 u32 index_min, index_max;
328 u32 dest_min, dest_max;
329 index_min = busn_min>>2; dest_min = busn_min - (index_min<<2);
330 index_max = busn_max>>2; dest_max = busn_max - (index_max<<2);
332 // three case: index_min==index_max, index_min+1=index_max; index_min+1<index_max
333 #if defined(__PRE_RAM__)
334 dev = NODE_PCI(nodeid, 1);
336 dev = __f1_dev[nodeid];
338 if(index_min== index_max) {
339 pci_write_config32(dev, 0x110, index_min | (type<<28));
340 tempreg = pci_read_config32(dev, 0x114);
341 for(i=dest_min; i<=dest_max; i++) {
342 tempreg &= ~(0xff<<(i*8));
343 tempreg |= (cfg_map_dest<<(i*8));
345 pci_write_config32(dev, 0x110, index_min | (type<<28)); // do i need to write it again
346 pci_write_config32(dev, 0x114, tempreg);
347 } else if(index_min<index_max) {
348 pci_write_config32(dev, 0x110, index_min | (type<<28));
349 tempreg = pci_read_config32(dev, 0x114);
350 for(i=dest_min; i<=3; i++) {
351 tempreg &= ~(0xff<<(i*8));
352 tempreg |= (cfg_map_dest<<(i*8));
354 pci_write_config32(dev, 0x110, index_min | (type<<28)); // do i need to write it again
355 pci_write_config32(dev, 0x114, tempreg);
357 pci_write_config32(dev, 0x110, index_max | (type<<28));
358 tempreg = pci_read_config32(dev, 0x114);
359 for(i=0; i<=dest_max; i++) {
360 tempreg &= ~(0xff<<(i*8));
361 tempreg |= (cfg_map_dest<<(i*8));
363 pci_write_config32(dev, 0x110, index_max | (type<<28)); // do i need to write it again
364 pci_write_config32(dev, 0x114, tempreg);
365 if((index_max-index_min)>1) {
367 for(i=0; i<=3; i++) {
368 tempreg &= ~(0xff<<(i*8));
369 tempreg |= (cfg_map_dest<<(i*8));
371 for(i=index_min+1; i<index_max;i++) {
372 pci_write_config32(dev, 0x110, i | (type<<28));
373 pci_write_config32(dev, 0x114, tempreg);
380 static void set_config_map_reg(u32 nodeid, u32 linkn, u32 ht_c_index,
381 u32 busn_min, u32 busn_max, u32 segbit,
391 #if CONFIG_EXT_CONF_SUPPORT
394 tempreg = 3 | ((nodeid&0xf)<<4) | ((nodeid & 0x30)<<(12-4))|(linkn<<8)|((busn_min & 0xff)<<16)|((busn_max&0xff)<<24);
395 for(i=0; i<nodes; i++) {
396 #if defined(__PRE_RAM__)
397 dev = NODE_PCI(i, 1);
401 pci_write_config32(dev, 0xe0 + ht_c_index * 4, tempreg);
403 #if CONFIG_EXT_CONF_SUPPORT
408 // if ht_c_index > 3, We should use extend space x114_x6
412 // for nodeid at first
413 cfg_map_dest = (1<<7) | (1<<6) | (linkn<<0);
415 set_addr_map_reg_4_6_in_one_node(nodeid, cfg_map_dest, busn_min, busn_max, 6);
418 cfg_map_dest = (1<<7) | (0<<6) | (nodeid<<0);
419 for(j = 0; j< nodes; j++) {
420 if(j== nodeid) continue;
421 set_addr_map_reg_4_6_in_one_node(j,cfg_map_dest, busn_min, busn_max, 6);
426 static void clear_config_map_reg(u32 nodeid, u32 linkn, u32 ht_c_index,
427 u32 busn_min, u32 busn_max, u32 nodes)
432 #if CONFIG_EXT_CONF_SUPPORT
435 for(i=0; i<nodes; i++) {
436 #if defined(__PRE_RAM__)
437 dev = NODE_PCI(i, 1);
441 pci_write_config32(dev, 0xe0 + ht_c_index * 4, 0);
443 #if CONFIG_EXT_CONF_SUPPORT
447 // if hc_c_index >3, We should use busn_min and busn_max to clear extend space
454 for(j = 0; j< nodes; j++) {
455 set_addr_map_reg_4_6_in_one_node(j,cfg_map_dest, busn_min, busn_max, 6);
461 #if CONFIG_PCI_BUS_SEGN_BITS
462 static u32 check_segn(device_t dev, u32 segbusn, u32 nodes,
463 sys_info_conf_t *sysinfo)
465 //check segbusn here, We need every node have the same segn
466 if((segbusn & 0xff)>(0xe0-1)) {// use next segn
467 u32 segn = (segbusn >> 8) & 0x0f;
473 val = pci_read_config32(dev, 0x160);
475 val |= (segbusn & 0xf00)<<(25-8);
476 pci_write_config32(dev, 0x160, val);
483 #if defined(__PRE_RAM__)
484 static void set_ht_c_io_addr_reg(u32 nodeid, u32 linkn, u32 ht_c_index,
485 u32 io_min, u32 io_max, u32 nodes)
491 #if CONFIG_EXT_CONF_SUPPORT
494 /* io range allocation */
495 tempreg = (nodeid&0xf) | ((nodeid & 0x30)<<(8-4)) | (linkn<<4) | ((io_max&0xf0)<<(12-4)); //limit
496 for(i=0; i<nodes; i++) {
497 #if defined(__PRE_RAM__)
498 dev = NODE_PCI(i, 1);
502 pci_write_config32(dev, 0xC4 + ht_c_index * 8, tempreg);
504 tempreg = 3 /*| ( 3<<4)*/ | ((io_min&0xf0)<<(12-4)); //base :ISA and VGA ?
505 for(i=0; i<nodes; i++){
506 #if defined(__PRE_RAM__)
507 dev = NODE_PCI(i, 1);
511 pci_write_config32(dev, 0xC0 + ht_c_index * 8, tempreg);
513 #if CONFIG_EXT_CONF_SUPPORT
520 // if ht_c_index > 3, We should use extend space
522 if(io_min>io_max) return;
524 // for nodeid at first
525 cfg_map_dest = (1<<7) | (1<<6) | (linkn<<0);
527 set_addr_map_reg_4_6_in_one_node(nodeid, cfg_map_dest, io_min, io_max, 4);
530 cfg_map_dest = (1<<7) | (0<<6) | (nodeid<<0);
531 for(j = 0; j< nodes; j++) {
532 if(j== nodeid) continue;
533 set_addr_map_reg_4_6_in_one_node(j,cfg_map_dest, io_min, io_max, 4);
539 static void clear_ht_c_io_addr_reg(u32 nodeid, u32 linkn, u32 ht_c_index,
540 u32 io_min, u32 io_max, u32 nodes)
544 #if CONFIG_EXT_CONF_SUPPORT
547 /* io range allocation */
548 for(i=0; i<nodes; i++) {
549 #if defined(__PRE_RAM__)
550 dev = NODE_PCI(i, 1);
554 pci_write_config32(dev, 0xC4 + ht_c_index * 8, 0);
555 pci_write_config32(dev, 0xC0 + ht_c_index * 8, 0);
557 #if CONFIG_EXT_CONF_SUPPORT
560 // : if hc_c_index > 3, We should use io_min, io_max to clear extend space
567 for(j = 0; j< nodes; j++) {
568 set_addr_map_reg_4_6_in_one_node(j,cfg_map_dest, io_min, io_max, 4);
575 static void re_set_all_config_map_reg(u32 nodes, u32 segbit,
576 sys_info_conf_t *sysinfo)
581 set_config_map_reg(0, sysinfo->sblk, 0, 0, sysinfo->ht_c_conf_bus[0]>>20, segbit, nodes);
584 for(ht_c_index=1;ht_c_index<4; ht_c_index++) {
586 for(i=0; i<nodes; i++) {
587 #if defined(__PRE_RAM__)
588 dev = NODE_PCI(i, 1);
592 pci_write_config32(dev, 0xe0 + ht_c_index * 4, 0);
595 #if CONFIG_EXT_CONF_SUPPORT
597 // clear the extend space
598 for(j = 0; j< nodes; j++) {
599 set_addr_map_reg_4_6_in_one_node(j,0, 0, 0xff, 6);
603 for(ht_c_index = 1; ht_c_index<sysinfo->ht_c_num; ht_c_index++) {
607 nodeid = (sysinfo->ht_c_conf_bus[ht_c_index] >> 2) & 0x3f;
608 linkn = (sysinfo->ht_c_conf_bus[ht_c_index]>>8) & 0x7;
609 busn_max = sysinfo->ht_c_conf_bus[ht_c_index]>>20;
610 busn_min = (sysinfo->ht_c_conf_bus[ht_c_index]>>12) & 0xff;
611 busn_min |= busn_max & 0xf00;
612 set_config_map_reg(nodeid, linkn, ht_c_index, busn_min, busn_max, segbit, nodes);
618 static u32 get_ht_c_index(u32 nodeid, u32 linkn, sys_info_conf_t *sysinfo)
624 tempreg = 3 | ((nodeid & 0xf) <<4) | ((nodeid & 0x30)<<(12-4)) | (linkn<<8);
626 for(ht_c_index=0;ht_c_index<4; ht_c_index++) {
627 reg = pci_read_config32(PCI_DEV(CONFIG_CBB, CONFIG_CDB, 1), 0xe0 + ht_c_index * 4);
628 if(((reg & 0xffff) == 0x0000)) { /*found free*/
633 tempreg = 3 | ((nodeid & 0x3f)<<2) | (linkn<<8);
634 for(ht_c_index=0; ht_c_index<32; ht_c_index++) {
635 if(((sysinfo->ht_c_conf_bus[ht_c_index] & 0xfff) == tempreg)){
640 for(ht_c_index=0; ht_c_index<32; ht_c_index++) {
641 if((sysinfo->ht_c_conf_bus[ht_c_index] == 0)){
650 static void store_ht_c_conf_bus(u32 nodeid, u32 linkn, u32 ht_c_index,
651 u32 busn_min, u32 busn_max,
652 sys_info_conf_t *sysinfo)
655 val = 3 | ((nodeid & 0x3f)<<2) | (linkn<<8);
656 sysinfo->ht_c_conf_bus[ht_c_index] = val | ((busn_min & 0xff) <<12) | (busn_max<<20); // same node need segn are same
661 static void set_BusSegmentEn(u32 node, u32 segbit)
663 #if CONFIG_PCI_BUS_SEGN_BITS
667 #if defined(__PRE_RAM__)
668 dev = NODE_PCI(node, 0);
670 dev = __f0_dev[node];
673 dword = pci_read_config32(dev, 0x68);
675 dword |= (segbit<<28); /* bus segment enable */
676 pci_write_config32(dev, 0x68, dword);
680 #if !defined(__PRE_RAM__)
681 static u32 get_io_addr_index(u32 nodeid, u32 linkn)
685 for(index=0; index<256; index++) {
686 if((sysconf.conf_io_addrx[index+4] == 0)){
687 sysconf.conf_io_addr[index+4] = (nodeid & 0x3f) ;
688 sysconf.conf_io_addrx[index+4] = 1 | ((linkn & 0x7)<<4);
697 static u32 get_mmio_addr_index(u32 nodeid, u32 linkn)
702 for(index=0; index<64; index++) {
703 if((sysconf.conf_mmio_addrx[index+8] == 0)){
704 sysconf.conf_mmio_addr[index+8] = (nodeid & 0x3f) ;
705 sysconf.conf_mmio_addrx[index+8] = 1 | ((linkn & 0x7)<<4);
714 static void store_conf_io_addr(u32 nodeid, u32 linkn, u32 reg, u32 index,
715 u32 io_min, u32 io_max)
718 #if CONFIG_EXT_CONF_SUPPORT
721 /* io range allocation */
722 index = (reg-0xc0)>>3;
723 #if CONFIG_EXT_CONF_SUPPORT
729 val = (nodeid & 0x3f); // 6 bits used
730 sysconf.conf_io_addr[index] = val | ((io_max<<8) & 0xfffff000); //limit : with nodeid
731 val = 3 | ((linkn & 0x7)<<4) ; // 8 bits used
732 sysconf.conf_io_addrx[index] = val | ((io_min<<8) & 0xfffff000); // base : with enable bit
734 if( sysconf.io_addr_num<(index+1))
735 sysconf.io_addr_num = index+1;
739 static void store_conf_mmio_addr(u32 nodeid, u32 linkn, u32 reg, u32 index,
740 u32 mmio_min, u32 mmio_max)
743 #if CONFIG_EXT_CONF_SUPPORT
746 /* io range allocation */
747 index = (reg-0x80)>>3;
748 #if CONFIG_EXT_CONF_SUPPORT
754 val = (nodeid & 0x3f) ; // 6 bits used
755 sysconf.conf_mmio_addr[index] = val | (mmio_max & 0xffffff00); //limit : with nodeid and linkn
756 val = 3 | ((linkn & 0x7)<<4) ; // 8 bits used
757 sysconf.conf_mmio_addrx[index] = val | (mmio_min & 0xffffff00); // base : with enable bit
759 if( sysconf.mmio_addr_num<(index+1))
760 sysconf.mmio_addr_num = index+1;
764 static void set_io_addr_reg(device_t dev, u32 nodeid, u32 linkn, u32 reg,
765 u32 io_min, u32 io_max)
770 #if CONFIG_EXT_CONF_SUPPORT
773 /* io range allocation */
774 tempreg = (nodeid&0xf) | ((nodeid & 0x30)<<(8-4)) | (linkn<<4) | ((io_max&0xf0)<<(12-4)); //limit
775 for(i=0; i<sysconf.nodes; i++)
776 pci_write_config32(__f1_dev[i], reg+4, tempreg);
778 tempreg = 3 /*| ( 3<<4)*/ | ((io_min&0xf0)<<(12-4)); //base :ISA and VGA ?
780 // FIXME: can we use VGA reg instead?
781 if (dev->link[link].bridge_ctrl & PCI_BRIDGE_CTL_VGA) {
782 printk(BIOS_SPEW, "%s, enabling legacy VGA IO forwarding for %s link %s\n",
783 __func__, dev_path(dev), link);
784 tempreg |= PCI_IO_BASE_VGA_EN;
786 if (dev->link[link].bridge_ctrl & PCI_BRIDGE_CTL_NO_ISA) {
787 tempreg |= PCI_IO_BASE_NO_ISA;
790 for(i=0; i<sysconf.nodes; i++)
791 pci_write_config32(__f1_dev[i], reg, tempreg);
792 #if CONFIG_EXT_CONF_SUPPORT
798 // if ht_c_index > 3, We should use extend space
799 if(io_min>io_max) return;
800 // for nodeid at first
801 cfg_map_dest = (1<<7) | (1<<6) | (linkn<<0);
803 set_addr_map_reg_4_6_in_one_node(nodeid, cfg_map_dest, io_min, io_max, 4);
806 cfg_map_dest = (1<<7) | (0<<6) | (nodeid<<0);
807 for(j = 0; j< sysconf.nodes; j++) {
808 if(j== nodeid) continue;
809 set_addr_map_reg_4_6_in_one_node(j,cfg_map_dest, io_min, io_max, 4);
814 static void set_mmio_addr_reg(u32 nodeid, u32 linkn, u32 reg, u32 index, u32 mmio_min, u32 mmio_max, u32 nodes)
819 #if CONFIG_EXT_CONF_SUPPORT
822 /* io range allocation */
823 tempreg = (nodeid&0xf) | (linkn<<4) | (mmio_max&0xffffff00); //limit
824 for(i=0; i<nodes; i++)
825 pci_write_config32(__f1_dev[i], reg+4, tempreg);
826 tempreg = 3 | (nodeid & 0x30) | (mmio_min&0xffffff00);
827 for(i=0; i<sysconf.nodes; i++)
828 pci_write_config32(__f1_dev[i], reg, tempreg);
829 #if CONFIG_EXT_CONF_SUPPORT
835 // if ht_c_index > 3, We should use extend space
836 // for nodeid at first
839 if(mmio_min>mmio_max) {
845 dev = __f1_dev[nodeid];
846 tempreg = ((mmio_min>>3) & 0x1fffff00)| (1<<6) | (linkn<<0);
847 pci_write_config32(dev, 0x110, index | (2<<28));
848 pci_write_config32(dev, 0x114, tempreg);
850 tempreg = ((mmio_max>>3) & 0x1fffff00) | enable;
851 pci_write_config32(dev, 0x110, index | (3<<28));
852 pci_write_config32(dev, 0x114, tempreg);
856 tempreg = ((mmio_min>>3) & 0x1fffff00) | (0<<6) | (nodeid<<0);
857 for(j = 0; j< sysconf.nodes; j++) {
858 if(j== nodeid) continue;
860 pci_write_config32(dev, 0x110, index | (2<<28));
861 pci_write_config32(dev, 0x114, tempreg);
864 tempreg = ((mmio_max>>3) & 0x1fffff00) | enable;
865 for(j = 0; j< sysconf.nodes; j++) {
866 if(j==nodeid) continue;
868 pci_write_config32(dev, 0x110, index | (3<<28));
869 pci_write_config32(dev, 0x114, tempreg);