AMD K8 fam10: Remove some excessive preprocessor use

Change-Id: Iee51c51b662d1f5e3d918d1e5b961f06c6b99df6
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: http://review.coreboot.org/8346
Tested-by: build bot (Jenkins)
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
This commit is contained in:
Kyösti Mälkki 2015-02-02 20:07:58 +02:00
parent d15bddab57
commit fe57eeb5bf
3 changed files with 36 additions and 60 deletions

View File

@ -288,37 +288,27 @@ static unsigned amdfam10_scan_chains(device_t dev, unsigned max)
unsigned nodeid; unsigned nodeid;
struct bus *link; struct bus *link;
unsigned sblink = sysconf.sblk; unsigned sblink = sysconf.sblk;
unsigned offset_unitid = 0;
nodeid = amdfam10_nodeid(dev); nodeid = amdfam10_nodeid(dev);
// Put sb chain in bus 0 /* Do sb ht chain at first, in case s2885 put sb chain (8131/8111) on link2, but put 8151 on link0 */
#if CONFIG_SB_HT_CHAIN_ON_BUS0 > 0 for (link = dev->link_list; link; link = link->next) {
if(nodeid==0) { unsigned offset_unitid = (CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20);
#if ((CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20)) if ((CONFIG_SB_HT_CHAIN_ON_BUS0 > 0) && (nodeid == 0) && (link->link_num == sblink))
offset_unitid = 1; max = amdfam10_scan_chain(dev, nodeid, link, link->link_num, sblink, max, offset_unitid);
#endif
for (link = dev->link_list; link; link = link->next)
if (link->link_num == sblink)
max = amdfam10_scan_chain(dev, nodeid, link, sblink, sblink, max, offset_unitid ); // do sb ht chain at first, in case s2885 put sb chain (8131/8111) on link2, but put 8151 on link0
} }
#endif
#if CONFIG_PCI_BUS_SEGN_BITS #if CONFIG_PCI_BUS_SEGN_BITS
max = check_segn(dev, max, sysconf.nodes, &sysconf); max = check_segn(dev, max, sysconf.nodes, &sysconf);
#endif #endif
for(link = dev->link_list; link; link = link->next) { for (link = dev->link_list; link; link = link->next) {
#if CONFIG_SB_HT_CHAIN_ON_BUS0 > 0 if ((CONFIG_SB_HT_CHAIN_ON_BUS0 > 0) && (nodeid == 0) && (link->link_num == sblink))
if( (nodeid == 0) && (sblink == link->link_num) ) continue; //already done continue;
#endif
offset_unitid = 0; unsigned offset_unitid = (CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20);
#if ((CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20)) offset_unitid = offset_unitid &&
#if CONFIG_SB_HT_CHAIN_UNITID_OFFSET_ONLY (((nodeid == 0) && (sblink == link->link_num)) || !CONFIG_SB_HT_CHAIN_UNITID_OFFSET_ONLY);
if((nodeid == 0) && (sblink == link->link_num))
#endif
offset_unitid = 1;
#endif
max = amdfam10_scan_chain(dev, nodeid, link, link->link_num, sblink, max, offset_unitid); max = amdfam10_scan_chain(dev, nodeid, link, link->link_num, sblink, max, offset_unitid);
} }

View File

