From 8f8f14b136cd82ae739231100463f5508241bad1 Mon Sep 17 00:00:00 2001 From: "Ronald G. Minnich" Date: Mon, 6 Oct 2008 17:14:41 +0000 Subject: [PATCH] Changes to make a get_nodes that can be built into stage1 and (for m57sli) add incoherent ht chain support to stage1 as well. dbe62 was tested and works i.e. this does no harm. Signed-off-by: Ronald G. Minnich Acked-by: Ronald G. Minnich git-svn-id: svn://coreboot.org/repository/coreboot-v3@895 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- northbridge/amd/k8/coherent_ht.c | 11 --- northbridge/amd/k8/get_nodes.c | 49 ++++++++++++ northbridge/amd/k8/incoherent_ht_chain.c | 98 ++++++++++++++++++++++++ 3 files changed, 147 insertions(+), 11 deletions(-) create mode 100644 northbridge/amd/k8/get_nodes.c create mode 100644 northbridge/amd/k8/incoherent_ht_chain.c diff --git a/northbridge/amd/k8/coherent_ht.c b/northbridge/amd/k8/coherent_ht.c index 2536623a94..56437d6de2 100644 --- a/northbridge/amd/k8/coherent_ht.c +++ b/northbridge/amd/k8/coherent_ht.c @@ -1689,17 +1689,6 @@ int optimize_link_read_pointers(unsigned nodes) return needs_reset; } -/** - * get_nodes - * see page 46 of the BKDG Publication # 26094 Revision: 3.30 Issue Date: February 2006 - * @returns an int containing the number of nodes. - * The format of the register is 32 bits, and the node count is in bits 4-6 - */ -unsigned int get_nodes(void) -{ - return ((pci_conf1_read_config32(PCI_BDF(0, 0x18, 0), NODEID)>>4) & 7) + 1; -} - int optimize_link_coherent_ht(void) { int needs_reset = 0; diff --git a/northbridge/amd/k8/get_nodes.c b/northbridge/amd/k8/get_nodes.c new file mode 100644 index 0000000000..ec73520e4a --- /dev/null +++ b/northbridge/amd/k8/get_nodes.c @@ -0,0 +1,49 @@ +/* + * coherent hypertransport initialization for AMD64 + * This file is part of the coreboot project. + * + * written by Stefan Reinauer + * (c) 2003-2004 by SuSE Linux AG + * + * (c) 2004 Tyan Computer + * 2004.12 yhlu added support to create routing table dynamically. + * it also support 8 ways too. (8 ways ladder or 8 ways crossbar) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * get_nodes + * see page 46 of the BKDG Publication # 26094 Revision: 3.30 Issue Date: February 2006 + * @returns an int containing the number of nodes. + * The format of the register is 32 bits, and the node count is in bits 4-6 + */ +unsigned int get_nodes(void) +{ + return ((pci_conf1_read_config32(PCI_BDF(0, 0x18, 0), NODEID)>>4) & 7) + 1; +} + diff --git a/northbridge/amd/k8/incoherent_ht_chain.c b/northbridge/amd/k8/incoherent_ht_chain.c new file mode 100644 index 0000000000..e9ab7929f6 --- /dev/null +++ b/northbridge/amd/k8/incoherent_ht_chain.c @@ -0,0 +1,98 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2002 Linux Networx + * (Written by Eric Biederman for Linux Networx) + * Copyright (C) 2004 YingHai Lu + * Copyright (C) 2008 Ronald G. Minnich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA + */ +/* + This should be done by Eric + 2004.12 yhlu add multi ht chain dynamically support + 2005.11 yhlu add let real sb to use small unitid +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int set_ht_link_buffer_count(u8 node, u8 linkn, u8 linkt, unsigned val) +{ + u32 dword; + u8 link_type; + unsigned regpos; + u32 bdf; + + /* This works on an Athlon64 because unimplemented links return 0 */ + regpos = 0x98 + (linkn * 0x20); + bdf = PCI_BDF(0,0x18+node,0); + dword = pci_conf1_read_config32(bdf, regpos); + link_type = dword & 0xff; + + if ( (link_type & 0x7) == linkt ) { /* Coherent Link only linkt = 3, ncoherent = 7*/ + regpos = 0x90 + (linkn * 0x20); + dword = pci_conf1_read_config32(bdf, regpos ); + + if (dword != val) { + pci_conf1_write_config32(bdf, regpos, val); + return 1; + } + } + + return 0; +} + +int set_ht_link_buffer_counts_chain(u8 ht_c_num, unsigned vendorid, unsigned val) +{ + int reset_needed; + u8 i; + + reset_needed = 0; + + for (i = 0; i < ht_c_num; i++) { + u32 reg; + u8 nodeid, linkn; + u8 busn; + unsigned devn; + + reg = pci_conf1_read_config32(PCI_BDF(0,0x18,1), 0xe0 + i * 4); + if((reg & 3) != 3) continue; // not enabled + + nodeid = ((reg & 0xf0)>>4); // nodeid + linkn = ((reg & 0xf00)>>8); // link n + busn = (reg & 0xff0000)>>16; //busn + + for(devn = 0; devn < 0x20; devn++) { + reg = pci_conf1_read_config32( PCI_BDF(busn, devn, 0), PCI_VENDOR_ID); //1? + if ( (reg & 0xffff) == vendorid ) { + reset_needed |= set_ht_link_buffer_count(nodeid, linkn, 0x07,val); + break; + } + } + } + + return reset_needed; +} +