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.3 (Berkeley) 03/09/93 13 */ 14 15 #ifdef IPC_MRX 16 #include "../../iop/framebuf.h" 17 #include "types.h" 18 #include "exec.h" 19 #include "romsw.h" 20 #else 21 #include <news3400/iop/framebuf.h> 22 #include <sys/types.h> 23 #include <sys/exec.h> 24 #endif 25 26 #include <news3400/fb/fbdefs.h> 27 28 #ifdef CPU_SINGLE 29 #define SW_CONSOLE 0x07 30 #define SW_NWB512 0x04 31 #define SW_NWB225 0x01 32 #define SW_FBPOP 0x02 33 #define SW_FBPOP1 0x06 34 #define SW_FBPOP2 0x03 35 #define SW_AUTOSEL 0x07 36 #endif 37 38 struct fbdev *consfb; 39 int nfbdev = 0; 40 41 static int cons_dev = -1; 42 extern struct fbdevsw fbdevsw[]; 43 44 #ifdef news3400 45 struct autodev autodev[] = { 46 -1, (char *)0xb8600000, (char *)0xb8610000, 47 -1, (char *)0xb8620000, (char *)0xb8630000, 48 -1, (char *)0xb8640000, (char *)0xb8650000, 49 -1, (char *)0xb8660000, (char *)0xb8670000, 50 -1, (char *)0xb8680000, (char *)0xb8690000, 51 -1, (char *)0xb86a0000, (char *)0xb86b0000, 52 -1, (char *)0xb86c0000, (char *)0xb86d0000, 53 -1, (char *)0xb86e0000, (char *)0xb86f0000, 54 }; 55 56 #define AUTOSEL 1 57 #endif /* news3400 */ 58 59 #ifdef news3800 60 struct autodev autodev[] = { 61 -1, (char *)0xee600000, (char *)0xee610000, 62 -1, (char *)0xee620000, (char *)0xee630000, 63 -1, (char *)0xee640000, (char *)0xee650000, 64 -1, (char *)0xee660000, (char *)0xee670000, 65 -1, (char *)0xee680000, (char *)0xee690000, 66 -1, (char *)0xee6a0000, (char *)0xee6b0000, 67 -1, (char *)0xee6c0000, (char *)0xee6d0000, 68 -1, (char *)0xee6e0000, (char *)0xee6f0000, 69 }; 70 71 #define AUTOSEL 1 72 #endif /* news3800 */ 73 74 search_fbdev(type, unit) 75 int type; 76 int unit; 77 { 78 register int i; 79 80 if (type == 0) { 81 if (cons_dev < 0) 82 return (unit < nfbdev ? unit : -1); 83 if (unit == 0) 84 return (cons_dev); 85 for (i = 0; i < nfbdev; i++) 86 if (i != cons_dev && --unit == 0) 87 return (i); 88 } else { 89 for (i = 0; i < nfbdev; i++) 90 if (fbdev[i].type == type && fbdev[i].unit == unit) 91 return(i); 92 } 93 return (-1); 94 } 95 96 #ifdef AUTOSEL 97 search_autocons() 98 { 99 register int i; 100 101 for (i = 0; i < 8; i++) 102 if (autodev[i].type != -1) 103 return (autodev[i].type); 104 return (-1); 105 } 106 107 fb_auto_probe() 108 { 109 register int i; 110 111 for (i = 0; i < 8; i++) { 112 if (badaddr(autodev[i].base, 1)) { 113 autodev[i].type = -1; 114 continue; 115 } 116 if (*(long *)autodev[i].base != OMAGIC) { 117 autodev[i].type = 1; 118 continue; 119 } 120 switch((*(int *)(autodev[i].base + 0x20))) { 121 case 0: 122 autodev[i].type = FB_NWB514; 123 break; 124 case 1: 125 autodev[i].type = FB_NWB251; 126 break; 127 case 2: 128 autodev[i].type = FB_NWB518; 129 break; 130 case 3: 131 case 8: 132 autodev[i].type = FB_NWB254; 133 break; 134 case 4: 135 case 0x10004: 136 case 0x20004: 137 autodev[i].type = FB_NWB257; 138 break; 139 case 0x10005: 140 case 0x20005: 141 autodev[i].type = FB_NWB256; 142 break; 143 case 6: 144 autodev[i].type = FB_SLB101; 145 break; 146 case 7: 147 autodev[i].type = FB_NWB255; 148 break; 149 default: 150 autodev[i].type = -1; 151 break; 152 } 153 } 154 } 155 #endif /* AUTOSEL */ 156 157 cons_probe(dipsw) 158 int dipsw; 159 { 160 switch (dipsw & SW_CONSOLE) { 161 162 case SW_NWB225: 163 cons_dev = search_fbdev(FB_NWB225, 0); 164 break; 165 166 case SW_NWB512: 167 cons_dev = search_fbdev(FB_NWB512, 0); 168 break; 169 170 #ifdef CPU_SINGLE 171 case SW_FBPOP: 172 case SW_FBPOP1: 173 case SW_FBPOP2: 174 if ((cons_dev = search_fbdev(FB_LCDM, 0)) >= 0) 175 break; 176 if ((cons_dev = search_fbdev(FB_POPM, 0)) >= 0) 177 break; 178 if ((cons_dev = search_fbdev(FB_POPC, 0)) >= 0) 179 break; 180 if ((cons_dev = search_fbdev(FB_NWB252, 0)) >= 0) 181 break; 182 if ((cons_dev = search_fbdev(FB_NWB253, 0)) >= 0) 183 break; 184 break; 185 #endif /* CPU_SINGLE */ 186 187 #ifdef AUTOSEL 188 case SW_AUTOSEL: 189 cons_dev = search_fbdev(search_autocons(), 0); 190 break; 191 #endif 192 193 default: 194 cons_dev = -1; 195 break; 196 } 197 if (cons_dev == -1) 198 consfb = 0; 199 else 200 consfb = &fbdev[cons_dev]; 201 } 202 203 void fbbm_probe(dipsw) 204 int dipsw; 205 { 206 register int i, j; 207 register struct fbdevsw *pfsw = fbdevsw; 208 209 j = 0; 210 211 #ifdef AUTOSEL 212 fb_auto_probe(); 213 #endif 214 215 while (pfsw->num) { 216 for (i = 0; i < pfsw->num; i++) { 217 if (fbdev[j].type = (*pfsw->fb_probe)(i, &fbdev[j])) { 218 fbdev[j].unit = i; 219 (*pfsw->fb_setup)(&fbdev[j], dipsw); 220 j++; 221 } 222 } 223 pfsw++; 224 } 225 nfbdev = j; 226 227 cons_probe(dipsw); 228 } 229