@ -532,19 +532,13 @@ static int optimize_link_read_pointers_chain(uint8_t ht_c_num)
reset_needed = 0; reset_needed = 0;
/* First one is SB HT chain. */
for (i = 0; i < ht_c_num; i++) { for (i = 0; i < ht_c_num; i++) {
uint32_t reg; uint32_t reg;
uint8_t nodeid, linkn; uint8_t nodeid, linkn;
uint8_t busn; uint8_t busn;
uint8_t val; uint8_t val;
unsigned devn = 1; unsigned devn;
#if ((CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20))
#if CONFIG_SB_HT_CHAIN_UNITID_OFFSET_ONLY
if(i==0) // to check if it is sb ht chain
#endif
devn = CONFIG_HT_CHAIN_UNITID_BASE;
#endif
reg = pci_read_config32(PCI_DEV(0,0x18,1), 0xe0 + i * 4); reg = pci_read_config32(PCI_DEV(0,0x18,1), 0xe0 + i * 4);
@ -552,6 +546,11 @@ static int optimize_link_read_pointers_chain(uint8_t ht_c_num)
linkn = ((reg & 0xf00)>>8); // link n linkn = ((reg & 0xf00)>>8); // link n
busn = (reg & 0xff0000)>>16; //busn busn = (reg & 0xff0000)>>16; //busn
unsigned offset_unitid = (CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20);
offset_unitid = offset_unitid && (!CONFIG_SB_HT_CHAIN_UNITID_OFFSET_ONLY || (i == 0));
devn = offset_unitid ? CONFIG_HT_CHAIN_UNITID_BASE : 1;
reg = pci_read_config32( PCI_DEV(busn, devn, 0), PCI_VENDOR_ID); // ? the chain dev maybe offseted reg = pci_read_config32( PCI_DEV(busn, devn, 0), PCI_VENDOR_ID); // ? the chain dev maybe offseted
if ( (reg & 0xffff) == PCI_VENDOR_ID_AMD) { if ( (reg & 0xffff) == PCI_VENDOR_ID_AMD) {
val = 0x25; val = 0x25;
@ -649,14 +648,13 @@ static int ht_setup_chains(uint8_t ht_c_num)
sysinfo->link_pair_num = 0; sysinfo->link_pair_num = 0;
#endif #endif
// first one is SB Chain /* First one is SB HT chain. */
for (i = 0; i < ht_c_num; i++) { for (i = 0; i < ht_c_num; i++) {
uint32_t reg; uint32_t reg;
uint8_t devpos; uint8_t devpos;
unsigned regpos; unsigned regpos;
uint32_t dword; uint32_t dword;
uint8_t busn; uint8_t busn;
unsigned offset_unitid = 0;
reg = pci_read_config32(PCI_DEV(0,0x18,1), 0xe0 + i * 4); reg = pci_read_config32(PCI_DEV(0,0x18,1), 0xe0 + i * 4);
@ -670,13 +668,8 @@ static int ht_setup_chains(uint8_t ht_c_num)
dword |= (reg & 0xffff0000)>>8; dword |= (reg & 0xffff0000)>>8;
pci_write_config32( PCI_DEV(0, devpos,0), regpos , dword); pci_write_config32( PCI_DEV(0, devpos,0), regpos , dword);
unsigned offset_unitid = (CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20);
#if ((CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20)) offset_unitid = offset_unitid && (!CONFIG_SB_HT_CHAIN_UNITID_OFFSET_ONLY || (i == 0));
#if CONFIG_SB_HT_CHAIN_UNITID_OFFSET_ONLY
if(i==0) // to check if it is sb ht chain
#endif
offset_unitid = 1;
#endif
/* Make certain the HT bus is not enumerated */ /* Make certain the HT bus is not enumerated */
ht_collapse_previous_enumeration(busn, offset_unitid); ht_collapse_previous_enumeration(busn, offset_unitid);

View File

@ -237,33 +237,26 @@ static unsigned amdk8_scan_chains(device_t dev, unsigned max)
unsigned nodeid; unsigned nodeid;
struct bus *link; struct bus *link;
unsigned sblink = 0; unsigned sblink = 0;
unsigned offset_unitid = 0;
nodeid = amdk8_nodeid(dev); nodeid = amdk8_nodeid(dev);
if (nodeid == 0)
if(nodeid==0) {
sblink = (pci_read_config32(dev, 0x64)>>8) & 3; sblink = (pci_read_config32(dev, 0x64)>>8) & 3;
#if CONFIG_SB_HT_CHAIN_ON_BUS0 > 0
#if ((CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20)) // do sb ht chain at first, in case s2885 put sb chain (8131/8111) on link2, but put 8151 on link0
offset_unitid = 1; for (link = dev->link_list; link; link = link->next) {
#endif unsigned offset_unitid = (CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20);
for (link = dev->link_list; link; link = link->next)
if (link->link_num == sblink) if ((CONFIG_SB_HT_CHAIN_ON_BUS0 > 0) && (nodeid == 0) && (link->link_num == sblink))
max = amdk8_scan_chain(dev, nodeid, link, sblink, sblink, max, offset_unitid ); // do sb ht chain at first, in case s2885 put sb chain (8131/8111) on link2, but put 8151 on link0 max = amdk8_scan_chain(dev, nodeid, link, link->link_num, sblink, max, offset_unitid);
#endif
} }
for (link = dev->link_list; link; link = link->next) { for (link = dev->link_list; link; link = link->next) {
#if CONFIG_SB_HT_CHAIN_ON_BUS0 > 0 if ((CONFIG_SB_HT_CHAIN_ON_BUS0 > 0) && (nodeid == 0) && (link->link_num == sblink))
if( (nodeid == 0) && (sblink == link->link_num) ) continue; //already done continue;
#endif
offset_unitid = 0; unsigned offset_unitid = (CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20);
#if ((CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20)) offset_unitid = offset_unitid &&
#if CONFIG_SB_HT_CHAIN_UNITID_OFFSET_ONLY (((nodeid == 0) && (sblink == link->link_num)) || !CONFIG_SB_HT_CHAIN_UNITID_OFFSET_ONLY);
if((nodeid == 0) && (sblink == link->link_num))
#endif
offset_unitid = 1;
#endif
max = amdk8_scan_chain(dev, nodeid, link, link->link_num, sblink, max, offset_unitid); max = amdk8_scan_chain(dev, nodeid, link, link->link_num, sblink, max, offset_unitid);
} }