summaryrefslogtreecommitdiff
path: root/src/northbridge
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2015-02-04 13:09:06 +0200
committerKyösti Mälkki <kyosti.malkki@gmail.com>2015-02-20 07:04:00 +0100
commit26c664759b53cca1de4bbb4c517fc65f4ca079c4 (patch)
treeb762375d053c9fd6f5264245aab35325dc9807e7 /src/northbridge
parentf5e7fa22e7f1d4292d26e72e4a801cb4c6669e26 (diff)
downloadcoreboot-26c664759b53cca1de4bbb4c517fc65f4ca079c4.tar.xz
AMD K8 fam10: Refactor offset_unitid configuration
Change-Id: I198f2ad321e1a8b6d932f5624b129e312e36a309 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/8349 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Diffstat (limited to 'src/northbridge')
-rw-r--r--src/northbridge/amd/amdfam10/northbridge.c23
-rw-r--r--src/northbridge/amd/amdk8/incoherent_ht.c14
-rw-r--r--src/northbridge/amd/amdk8/northbridge.c24
3 files changed, 24 insertions, 37 deletions
diff --git a/src/northbridge/amd/amdfam10/northbridge.c b/src/northbridge/amd/amdfam10/northbridge.c
index 8f6d6f9bed..275c79cdf2 100644
--- a/src/northbridge/amd/amdfam10/northbridge.c
+++ b/src/northbridge/amd/amdfam10/northbridge.c
@@ -140,8 +140,8 @@ static void set_vga_enable_reg(u32 nodeid, u32 linkn)
}
-static u32 amdfam10_scan_chain(device_t dev, u32 nodeid, struct bus *link, u32 sblink,
- u32 max, u32 offset_unitid)
+static u32 amdfam10_scan_chain(device_t dev, u32 nodeid, struct bus *link, bool is_sblink,
+ u32 max)
{
// I want to put sb chain in bus 0 can I?
@@ -197,7 +197,7 @@ static u32 amdfam10_scan_chain(device_t dev, u32 nodeid, struct bus *link, u32 s
*/
#if CONFIG_SB_HT_CHAIN_ON_BUS0 > 0
// first chain will on bus 0
- if((nodeid == 0) && (sblink==link->link_num)) { // actually max is 0 here
+ if (is_sblink) { // actually max is 0 here
min_bus = max;
}
#if CONFIG_SB_HT_CHAIN_ON_BUS0 > 1
@@ -253,7 +253,7 @@ static u32 amdfam10_scan_chain(device_t dev, u32 nodeid, struct bus *link, u32 s
else
max_devfn = (0x1f<<3) | 7;
- max = hypertransport_scan_chain(link, 0, max_devfn, max, ht_unitid_base, offset_unitid);
+ max = hypertransport_scan_chain(link, 0, max_devfn, max, ht_unitid_base, offset_unit_id(is_sblink));
/* We know the number of busses behind this bridge. Set the
* subordinate bus number to it's real value
@@ -290,9 +290,9 @@ static unsigned amdfam10_scan_chains(device_t dev, unsigned max)
/* Do sb ht chain at first, in case s2885 put sb chain (8131/8111) on link2, but put 8151 on link0 */
for (link = dev->link_list; link; link = link->next) {
- unsigned offset_unitid = (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))
- max = amdfam10_scan_chain(dev, nodeid, link, sblink, max, offset_unitid);
+ bool is_sblink = (nodeid == 0) && (link->link_num == sblink);
+ if ((CONFIG_SB_HT_CHAIN_ON_BUS0 > 0) && is_sblink)
+ max = amdfam10_scan_chain(dev, nodeid, link, is_sblink, max);
}
#if CONFIG_PCI_BUS_SEGN_BITS
@@ -300,14 +300,11 @@ static unsigned amdfam10_scan_chains(device_t dev, unsigned max)
#endif
for (link = dev->link_list; link; link = link->next) {
- if ((CONFIG_SB_HT_CHAIN_ON_BUS0 > 0) && (nodeid == 0) && (link->link_num == sblink))
+ bool is_sblink = (nodeid == 0) && (link->link_num == sblink);
+ if ((CONFIG_SB_HT_CHAIN_ON_BUS0 > 0) && is_sblink)
continue;
- unsigned offset_unitid = (CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20);
- offset_unitid = offset_unitid &&
- (((nodeid == 0) && (sblink == link->link_num)) || !CONFIG_SB_HT_CHAIN_UNITID_OFFSET_ONLY);
-
- max = amdfam10_scan_chain(dev, nodeid, link, sblink, max, offset_unitid);
+ max = amdfam10_scan_chain(dev, nodeid, link, is_sblink, max);
}
return max;
}
diff --git a/src/northbridge/amd/amdk8/incoherent_ht.c b/src/northbridge/amd/amdk8/incoherent_ht.c
index 40589c475c..d765fc7003 100644
--- a/src/northbridge/amd/amdk8/incoherent_ht.c
+++ b/src/northbridge/amd/amdk8/incoherent_ht.c
@@ -546,10 +546,7 @@ static int optimize_link_read_pointers_chain(uint8_t ht_c_num)
linkn = ((reg & 0xf00)>>8); // link n
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;
+ devn = offset_unit_id(i == 0) ? CONFIG_HT_CHAIN_UNITID_BASE : 1;
reg = pci_read_config32( PCI_DEV(busn, devn, 0), PCI_VENDOR_ID); // ? the chain dev maybe offseted
if ( (reg & 0xffff) == PCI_VENDOR_ID_AMD) {
@@ -668,19 +665,16 @@ static int ht_setup_chains(uint8_t ht_c_num)
dword |= (reg & 0xffff0000)>>8;
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);
- offset_unitid = offset_unitid && (!CONFIG_SB_HT_CHAIN_UNITID_OFFSET_ONLY || (i == 0));
-
/* Make certain the HT bus is not enumerated */
- ht_collapse_previous_enumeration(busn, offset_unitid);
+ ht_collapse_previous_enumeration(busn, offset_unit_id(i == 0));
upos = ((reg & 0xf00)>>8) * 0x20 + 0x80;
udev = PCI_DEV(0, devpos, 0);
#if CONFIG_RAMINIT_SYSINFO
- ht_setup_chainx(udev,upos,busn, offset_unitid, sysinfo); // all not
+ ht_setup_chainx(udev,upos,busn, offset_unit_id(i == 0), sysinfo); // all not
#else
- reset_needed |= ht_setup_chainx(udev,upos,busn, offset_unitid); //all not
+ reset_needed |= ht_setup_chainx(udev,upos,busn, offset_unit_id(i == 0)); //all not
#endif
}
diff --git a/src/northbridge/amd/amdk8/northbridge.c b/src/northbridge/amd/amdk8/northbridge.c
index 67856590e7..29fa2a42a6 100644
--- a/src/northbridge/amd/amdk8/northbridge.c
+++ b/src/northbridge/amd/amdk8/northbridge.c
@@ -84,8 +84,8 @@ static u32 amdk8_nodeid(device_t dev)
return (dev->path.pci.devfn >> 3) - 0x18;
}
-static u32 amdk8_scan_chain(device_t dev, u32 nodeid, struct bus *link, u32 sblink,
- u32 max, u32 offset_unitid)
+static u32 amdk8_scan_chain(device_t dev, u32 nodeid, struct bus *link, bool is_sblink,
+ u32 max)
{
u32 link_type;
@@ -143,7 +143,7 @@ static u32 amdk8_scan_chain(device_t dev, u32 nodeid, struct bus *link, u32 sbli
*/
#if CONFIG_SB_HT_CHAIN_ON_BUS0 > 0
// first chain will on bus 0
- if((nodeid == 0) && (sblink==link->link_num)) { // actually max is 0 here
+ if(is_sblink) { // actually max is 0 here
min_bus = max;
}
#if CONFIG_SB_HT_CHAIN_ON_BUS0 > 1
@@ -203,7 +203,7 @@ static u32 amdk8_scan_chain(device_t dev, u32 nodeid, struct bus *link, u32 sbli
else
max_devfn = (0x1f<<3) | 7;
- max = hypertransport_scan_chain(link, 0, max_devfn, max, ht_unitid_base, offset_unitid);
+ max = hypertransport_scan_chain(link, 0, max_devfn, max, ht_unitid_base, offset_unit_id(is_sblink));
/* We know the number of busses behind this bridge. Set the
* subordinate bus number to it's real value
@@ -244,21 +244,17 @@ static unsigned amdk8_scan_chains(device_t dev, unsigned max)
// do sb ht chain at first, in case s2885 put sb chain (8131/8111) on link2, but put 8151 on link0
for (link = dev->link_list; link; link = link->next) {
- unsigned offset_unitid = (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))
- max = amdk8_scan_chain(dev, nodeid, link, sblink, max, offset_unitid);
+ bool is_sblink = (nodeid == 0) && (link->link_num == sblink);
+ if ((CONFIG_SB_HT_CHAIN_ON_BUS0 > 0) && is_sblink)
+ max = amdk8_scan_chain(dev, nodeid, link, is_sblink, max);
}
for (link = dev->link_list; link; link = link->next) {
- if ((CONFIG_SB_HT_CHAIN_ON_BUS0 > 0) && (nodeid == 0) && (link->link_num == sblink))
+ bool is_sblink = (nodeid == 0) && (link->link_num == sblink);
+ if ((CONFIG_SB_HT_CHAIN_ON_BUS0 > 0) && is_sblink)
continue;
- unsigned offset_unitid = (CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20);
- offset_unitid = offset_unitid &&
- (((nodeid == 0) && (sblink == link->link_num)) || !CONFIG_SB_HT_CHAIN_UNITID_OFFSET_ONLY);
-
- max = amdk8_scan_chain(dev, nodeid, link, sblink, max, offset_unitid);
+ max = amdk8_scan_chain(dev, nodeid, link, is_sblink, max);
}
return max;
}