Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8566
-gerrit
commit d171760512e112f2bd7222521dbd4221b4ed8e86 Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Sat Mar 21 11:11:58 2015 +0200
AMD K8 fam10: HT link subordinate FIXME
Change-Id: I930f2beacdc95d0a7edd07db66a1c2e58bb2f3cd Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- src/northbridge/amd/agesa/family10/northbridge.c | 3 -- src/northbridge/amd/agesa/family15/northbridge.c | 3 -- src/northbridge/amd/amdfam10/northbridge.c | 49 ++++++++++------- src/northbridge/amd/amdk8/northbridge.c | 67 +++++++++++++++--------- 4 files changed, 72 insertions(+), 50 deletions(-)
diff --git a/src/northbridge/amd/agesa/family10/northbridge.c b/src/northbridge/amd/agesa/family10/northbridge.c index 87afa69..78d8572 100644 --- a/src/northbridge/amd/agesa/family10/northbridge.c +++ b/src/northbridge/amd/agesa/family10/northbridge.c @@ -561,7 +561,6 @@ static void amdfam10_scan_chains(device_t dev) unsigned sblink = sysconf.sblk; device_t io_hub = NULL; u32 next_unitid = 0xff; - unsigned int max = dev->bus->subordinate;
nodeid = amdfam10_nodeid(dev); if (nodeid == 0) { @@ -578,8 +577,6 @@ static void amdfam10_scan_chains(device_t dev) } max = dev->bus->subordinate; } - - dev->bus->subordinate = max; }
static struct device_operations northbridge_operations = { diff --git a/src/northbridge/amd/agesa/family15/northbridge.c b/src/northbridge/amd/agesa/family15/northbridge.c index 9c9ac02..9423344 100644 --- a/src/northbridge/amd/agesa/family15/northbridge.c +++ b/src/northbridge/amd/agesa/family15/northbridge.c @@ -465,7 +465,6 @@ static void scan_chains(device_t dev) struct bus *link; device_t io_hub = NULL; u32 next_unitid = 0x18; - unsigned int max = dev->bus->subordinate;
nodeid = amdfam15_nodeid(dev); if (nodeid == 0) { @@ -483,8 +482,6 @@ static void scan_chains(device_t dev) } max = dev->bus->subordinate; } - - dev->bus->subordinate = max; }
diff --git a/src/northbridge/amd/amdfam10/northbridge.c b/src/northbridge/amd/amdfam10/northbridge.c index a58756d..91a11bd 100644 --- a/src/northbridge/amd/amdfam10/northbridge.c +++ b/src/northbridge/amd/amdfam10/northbridge.c @@ -139,10 +139,26 @@ static void set_vga_enable_reg(u32 nodeid, u32 linkn)
}
-static void ht_route_link(struct bus *link) +typedef enum { + HT_ROUTE_CLOSE, + HT_ROUTE_SCAN, + HT_ROUTE_FINAL, +} scan_state; + +static void ht_route_link(struct bus *link, scan_state mode) { + struct bus *parent = link->dev->bus; u32 busses;
+ if (mode == HT_ROUTE_SCAN) { + if (parent->subordinate == 0) + link->secondary = 0; + else + link->secondary = parent->subordinate + 1; + + link->subordinate = link->secondary; + } + /* Configure the bus numbers for this bridge: the configuration * transactions will not be propagated by the bridge if it is * not correctly configured @@ -151,9 +167,16 @@ static void ht_route_link(struct bus *link) busses &= 0xffff00ff; busses |= ((u32)(link->secondary) << 8); pci_write_config32(link->dev, link->cap + 0x14, busses); + + if (mode == HT_ROUTE_FINAL) { + if (CONFIG_HT_CHAIN_DISTRIBUTE) + parent->subordinate = ALIGN_UP(link->subordinate, 8) - 1; + else + parent->subordinate = link->subordinate; + } }
-static u32 amdfam10_scan_chain(struct bus *link, u32 max) +static void amdfam10_scan_chain(struct bus *link) { unsigned int next_unitid;
@@ -161,24 +184,14 @@ static u32 amdfam10_scan_chain(struct bus *link, u32 max) * register in function 1. */ if (get_ht_c_index(link) >= 4) - return max; + return;
/* Set up the primary, secondary and subordinate bus numbers. * We have no idea how many busses are behind this bridge yet, * so we set the subordinate bus number to 0xff for the moment. */
- if (max != 0) - max++; - - /* One node can have 8 link and segn is the same. */ - if (CONFIG_HT_CHAIN_DISTRIBUTE) - max = ALIGN_UP(max, 8); - - link->secondary = max; - link->subordinate = 0xfc; - - ht_route_link(link); + ht_route_link(link, HT_ROUTE_SCAN);
/* set the config map space */ set_config_map_reg(link); @@ -199,12 +212,11 @@ static u32 amdfam10_scan_chain(struct bus *link, u32 max) /* Clear the extend reg. */ clear_config_map_reg(link); } + ht_route_link(link, HT_ROUTE_FINAL);
set_config_map_reg(link);
store_ht_c_conf_bus(link); - - return link->subordinate; }
/* Do sb ht chain at first, in case s2885 put sb chain @@ -248,17 +260,14 @@ static void trim_ht_chain(struct device *dev) static void amdfam10_scan_chains(device_t dev) { struct bus *link; - unsigned int max = dev->bus->subordinate;
/* Do sb ht chain at first, in case s2885 put sb chain (8131/8111) on link2, but put 8151 on link0 */ trim_ht_chain(dev);
for (link = dev->link_list; link; link = link->next) { if (link->ht_link_up) - max = amdfam10_scan_chain(link, max); + amdfam10_scan_chain(link); } - - dev->bus->subordinate = max; }
diff --git a/src/northbridge/amd/amdk8/northbridge.c b/src/northbridge/amd/amdk8/northbridge.c index 0869964..fa2dcb7 100644 --- a/src/northbridge/amd/amdk8/northbridge.c +++ b/src/northbridge/amd/amdk8/northbridge.c @@ -79,20 +79,53 @@ static void f1_write_config32(unsigned reg, u32 value) } }
-static void ht_route_link(struct bus *link) +typedef enum { + HT_ROUTE_CLOSE, + HT_ROUTE_SCAN, + HT_ROUTE_FINAL, +} scan_state; + +static void ht_route_link(struct bus *link, scan_state mode) { + struct device *dev = link->dev; + struct bus *parent = dev->bus; u32 busses;
+ if (mode == HT_ROUTE_SCAN) { + if (link->dev->bus->subordinate == 0) + link->secondary = 0; + else + link->secondary = parent->subordinate + 1; + + link->subordinate = link->secondary; + } + /* Configure the bus numbers for this bridge: the configuration * transactions will not be propagated by the bridge if it is * not correctly configured */ busses = pci_read_config32(link->dev, link->cap + 0x14); busses &= 0xff000000; - busses |= (((unsigned int)(link->dev->bus->secondary) << 0) | - ((unsigned int)(link->secondary) << 8) | - ((unsigned int)(link->subordinate) << 16)); + busses |= parent->secondary & 0xff; + if (mode == HT_ROUTE_CLOSE) { + busses |= 0xfeff << 8; + } else if (mode == HT_ROUTE_SCAN) { + busses |= ((u32) link->secondary & 0xff) << 8; + busses |= 0xff << 16; /* MAX PCI_BUS number here */ + } else if (mode == HT_ROUTE_FINAL) { + busses |= ((u32) link->secondary & 0xff) << 8; + busses |= ((u32) link->subordinate & 0xff) << 16; + } + pci_write_config32(link->dev, link->cap + 0x14, busses); + + if (mode == HT_ROUTE_FINAL) { + /* Second chain will be on 0x40, third 0x80, forth 0xc0. */ + if (CONFIG_HT_CHAIN_DISTRIBUTE) + parent->subordinate = ALIGN_UP(link->subordinate, 0x40) - 1; + else + parent->subordinate = link->subordinate; + } }
static u32 amdk8_nodeid(device_t dev) @@ -100,7 +133,7 @@ static u32 amdk8_nodeid(device_t dev) return (dev->path.pci.devfn >> 3) - 0x18; }
-static u32 amdk8_scan_chain(struct bus *link, u32 max) +static void amdk8_scan_chain(struct bus *link) { unsigned int next_unitid; int index; @@ -132,7 +165,7 @@ static u32 amdk8_scan_chain(struct bus *link, u32 max) * register skip this bus */ if (config_reg > 0xec) { - return max; + return; }
/* Set up the primary, secondary and subordinate bus numbers. @@ -140,17 +173,7 @@ static u32 amdk8_scan_chain(struct bus *link, u32 max) * so we set the subordinate bus number to 0xff for the moment. */
- if (max != 0) - max++; - - /* Second chain will be on 0x40, third 0x80, forth 0xc0. */ - if (CONFIG_HT_CHAIN_DISTRIBUTE) - max = ALIGN_UP(max, 0x40); - - link->secondary = max; - link->subordinate = 0xff; - - ht_route_link(link); + ht_route_link(link, HT_ROUTE_SCAN);
config_busses = f1_read_config32(config_reg); config_busses &= 0x000fc88; @@ -174,7 +197,8 @@ static u32 amdk8_scan_chain(struct bus *link, u32 max) /* We know the number of busses behind this bridge. Set the * subordinate bus number to it's real value */ - ht_route_link(link); + + ht_route_link(link, HT_ROUTE_FINAL);
config_busses = (config_busses & 0x00ffffff) | (link->subordinate << 24); @@ -182,8 +206,6 @@ static u32 amdk8_scan_chain(struct bus *link, u32 max)
index = (config_reg-0xe0) >> 2; sysconf.hcdn_reg[index] = link->hcdn_reg; - - return link->subordinate; }
/* Do sb ht chain at first, in case s2885 put sb chain @@ -227,16 +249,13 @@ static void trim_ht_chain(struct device *dev) static void amdk8_scan_chains(device_t dev) { struct bus *link; - unsigned int max = dev->bus->subordinate;
trim_ht_chain(dev);
for (link = dev->link_list; link; link = link->next) { if (link->ht_link_up) - max = amdk8_scan_chain(link, max); + amdk8_scan_chain(link); } - - dev->bus->subordinate = max; }