[PATCH] briq_panel: read() and write() get __user pointers, damnit
[linux-2.6/verdex.git] / arch / m68k / amiga / config.c
blob092e50d2cb137781d1378f43fdb006f8ae73e720
1 /*
2 * linux/arch/m68k/amiga/config.c
4 * Copyright (C) 1993 Hamish Macdonald
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
12 * Miscellaneous Amiga stuff
15 #include <linux/types.h>
16 #include <linux/kernel.h>
17 #include <linux/mm.h>
18 #include <linux/tty.h>
19 #include <linux/console.h>
20 #include <linux/rtc.h>
21 #include <linux/init.h>
22 #include <linux/vt_kern.h>
23 #include <linux/delay.h>
24 #include <linux/interrupt.h>
25 #ifdef CONFIG_ZORRO
26 #include <linux/zorro.h>
27 #endif
29 #include <asm/bootinfo.h>
30 #include <asm/setup.h>
31 #include <asm/system.h>
32 #include <asm/pgtable.h>
33 #include <asm/amigahw.h>
34 #include <asm/amigaints.h>
35 #include <asm/irq.h>
36 #include <asm/rtc.h>
37 #include <asm/machdep.h>
38 #include <asm/io.h>
40 unsigned long amiga_model;
41 unsigned long amiga_eclock;
42 unsigned long amiga_masterclock;
43 unsigned long amiga_colorclock;
44 unsigned long amiga_chipset;
45 unsigned char amiga_vblank;
46 unsigned char amiga_psfreq;
47 struct amiga_hw_present amiga_hw_present;
49 static char s_a500[] __initdata = "A500";
50 static char s_a500p[] __initdata = "A500+";
51 static char s_a600[] __initdata = "A600";
52 static char s_a1000[] __initdata = "A1000";
53 static char s_a1200[] __initdata = "A1200";
54 static char s_a2000[] __initdata = "A2000";
55 static char s_a2500[] __initdata = "A2500";
56 static char s_a3000[] __initdata = "A3000";
57 static char s_a3000t[] __initdata = "A3000T";
58 static char s_a3000p[] __initdata = "A3000+";
59 static char s_a4000[] __initdata = "A4000";
60 static char s_a4000t[] __initdata = "A4000T";
61 static char s_cdtv[] __initdata = "CDTV";
62 static char s_cd32[] __initdata = "CD32";
63 static char s_draco[] __initdata = "Draco";
64 static char *amiga_models[] __initdata = {
65 [AMI_500-AMI_500] = s_a500,
66 [AMI_500PLUS-AMI_500] = s_a500p,
67 [AMI_600-AMI_500] = s_a600,
68 [AMI_1000-AMI_500] = s_a1000,
69 [AMI_1200-AMI_500] = s_a1200,
70 [AMI_2000-AMI_500] = s_a2000,
71 [AMI_2500-AMI_500] = s_a2500,
72 [AMI_3000-AMI_500] = s_a3000,
73 [AMI_3000T-AMI_500] = s_a3000t,
74 [AMI_3000PLUS-AMI_500] = s_a3000p,
75 [AMI_4000-AMI_500] = s_a4000,
76 [AMI_4000T-AMI_500] = s_a4000t,
77 [AMI_CDTV-AMI_500] = s_cdtv,
78 [AMI_CD32-AMI_500] = s_cd32,
79 [AMI_DRACO-AMI_500] = s_draco,
82 static char amiga_model_name[13] = "Amiga ";
84 extern char m68k_debug_device[];
86 static void amiga_sched_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
87 /* amiga specific irq functions */
88 extern void amiga_init_IRQ (void);
89 static void amiga_get_model(char *model);
90 static int amiga_get_hardware_list(char *buffer);
91 /* amiga specific timer functions */
92 static unsigned long amiga_gettimeoffset (void);
93 static int a3000_hwclk (int, struct rtc_time *);
94 static int a2000_hwclk (int, struct rtc_time *);
95 static int amiga_set_clock_mmss (unsigned long);
96 static unsigned int amiga_get_ss (void);
97 extern void amiga_mksound( unsigned int count, unsigned int ticks );
98 static void amiga_reset (void);
99 extern void amiga_init_sound(void);
100 static void amiga_savekmsg_init(void);
101 static void amiga_mem_console_write(struct console *co, const char *b,
102 unsigned int count);
103 void amiga_serial_console_write(struct console *co, const char *s,
104 unsigned int count);
105 static void amiga_debug_init(void);
106 #ifdef CONFIG_HEARTBEAT
107 static void amiga_heartbeat(int on);
108 #endif
110 static struct console amiga_console_driver = {
111 .name = "debug",
112 .flags = CON_PRINTBUFFER,
113 .index = -1,
118 * Motherboard Resources present in all Amiga models
121 static struct {
122 struct resource _ciab, _ciaa, _custom, _kickstart;
123 } mb_resources = {
124 ._ciab = {
125 .name = "CIA B", .start = 0x00bfd000, .end = 0x00bfdfff
127 ._ciaa = {
128 .name = "CIA A", .start = 0x00bfe000, .end = 0x00bfefff
130 ._custom = {
131 .name = "Custom I/O", .start = 0x00dff000, .end = 0x00dfffff
133 ._kickstart = {
134 .name = "Kickstart ROM", .start = 0x00f80000, .end = 0x00ffffff
138 static struct resource rtc_resource = {
139 .start = 0x00dc0000, .end = 0x00dcffff
142 static struct resource ram_resource[NUM_MEMINFO];
146 * Parse an Amiga-specific record in the bootinfo
149 int amiga_parse_bootinfo(const struct bi_record *record)
151 int unknown = 0;
152 const unsigned long *data = record->data;
154 switch (record->tag) {
155 case BI_AMIGA_MODEL:
156 amiga_model = *data;
157 break;
159 case BI_AMIGA_ECLOCK:
160 amiga_eclock = *data;
161 break;
163 case BI_AMIGA_CHIPSET:
164 amiga_chipset = *data;
165 break;
167 case BI_AMIGA_CHIP_SIZE:
168 amiga_chip_size = *(const int *)data;
169 break;
171 case BI_AMIGA_VBLANK:
172 amiga_vblank = *(const unsigned char *)data;
173 break;
175 case BI_AMIGA_PSFREQ:
176 amiga_psfreq = *(const unsigned char *)data;
177 break;
179 case BI_AMIGA_AUTOCON:
180 #ifdef CONFIG_ZORRO
181 if (zorro_num_autocon < ZORRO_NUM_AUTO) {
182 const struct ConfigDev *cd = (struct ConfigDev *)data;
183 struct zorro_dev *dev = &zorro_autocon[zorro_num_autocon++];
184 dev->rom = cd->cd_Rom;
185 dev->slotaddr = cd->cd_SlotAddr;
186 dev->slotsize = cd->cd_SlotSize;
187 dev->resource.start = (unsigned long)cd->cd_BoardAddr;
188 dev->resource.end = dev->resource.start+cd->cd_BoardSize-1;
189 } else
190 printk("amiga_parse_bootinfo: too many AutoConfig devices\n");
191 #endif /* CONFIG_ZORRO */
192 break;
194 case BI_AMIGA_SERPER:
195 /* serial port period: ignored here */
196 break;
198 default:
199 unknown = 1;
201 return(unknown);
205 * Identify builtin hardware
208 static void __init amiga_identify(void)
210 /* Fill in some default values, if necessary */
211 if (amiga_eclock == 0)
212 amiga_eclock = 709379;
214 memset(&amiga_hw_present, 0, sizeof(amiga_hw_present));
216 printk("Amiga hardware found: ");
217 if (amiga_model >= AMI_500 && amiga_model <= AMI_DRACO) {
218 printk("[%s] ", amiga_models[amiga_model-AMI_500]);
219 strcat(amiga_model_name, amiga_models[amiga_model-AMI_500]);
222 switch(amiga_model) {
223 case AMI_UNKNOWN:
224 goto Generic;
226 case AMI_600:
227 case AMI_1200:
228 AMIGAHW_SET(A1200_IDE);
229 AMIGAHW_SET(PCMCIA);
230 case AMI_500:
231 case AMI_500PLUS:
232 case AMI_1000:
233 case AMI_2000:
234 case AMI_2500:
235 AMIGAHW_SET(A2000_CLK); /* Is this correct for all models? */
236 goto Generic;
238 case AMI_3000:
239 case AMI_3000T:
240 AMIGAHW_SET(AMBER_FF);
241 AMIGAHW_SET(MAGIC_REKICK);
242 /* fall through */
243 case AMI_3000PLUS:
244 AMIGAHW_SET(A3000_SCSI);
245 AMIGAHW_SET(A3000_CLK);
246 AMIGAHW_SET(ZORRO3);
247 goto Generic;
249 case AMI_4000T:
250 AMIGAHW_SET(A4000_SCSI);
251 /* fall through */
252 case AMI_4000:
253 AMIGAHW_SET(A4000_IDE);
254 AMIGAHW_SET(A3000_CLK);
255 AMIGAHW_SET(ZORRO3);
256 goto Generic;
258 case AMI_CDTV:
259 case AMI_CD32:
260 AMIGAHW_SET(CD_ROM);
261 AMIGAHW_SET(A2000_CLK); /* Is this correct? */
262 goto Generic;
264 Generic:
265 AMIGAHW_SET(AMI_VIDEO);
266 AMIGAHW_SET(AMI_BLITTER);
267 AMIGAHW_SET(AMI_AUDIO);
268 AMIGAHW_SET(AMI_FLOPPY);
269 AMIGAHW_SET(AMI_KEYBOARD);
270 AMIGAHW_SET(AMI_MOUSE);
271 AMIGAHW_SET(AMI_SERIAL);
272 AMIGAHW_SET(AMI_PARALLEL);
273 AMIGAHW_SET(CHIP_RAM);
274 AMIGAHW_SET(PAULA);
276 switch(amiga_chipset) {
277 case CS_OCS:
278 case CS_ECS:
279 case CS_AGA:
280 switch (amiga_custom.deniseid & 0xf) {
281 case 0x0c:
282 AMIGAHW_SET(DENISE_HR);
283 break;
284 case 0x08:
285 AMIGAHW_SET(LISA);
286 break;
288 break;
289 default:
290 AMIGAHW_SET(DENISE);
291 break;
293 switch ((amiga_custom.vposr>>8) & 0x7f) {
294 case 0x00:
295 AMIGAHW_SET(AGNUS_PAL);
296 break;
297 case 0x10:
298 AMIGAHW_SET(AGNUS_NTSC);
299 break;
300 case 0x20:
301 case 0x21:
302 AMIGAHW_SET(AGNUS_HR_PAL);
303 break;
304 case 0x30:
305 case 0x31:
306 AMIGAHW_SET(AGNUS_HR_NTSC);
307 break;
308 case 0x22:
309 case 0x23:
310 AMIGAHW_SET(ALICE_PAL);
311 break;
312 case 0x32:
313 case 0x33:
314 AMIGAHW_SET(ALICE_NTSC);
315 break;
317 AMIGAHW_SET(ZORRO);
318 break;
320 case AMI_DRACO:
321 panic("No support for Draco yet");
323 default:
324 panic("Unknown Amiga Model");
327 #define AMIGAHW_ANNOUNCE(name, str) \
328 if (AMIGAHW_PRESENT(name)) \
329 printk(str)
331 AMIGAHW_ANNOUNCE(AMI_VIDEO, "VIDEO ");
332 AMIGAHW_ANNOUNCE(AMI_BLITTER, "BLITTER ");
333 AMIGAHW_ANNOUNCE(AMBER_FF, "AMBER_FF ");
334 AMIGAHW_ANNOUNCE(AMI_AUDIO, "AUDIO ");
335 AMIGAHW_ANNOUNCE(AMI_FLOPPY, "FLOPPY ");
336 AMIGAHW_ANNOUNCE(A3000_SCSI, "A3000_SCSI ");
337 AMIGAHW_ANNOUNCE(A4000_SCSI, "A4000_SCSI ");
338 AMIGAHW_ANNOUNCE(A1200_IDE, "A1200_IDE ");
339 AMIGAHW_ANNOUNCE(A4000_IDE, "A4000_IDE ");
340 AMIGAHW_ANNOUNCE(CD_ROM, "CD_ROM ");
341 AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "KEYBOARD ");
342 AMIGAHW_ANNOUNCE(AMI_MOUSE, "MOUSE ");
343 AMIGAHW_ANNOUNCE(AMI_SERIAL, "SERIAL ");
344 AMIGAHW_ANNOUNCE(AMI_PARALLEL, "PARALLEL ");
345 AMIGAHW_ANNOUNCE(A2000_CLK, "A2000_CLK ");
346 AMIGAHW_ANNOUNCE(A3000_CLK, "A3000_CLK ");
347 AMIGAHW_ANNOUNCE(CHIP_RAM, "CHIP_RAM ");
348 AMIGAHW_ANNOUNCE(PAULA, "PAULA ");
349 AMIGAHW_ANNOUNCE(DENISE, "DENISE ");
350 AMIGAHW_ANNOUNCE(DENISE_HR, "DENISE_HR ");
351 AMIGAHW_ANNOUNCE(LISA, "LISA ");
352 AMIGAHW_ANNOUNCE(AGNUS_PAL, "AGNUS_PAL ");
353 AMIGAHW_ANNOUNCE(AGNUS_NTSC, "AGNUS_NTSC ");
354 AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "AGNUS_HR_PAL ");
355 AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "AGNUS_HR_NTSC ");
356 AMIGAHW_ANNOUNCE(ALICE_PAL, "ALICE_PAL ");
357 AMIGAHW_ANNOUNCE(ALICE_NTSC, "ALICE_NTSC ");
358 AMIGAHW_ANNOUNCE(MAGIC_REKICK, "MAGIC_REKICK ");
359 AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA ");
360 if (AMIGAHW_PRESENT(ZORRO))
361 printk("ZORRO%s ", AMIGAHW_PRESENT(ZORRO3) ? "3" : "");
362 printk("\n");
364 #undef AMIGAHW_ANNOUNCE
368 * Setup the Amiga configuration info
371 void __init config_amiga(void)
373 int i;
375 amiga_debug_init();
376 amiga_identify();
378 /* Yuk, we don't have PCI memory */
379 iomem_resource.name = "Memory";
380 for (i = 0; i < 4; i++)
381 request_resource(&iomem_resource, &((struct resource *)&mb_resources)[i]);
383 mach_sched_init = amiga_sched_init;
384 mach_init_IRQ = amiga_init_IRQ;
385 mach_get_model = amiga_get_model;
386 mach_get_hardware_list = amiga_get_hardware_list;
387 mach_gettimeoffset = amiga_gettimeoffset;
388 if (AMIGAHW_PRESENT(A3000_CLK)){
389 mach_hwclk = a3000_hwclk;
390 rtc_resource.name = "A3000 RTC";
391 request_resource(&iomem_resource, &rtc_resource);
393 else{ /* if (AMIGAHW_PRESENT(A2000_CLK)) */
394 mach_hwclk = a2000_hwclk;
395 rtc_resource.name = "A2000 RTC";
396 request_resource(&iomem_resource, &rtc_resource);
399 mach_max_dma_address = 0xffffffff; /*
400 * default MAX_DMA=0xffffffff
401 * on all machines. If we don't
402 * do so, the SCSI code will not
403 * be able to allocate any mem
404 * for transfers, unless we are
405 * dealing with a Z2 mem only
406 * system. /Jes
409 mach_set_clock_mmss = amiga_set_clock_mmss;
410 mach_get_ss = amiga_get_ss;
411 mach_reset = amiga_reset;
412 #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
413 mach_beep = amiga_mksound;
414 #endif
416 #ifdef CONFIG_HEARTBEAT
417 mach_heartbeat = amiga_heartbeat;
418 #endif
420 /* Fill in the clock values (based on the 700 kHz E-Clock) */
421 amiga_masterclock = 40*amiga_eclock; /* 28 MHz */
422 amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */
424 /* clear all DMA bits */
425 amiga_custom.dmacon = DMAF_ALL;
426 /* ensure that the DMA master bit is set */
427 amiga_custom.dmacon = DMAF_SETCLR | DMAF_MASTER;
429 /* don't use Z2 RAM as system memory on Z3 capable machines */
430 if (AMIGAHW_PRESENT(ZORRO3)) {
431 int i, j;
432 u32 disabled_z2mem = 0;
433 for (i = 0; i < m68k_num_memory; i++)
434 if (m68k_memory[i].addr < 16*1024*1024) {
435 if (i == 0) {
436 /* don't cut off the branch we're sitting on */
437 printk("Warning: kernel runs in Zorro II memory\n");
438 continue;
440 disabled_z2mem += m68k_memory[i].size;
441 m68k_num_memory--;
442 for (j = i; j < m68k_num_memory; j++)
443 m68k_memory[j] = m68k_memory[j+1];
444 i--;
446 if (disabled_z2mem)
447 printk("%dK of Zorro II memory will not be used as system memory\n",
448 disabled_z2mem>>10);
451 /* request all RAM */
452 for (i = 0; i < m68k_num_memory; i++) {
453 ram_resource[i].name =
454 (m68k_memory[i].addr >= 0x01000000) ? "32-bit Fast RAM" :
455 (m68k_memory[i].addr < 0x00c00000) ? "16-bit Fast RAM" :
456 "16-bit Slow RAM";
457 ram_resource[i].start = m68k_memory[i].addr;
458 ram_resource[i].end = m68k_memory[i].addr+m68k_memory[i].size-1;
459 request_resource(&iomem_resource, &ram_resource[i]);
462 /* initialize chipram allocator */
463 amiga_chip_init ();
465 /* debugging using chipram */
466 if (!strcmp( m68k_debug_device, "mem" )){
467 if (!AMIGAHW_PRESENT(CHIP_RAM))
468 printk("Warning: no chipram present for debugging\n");
469 else {
470 amiga_savekmsg_init();
471 amiga_console_driver.write = amiga_mem_console_write;
472 register_console(&amiga_console_driver);
476 /* our beloved beeper */
477 if (AMIGAHW_PRESENT(AMI_AUDIO))
478 amiga_init_sound();
481 * if it is an A3000, set the magic bit that forces
482 * a hard rekick
484 if (AMIGAHW_PRESENT(MAGIC_REKICK))
485 *(unsigned char *)ZTWO_VADDR(0xde0002) |= 0x80;
488 static unsigned short jiffy_ticks;
490 static void __init amiga_sched_init(irqreturn_t (*timer_routine)(int, void *,
491 struct pt_regs *))
493 static struct resource sched_res = {
494 .name = "timer", .start = 0x00bfd400, .end = 0x00bfd5ff,
496 jiffy_ticks = (amiga_eclock+HZ/2)/HZ;
498 if (request_resource(&mb_resources._ciab, &sched_res))
499 printk("Cannot allocate ciab.ta{lo,hi}\n");
500 ciab.cra &= 0xC0; /* turn off timer A, continuous mode, from Eclk */
501 ciab.talo = jiffy_ticks % 256;
502 ciab.tahi = jiffy_ticks / 256;
504 /* install interrupt service routine for CIAB Timer A
506 * Please don't change this to use ciaa, as it interferes with the
507 * SCSI code. We'll have to take a look at this later
509 request_irq(IRQ_AMIGA_CIAB_TA, timer_routine, 0, "timer", NULL);
510 /* start timer */
511 ciab.cra |= 0x11;
514 #define TICK_SIZE 10000
516 /* This is always executed with interrupts disabled. */
517 static unsigned long amiga_gettimeoffset (void)
519 unsigned short hi, lo, hi2;
520 unsigned long ticks, offset = 0;
522 /* read CIA B timer A current value */
523 hi = ciab.tahi;
524 lo = ciab.talo;
525 hi2 = ciab.tahi;
527 if (hi != hi2) {
528 lo = ciab.talo;
529 hi = hi2;
532 ticks = hi << 8 | lo;
534 if (ticks > jiffy_ticks / 2)
535 /* check for pending interrupt */
536 if (cia_set_irq(&ciab_base, 0) & CIA_ICR_TA)
537 offset = 10000;
539 ticks = jiffy_ticks - ticks;
540 ticks = (10000 * ticks) / jiffy_ticks;
542 return ticks + offset;
545 static int a3000_hwclk(int op, struct rtc_time *t)
547 tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD;
549 if (!op) { /* read */
550 t->tm_sec = tod_3000.second1 * 10 + tod_3000.second2;
551 t->tm_min = tod_3000.minute1 * 10 + tod_3000.minute2;
552 t->tm_hour = tod_3000.hour1 * 10 + tod_3000.hour2;
553 t->tm_mday = tod_3000.day1 * 10 + tod_3000.day2;
554 t->tm_wday = tod_3000.weekday;
555 t->tm_mon = tod_3000.month1 * 10 + tod_3000.month2 - 1;
556 t->tm_year = tod_3000.year1 * 10 + tod_3000.year2;
557 if (t->tm_year <= 69)
558 t->tm_year += 100;
559 } else {
560 tod_3000.second1 = t->tm_sec / 10;
561 tod_3000.second2 = t->tm_sec % 10;
562 tod_3000.minute1 = t->tm_min / 10;
563 tod_3000.minute2 = t->tm_min % 10;
564 tod_3000.hour1 = t->tm_hour / 10;
565 tod_3000.hour2 = t->tm_hour % 10;
566 tod_3000.day1 = t->tm_mday / 10;
567 tod_3000.day2 = t->tm_mday % 10;
568 if (t->tm_wday != -1)
569 tod_3000.weekday = t->tm_wday;
570 tod_3000.month1 = (t->tm_mon + 1) / 10;
571 tod_3000.month2 = (t->tm_mon + 1) % 10;
572 if (t->tm_year >= 100)
573 t->tm_year -= 100;
574 tod_3000.year1 = t->tm_year / 10;
575 tod_3000.year2 = t->tm_year % 10;
578 tod_3000.cntrl1 = TOD3000_CNTRL1_FREE;
580 return 0;
583 static int a2000_hwclk(int op, struct rtc_time *t)
585 int cnt = 5;
587 tod_2000.cntrl1 = TOD2000_CNTRL1_HOLD;
589 while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--)
591 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD;
592 udelay(70);
593 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD;
596 if (!cnt)
597 printk(KERN_INFO "hwclk: timed out waiting for RTC (0x%x)\n", tod_2000.cntrl1);
599 if (!op) { /* read */
600 t->tm_sec = tod_2000.second1 * 10 + tod_2000.second2;
601 t->tm_min = tod_2000.minute1 * 10 + tod_2000.minute2;
602 t->tm_hour = (tod_2000.hour1 & 3) * 10 + tod_2000.hour2;
603 t->tm_mday = tod_2000.day1 * 10 + tod_2000.day2;
604 t->tm_wday = tod_2000.weekday;
605 t->tm_mon = tod_2000.month1 * 10 + tod_2000.month2 - 1;
606 t->tm_year = tod_2000.year1 * 10 + tod_2000.year2;
607 if (t->tm_year <= 69)
608 t->tm_year += 100;
610 if (!(tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE)){
611 if (!(tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour == 12)
612 t->tm_hour = 0;
613 else if ((tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour != 12)
614 t->tm_hour += 12;
616 } else {
617 tod_2000.second1 = t->tm_sec / 10;
618 tod_2000.second2 = t->tm_sec % 10;
619 tod_2000.minute1 = t->tm_min / 10;
620 tod_2000.minute2 = t->tm_min % 10;
621 if (tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE)
622 tod_2000.hour1 = t->tm_hour / 10;
623 else if (t->tm_hour >= 12)
624 tod_2000.hour1 = TOD2000_HOUR1_PM +
625 (t->tm_hour - 12) / 10;
626 else
627 tod_2000.hour1 = t->tm_hour / 10;
628 tod_2000.hour2 = t->tm_hour % 10;
629 tod_2000.day1 = t->tm_mday / 10;
630 tod_2000.day2 = t->tm_mday % 10;
631 if (t->tm_wday != -1)
632 tod_2000.weekday = t->tm_wday;
633 tod_2000.month1 = (t->tm_mon + 1) / 10;
634 tod_2000.month2 = (t->tm_mon + 1) % 10;
635 if (t->tm_year >= 100)
636 t->tm_year -= 100;
637 tod_2000.year1 = t->tm_year / 10;
638 tod_2000.year2 = t->tm_year % 10;
641 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD;
643 return 0;
646 static int amiga_set_clock_mmss (unsigned long nowtime)
648 short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60;
650 if (AMIGAHW_PRESENT(A3000_CLK)) {
651 tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD;
653 tod_3000.second1 = real_seconds / 10;
654 tod_3000.second2 = real_seconds % 10;
655 tod_3000.minute1 = real_minutes / 10;
656 tod_3000.minute2 = real_minutes % 10;
658 tod_3000.cntrl1 = TOD3000_CNTRL1_FREE;
659 } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ {
660 int cnt = 5;
662 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD;
664 while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--)
666 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD;
667 udelay(70);
668 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD;
671 if (!cnt)
672 printk(KERN_INFO "set_clock_mmss: timed out waiting for RTC (0x%x)\n", tod_2000.cntrl1);
674 tod_2000.second1 = real_seconds / 10;
675 tod_2000.second2 = real_seconds % 10;
676 tod_2000.minute1 = real_minutes / 10;
677 tod_2000.minute2 = real_minutes % 10;
679 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD;
682 return 0;
685 static unsigned int amiga_get_ss( void )
687 unsigned int s;
689 if (AMIGAHW_PRESENT(A3000_CLK)) {
690 tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD;
691 s = tod_3000.second1 * 10 + tod_3000.second2;
692 tod_3000.cntrl1 = TOD3000_CNTRL1_FREE;
693 } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ {
694 s = tod_2000.second1 * 10 + tod_2000.second2;
696 return s;
699 static NORET_TYPE void amiga_reset( void )
700 ATTRIB_NORET;
702 static void amiga_reset (void)
704 unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
705 unsigned long jmp_addr = virt_to_phys(&&jmp_addr_label);
707 local_irq_disable();
708 if (CPU_IS_040_OR_060)
709 /* Setup transparent translation registers for mapping
710 * of 16 MB kernel segment before disabling translation
712 __asm__ __volatile__
713 ("movel %0,%/d0\n\t"
714 "andl #0xff000000,%/d0\n\t"
715 "orw #0xe020,%/d0\n\t" /* map 16 MB, enable, cacheable */
716 ".chip 68040\n\t"
717 "movec %%d0,%%itt0\n\t"
718 "movec %%d0,%%dtt0\n\t"
719 ".chip 68k\n\t"
720 "jmp %0@\n\t"
721 : /* no outputs */
722 : "a" (jmp_addr040));
723 else
724 /* for 680[23]0, just disable translation and jump to the physical
725 * address of the label
727 __asm__ __volatile__
728 ("pmove %/tc,%@\n\t"
729 "bclr #7,%@\n\t"
730 "pmove %@,%/tc\n\t"
731 "jmp %0@\n\t"
732 : /* no outputs */
733 : "a" (jmp_addr));
734 jmp_addr_label040:
735 /* disable translation on '040 now */
736 __asm__ __volatile__
737 ("moveq #0,%/d0\n\t"
738 ".chip 68040\n\t"
739 "movec %%d0,%%tc\n\t" /* disable MMU */
740 ".chip 68k\n\t"
741 : /* no outputs */
742 : /* no inputs */
743 : "d0");
745 jmp_addr_label:
746 /* pickup reset address from AmigaOS ROM, reset devices and jump
747 * to reset address
749 __asm__ __volatile__
750 ("movew #0x2700,%/sr\n\t"
751 "leal 0x01000000,%/a0\n\t"
752 "subl %/a0@(-0x14),%/a0\n\t"
753 "movel %/a0@(4),%/a0\n\t"
754 "subql #2,%/a0\n\t"
755 "bra 1f\n\t"
756 /* align on a longword boundary */
757 __ALIGN_STR "\n"
758 "1:\n\t"
759 "reset\n\t"
760 "jmp %/a0@" : /* Just that gcc scans it for % escapes */ );
762 for (;;);
768 * Debugging
771 #define SAVEKMSG_MAXMEM 128*1024
773 #define SAVEKMSG_MAGIC1 0x53415645 /* 'SAVE' */
774 #define SAVEKMSG_MAGIC2 0x4B4D5347 /* 'KMSG' */
776 struct savekmsg {
777 unsigned long magic1; /* SAVEKMSG_MAGIC1 */
778 unsigned long magic2; /* SAVEKMSG_MAGIC2 */
779 unsigned long magicptr; /* address of magic1 */
780 unsigned long size;
781 char data[0];
784 static struct savekmsg *savekmsg;
786 static void amiga_mem_console_write(struct console *co, const char *s,
787 unsigned int count)
789 if (savekmsg->size+count <= SAVEKMSG_MAXMEM-sizeof(struct savekmsg)) {
790 memcpy(savekmsg->data+savekmsg->size, s, count);
791 savekmsg->size += count;
795 static void amiga_savekmsg_init(void)
797 static struct resource debug_res = { .name = "Debug" };
799 savekmsg = amiga_chip_alloc_res(SAVEKMSG_MAXMEM, &debug_res);
800 savekmsg->magic1 = SAVEKMSG_MAGIC1;
801 savekmsg->magic2 = SAVEKMSG_MAGIC2;
802 savekmsg->magicptr = ZTWO_PADDR(savekmsg);
803 savekmsg->size = 0;
806 static void amiga_serial_putc(char c)
808 amiga_custom.serdat = (unsigned char)c | 0x100;
809 while (!(amiga_custom.serdatr & 0x2000))
813 void amiga_serial_console_write(struct console *co, const char *s,
814 unsigned int count)
816 while (count--) {
817 if (*s == '\n')
818 amiga_serial_putc('\r');
819 amiga_serial_putc(*s++);
823 #ifdef CONFIG_SERIAL_CONSOLE
824 void amiga_serial_puts(const char *s)
826 amiga_serial_console_write(NULL, s, strlen(s));
829 int amiga_serial_console_wait_key(struct console *co)
831 int ch;
833 while (!(amiga_custom.intreqr & IF_RBF))
834 barrier();
835 ch = amiga_custom.serdatr & 0xff;
836 /* clear the interrupt, so that another character can be read */
837 amiga_custom.intreq = IF_RBF;
838 return ch;
841 void amiga_serial_gets(struct console *co, char *s, int len)
843 int ch, cnt = 0;
845 while (1) {
846 ch = amiga_serial_console_wait_key(co);
848 /* Check for backspace. */
849 if (ch == 8 || ch == 127) {
850 if (cnt == 0) {
851 amiga_serial_putc('\007');
852 continue;
854 cnt--;
855 amiga_serial_puts("\010 \010");
856 continue;
859 /* Check for enter. */
860 if (ch == 10 || ch == 13)
861 break;
863 /* See if line is too long. */
864 if (cnt >= len + 1) {
865 amiga_serial_putc(7);
866 cnt--;
867 continue;
870 /* Store and echo character. */
871 s[cnt++] = ch;
872 amiga_serial_putc(ch);
874 /* Print enter. */
875 amiga_serial_puts("\r\n");
876 s[cnt] = 0;
878 #endif
880 static void __init amiga_debug_init(void)
882 if (!strcmp( m68k_debug_device, "ser" )) {
883 /* no initialization required (?) */
884 amiga_console_driver.write = amiga_serial_console_write;
885 register_console(&amiga_console_driver);
889 #ifdef CONFIG_HEARTBEAT
890 static void amiga_heartbeat(int on)
892 if (on)
893 ciaa.pra &= ~2;
894 else
895 ciaa.pra |= 2;
897 #endif
900 * Amiga specific parts of /proc
903 static void amiga_get_model(char *model)
905 strcpy(model, amiga_model_name);
909 static int amiga_get_hardware_list(char *buffer)
911 int len = 0;
913 if (AMIGAHW_PRESENT(CHIP_RAM))
914 len += sprintf(buffer+len, "Chip RAM:\t%ldK\n", amiga_chip_size>>10);
915 len += sprintf(buffer+len, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n",
916 amiga_psfreq, amiga_eclock);
917 if (AMIGAHW_PRESENT(AMI_VIDEO)) {
918 char *type;
919 switch(amiga_chipset) {
920 case CS_OCS:
921 type = "OCS";
922 break;
923 case CS_ECS:
924 type = "ECS";
925 break;
926 case CS_AGA:
927 type = "AGA";
928 break;
929 default:
930 type = "Old or Unknown";
931 break;
933 len += sprintf(buffer+len, "Graphics:\t%s\n", type);
936 #define AMIGAHW_ANNOUNCE(name, str) \
937 if (AMIGAHW_PRESENT(name)) \
938 len += sprintf (buffer+len, "\t%s\n", str)
940 len += sprintf (buffer + len, "Detected hardware:\n");
942 AMIGAHW_ANNOUNCE(AMI_VIDEO, "Amiga Video");
943 AMIGAHW_ANNOUNCE(AMI_BLITTER, "Blitter");
944 AMIGAHW_ANNOUNCE(AMBER_FF, "Amber Flicker Fixer");
945 AMIGAHW_ANNOUNCE(AMI_AUDIO, "Amiga Audio");
946 AMIGAHW_ANNOUNCE(AMI_FLOPPY, "Floppy Controller");
947 AMIGAHW_ANNOUNCE(A3000_SCSI, "SCSI Controller WD33C93 (A3000 style)");
948 AMIGAHW_ANNOUNCE(A4000_SCSI, "SCSI Controller NCR53C710 (A4000T style)");
949 AMIGAHW_ANNOUNCE(A1200_IDE, "IDE Interface (A1200 style)");
950 AMIGAHW_ANNOUNCE(A4000_IDE, "IDE Interface (A4000 style)");
951 AMIGAHW_ANNOUNCE(CD_ROM, "Internal CD ROM drive");
952 AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "Keyboard");
953 AMIGAHW_ANNOUNCE(AMI_MOUSE, "Mouse Port");
954 AMIGAHW_ANNOUNCE(AMI_SERIAL, "Serial Port");
955 AMIGAHW_ANNOUNCE(AMI_PARALLEL, "Parallel Port");
956 AMIGAHW_ANNOUNCE(A2000_CLK, "Hardware Clock (A2000 style)");
957 AMIGAHW_ANNOUNCE(A3000_CLK, "Hardware Clock (A3000 style)");
958 AMIGAHW_ANNOUNCE(CHIP_RAM, "Chip RAM");
959 AMIGAHW_ANNOUNCE(PAULA, "Paula 8364");
960 AMIGAHW_ANNOUNCE(DENISE, "Denise 8362");
961 AMIGAHW_ANNOUNCE(DENISE_HR, "Denise 8373");
962 AMIGAHW_ANNOUNCE(LISA, "Lisa 8375");
963 AMIGAHW_ANNOUNCE(AGNUS_PAL, "Normal/Fat PAL Agnus 8367/8371");
964 AMIGAHW_ANNOUNCE(AGNUS_NTSC, "Normal/Fat NTSC Agnus 8361/8370");
965 AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "Fat Hires PAL Agnus 8372");
966 AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "Fat Hires NTSC Agnus 8372");
967 AMIGAHW_ANNOUNCE(ALICE_PAL, "PAL Alice 8374");
968 AMIGAHW_ANNOUNCE(ALICE_NTSC, "NTSC Alice 8374");
969 AMIGAHW_ANNOUNCE(MAGIC_REKICK, "Magic Hard Rekick");
970 AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA Slot");
971 #ifdef CONFIG_ZORRO
972 if (AMIGAHW_PRESENT(ZORRO))
973 len += sprintf(buffer+len, "\tZorro II%s AutoConfig: %d Expansion "
974 "Device%s\n",
975 AMIGAHW_PRESENT(ZORRO3) ? "I" : "",
976 zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s");
977 #endif /* CONFIG_ZORRO */
979 #undef AMIGAHW_ANNOUNCE
981 return(len);