1/* $Id: klgraph_hack.c,v 1.1.1.1 2008/10/15 03:26:03 james26_jang Exp $ 2 * 3 * This file is subject to the terms and conditions of the GNU General Public 4 * License. See the file "COPYING" in the main directory of this archive 5 * for more details. 6 * 7 * Copyright (C) 1992 - 1997, 2000-2002 Silicon Graphics, Inc. All rights reserved. 8 */ 9 10 11/* 12 * This is a temporary file that statically initializes the expected 13 * initial klgraph information that is normally provided by prom. 14 */ 15 16#include <linux/types.h> 17#include <linux/slab.h> 18#include <linux/vmalloc.h> 19#include <asm/sn/sgi.h> 20#include <asm/sn/io.h> 21#include <asm/sn/klconfig.h> 22 23void * real_port; 24void * real_io_base; 25void * real_addr; 26 27char *BW0 = NULL; 28 29kl_config_hdr_t *linux_klcfg; 30 31#ifdef DEFINE_DUMP_RTNS 32/* forward declarations */ 33static void dump_ii(void), dump_crossbow(void); 34static void clear_ii_error(void); 35#endif /* DEFINE_DUMP_RTNS */ 36 37#define SYNERGY_WIDGET ((char *)0xc0000e0000000000) 38#define SYNERGY_SWIZZLE ((char *)0xc0000e0000000400) 39#define HUBREG ((char *)0xc0000a0001e00000) 40#define WIDGET0 ((char *)0xc0000a0000000000) 41#define WIDGET4 ((char *)0xc0000a0000000004) 42 43#define SYNERGY_WIDGET ((char *)0xc0000e0000000000) 44#define SYNERGY_SWIZZLE ((char *)0xc0000e0000000400) 45#define HUBREG ((char *)0xc0000a0001e00000) 46#define WIDGET0 ((char *)0xc0000a0000000000) 47 48void 49klgraph_hack_init(void) 50{ 51 52 /* 53 * We need to know whether we are booting from PROM or 54 * boot from disk. 55 */ 56 linux_klcfg = (kl_config_hdr_t *)0xe000000000030000; 57 if (linux_klcfg->ch_magic == 0xbeedbabe) { 58 return; 59 } else { 60 panic("klgraph_hack_init: Unable to locate KLCONFIG TABLE\n"); 61 } 62 63} 64 65 66 67 68 69#ifdef DEFINE_DUMP_RTNS 70/* 71 * these were useful for printing out registers etc 72 * during bringup 73 */ 74 75static void 76xdump(long long *addr, int count) 77{ 78 int ii; 79 volatile long long *xx = addr; 80 81 for ( ii = 0; ii < count; ii++, xx++ ) { 82 printk("0x%p : 0x%p\n", (void *)xx, (void *)*xx); 83 } 84} 85 86static void 87xdump32(unsigned int *addr, int count) 88{ 89 int ii; 90 volatile unsigned int *xx = addr; 91 92 for ( ii = 0; ii < count; ii++, xx++ ) { 93 printk("0x%p : 0x%0x\n", (void *)xx, (int)*xx); 94 } 95} 96 97static void 98clear_ii_error(void) 99{ 100 volatile long long *tmp; 101 102 printk("... WSTAT "); 103 xdump((long long *)0xc0000a0001c00008, 1); 104 printk("... WCTRL "); 105 xdump((long long *)0xc0000a0001c00020, 1); 106 printk("... WLCSR "); 107 xdump((long long *)0xc0000a0001c00128, 1); 108 printk("... IIDSR "); 109 xdump((long long *)0xc0000a0001c00138, 1); 110 printk("... IOPRBs "); 111 xdump((long long *)0xc0000a0001c00198, 9); 112 printk("... IXSS "); 113 xdump((long long *)0xc0000a0001c00210, 1); 114 printk("... IBLS0 "); 115 xdump((long long *)0xc0000a0001c10000, 1); 116 printk("... IBLS1 "); 117 xdump((long long *)0xc0000a0001c20000, 1); 118 119 /* Write IOERR clear to clear the CRAZY bit in the status */ 120 tmp = (long long *)0xc0000a0001c001f8; *tmp = (long long)0xffffffff; 121 122 /* dump out local block error registers */ 123 printk("... "); 124 xdump((long long *)0xc0000a0001e04040, 1); /* LB_ERROR_BITS */ 125 printk("... "); 126 xdump((long long *)0xc0000a0001e04050, 1); /* LB_ERROR_HDR1 */ 127 printk("... "); 128 xdump((long long *)0xc0000a0001e04058, 1); /* LB_ERROR_HDR2 */ 129 /* and clear the LB_ERROR_BITS */ 130 tmp = (long long *)0xc0000a0001e04040; *tmp = 0x0; 131 printk("clr: "); 132 xdump((long long *)0xc0000a0001e04040, 1); /* LB_ERROR_BITS */ 133 tmp = (long long *)0xc0000a0001e04050; *tmp = 0x0; 134 tmp = (long long *)0xc0000a0001e04058; *tmp = 0x0; 135} 136 137 138static void 139dump_ii(void) 140{ 141 printk("===== Dump the II regs =====\n"); 142 xdump((long long *)0xc0000a0001c00000, 2); 143 xdump((long long *)0xc0000a0001c00020, 1); 144 xdump((long long *)0xc0000a0001c00100, 37); 145 xdump((long long *)0xc0000a0001c00300, 98); 146 xdump((long long *)0xc0000a0001c10000, 6); 147 xdump((long long *)0xc0000a0001c20000, 6); 148 xdump((long long *)0xc0000a0001c30000, 2); 149 150 xdump((long long *)0xc0000a0000000000, 1); 151 xdump((long long *)0xc0000a0001000000, 1); 152 xdump((long long *)0xc0000a0002000000, 1); 153 xdump((long long *)0xc0000a0003000000, 1); 154 xdump((long long *)0xc0000a0004000000, 1); 155 xdump((long long *)0xc0000a0005000000, 1); 156 xdump((long long *)0xc0000a0006000000, 1); 157 xdump((long long *)0xc0000a0007000000, 1); 158 xdump((long long *)0xc0000a0008000000, 1); 159 xdump((long long *)0xc0000a0009000000, 1); 160 xdump((long long *)0xc0000a000a000000, 1); 161 xdump((long long *)0xc0000a000b000000, 1); 162 xdump((long long *)0xc0000a000c000000, 1); 163 xdump((long long *)0xc0000a000d000000, 1); 164 xdump((long long *)0xc0000a000e000000, 1); 165 xdump((long long *)0xc0000a000f000000, 1); 166} 167 168static void 169dump_crossbow(void) 170{ 171 printk("===== Dump the Crossbow regs =====\n"); 172 clear_ii_error(); 173 xdump32((unsigned int *)0xc0000a0000000004, 1); 174 clear_ii_error(); 175 xdump32((unsigned int *)0xc0000a0000000000, 1); 176 printk("and again..\n"); 177 xdump32((unsigned int *)0xc0000a0000000000, 1); 178 xdump32((unsigned int *)0xc0000a0000000000, 1); 179 180 181 clear_ii_error(); 182 183 xdump32((unsigned int *)0xc000020000000004, 1); 184 clear_ii_error(); 185 xdump32((unsigned int *)0xc000020000000000, 1); 186 clear_ii_error(); 187 188 xdump32((unsigned int *)0xc0000a0000800004, 1); 189 clear_ii_error(); 190 xdump32((unsigned int *)0xc0000a0000800000, 1); 191 clear_ii_error(); 192 193 xdump32((unsigned int *)0xc000020000800004, 1); 194 clear_ii_error(); 195 xdump32((unsigned int *)0xc000020000800000, 1); 196 clear_ii_error(); 197 198 199} 200#endif /* DEFINE_DUMP_RTNS */ 201