In the progress of getting hypertransport setup completely dynamic, I
made the following patch that completely gets rid of the CONNECTION
and link name macros in coherent_ht.c
(UP, ACROSS, DOWN and CONNECTION_0_1, CONNECTION_0_2, CONNECTION_1_3)
Therefore I added two simple helper functions that gain the needed
information from generate_row().
This patch probably raises the register pressure during ht setup, but
even on a 4p machine I could not see any problems with romcc. 
Dropping another couple of hardcodes seems like the right thing to
do[tm].

If nobody is opposing, I am going to check this into CVS.

  Stefan


-- 
  Stefan Reinauer, SUSE LINUX AG
Head of Architecture Development
Index: coherent_ht.c
===================================================================
RCS file: /cvsroot/freebios/freebios2/src/northbridge/amd/amdk8/coherent_ht.c,v
retrieving revision 1.23
diff -u -r1.23 coherent_ht.c
--- coherent_ht.c       12 Mar 2004 12:18:25 -0000      1.23
+++ coherent_ht.c       24 Mar 2004 17:15:55 -0000
@@ -20,33 +20,6 @@
 #include "arch/romcc_io.h"
 #include "amdk8.h"
 
-/*
- * Until we have a completely dynamic setup we want
- * to be able to map different cpu graphs.
- */
-
-#define UP     0x00
-#define ACROSS 0x20
-#define DOWN   0x40
-
-/* 
- * set some default values. These are used if they are not
- * differently defined in the motherboard's auto.c file.
- * See src/mainboard/amd/quartet/auto.c for an example.
- */
-
-#ifndef CONNECTION_0_1 
-#define CONNECTION_0_1 ACROSS
-#endif
-
-#ifndef CONNECTION_0_2 
-#define CONNECTION_0_2 UP
-#endif
-
-#ifndef CONNECTION_1_3 
-#define CONNECTION_1_3 UP
-#endif
-
 /* when generating a temporary row configuration we
  * don't want broadcast to be enabled for that node.
  */
@@ -68,6 +41,34 @@
 #define TRUE  (-1)
 #define FALSE (0)
 
+static u8 link_to_register(int ldt)
+{
+       /*
+        * [ 0: 3] Request Route
+        *     [0] Route to this node
+        *     [1] Route to Link 0
+        *     [2] Route to Link 1
+        *     [3] Route to Link 2
+        */
+
+       if (ldt&0x08) return 0x40;
+       if (ldt&0x04) return 0x20;
+       if (ldt&0x02) return 0x00;
+       
+       /* we should never get here */
+       print_debug("Unknown Link\n");
+       return 0;
+}
+
+static int link_connection(int src, int dest)
+{
+       /* we generate the needed link information from the rows
+        * by taking the Request Route of the according row.
+        */
+       
+       return generate_row(src, dest, CONFIG_MAX_CPUS) & 0x0f;
+}
+
 static void disable_probes(void)
 {
        /* disable read/write/fill probes for uniprocessor setup
@@ -367,7 +368,7 @@
        /* Setup and check a temporary connection to node 1 */
        setup_temp_row(0, 1, result.cpus);
        
-       if (!check_connection(0, 7, CONNECTION_0_1)) {
+       if (!check_connection(0, 7, link_to_register(link_connection(0,1)))) {
                print_debug("No connection to Node 1.\r\n");
                clear_temp_row(0);      /* delete temp connection */
                setup_uniprocessor();   /* and get up working     */
@@ -376,8 +377,10 @@
        }
 
        /* We found 2 nodes so far */
-       result.needs_reset = 
-               optimize_connection(NODE_HT(0), 0x80 + CONNECTION_0_1, NODE_HT(7), 
0x80 + CONNECTION_0_1);
+       result.needs_reset = optimize_connection(
+               NODE_HT(0), 0x80 + link_to_register(link_connection(0,1)),
+               NODE_HT(7), 0x80 + link_to_register(link_connection(1,0)) );
+               
        setup_node(0, result.cpus);     /* Node 1 is there. Setup Node 0 correctly */
        setup_remote_node(1, result.cpus);  /* Setup the routes on the remote node */
         rename_temp_node(1);    /* Rename Node 7 to Node 1  */
@@ -391,7 +394,7 @@
        /* Setup and check temporary connection from Node 0 to Node 2 */
        setup_temp_row(0,2, result.cpus);
 
-       if (!check_connection(0, 7, CONNECTION_0_2)) {
+       if (!check_connection(0, 7, link_to_register(link_connection(0,2))) ) {
                print_debug("No connection to Node 2.\r\n");
                clear_temp_row(0);       /* delete temp connection */
                result.cpus = 2;
@@ -405,7 +408,7 @@
        setup_temp_row(0,1, result.cpus); /* temp. link between nodes 0 and 1 */
        setup_temp_row(1,3, result.cpus); /* temp. link between nodes 1 and 3 */
 
-       if (!check_connection(1, 7, CONNECTION_1_3)) {
+       if (!check_connection(1, 7, link_to_register(link_connection(1,3)))) {
                print_debug("No connection to Node 3.\r\n");
                clear_temp_row(0);       /* delete temp connection */
                clear_temp_row(1);       /* delete temp connection */

Reply via email to