* better
[mascara-docs.git] / i386 / linux-2.3.21 / arch / m68k / mac / config.c
blobb5057f6e8dd1549137b91bec0eaece0233d1c997
1 /*
2 * linux/arch/m68k/mac/config.c
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive
6 * for more details.
7 */
9 /*
10 * Miscellaneous linux stuff
13 #include <linux/config.h>
14 #include <linux/types.h>
15 #include <linux/mm.h>
16 #include <linux/kd.h>
17 #include <linux/tty.h>
18 #include <linux/console.h>
19 #include <linux/interrupt.h>
20 /* keyb */
21 #include <linux/random.h>
22 #include <linux/delay.h>
23 /* keyb */
24 #include <linux/init.h>
26 #define BOOTINFO_COMPAT_1_0
27 #include <asm/setup.h>
28 #include <asm/bootinfo.h>
30 #include <asm/system.h>
31 #include <asm/io.h>
32 #include <asm/irq.h>
33 #include <asm/pgtable.h>
34 #include <asm/machdep.h>
36 #include <asm/macintosh.h>
37 #include <asm/macints.h>
38 #include <asm/machw.h>
40 #include <asm/mac_iop.h>
41 #include <asm/mac_via.h>
42 #include <asm/mac_oss.h>
43 #include <asm/mac_psc.h>
45 /* Offset between Unix time (1970-based) and Mac time (1904-based) */
47 #define MAC_TIME_OFFSET 2082844800
50 * hardware reset vector
53 static void (*rom_reset)(void);
55 /* Mac bootinfo struct */
57 struct mac_booter_data mac_bi_data = {0,};
58 int mac_bisize = sizeof mac_bi_data;
60 /* New m68k bootinfo stuff and videobase */
62 extern int m68k_num_memory;
63 extern struct mem_info m68k_memory[NUM_MEMINFO];
65 extern struct mem_info m68k_ramdisk;
67 extern char m68k_command_line[CL_SIZE];
69 void *mac_env; /* Loaded by the boot asm */
71 /* The phys. video addr. - might be bogus on some machines */
72 unsigned long mac_orig_videoaddr;
74 /* Mac specific keyboard functions */
75 extern int mackbd_init_hw(void);
76 extern void mackbd_leds(unsigned int leds);
78 /* Mac specific timer functions */
79 extern unsigned long mac_gettimeoffset (void);
80 static void mac_gettod (int *, int *, int *, int *, int *, int *);
81 static int mac_hwclk (int, struct hwclk_time *);
82 static int mac_set_clock_mmss (unsigned long);
83 extern void iop_preinit(void);
84 extern void iop_init(void);
85 extern void via_init(void);
86 extern void via_init_clock(void (*func)(int, void *, struct pt_regs *));
87 extern void via_flush_cache(void);
88 extern void oss_init(void);
89 extern void psc_init(void);
91 extern void (*kd_mksound)(unsigned int, unsigned int);
92 extern void mac_mksound(unsigned int, unsigned int);
93 extern int mac_floppy_init(void);
94 extern void mac_floppy_setup(char *,int *);
96 extern void nubus_sweep_video(void);
98 /* Mac specific debug functions (in debug.c) */
99 extern void mac_debug_init(void);
100 extern void mac_debugging_long(int, long);
102 /* poweroff functions */
103 extern void via_poweroff(void);
104 extern void oss_poweroff(void);
105 extern void adb_poweroff(void);
106 extern void adb_hwreset(void);
108 /* pram functions */
109 extern __u32 via_read_time(void);
110 extern void via_write_time(__u32);
111 extern __u32 adb_read_time(void);
112 extern void adb_write_time(__u32);
114 #ifdef CONFIG_MAGIC_SYSRQ
115 static char mac_sysrq_xlate[128] =
116 "\000sdfghzxcv\000bqwer" /* 0x00 - 0x0f */
117 "yt123465=97-80)o" /* 0x10 - 0x1f */
118 "u(ip\rlj'k;\\,/nm." /* 0x20 - 0x2f */
119 "\t `\000\033\000\000\000\000\000\000\000\000\000\000\000" /* 0x30 - 0x3f */
120 "\000.\000*\000+\000\000\000\000\000/\r\000-\000" /* 0x40 - 0x4f */
121 "\000\00001234567a89\000\000\000" /* 0x50 - 0x5f */
122 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" /* 0x60 - 0x6f */
123 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"; /* 0x70 - 0x7f */
124 #endif
126 extern void (*kd_mksound)(unsigned int, unsigned int);
128 static void mac_get_model(char *str);
130 void mac_bang(int irq, void *vector, struct pt_regs *p)
132 printk("Resetting ...\n");
133 mac_reset();
136 static void mac_sched_init(void (*vector)(int, void *, struct pt_regs *))
138 via_init_clock(vector);
141 extern int console_loglevel;
143 /* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
144 * Assumes input in normal date format, i.e. 1980-12-31 23:59:59
145 * => year=1980, mon=12, day=31, hour=23, min=59, sec=59.
147 * [For the Julian calendar (which was used in Russia before 1917,
148 * Britain & colonies before 1752, anywhere else before 1582,
149 * and is still in use by some communities) leave out the
150 * -year/100+year/400 terms, and add 10.]
152 * This algorithm was first published by Gauss (I think).
154 * WARNING: this function will overflow on 2106-02-07 06:28:16 on
155 * machines were long is 32-bit! (However, as time_t is signed, we
156 * will already get problems at other places on 2038-01-19 03:14:08)
158 static unsigned long mktime(unsigned int year, unsigned int mon,
159 unsigned int day, unsigned int hour,
160 unsigned int min, unsigned int sec)
162 if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */
163 mon += 12; /* Puts Feb last since it has leap day */
164 year -= 1;
166 return (((
167 (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) +
168 year*365 - 719499
169 )*24 + hour /* now have hours */
170 )*60 + min /* now have minutes */
171 )*60 + sec; /* finally seconds */
175 * This function translates seconds since 1970 into a proper date.
177 * Algorithm cribbed from glibc2.1, __offtime().
179 #define SECS_PER_MINUTE (60)
180 #define SECS_PER_HOUR (SECS_PER_MINUTE * 60)
181 #define SECS_PER_DAY (SECS_PER_HOUR * 24)
183 static void unmktime(unsigned long time, long offset,
184 int *yearp, int *monp, int *dayp,
185 int *hourp, int *minp, int *secp)
187 /* How many days come before each month (0-12). */
188 static const unsigned short int __mon_yday[2][13] =
190 /* Normal years. */
191 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
192 /* Leap years. */
193 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
195 long int days, rem, y, wday, yday;
196 const unsigned short int *ip;
198 days = time / SECS_PER_DAY;
199 rem = time % SECS_PER_DAY;
200 rem += offset;
201 while (rem < 0) {
202 rem += SECS_PER_DAY;
203 --days;
205 while (rem >= SECS_PER_DAY) {
206 rem -= SECS_PER_DAY;
207 ++days;
209 *hourp = rem / SECS_PER_HOUR;
210 rem %= SECS_PER_HOUR;
211 *minp = rem / SECS_PER_MINUTE;
212 *secp = rem % SECS_PER_MINUTE;
213 /* January 1, 1970 was a Thursday. */
214 wday = (4 + days) % 7; /* Day in the week. Not currently used */
215 if (wday < 0) wday += 7;
216 y = 1970;
218 #define DIV(a, b) ((a) / (b) - ((a) % (b) < 0))
219 #define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400))
220 #define __isleap(year) \
221 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
223 while (days < 0 || days >= (__isleap (y) ? 366 : 365))
225 /* Guess a corrected year, assuming 365 days per year. */
226 long int yg = y + days / 365 - (days % 365 < 0);
228 /* Adjust DAYS and Y to match the guessed year. */
229 days -= ((yg - y) * 365
230 + LEAPS_THRU_END_OF (yg - 1)
231 - LEAPS_THRU_END_OF (y - 1));
232 y = yg;
234 *yearp = y - 1900;
235 yday = days; /* day in the year. Not currently used. */
236 ip = __mon_yday[__isleap(y)];
237 for (y = 11; days < (long int) ip[y]; --y)
238 continue;
239 days -= ip[y];
240 *monp = y;
241 *dayp = days + 1; /* day in the month */
242 return;
246 * Return the boot time for use in initializing the kernel clock.
248 * I'd like to read the hardware clock here but many machines read
249 * the PRAM through ADB, and interrupts aren't initialized when this
250 * is called so ADB obviously won't work.
253 static void mac_gettod(int *yearp, int *monp, int *dayp,
254 int *hourp, int *minp, int *secp)
256 /* Yes the GMT bias is backwards. It looks like Penguin is
257 screwing up the boottime it gives us... This works for me
258 in Canada/Eastern but it might be wrong everywhere else. */
259 unmktime(mac_bi_data.boottime, -mac_bi_data.gmtbias * 60,
260 yearp, monp, dayp, hourp, minp, secp);
261 /* For some reason this is off by one */
262 *monp = *monp + 1;
266 * Read/write the hardware clock.
269 static int mac_hwclk(int op, struct hwclk_time *t)
271 unsigned long now;
273 if (!op) { /* read */
274 if (macintosh_config->adb_type == MAC_ADB_II) {
275 now = via_read_time();
276 } else if ((macintosh_config->adb_type == MAC_ADB_IISI) ||
277 (macintosh_config->adb_type == MAC_ADB_CUDA)) {
278 now = adb_read_time();
279 } else if (macintosh_config->adb_type == MAC_ADB_IOP) {
280 now = via_read_time();
281 } else {
282 now = MAC_TIME_OFFSET;
285 now -= MAC_TIME_OFFSET;
287 t->wday = 0;
288 unmktime(now, 0,
289 &t->year, &t->mon, &t->day,
290 &t->hour, &t->min, &t->sec);
291 } else { /* write */
292 now = mktime(t->year + 1900, t->mon + 1, t->day,
293 t->hour, t->min, t->sec) + MAC_TIME_OFFSET;
295 if (macintosh_config->adb_type == MAC_ADB_II) {
296 via_write_time(now);
297 } else if ((macintosh_config->adb_type == MAC_ADB_IISI) ||
298 (macintosh_config->adb_type == MAC_ADB_CUDA)) {
299 adb_write_time(now);
300 } else if (macintosh_config->adb_type == MAC_ADB_IOP) {
301 via_write_time(now);
304 return 0;
308 * Set minutes/seconds in the hardware clock
311 static int mac_set_clock_mmss (unsigned long nowtime)
313 struct hwclk_time now;
315 mac_hwclk(0, &now);
316 now.sec = nowtime % 60;
317 now.min = (nowtime / 60) % 60;
318 mac_hwclk(1, &now);
320 return 0;
323 #if 0
324 void mac_waitbut (void)
328 #endif
330 extern struct consw fb_con;
331 extern struct fb_info *mac_fb_init(long *);
334 * Parse a Macintosh-specific record in the bootinfo
337 int __init mac_parse_bootinfo(const struct bi_record *record)
339 int unknown = 0;
340 const u_long *data = record->data;
342 switch (record->tag) {
343 case BI_MAC_MODEL:
344 mac_bi_data.id = *data;
345 break;
346 case BI_MAC_VADDR:
347 mac_bi_data.videoaddr = *data;
348 break;
349 case BI_MAC_VDEPTH:
350 mac_bi_data.videodepth = *data;
351 break;
352 case BI_MAC_VROW:
353 mac_bi_data.videorow = *data;
354 break;
355 case BI_MAC_VDIM:
356 mac_bi_data.dimensions = *data;
357 break;
358 case BI_MAC_VLOGICAL:
359 mac_bi_data.videological = VIDEOMEMBASE + (*data & ~VIDEOMEMMASK);
360 mac_orig_videoaddr = *data;
361 break;
362 case BI_MAC_SCCBASE:
363 mac_bi_data.sccbase = *data;
364 break;
365 case BI_MAC_BTIME:
366 mac_bi_data.boottime = *data;
367 break;
368 case BI_MAC_GMTBIAS:
369 mac_bi_data.gmtbias = *data;
370 break;
371 case BI_MAC_MEMSIZE:
372 mac_bi_data.memsize = *data;
373 break;
374 case BI_MAC_CPUID:
375 mac_bi_data.cpuid = *data;
376 break;
377 case BI_MAC_ROMBASE:
378 mac_bi_data.rombase = *data;
379 break;
380 default:
381 unknown = 1;
383 return(unknown);
387 * Flip into 24bit mode for an instant - flushes the L2 cache card. We
388 * have to disable interrupts for this. Our IRQ handlers will crap
389 * themselves if they take an IRQ in 24bit mode!
392 static void mac_cache_card_flush(int writeback)
394 unsigned long cpu_flags;
395 save_flags(cpu_flags);
396 cli();
397 via_flush_cache();
398 restore_flags(cpu_flags);
401 void __init config_mac(void)
404 if (!MACH_IS_MAC) {
405 printk("ERROR: no Mac, but config_mac() called!! \n");
408 mach_sched_init = mac_sched_init;
409 mach_keyb_init = mackbd_init_hw;
410 mach_kbd_leds = mackbd_leds;
411 mach_init_IRQ = mac_init_IRQ;
412 mach_request_irq = mac_request_irq;
413 mach_free_irq = mac_free_irq;
414 enable_irq = mac_enable_irq;
415 disable_irq = mac_disable_irq;
416 mach_get_model = mac_get_model;
417 mach_gettimeoffset = mac_gettimeoffset;
418 mach_gettod = mac_gettod;
419 mach_hwclk = mac_hwclk;
420 mach_set_clock_mmss = mac_set_clock_mmss;
421 #if 0
422 mach_mksound = mac_mksound;
423 #endif
424 mach_reset = mac_reset;
425 mach_halt = mac_poweroff;
426 mach_power_off = mac_poweroff;
427 conswitchp = &dummy_con;
428 mach_max_dma_address = 0xffffffff;
429 #if 0
430 mach_debug_init = mac_debug_init;
431 #endif
432 kd_mksound = mac_mksound;
433 #ifdef CONFIG_MAGIC_SYSRQ
434 mach_sysrq_key = 114; /* HELP */
435 mach_sysrq_shift_state = 8; /* Alt */
436 mach_sysrq_shift_mask = 0xff; /* all modifiers except CapsLock */
437 mach_sysrq_xlate = mac_sysrq_xlate;
438 #endif
439 #ifdef CONFIG_HEARTBEAT
440 #if 0
441 mach_heartbeat = mac_heartbeat;
442 mach_heartbeat_irq = IRQ_MAC_TIMER;
443 #endif
444 #endif
447 * Determine hardware present
450 mac_identify();
451 mac_report_hardware();
453 /* AFAIK only the IIci takes a cache card. The IIfx has onboard
454 cache ... someone needs to figure out how to tell if it's on or
455 not. */
456 if (macintosh_config->ident == MAC_MODEL_IICI
457 || macintosh_config->ident == MAC_MODEL_IIFX) {
458 mach_l2_flush = mac_cache_card_flush;
460 #ifdef MAC_DEBUG_SOUND
461 /* goes on forever if timers broken */
462 mac_mksound(1000,10);
463 #endif
466 * Check for machine specific fixups.
469 #ifdef OLD_NUBUS_CODE
470 nubus_sweep_video();
471 #endif
476 * Macintosh Table: hardcoded model configuration data.
478 * Much of this was defined by Alan, based on who knows what docs.
479 * I've added a lot more, and some of that was pure guesswork based
480 * on hardware pages present on the Mac web site. Possibly wildly
481 * inaccurate, so look here if a new Mac model won't run. Example: if
482 * a Mac crashes immediately after the VIA1 registers have been dumped
483 * to the screen, it probably died attempting to read DirB on a RBV.
484 * Meaning it should have MAC_VIA_IIci here :-)
487 struct mac_model *macintosh_config;
489 static struct mac_model mac_data_table[]=
492 * The default machine, in case we get an unsupported one
493 * We'll pretend to be a Macintosh II, that's pretty safe.
496 { MAC_MODEL_II, "Unknown", MAC_ADB_II, MAC_VIA_II, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
499 * Original MacII hardware
503 { MAC_MODEL_II, "II", MAC_ADB_II, MAC_VIA_II, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
504 { MAC_MODEL_IIX, "IIx", MAC_ADB_II, MAC_VIA_II, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
505 { MAC_MODEL_IICX, "IIcx", MAC_ADB_II, MAC_VIA_II, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
506 { MAC_MODEL_SE30, "SE/30", MAC_ADB_II, MAC_VIA_II, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
509 * Weirdified MacII hardware - all subtley different. Gee thanks
510 * Apple. All these boxes seem to have VIA2 in a different place to
511 * the MacII (+1A000 rather than +4000)
513 * The IIfx apparently has different ADB hardware, and stuff
514 * so zany nobody knows how to drive it.
515 * Even so, with Marten's help we'll try to deal with it :-)
516 * CSA: see http://developer.apple.com/technotes/hw/hw_09.html
519 { MAC_MODEL_IICI, "IIci", MAC_ADB_II, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
520 { MAC_MODEL_IIFX, "IIfx", MAC_ADB_IOP, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_IOP, MAC_ETHER_NONE, MAC_NUBUS},
521 { MAC_MODEL_IISI, "IIsi", MAC_ADB_IISI, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
522 { MAC_MODEL_IIVI, "IIvi", MAC_ADB_IISI, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
523 { MAC_MODEL_IIVX, "IIvx", MAC_ADB_IISI, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
526 * Classic models (guessing: similar to SE/30 ?? Nope, similar to LC ...)
529 { MAC_MODEL_CLII, "Classic II", MAC_ADB_IISI, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
530 { MAC_MODEL_CCL, "Color Classic", MAC_ADB_CUDA, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
533 * Some Mac LC machines. Basically the same as the IIci, ADB like IIsi
536 { MAC_MODEL_LC, "LC", MAC_ADB_IISI, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
537 { MAC_MODEL_LCII, "LC II", MAC_ADB_IISI, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
538 { MAC_MODEL_LCIII,"LC III", MAC_ADB_IISI, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
541 * Quadra. Video is at 0xF9000000, via is like a MacII. We label it differently
542 * as some of the stuff connected to VIA2 seems different. Better SCSI chip and
543 * onboard ethernet using a NatSemi SONIC except the 660AV and 840AV which use an
544 * AMD 79C940 (MACE).
545 * The 700, 900 and 950 have some I/O chips in the wrong place to
546 * confuse us. The 840AV has a SCSI location of its own (same as
547 * the 660AV).
550 { MAC_MODEL_Q605, "Quadra 605", MAC_ADB_CUDA, MAC_VIA_QUADRA, MAC_SCSI_QUADRA, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
551 { MAC_MODEL_Q610, "Quadra 610", MAC_ADB_II, MAC_VIA_QUADRA, MAC_SCSI_QUADRA, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_SONIC, MAC_NUBUS},
552 { MAC_MODEL_Q630, "Quadra 630", MAC_ADB_CUDA, MAC_VIA_QUADRA, MAC_SCSI_QUADRA, MAC_IDE_QUADRA, MAC_SCC_QUADRA, MAC_ETHER_SONIC, MAC_NUBUS},
553 { MAC_MODEL_Q650, "Quadra 650", MAC_ADB_II, MAC_VIA_QUADRA, MAC_SCSI_QUADRA, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_SONIC, MAC_NUBUS},
554 /* The Q700 does have a NS Sonic */
555 { MAC_MODEL_Q700, "Quadra 700", MAC_ADB_II, MAC_VIA_QUADRA, MAC_SCSI_QUADRA2, MAC_IDE_NONE, MAC_SCC_QUADRA2, MAC_ETHER_SONIC, MAC_NUBUS},
556 { MAC_MODEL_Q800, "Quadra 800", MAC_ADB_II, MAC_VIA_QUADRA, MAC_SCSI_QUADRA, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_SONIC, MAC_NUBUS},
557 { MAC_MODEL_Q840, "Quadra 840AV", MAC_ADB_CUDA, MAC_VIA_QUADRA, MAC_SCSI_QUADRA3, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_MACE, MAC_NUBUS},
558 { MAC_MODEL_Q900, "Quadra 900", MAC_ADB_IOP, MAC_VIA_QUADRA, MAC_SCSI_QUADRA2, MAC_IDE_NONE, MAC_SCC_IOP, MAC_ETHER_SONIC, MAC_NUBUS},
559 { MAC_MODEL_Q950, "Quadra 950", MAC_ADB_IOP, MAC_VIA_QUADRA, MAC_SCSI_QUADRA2, MAC_IDE_NONE, MAC_SCC_IOP, MAC_ETHER_SONIC, MAC_NUBUS},
562 * Performa - more LC type machines
565 { MAC_MODEL_P460, "Performa 460", MAC_ADB_IISI, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
566 { MAC_MODEL_P475, "Performa 475", MAC_ADB_CUDA, MAC_VIA_QUADRA, MAC_SCSI_QUADRA, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
567 { MAC_MODEL_P475F, "Performa 475", MAC_ADB_CUDA, MAC_VIA_QUADRA, MAC_SCSI_QUADRA, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
568 { MAC_MODEL_P520, "Performa 520", MAC_ADB_CUDA, MAC_VIA_QUADRA, MAC_SCSI_QUADRA, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
570 { MAC_MODEL_P550, "Performa 550", MAC_ADB_CUDA, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
571 { MAC_MODEL_P575, "Performa 575", MAC_ADB_CUDA, MAC_VIA_QUADRA, MAC_SCSI_QUADRA, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
572 /* These have the comm slot, and therefore the possibility of SONIC ethernet */
573 { MAC_MODEL_P588, "Performa 588", MAC_ADB_CUDA, MAC_VIA_QUADRA, MAC_SCSI_QUADRA, MAC_IDE_QUADRA, MAC_SCC_II, MAC_ETHER_SONIC, MAC_NUBUS},
574 { MAC_MODEL_TV, "TV", MAC_ADB_CUDA, MAC_VIA_QUADRA, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
575 { MAC_MODEL_P600, "Performa 600", MAC_ADB_IISI, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_II, MAC_ETHER_NONE, MAC_NUBUS},
578 * Centris - just guessing again; maybe like Quadra
581 /* The C610 may or may not have SONIC. We probe to make sure */
582 { MAC_MODEL_C610, "Centris 610", MAC_ADB_II, MAC_VIA_QUADRA, MAC_SCSI_QUADRA, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_SONIC, MAC_NUBUS},
583 { MAC_MODEL_C650, "Centris 650", MAC_ADB_II, MAC_VIA_QUADRA, MAC_SCSI_QUADRA, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_SONIC, MAC_NUBUS},
584 { MAC_MODEL_C660, "Centris 660AV", MAC_ADB_CUDA, MAC_VIA_QUADRA, MAC_SCSI_QUADRA3, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_MACE, MAC_NUBUS},
587 * Power books - seem similar to early Quadras ? (most have 030 though)
590 { MAC_MODEL_PB140, "PowerBook 140", MAC_ADB_PB1, MAC_VIA_QUADRA, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
591 { MAC_MODEL_PB145, "PowerBook 145", MAC_ADB_PB1, MAC_VIA_QUADRA, MAC_SCSI_NONE, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
592 /* The PB150 has IDE, and IIci style VIA */
593 { MAC_MODEL_PB150, "PowerBook 150", MAC_ADB_PB1, MAC_VIA_IIci, MAC_SCSI_NONE, MAC_IDE_PB, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
594 { MAC_MODEL_PB160, "PowerBook 160", MAC_ADB_PB1, MAC_VIA_QUADRA, MAC_SCSI_NONE, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
595 { MAC_MODEL_PB165, "PowerBook 165", MAC_ADB_PB1, MAC_VIA_QUADRA, MAC_SCSI_NONE, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
596 { MAC_MODEL_PB165C, "PowerBook 165c", MAC_ADB_PB1, MAC_VIA_QUADRA, MAC_SCSI_NONE, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
597 { MAC_MODEL_PB170, "PowerBook 170", MAC_ADB_PB1, MAC_VIA_QUADRA, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
598 { MAC_MODEL_PB180, "PowerBook 180", MAC_ADB_PB1, MAC_VIA_QUADRA, MAC_SCSI_NONE, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
599 { MAC_MODEL_PB180C, "PowerBook 180c", MAC_ADB_PB1, MAC_VIA_QUADRA, MAC_SCSI_NONE, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
600 { MAC_MODEL_PB190, "PowerBook 190cs", MAC_ADB_PB1, MAC_VIA_QUADRA, MAC_SCSI_NONE, MAC_IDE_PB, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
601 /* These have onboard SONIC */
602 { MAC_MODEL_PB520, "PowerBook 520", MAC_ADB_PB2, MAC_VIA_QUADRA, MAC_SCSI_NONE, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_SONIC, MAC_NUBUS},
605 * Power book Duos - similar to Power books, I hope
608 /* All of these might have onboard SONIC in the Dock but I'm not quite sure */
609 { MAC_MODEL_PB210, "PowerBook Duo 210", MAC_ADB_PB2, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
610 { MAC_MODEL_PB230, "PowerBook Duo 230", MAC_ADB_PB2, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
611 { MAC_MODEL_PB250, "PowerBook Duo 250", MAC_ADB_PB2, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
612 { MAC_MODEL_PB270C, "PowerBook Duo 270c", MAC_ADB_PB2, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
613 { MAC_MODEL_PB280, "PowerBook Duo 280", MAC_ADB_PB2, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
614 { MAC_MODEL_PB280C, "PowerBook Duo 280c", MAC_ADB_PB2, MAC_VIA_IIci, MAC_SCSI_OLD, MAC_IDE_NONE, MAC_SCC_QUADRA, MAC_ETHER_NONE, MAC_NUBUS},
617 * Other stuff ??
619 { -1, NULL, 0,0,0,}
622 void mac_identify(void)
624 struct mac_model *m;
626 /* Penguin data useful? */
627 int model = mac_bi_data.id;
628 if (!model) {
629 /* no bootinfo model id -> NetBSD booter was used! */
630 /* XXX FIXME: breaks for model > 31 */
631 model=(mac_bi_data.cpuid>>2)&63;
632 printk ("No bootinfo model ID, using cpuid instead (hey, use Penguin!)\n");
635 macintosh_config = mac_data_table;
636 for (m = macintosh_config ; m->ident != -1 ; m++) {
637 if (m->ident == model) {
638 macintosh_config = m;
639 break;
643 /* We need to pre-init the IOPs, if any. Otherwise */
644 /* the serial console won't work if the user had */
645 /* the serial ports set to "Faster" mode in MacOS. */
647 iop_preinit();
648 mac_debug_init();
650 printk ("Detected Macintosh model: %d \n", model);
653 * Report booter data:
655 printk (" Penguin bootinfo data:\n");
656 printk (" Video: addr 0x%lx row 0x%lx depth %lx dimensions %ld x %ld\n",
657 mac_bi_data.videoaddr, mac_bi_data.videorow,
658 mac_bi_data.videodepth, mac_bi_data.dimensions & 0xFFFF,
659 mac_bi_data.dimensions >> 16);
660 printk (" Videological 0x%lx phys. 0x%lx, SCC at 0x%lx \n",
661 mac_bi_data.videological, mac_orig_videoaddr,
662 mac_bi_data.sccbase);
663 printk (" Boottime: 0x%lx GMTBias: 0x%lx \n",
664 mac_bi_data.boottime, mac_bi_data.gmtbias);
665 printk (" Machine ID: %ld CPUid: 0x%lx memory size: 0x%lx \n",
666 mac_bi_data.id, mac_bi_data.cpuid, mac_bi_data.memsize);
667 #if 0
668 printk ("Ramdisk: addr 0x%lx size 0x%lx\n",
669 m68k_ramdisk.addr, m68k_ramdisk.size);
670 #endif
673 * TODO: set the various fields in macintosh_config->hw_present here!
675 switch (macintosh_config->scsi_type) {
676 case MAC_SCSI_OLD:
677 MACHW_SET(MAC_SCSI_80);
678 break;
679 case MAC_SCSI_QUADRA:
680 case MAC_SCSI_QUADRA2:
681 case MAC_SCSI_QUADRA3:
682 MACHW_SET(MAC_SCSI_96);
683 if ((macintosh_config->ident == MAC_MODEL_Q900) ||
684 (macintosh_config->ident == MAC_MODEL_Q950))
685 MACHW_SET(MAC_SCSI_96_2);
686 break;
687 default:
688 printk("config.c: wtf: unknown scsi, using 53c80\n");
689 MACHW_SET(MAC_SCSI_80);
690 break;
693 iop_init();
694 via_init();
695 oss_init();
696 psc_init();
699 void mac_report_hardware(void)
701 printk("Apple Macintosh %s\n", macintosh_config->name);
704 static void mac_get_model(char *str)
706 strcpy(str,"Macintosh ");
707 strcat(str, macintosh_config->name);
711 * The power switch - yes it's software!
714 void mac_poweroff(void)
717 * MAC_ADB_IISI may need to be moved up here if it doesn't actually
718 * work using the ADB packet method. --David Kilzer
721 if (oss_present) {
722 oss_poweroff();
723 } else if (macintosh_config->adb_type == MAC_ADB_II) {
724 via_poweroff();
725 } else {
726 adb_poweroff();
731 * Not all Macs support software power down; for the rest, just
732 * try the ROM reset vector ...
734 void mac_reset(void)
737 * MAC_ADB_IISI may need to be moved up here if it doesn't actually
738 * work using the ADB packet method. --David Kilzer
741 if (macintosh_config->adb_type == MAC_ADB_II) {
742 unsigned long cpu_flags;
744 /* need ROMBASE in booter */
745 /* indeed, plus need to MAP THE ROM !! */
747 if (mac_bi_data.rombase == 0)
748 mac_bi_data.rombase = 0x40800000;
750 /* works on some */
751 rom_reset = (void *) (mac_bi_data.rombase + 0xa);
753 if (macintosh_config->ident == MAC_MODEL_SE30) {
755 * MSch: Machines known to crash on ROM reset ...
757 printk("System halted.\n");
758 while(1);
759 } else {
760 save_flags(cpu_flags);
761 cli();
763 rom_reset();
765 restore_flags(cpu_flags);
768 /* We never make it this far... it usually panics above. */
769 printk ("Restart failed. Please restart manually.\n");
771 /* XXX - delay do we need to spin here ? */
772 while(1); /* Just in case .. */
773 } else if (macintosh_config->adb_type == MAC_ADB_IISI
774 || macintosh_config->adb_type == MAC_ADB_CUDA) {
775 adb_hwreset();
776 } else if (CPU_IS_030) {
778 /* 030-specific reset routine. The idea is general, but the
779 * specific registers to reset are '030-specific. Until I
780 * have a non-030 machine, I can't test anything else.
781 * -- C. Scott Ananian <cananian@alumni.princeton.edu>
784 unsigned long rombase = 0x40000000;
786 /* make a 1-to-1 mapping, using the transparent tran. reg. */
787 unsigned long virt = (unsigned long) mac_reset;
788 unsigned long phys = virt_to_phys(mac_reset);
789 unsigned long offset = phys-virt;
790 cli(); /* lets not screw this up, ok? */
791 __asm__ __volatile__(".chip 68030\n\t"
792 "pmove %0,%/tt0\n\t"
793 ".chip 68k"
794 : : "m" ((phys&0xFF000000)|0x8777));
795 /* Now jump to physical address so we can disable MMU */
796 __asm__ __volatile__(
797 ".chip 68030\n\t"
798 "lea %/pc@(1f),%/a0\n\t"
799 "addl %0,%/a0\n\t"/* fixup target address and stack ptr */
800 "addl %0,%/sp\n\t"
801 "pflusha\n\t"
802 "jmp %/a0@\n\t" /* jump into physical memory */
803 "0:.long 0\n\t" /* a constant zero. */
804 /* OK. Now reset everything and jump to reset vector. */
805 "1:\n\t"
806 "lea %/pc@(0b),%/a0\n\t"
807 "pmove %/a0@, %/tc\n\t" /* disable mmu */
808 "pmove %/a0@, %/tt0\n\t" /* disable tt0 */
809 "pmove %/a0@, %/tt1\n\t" /* disable tt1 */
810 "movel #0, %/a0\n\t"
811 "movec %/a0, %/vbr\n\t" /* clear vector base register */
812 "movec %/a0, %/cacr\n\t" /* disable caches */
813 "movel #0x0808,%/a0\n\t"
814 "movec %/a0, %/cacr\n\t" /* flush i&d caches */
815 "movew #0x2700,%/sr\n\t" /* set up status register */
816 "movel %1@(0x0),%/a0\n\t"/* load interrupt stack pointer */
817 "movec %/a0, %/isp\n\t"
818 "movel %1@(0x4),%/a0\n\t" /* load reset vector */
819 "reset\n\t" /* reset external devices */
820 "jmp %/a0@\n\t" /* jump to the reset vector */
821 ".chip 68k"
822 : : "r" (offset), "a" (rombase) : "a0");
824 /* should never get here */
825 sti(); /* sure, why not */
826 printk ("030 Restart failed. Please restart manually.\n");
827 while(1);
828 } else {
829 /* We never make it here... The above shoule handle all cases. */
830 printk ("Restart failed. Please restart manually.\n");
832 /* XXX - delay do we need to spin here ? */
833 while(1); /* Just in case .. */
838 * Local variables:
839 * c-indent-level: 4
840 * tab-width: 8
841 * End: