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>
This commit is contained in:
parent
f5e7fa22e7
commit
26c664759b
|
@ -18,4 +18,11 @@
|
|||
#define HT_FREQ_2600Mhz 14
|
||||
#define HT_FREQ_VENDOR 15 /* AMD defines this to be 100Mhz */
|
||||
|
||||
|
||||
static inline bool offset_unit_id(bool is_sb_ht_chain)
|
||||
{
|
||||
bool need_offset = (CONFIG_HT_CHAIN_UNITID_BASE != 1) || (CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20);
|
||||
return need_offset && (!CONFIG_SB_HT_CHAIN_UNITID_OFFSET_ONLY || is_sb_ht_chain);
|
||||
}
|
||||
|
||||
#endif /* DEVICE_HYPERTRANSPORT_DEF_H */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue