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