1 /* 2 * Copyright (c) 1992 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Sony Corp. and Kazumasa Utashiro of Software Research Associates, Inc. 7 * 8 * %sccs.include.redist.c% 9 * 10 * from: $Hdr: fb_probe.c,v 4.300 91/06/09 06:32:57 root Rel41 $ SONY 11 * 12 * @(#)fb_probe.c 7.1 (Berkeley) 06/04/92 13 */ 14 15 #include "../include/fix_machine_type.h" 16 17 #ifdef IPC_MRX 18 #include "../../iop/framebuf.h" 19 #include "types.h" 20 #include "exec.h" 21 #include "romsw.h" 22 #else 23 #include "../iop/framebuf.h" 24 #include "types.h" 25 #include "exec.h" 26 #endif 27 28 #include "../fb/fbdefs.h" 29 30 #ifdef CPU_SINGLE 31 #define SW_CONSOLE 0x07 32 #define SW_NWB512 0x04 33 #define SW_NWB225 0x01 34 #define SW_FBPOP 0x02 35 #define SW_FBPOP1 0x06 36 #define SW_FBPOP2 0x03 37 #define SW_AUTOSEL 0x07 38 #endif 39 40 struct fbdev *consfb; 41 int nfbdev = 0; 42 43 static int cons_dev = -1; 44 extern struct fbdevsw fbdevsw[]; 45 46 #if defined(news1700) 47 struct autodev autodev[] = { 48 -1, (char *)0xf0600000, (char *)0xf0610000, 49 -1, (char *)0xf0620000, (char *)0xf0630000, 50 -1, (char *)0xf0640000, (char *)0xf0650000, 51 -1, (char *)0xf0660000, (char *)0xf0670000, 52 -1, (char *)0xf0680000, (char *)0xf0690000, 53 -1, (char *)0xf06a0000, (char *)0xf06b0000, 54 -1, (char *)0xf06c0000, (char *)0xf06d0000, 55 -1, (char *)0xf06e0000, (char *)0xf06f0000, 56 }; 57 58 #define AUTOSEL 1 59 #endif /* defined(news1700) */ 60 61 #ifdef news1800 62 struct autodev autodev[] = { 63 -1, (char *)0x20600000, (char *)0x20610000, 64 -1, (char *)0x20620000, (char *)0x20630000, 65 -1, (char *)0x20640000, (char *)0x20650000, 66 -1, (char *)0x20660000, (char *)0x20670000, 67 -1, (char *)0x20680000, (char *)0x20690000, 68 -1, (char *)0x206a0000, (char *)0x206b0000, 69 -1, (char *)0x206c0000, (char *)0x206d0000, 70 -1, (char *)0x206e0000, (char *)0x206f0000, 71 }; 72 73 #define AUTOSEL 1 74 #endif /* news1800 */ 75 76 #ifdef news3400 77 struct autodev autodev[] = { 78 -1, (char *)0xb8600000, (char *)0xb8610000, 79 -1, (char *)0xb8620000, (char *)0xb8630000, 80 -1, (char *)0xb8640000, (char *)0xb8650000, 81 -1, (char *)0xb8660000, (char *)0xb8670000, 82 -1, (char *)0xb8680000, (char *)0xb8690000, 83 -1, (char *)0xb86a0000, (char *)0xb86b0000, 84 -1, (char *)0xb86c0000, (char *)0xb86d0000, 85 -1, (char *)0xb86e0000, (char *)0xb86f0000, 86 }; 87 88 #define AUTOSEL 1 89 #endif /* news3400 */ 90 91 #ifdef news3800 92 struct autodev autodev[] = { 93 -1, (char *)0xee600000, (char *)0xee610000, 94 -1, (char *)0xee620000, (char *)0xee630000, 95 -1, (char *)0xee640000, (char *)0xee650000, 96 -1, (char *)0xee660000, (char *)0xee670000, 97 -1, (char *)0xee680000, (char *)0xee690000, 98 -1, (char *)0xee6a0000, (char *)0xee6b0000, 99 -1, (char *)0xee6c0000, (char *)0xee6d0000, 100 -1, (char *)0xee6e0000, (char *)0xee6f0000, 101 }; 102 103 #define AUTOSEL 1 104 #endif /* news3800 */ 105 106 search_fbdev(type, unit) 107 int type; 108 int unit; 109 { 110 register int i; 111 112 if (type == 0) { 113 if (cons_dev < 0) 114 return (unit < nfbdev ? unit : -1); 115 if (unit == 0) 116 return (cons_dev); 117 for (i = 0; i < nfbdev; i++) 118 if (i != cons_dev && --unit == 0) 119 return (i); 120 } else { 121 for (i = 0; i < nfbdev; i++) 122 if (fbdev[i].type == type && fbdev[i].unit == unit) 123 return(i); 124 } 125 return (-1); 126 } 127 128 #ifdef AUTOSEL 129 search_autocons() 130 { 131 register int i; 132 133 for (i = 0; i < 8; i++) 134 if (autodev[i].type != -1) 135 return (autodev[i].type); 136 return (-1); 137 } 138 139 fb_auto_probe() 140 { 141 register int i; 142 143 for (i = 0; i < 8; i++) { 144 if (badaddr(autodev[i].base, 1)) { 145 autodev[i].type = -1; 146 continue; 147 } 148 if (*(long *)autodev[i].base != OMAGIC) { 149 autodev[i].type = 1; 150 continue; 151 } 152 switch((*(int *)(autodev[i].base + 0x20))) { 153 case 0: 154 autodev[i].type = FB_NWB514; 155 break; 156 case 1: 157 autodev[i].type = FB_NWB251; 158 break; 159 case 2: 160 autodev[i].type = FB_NWB518; 161 break; 162 case 3: 163 case 8: 164 autodev[i].type = FB_NWB254; 165 break; 166 case 4: 167 case 0x10004: 168 case 0x20004: 169 autodev[i].type = FB_NWB257; 170 break; 171 case 0x10005: 172 case 0x20005: 173 autodev[i].type = FB_NWB256; 174 break; 175 case 6: 176 autodev[i].type = FB_SLB101; 177 break; 178 case 7: 179 autodev[i].type = FB_NWB255; 180 break; 181 default: 182 autodev[i].type = -1; 183 break; 184 } 185 } 186 } 187 #endif /* AUTOSEL */ 188 189 cons_probe(dipsw) 190 int dipsw; 191 { 192 switch (dipsw & SW_CONSOLE) { 193 194 case SW_NWB225: 195 cons_dev = search_fbdev(FB_NWB225, 0); 196 break; 197 198 case SW_NWB512: 199 cons_dev = search_fbdev(FB_NWB512, 0); 200 break; 201 202 #ifdef CPU_SINGLE 203 case SW_FBPOP: 204 case SW_FBPOP1: 205 case SW_FBPOP2: 206 if ((cons_dev = search_fbdev(FB_LCDM, 0)) >= 0) 207 break; 208 if ((cons_dev = search_fbdev(FB_POPM, 0)) >= 0) 209 break; 210 if ((cons_dev = search_fbdev(FB_POPC, 0)) >= 0) 211 break; 212 if ((cons_dev = search_fbdev(FB_NWB252, 0)) >= 0) 213 break; 214 if ((cons_dev = search_fbdev(FB_NWB253, 0)) >= 0) 215 break; 216 break; 217 #endif /* CPU_SINGLE */ 218 219 #ifdef AUTOSEL 220 case SW_AUTOSEL: 221 cons_dev = search_fbdev(search_autocons(), 0); 222 break; 223 #endif 224 225 default: 226 cons_dev = -1; 227 break; 228 } 229 if (cons_dev == -1) 230 consfb = 0; 231 else 232 consfb = &fbdev[cons_dev]; 233 } 234 235 void fbbm_probe(dipsw) 236 int dipsw; 237 { 238 register int i, j; 239 register struct fbdevsw *pfsw = fbdevsw; 240 241 j = 0; 242 243 #ifdef AUTOSEL 244 fb_auto_probe(); 245 #endif 246 247 while (pfsw->num) { 248 for (i = 0; i < pfsw->num; i++) { 249 if (fbdev[j].type = (*pfsw->fb_probe)(i, &fbdev[j])) { 250 fbdev[j].unit = i; 251 (*pfsw->fb_setup)(&fbdev[j], dipsw); 252 j++; 253 } 254 } 255 pfsw++; 256 } 257 nfbdev = j; 258 259 cons_probe(dipsw); 260 } 261