11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * linux/arch/m68k/amiga/config.c 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Copyright (C) 1993 Hamish Macdonald 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This file is subject to the terms and conditions of the GNU General Public 71da177e4SLinus Torvalds * License. See the file COPYING in the main directory of this archive 81da177e4SLinus Torvalds * for more details. 91da177e4SLinus Torvalds */ 101da177e4SLinus Torvalds 111da177e4SLinus Torvalds /* 121da177e4SLinus Torvalds * Miscellaneous Amiga stuff 131da177e4SLinus Torvalds */ 141da177e4SLinus Torvalds 151da177e4SLinus Torvalds #include <linux/config.h> 161da177e4SLinus Torvalds #include <linux/types.h> 171da177e4SLinus Torvalds #include <linux/kernel.h> 181da177e4SLinus Torvalds #include <linux/mm.h> 191da177e4SLinus Torvalds #include <linux/tty.h> 201da177e4SLinus Torvalds #include <linux/console.h> 211da177e4SLinus Torvalds #include <linux/rtc.h> 221da177e4SLinus Torvalds #include <linux/init.h> 231da177e4SLinus Torvalds #include <linux/vt_kern.h> 241da177e4SLinus Torvalds #include <linux/delay.h> 251da177e4SLinus Torvalds #include <linux/interrupt.h> 261da177e4SLinus Torvalds #ifdef CONFIG_ZORRO 271da177e4SLinus Torvalds #include <linux/zorro.h> 281da177e4SLinus Torvalds #endif 291da177e4SLinus Torvalds 301da177e4SLinus Torvalds #include <asm/bootinfo.h> 311da177e4SLinus Torvalds #include <asm/setup.h> 321da177e4SLinus Torvalds #include <asm/system.h> 331da177e4SLinus Torvalds #include <asm/pgtable.h> 341da177e4SLinus Torvalds #include <asm/amigahw.h> 351da177e4SLinus Torvalds #include <asm/amigaints.h> 361da177e4SLinus Torvalds #include <asm/irq.h> 371da177e4SLinus Torvalds #include <asm/rtc.h> 381da177e4SLinus Torvalds #include <asm/machdep.h> 391da177e4SLinus Torvalds #include <asm/io.h> 401da177e4SLinus Torvalds 411da177e4SLinus Torvalds unsigned long amiga_model; 421da177e4SLinus Torvalds unsigned long amiga_eclock; 431da177e4SLinus Torvalds unsigned long amiga_masterclock; 441da177e4SLinus Torvalds unsigned long amiga_colorclock; 451da177e4SLinus Torvalds unsigned long amiga_chipset; 461da177e4SLinus Torvalds unsigned char amiga_vblank; 471da177e4SLinus Torvalds unsigned char amiga_psfreq; 481da177e4SLinus Torvalds struct amiga_hw_present amiga_hw_present; 491da177e4SLinus Torvalds 501da177e4SLinus Torvalds static char s_a500[] __initdata = "A500"; 511da177e4SLinus Torvalds static char s_a500p[] __initdata = "A500+"; 521da177e4SLinus Torvalds static char s_a600[] __initdata = "A600"; 531da177e4SLinus Torvalds static char s_a1000[] __initdata = "A1000"; 541da177e4SLinus Torvalds static char s_a1200[] __initdata = "A1200"; 551da177e4SLinus Torvalds static char s_a2000[] __initdata = "A2000"; 561da177e4SLinus Torvalds static char s_a2500[] __initdata = "A2500"; 571da177e4SLinus Torvalds static char s_a3000[] __initdata = "A3000"; 581da177e4SLinus Torvalds static char s_a3000t[] __initdata = "A3000T"; 591da177e4SLinus Torvalds static char s_a3000p[] __initdata = "A3000+"; 601da177e4SLinus Torvalds static char s_a4000[] __initdata = "A4000"; 611da177e4SLinus Torvalds static char s_a4000t[] __initdata = "A4000T"; 621da177e4SLinus Torvalds static char s_cdtv[] __initdata = "CDTV"; 631da177e4SLinus Torvalds static char s_cd32[] __initdata = "CD32"; 641da177e4SLinus Torvalds static char s_draco[] __initdata = "Draco"; 651da177e4SLinus Torvalds static char *amiga_models[] __initdata = { 661da177e4SLinus Torvalds [AMI_500-AMI_500] = s_a500, 671da177e4SLinus Torvalds [AMI_500PLUS-AMI_500] = s_a500p, 681da177e4SLinus Torvalds [AMI_600-AMI_500] = s_a600, 691da177e4SLinus Torvalds [AMI_1000-AMI_500] = s_a1000, 701da177e4SLinus Torvalds [AMI_1200-AMI_500] = s_a1200, 711da177e4SLinus Torvalds [AMI_2000-AMI_500] = s_a2000, 721da177e4SLinus Torvalds [AMI_2500-AMI_500] = s_a2500, 731da177e4SLinus Torvalds [AMI_3000-AMI_500] = s_a3000, 741da177e4SLinus Torvalds [AMI_3000T-AMI_500] = s_a3000t, 751da177e4SLinus Torvalds [AMI_3000PLUS-AMI_500] = s_a3000p, 761da177e4SLinus Torvalds [AMI_4000-AMI_500] = s_a4000, 771da177e4SLinus Torvalds [AMI_4000T-AMI_500] = s_a4000t, 781da177e4SLinus Torvalds [AMI_CDTV-AMI_500] = s_cdtv, 791da177e4SLinus Torvalds [AMI_CD32-AMI_500] = s_cd32, 801da177e4SLinus Torvalds [AMI_DRACO-AMI_500] = s_draco, 811da177e4SLinus Torvalds }; 821da177e4SLinus Torvalds 831da177e4SLinus Torvalds static char amiga_model_name[13] = "Amiga "; 841da177e4SLinus Torvalds 851da177e4SLinus Torvalds extern char m68k_debug_device[]; 861da177e4SLinus Torvalds 871da177e4SLinus Torvalds static void amiga_sched_init(irqreturn_t (*handler)(int, void *, struct pt_regs *)); 881da177e4SLinus Torvalds /* amiga specific irq functions */ 891da177e4SLinus Torvalds extern void amiga_init_IRQ (void); 901da177e4SLinus Torvalds extern irqreturn_t (*amiga_default_handler[]) (int, void *, struct pt_regs *); 911da177e4SLinus Torvalds extern int amiga_request_irq (unsigned int irq, 921da177e4SLinus Torvalds irqreturn_t (*handler)(int, void *, struct pt_regs *), 931da177e4SLinus Torvalds unsigned long flags, const char *devname, 941da177e4SLinus Torvalds void *dev_id); 951da177e4SLinus Torvalds extern void amiga_free_irq (unsigned int irq, void *dev_id); 961da177e4SLinus Torvalds extern void amiga_enable_irq (unsigned int); 971da177e4SLinus Torvalds extern void amiga_disable_irq (unsigned int); 981da177e4SLinus Torvalds static void amiga_get_model(char *model); 991da177e4SLinus Torvalds static int amiga_get_hardware_list(char *buffer); 1001da177e4SLinus Torvalds extern int show_amiga_interrupts (struct seq_file *, void *); 1011da177e4SLinus Torvalds /* amiga specific timer functions */ 1021da177e4SLinus Torvalds static unsigned long amiga_gettimeoffset (void); 1031da177e4SLinus Torvalds static int a3000_hwclk (int, struct rtc_time *); 1041da177e4SLinus Torvalds static int a2000_hwclk (int, struct rtc_time *); 1051da177e4SLinus Torvalds static int amiga_set_clock_mmss (unsigned long); 1061da177e4SLinus Torvalds static unsigned int amiga_get_ss (void); 1071da177e4SLinus Torvalds extern void amiga_mksound( unsigned int count, unsigned int ticks ); 1081da177e4SLinus Torvalds #ifdef CONFIG_AMIGA_FLOPPY 1091da177e4SLinus Torvalds extern void amiga_floppy_setup(char *, int *); 1101da177e4SLinus Torvalds #endif 1111da177e4SLinus Torvalds static void amiga_reset (void); 1121da177e4SLinus Torvalds extern void amiga_init_sound(void); 1131da177e4SLinus Torvalds static void amiga_savekmsg_init(void); 1141da177e4SLinus Torvalds static void amiga_mem_console_write(struct console *co, const char *b, 1151da177e4SLinus Torvalds unsigned int count); 1161da177e4SLinus Torvalds void amiga_serial_console_write(struct console *co, const char *s, 1171da177e4SLinus Torvalds unsigned int count); 1181da177e4SLinus Torvalds static void amiga_debug_init(void); 1191da177e4SLinus Torvalds #ifdef CONFIG_HEARTBEAT 1201da177e4SLinus Torvalds static void amiga_heartbeat(int on); 1211da177e4SLinus Torvalds #endif 1221da177e4SLinus Torvalds 1231da177e4SLinus Torvalds static struct console amiga_console_driver = { 1241da177e4SLinus Torvalds .name = "debug", 1251da177e4SLinus Torvalds .flags = CON_PRINTBUFFER, 1261da177e4SLinus Torvalds .index = -1, 1271da177e4SLinus Torvalds }; 1281da177e4SLinus Torvalds 1291da177e4SLinus Torvalds 1301da177e4SLinus Torvalds /* 1311da177e4SLinus Torvalds * Motherboard Resources present in all Amiga models 1321da177e4SLinus Torvalds */ 1331da177e4SLinus Torvalds 1341da177e4SLinus Torvalds static struct { 1351da177e4SLinus Torvalds struct resource _ciab, _ciaa, _custom, _kickstart; 1361da177e4SLinus Torvalds } mb_resources = { 1371da177e4SLinus Torvalds ._ciab = { 1381da177e4SLinus Torvalds .name = "CIA B", .start = 0x00bfd000, .end = 0x00bfdfff 1391da177e4SLinus Torvalds }, 1401da177e4SLinus Torvalds ._ciaa = { 1411da177e4SLinus Torvalds .name = "CIA A", .start = 0x00bfe000, .end = 0x00bfefff 1421da177e4SLinus Torvalds }, 1431da177e4SLinus Torvalds ._custom = { 1441da177e4SLinus Torvalds .name = "Custom I/O", .start = 0x00dff000, .end = 0x00dfffff 1451da177e4SLinus Torvalds }, 1461da177e4SLinus Torvalds ._kickstart = { 1471da177e4SLinus Torvalds .name = "Kickstart ROM", .start = 0x00f80000, .end = 0x00ffffff 1481da177e4SLinus Torvalds } 1491da177e4SLinus Torvalds }; 1501da177e4SLinus Torvalds 1511da177e4SLinus Torvalds static struct resource rtc_resource = { 1521da177e4SLinus Torvalds .start = 0x00dc0000, .end = 0x00dcffff 1531da177e4SLinus Torvalds }; 1541da177e4SLinus Torvalds 1551da177e4SLinus Torvalds static struct resource ram_resource[NUM_MEMINFO]; 1561da177e4SLinus Torvalds 1571da177e4SLinus Torvalds 1581da177e4SLinus Torvalds /* 1591da177e4SLinus Torvalds * Parse an Amiga-specific record in the bootinfo 1601da177e4SLinus Torvalds */ 1611da177e4SLinus Torvalds 1621da177e4SLinus Torvalds int amiga_parse_bootinfo(const struct bi_record *record) 1631da177e4SLinus Torvalds { 1641da177e4SLinus Torvalds int unknown = 0; 1651da177e4SLinus Torvalds const unsigned long *data = record->data; 1661da177e4SLinus Torvalds 1671da177e4SLinus Torvalds switch (record->tag) { 1681da177e4SLinus Torvalds case BI_AMIGA_MODEL: 1691da177e4SLinus Torvalds amiga_model = *data; 1701da177e4SLinus Torvalds break; 1711da177e4SLinus Torvalds 1721da177e4SLinus Torvalds case BI_AMIGA_ECLOCK: 1731da177e4SLinus Torvalds amiga_eclock = *data; 1741da177e4SLinus Torvalds break; 1751da177e4SLinus Torvalds 1761da177e4SLinus Torvalds case BI_AMIGA_CHIPSET: 1771da177e4SLinus Torvalds amiga_chipset = *data; 1781da177e4SLinus Torvalds break; 1791da177e4SLinus Torvalds 1801da177e4SLinus Torvalds case BI_AMIGA_CHIP_SIZE: 1811da177e4SLinus Torvalds amiga_chip_size = *(const int *)data; 1821da177e4SLinus Torvalds break; 1831da177e4SLinus Torvalds 1841da177e4SLinus Torvalds case BI_AMIGA_VBLANK: 1851da177e4SLinus Torvalds amiga_vblank = *(const unsigned char *)data; 1861da177e4SLinus Torvalds break; 1871da177e4SLinus Torvalds 1881da177e4SLinus Torvalds case BI_AMIGA_PSFREQ: 1891da177e4SLinus Torvalds amiga_psfreq = *(const unsigned char *)data; 1901da177e4SLinus Torvalds break; 1911da177e4SLinus Torvalds 1921da177e4SLinus Torvalds case BI_AMIGA_AUTOCON: 1931da177e4SLinus Torvalds #ifdef CONFIG_ZORRO 1941da177e4SLinus Torvalds if (zorro_num_autocon < ZORRO_NUM_AUTO) { 1951da177e4SLinus Torvalds const struct ConfigDev *cd = (struct ConfigDev *)data; 1961da177e4SLinus Torvalds struct zorro_dev *dev = &zorro_autocon[zorro_num_autocon++]; 1971da177e4SLinus Torvalds dev->rom = cd->cd_Rom; 1981da177e4SLinus Torvalds dev->slotaddr = cd->cd_SlotAddr; 1991da177e4SLinus Torvalds dev->slotsize = cd->cd_SlotSize; 2001da177e4SLinus Torvalds dev->resource.start = (unsigned long)cd->cd_BoardAddr; 2011da177e4SLinus Torvalds dev->resource.end = dev->resource.start+cd->cd_BoardSize-1; 2021da177e4SLinus Torvalds } else 2031da177e4SLinus Torvalds printk("amiga_parse_bootinfo: too many AutoConfig devices\n"); 2041da177e4SLinus Torvalds #endif /* CONFIG_ZORRO */ 2051da177e4SLinus Torvalds break; 2061da177e4SLinus Torvalds 2071da177e4SLinus Torvalds case BI_AMIGA_SERPER: 2081da177e4SLinus Torvalds /* serial port period: ignored here */ 2091da177e4SLinus Torvalds break; 2101da177e4SLinus Torvalds 2111da177e4SLinus Torvalds default: 2121da177e4SLinus Torvalds unknown = 1; 2131da177e4SLinus Torvalds } 2141da177e4SLinus Torvalds return(unknown); 2151da177e4SLinus Torvalds } 2161da177e4SLinus Torvalds 2171da177e4SLinus Torvalds /* 2181da177e4SLinus Torvalds * Identify builtin hardware 2191da177e4SLinus Torvalds */ 2201da177e4SLinus Torvalds 2211da177e4SLinus Torvalds static void __init amiga_identify(void) 2221da177e4SLinus Torvalds { 2231da177e4SLinus Torvalds /* Fill in some default values, if necessary */ 2241da177e4SLinus Torvalds if (amiga_eclock == 0) 2251da177e4SLinus Torvalds amiga_eclock = 709379; 2261da177e4SLinus Torvalds 2271da177e4SLinus Torvalds memset(&amiga_hw_present, 0, sizeof(amiga_hw_present)); 2281da177e4SLinus Torvalds 2291da177e4SLinus Torvalds printk("Amiga hardware found: "); 2301da177e4SLinus Torvalds if (amiga_model >= AMI_500 && amiga_model <= AMI_DRACO) { 2311da177e4SLinus Torvalds printk("[%s] ", amiga_models[amiga_model-AMI_500]); 2321da177e4SLinus Torvalds strcat(amiga_model_name, amiga_models[amiga_model-AMI_500]); 2331da177e4SLinus Torvalds } 2341da177e4SLinus Torvalds 2351da177e4SLinus Torvalds switch(amiga_model) { 2361da177e4SLinus Torvalds case AMI_UNKNOWN: 2371da177e4SLinus Torvalds goto Generic; 2381da177e4SLinus Torvalds 2391da177e4SLinus Torvalds case AMI_600: 2401da177e4SLinus Torvalds case AMI_1200: 2411da177e4SLinus Torvalds AMIGAHW_SET(A1200_IDE); 2421da177e4SLinus Torvalds AMIGAHW_SET(PCMCIA); 2431da177e4SLinus Torvalds case AMI_500: 2441da177e4SLinus Torvalds case AMI_500PLUS: 2451da177e4SLinus Torvalds case AMI_1000: 2461da177e4SLinus Torvalds case AMI_2000: 2471da177e4SLinus Torvalds case AMI_2500: 2481da177e4SLinus Torvalds AMIGAHW_SET(A2000_CLK); /* Is this correct for all models? */ 2491da177e4SLinus Torvalds goto Generic; 2501da177e4SLinus Torvalds 2511da177e4SLinus Torvalds case AMI_3000: 2521da177e4SLinus Torvalds case AMI_3000T: 2531da177e4SLinus Torvalds AMIGAHW_SET(AMBER_FF); 2541da177e4SLinus Torvalds AMIGAHW_SET(MAGIC_REKICK); 2551da177e4SLinus Torvalds /* fall through */ 2561da177e4SLinus Torvalds case AMI_3000PLUS: 2571da177e4SLinus Torvalds AMIGAHW_SET(A3000_SCSI); 2581da177e4SLinus Torvalds AMIGAHW_SET(A3000_CLK); 2591da177e4SLinus Torvalds AMIGAHW_SET(ZORRO3); 2601da177e4SLinus Torvalds goto Generic; 2611da177e4SLinus Torvalds 2621da177e4SLinus Torvalds case AMI_4000T: 2631da177e4SLinus Torvalds AMIGAHW_SET(A4000_SCSI); 2641da177e4SLinus Torvalds /* fall through */ 2651da177e4SLinus Torvalds case AMI_4000: 2661da177e4SLinus Torvalds AMIGAHW_SET(A4000_IDE); 2671da177e4SLinus Torvalds AMIGAHW_SET(A3000_CLK); 2681da177e4SLinus Torvalds AMIGAHW_SET(ZORRO3); 2691da177e4SLinus Torvalds goto Generic; 2701da177e4SLinus Torvalds 2711da177e4SLinus Torvalds case AMI_CDTV: 2721da177e4SLinus Torvalds case AMI_CD32: 2731da177e4SLinus Torvalds AMIGAHW_SET(CD_ROM); 2741da177e4SLinus Torvalds AMIGAHW_SET(A2000_CLK); /* Is this correct? */ 2751da177e4SLinus Torvalds goto Generic; 2761da177e4SLinus Torvalds 2771da177e4SLinus Torvalds Generic: 2781da177e4SLinus Torvalds AMIGAHW_SET(AMI_VIDEO); 2791da177e4SLinus Torvalds AMIGAHW_SET(AMI_BLITTER); 2801da177e4SLinus Torvalds AMIGAHW_SET(AMI_AUDIO); 2811da177e4SLinus Torvalds AMIGAHW_SET(AMI_FLOPPY); 2821da177e4SLinus Torvalds AMIGAHW_SET(AMI_KEYBOARD); 2831da177e4SLinus Torvalds AMIGAHW_SET(AMI_MOUSE); 2841da177e4SLinus Torvalds AMIGAHW_SET(AMI_SERIAL); 2851da177e4SLinus Torvalds AMIGAHW_SET(AMI_PARALLEL); 2861da177e4SLinus Torvalds AMIGAHW_SET(CHIP_RAM); 2871da177e4SLinus Torvalds AMIGAHW_SET(PAULA); 2881da177e4SLinus Torvalds 2891da177e4SLinus Torvalds switch(amiga_chipset) { 2901da177e4SLinus Torvalds case CS_OCS: 2911da177e4SLinus Torvalds case CS_ECS: 2921da177e4SLinus Torvalds case CS_AGA: 293*b4290a23SAl Viro switch (amiga_custom.deniseid & 0xf) { 2941da177e4SLinus Torvalds case 0x0c: 2951da177e4SLinus Torvalds AMIGAHW_SET(DENISE_HR); 2961da177e4SLinus Torvalds break; 2971da177e4SLinus Torvalds case 0x08: 2981da177e4SLinus Torvalds AMIGAHW_SET(LISA); 2991da177e4SLinus Torvalds break; 3001da177e4SLinus Torvalds } 3011da177e4SLinus Torvalds break; 3021da177e4SLinus Torvalds default: 3031da177e4SLinus Torvalds AMIGAHW_SET(DENISE); 3041da177e4SLinus Torvalds break; 3051da177e4SLinus Torvalds } 306*b4290a23SAl Viro switch ((amiga_custom.vposr>>8) & 0x7f) { 3071da177e4SLinus Torvalds case 0x00: 3081da177e4SLinus Torvalds AMIGAHW_SET(AGNUS_PAL); 3091da177e4SLinus Torvalds break; 3101da177e4SLinus Torvalds case 0x10: 3111da177e4SLinus Torvalds AMIGAHW_SET(AGNUS_NTSC); 3121da177e4SLinus Torvalds break; 3131da177e4SLinus Torvalds case 0x20: 3141da177e4SLinus Torvalds case 0x21: 3151da177e4SLinus Torvalds AMIGAHW_SET(AGNUS_HR_PAL); 3161da177e4SLinus Torvalds break; 3171da177e4SLinus Torvalds case 0x30: 3181da177e4SLinus Torvalds case 0x31: 3191da177e4SLinus Torvalds AMIGAHW_SET(AGNUS_HR_NTSC); 3201da177e4SLinus Torvalds break; 3211da177e4SLinus Torvalds case 0x22: 3221da177e4SLinus Torvalds case 0x23: 3231da177e4SLinus Torvalds AMIGAHW_SET(ALICE_PAL); 3241da177e4SLinus Torvalds break; 3251da177e4SLinus Torvalds case 0x32: 3261da177e4SLinus Torvalds case 0x33: 3271da177e4SLinus Torvalds AMIGAHW_SET(ALICE_NTSC); 3281da177e4SLinus Torvalds break; 3291da177e4SLinus Torvalds } 3301da177e4SLinus Torvalds AMIGAHW_SET(ZORRO); 3311da177e4SLinus Torvalds break; 3321da177e4SLinus Torvalds 3331da177e4SLinus Torvalds case AMI_DRACO: 3341da177e4SLinus Torvalds panic("No support for Draco yet"); 3351da177e4SLinus Torvalds 3361da177e4SLinus Torvalds default: 3371da177e4SLinus Torvalds panic("Unknown Amiga Model"); 3381da177e4SLinus Torvalds } 3391da177e4SLinus Torvalds 3401da177e4SLinus Torvalds #define AMIGAHW_ANNOUNCE(name, str) \ 3411da177e4SLinus Torvalds if (AMIGAHW_PRESENT(name)) \ 3421da177e4SLinus Torvalds printk(str) 3431da177e4SLinus Torvalds 3441da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_VIDEO, "VIDEO "); 3451da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_BLITTER, "BLITTER "); 3461da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMBER_FF, "AMBER_FF "); 3471da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_AUDIO, "AUDIO "); 3481da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_FLOPPY, "FLOPPY "); 3491da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A3000_SCSI, "A3000_SCSI "); 3501da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A4000_SCSI, "A4000_SCSI "); 3511da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A1200_IDE, "A1200_IDE "); 3521da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A4000_IDE, "A4000_IDE "); 3531da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(CD_ROM, "CD_ROM "); 3541da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "KEYBOARD "); 3551da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_MOUSE, "MOUSE "); 3561da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_SERIAL, "SERIAL "); 3571da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_PARALLEL, "PARALLEL "); 3581da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A2000_CLK, "A2000_CLK "); 3591da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A3000_CLK, "A3000_CLK "); 3601da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(CHIP_RAM, "CHIP_RAM "); 3611da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(PAULA, "PAULA "); 3621da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(DENISE, "DENISE "); 3631da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(DENISE_HR, "DENISE_HR "); 3641da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(LISA, "LISA "); 3651da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_PAL, "AGNUS_PAL "); 3661da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_NTSC, "AGNUS_NTSC "); 3671da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "AGNUS_HR_PAL "); 3681da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "AGNUS_HR_NTSC "); 3691da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(ALICE_PAL, "ALICE_PAL "); 3701da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(ALICE_NTSC, "ALICE_NTSC "); 3711da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(MAGIC_REKICK, "MAGIC_REKICK "); 3721da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA "); 3731da177e4SLinus Torvalds if (AMIGAHW_PRESENT(ZORRO)) 3741da177e4SLinus Torvalds printk("ZORRO%s ", AMIGAHW_PRESENT(ZORRO3) ? "3" : ""); 3751da177e4SLinus Torvalds printk("\n"); 3761da177e4SLinus Torvalds 3771da177e4SLinus Torvalds #undef AMIGAHW_ANNOUNCE 3781da177e4SLinus Torvalds } 3791da177e4SLinus Torvalds 3801da177e4SLinus Torvalds /* 3811da177e4SLinus Torvalds * Setup the Amiga configuration info 3821da177e4SLinus Torvalds */ 3831da177e4SLinus Torvalds 3841da177e4SLinus Torvalds void __init config_amiga(void) 3851da177e4SLinus Torvalds { 3861da177e4SLinus Torvalds int i; 3871da177e4SLinus Torvalds 3881da177e4SLinus Torvalds amiga_debug_init(); 3891da177e4SLinus Torvalds amiga_identify(); 3901da177e4SLinus Torvalds 3911da177e4SLinus Torvalds /* Yuk, we don't have PCI memory */ 3921da177e4SLinus Torvalds iomem_resource.name = "Memory"; 3931da177e4SLinus Torvalds for (i = 0; i < 4; i++) 3941da177e4SLinus Torvalds request_resource(&iomem_resource, &((struct resource *)&mb_resources)[i]); 3951da177e4SLinus Torvalds 3961da177e4SLinus Torvalds mach_sched_init = amiga_sched_init; 3971da177e4SLinus Torvalds mach_init_IRQ = amiga_init_IRQ; 3981da177e4SLinus Torvalds mach_default_handler = &amiga_default_handler; 3991da177e4SLinus Torvalds mach_request_irq = amiga_request_irq; 4001da177e4SLinus Torvalds mach_free_irq = amiga_free_irq; 4011da177e4SLinus Torvalds enable_irq = amiga_enable_irq; 4021da177e4SLinus Torvalds disable_irq = amiga_disable_irq; 4031da177e4SLinus Torvalds mach_get_model = amiga_get_model; 4041da177e4SLinus Torvalds mach_get_hardware_list = amiga_get_hardware_list; 4051da177e4SLinus Torvalds mach_get_irq_list = show_amiga_interrupts; 4061da177e4SLinus Torvalds mach_gettimeoffset = amiga_gettimeoffset; 4071da177e4SLinus Torvalds if (AMIGAHW_PRESENT(A3000_CLK)){ 4081da177e4SLinus Torvalds mach_hwclk = a3000_hwclk; 4091da177e4SLinus Torvalds rtc_resource.name = "A3000 RTC"; 4101da177e4SLinus Torvalds request_resource(&iomem_resource, &rtc_resource); 4111da177e4SLinus Torvalds } 4121da177e4SLinus Torvalds else{ /* if (AMIGAHW_PRESENT(A2000_CLK)) */ 4131da177e4SLinus Torvalds mach_hwclk = a2000_hwclk; 4141da177e4SLinus Torvalds rtc_resource.name = "A2000 RTC"; 4151da177e4SLinus Torvalds request_resource(&iomem_resource, &rtc_resource); 4161da177e4SLinus Torvalds } 4171da177e4SLinus Torvalds 4181da177e4SLinus Torvalds mach_max_dma_address = 0xffffffff; /* 4191da177e4SLinus Torvalds * default MAX_DMA=0xffffffff 4201da177e4SLinus Torvalds * on all machines. If we don't 4211da177e4SLinus Torvalds * do so, the SCSI code will not 4221da177e4SLinus Torvalds * be able to allocate any mem 4231da177e4SLinus Torvalds * for transfers, unless we are 4241da177e4SLinus Torvalds * dealing with a Z2 mem only 4251da177e4SLinus Torvalds * system. /Jes 4261da177e4SLinus Torvalds */ 4271da177e4SLinus Torvalds 4281da177e4SLinus Torvalds mach_set_clock_mmss = amiga_set_clock_mmss; 4291da177e4SLinus Torvalds mach_get_ss = amiga_get_ss; 4301da177e4SLinus Torvalds #ifdef CONFIG_AMIGA_FLOPPY 4311da177e4SLinus Torvalds mach_floppy_setup = amiga_floppy_setup; 4321da177e4SLinus Torvalds #endif 4331da177e4SLinus Torvalds mach_reset = amiga_reset; 4341da177e4SLinus Torvalds #ifdef CONFIG_DUMMY_CONSOLE 4351da177e4SLinus Torvalds conswitchp = &dummy_con; 4361da177e4SLinus Torvalds #endif 4371da177e4SLinus Torvalds #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) 4381da177e4SLinus Torvalds mach_beep = amiga_mksound; 4391da177e4SLinus Torvalds #endif 4401da177e4SLinus Torvalds 4411da177e4SLinus Torvalds #ifdef CONFIG_HEARTBEAT 4421da177e4SLinus Torvalds mach_heartbeat = amiga_heartbeat; 4431da177e4SLinus Torvalds #endif 4441da177e4SLinus Torvalds 4451da177e4SLinus Torvalds /* Fill in the clock values (based on the 700 kHz E-Clock) */ 4461da177e4SLinus Torvalds amiga_masterclock = 40*amiga_eclock; /* 28 MHz */ 4471da177e4SLinus Torvalds amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */ 4481da177e4SLinus Torvalds 4491da177e4SLinus Torvalds /* clear all DMA bits */ 450*b4290a23SAl Viro amiga_custom.dmacon = DMAF_ALL; 4511da177e4SLinus Torvalds /* ensure that the DMA master bit is set */ 452*b4290a23SAl Viro amiga_custom.dmacon = DMAF_SETCLR | DMAF_MASTER; 4531da177e4SLinus Torvalds 4541da177e4SLinus Torvalds /* don't use Z2 RAM as system memory on Z3 capable machines */ 4551da177e4SLinus Torvalds if (AMIGAHW_PRESENT(ZORRO3)) { 4561da177e4SLinus Torvalds int i, j; 4571da177e4SLinus Torvalds u32 disabled_z2mem = 0; 4581da177e4SLinus Torvalds for (i = 0; i < m68k_num_memory; i++) 4591da177e4SLinus Torvalds if (m68k_memory[i].addr < 16*1024*1024) { 4601da177e4SLinus Torvalds if (i == 0) { 4611da177e4SLinus Torvalds /* don't cut off the branch we're sitting on */ 4621da177e4SLinus Torvalds printk("Warning: kernel runs in Zorro II memory\n"); 4631da177e4SLinus Torvalds continue; 4641da177e4SLinus Torvalds } 4651da177e4SLinus Torvalds disabled_z2mem += m68k_memory[i].size; 4661da177e4SLinus Torvalds m68k_num_memory--; 4671da177e4SLinus Torvalds for (j = i; j < m68k_num_memory; j++) 4681da177e4SLinus Torvalds m68k_memory[j] = m68k_memory[j+1]; 4691da177e4SLinus Torvalds i--; 4701da177e4SLinus Torvalds } 4711da177e4SLinus Torvalds if (disabled_z2mem) 4721da177e4SLinus Torvalds printk("%dK of Zorro II memory will not be used as system memory\n", 4731da177e4SLinus Torvalds disabled_z2mem>>10); 4741da177e4SLinus Torvalds } 4751da177e4SLinus Torvalds 4761da177e4SLinus Torvalds /* request all RAM */ 4771da177e4SLinus Torvalds for (i = 0; i < m68k_num_memory; i++) { 4781da177e4SLinus Torvalds ram_resource[i].name = 4791da177e4SLinus Torvalds (m68k_memory[i].addr >= 0x01000000) ? "32-bit Fast RAM" : 4801da177e4SLinus Torvalds (m68k_memory[i].addr < 0x00c00000) ? "16-bit Fast RAM" : 4811da177e4SLinus Torvalds "16-bit Slow RAM"; 4821da177e4SLinus Torvalds ram_resource[i].start = m68k_memory[i].addr; 4831da177e4SLinus Torvalds ram_resource[i].end = m68k_memory[i].addr+m68k_memory[i].size-1; 4841da177e4SLinus Torvalds request_resource(&iomem_resource, &ram_resource[i]); 4851da177e4SLinus Torvalds } 4861da177e4SLinus Torvalds 4871da177e4SLinus Torvalds /* initialize chipram allocator */ 4881da177e4SLinus Torvalds amiga_chip_init (); 4891da177e4SLinus Torvalds 4901da177e4SLinus Torvalds /* debugging using chipram */ 4911da177e4SLinus Torvalds if (!strcmp( m68k_debug_device, "mem" )){ 4921da177e4SLinus Torvalds if (!AMIGAHW_PRESENT(CHIP_RAM)) 4931da177e4SLinus Torvalds printk("Warning: no chipram present for debugging\n"); 4941da177e4SLinus Torvalds else { 4951da177e4SLinus Torvalds amiga_savekmsg_init(); 4961da177e4SLinus Torvalds amiga_console_driver.write = amiga_mem_console_write; 4971da177e4SLinus Torvalds register_console(&amiga_console_driver); 4981da177e4SLinus Torvalds } 4991da177e4SLinus Torvalds } 5001da177e4SLinus Torvalds 5011da177e4SLinus Torvalds /* our beloved beeper */ 5021da177e4SLinus Torvalds if (AMIGAHW_PRESENT(AMI_AUDIO)) 5031da177e4SLinus Torvalds amiga_init_sound(); 5041da177e4SLinus Torvalds 5051da177e4SLinus Torvalds /* 5061da177e4SLinus Torvalds * if it is an A3000, set the magic bit that forces 5071da177e4SLinus Torvalds * a hard rekick 5081da177e4SLinus Torvalds */ 5091da177e4SLinus Torvalds if (AMIGAHW_PRESENT(MAGIC_REKICK)) 5101da177e4SLinus Torvalds *(unsigned char *)ZTWO_VADDR(0xde0002) |= 0x80; 5111da177e4SLinus Torvalds } 5121da177e4SLinus Torvalds 5131da177e4SLinus Torvalds static unsigned short jiffy_ticks; 5141da177e4SLinus Torvalds 5151da177e4SLinus Torvalds static void __init amiga_sched_init(irqreturn_t (*timer_routine)(int, void *, 5161da177e4SLinus Torvalds struct pt_regs *)) 5171da177e4SLinus Torvalds { 5181da177e4SLinus Torvalds static struct resource sched_res = { 5191da177e4SLinus Torvalds .name = "timer", .start = 0x00bfd400, .end = 0x00bfd5ff, 5201da177e4SLinus Torvalds }; 5211da177e4SLinus Torvalds jiffy_ticks = (amiga_eclock+HZ/2)/HZ; 5221da177e4SLinus Torvalds 5231da177e4SLinus Torvalds if (request_resource(&mb_resources._ciab, &sched_res)) 5241da177e4SLinus Torvalds printk("Cannot allocate ciab.ta{lo,hi}\n"); 5251da177e4SLinus Torvalds ciab.cra &= 0xC0; /* turn off timer A, continuous mode, from Eclk */ 5261da177e4SLinus Torvalds ciab.talo = jiffy_ticks % 256; 5271da177e4SLinus Torvalds ciab.tahi = jiffy_ticks / 256; 5281da177e4SLinus Torvalds 5291da177e4SLinus Torvalds /* install interrupt service routine for CIAB Timer A 5301da177e4SLinus Torvalds * 5311da177e4SLinus Torvalds * Please don't change this to use ciaa, as it interferes with the 5321da177e4SLinus Torvalds * SCSI code. We'll have to take a look at this later 5331da177e4SLinus Torvalds */ 5341da177e4SLinus Torvalds request_irq(IRQ_AMIGA_CIAB_TA, timer_routine, 0, "timer", NULL); 5351da177e4SLinus Torvalds /* start timer */ 5361da177e4SLinus Torvalds ciab.cra |= 0x11; 5371da177e4SLinus Torvalds } 5381da177e4SLinus Torvalds 5391da177e4SLinus Torvalds #define TICK_SIZE 10000 5401da177e4SLinus Torvalds 5411da177e4SLinus Torvalds /* This is always executed with interrupts disabled. */ 5421da177e4SLinus Torvalds static unsigned long amiga_gettimeoffset (void) 5431da177e4SLinus Torvalds { 5441da177e4SLinus Torvalds unsigned short hi, lo, hi2; 5451da177e4SLinus Torvalds unsigned long ticks, offset = 0; 5461da177e4SLinus Torvalds 5471da177e4SLinus Torvalds /* read CIA B timer A current value */ 5481da177e4SLinus Torvalds hi = ciab.tahi; 5491da177e4SLinus Torvalds lo = ciab.talo; 5501da177e4SLinus Torvalds hi2 = ciab.tahi; 5511da177e4SLinus Torvalds 5521da177e4SLinus Torvalds if (hi != hi2) { 5531da177e4SLinus Torvalds lo = ciab.talo; 5541da177e4SLinus Torvalds hi = hi2; 5551da177e4SLinus Torvalds } 5561da177e4SLinus Torvalds 5571da177e4SLinus Torvalds ticks = hi << 8 | lo; 5581da177e4SLinus Torvalds 5591da177e4SLinus Torvalds if (ticks > jiffy_ticks / 2) 5601da177e4SLinus Torvalds /* check for pending interrupt */ 5611da177e4SLinus Torvalds if (cia_set_irq(&ciab_base, 0) & CIA_ICR_TA) 5621da177e4SLinus Torvalds offset = 10000; 5631da177e4SLinus Torvalds 5641da177e4SLinus Torvalds ticks = jiffy_ticks - ticks; 5651da177e4SLinus Torvalds ticks = (10000 * ticks) / jiffy_ticks; 5661da177e4SLinus Torvalds 5671da177e4SLinus Torvalds return ticks + offset; 5681da177e4SLinus Torvalds } 5691da177e4SLinus Torvalds 5701da177e4SLinus Torvalds static int a3000_hwclk(int op, struct rtc_time *t) 5711da177e4SLinus Torvalds { 5721da177e4SLinus Torvalds tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD; 5731da177e4SLinus Torvalds 5741da177e4SLinus Torvalds if (!op) { /* read */ 5751da177e4SLinus Torvalds t->tm_sec = tod_3000.second1 * 10 + tod_3000.second2; 5761da177e4SLinus Torvalds t->tm_min = tod_3000.minute1 * 10 + tod_3000.minute2; 5771da177e4SLinus Torvalds t->tm_hour = tod_3000.hour1 * 10 + tod_3000.hour2; 5781da177e4SLinus Torvalds t->tm_mday = tod_3000.day1 * 10 + tod_3000.day2; 5791da177e4SLinus Torvalds t->tm_wday = tod_3000.weekday; 5801da177e4SLinus Torvalds t->tm_mon = tod_3000.month1 * 10 + tod_3000.month2 - 1; 5811da177e4SLinus Torvalds t->tm_year = tod_3000.year1 * 10 + tod_3000.year2; 5821da177e4SLinus Torvalds if (t->tm_year <= 69) 5831da177e4SLinus Torvalds t->tm_year += 100; 5841da177e4SLinus Torvalds } else { 5851da177e4SLinus Torvalds tod_3000.second1 = t->tm_sec / 10; 5861da177e4SLinus Torvalds tod_3000.second2 = t->tm_sec % 10; 5871da177e4SLinus Torvalds tod_3000.minute1 = t->tm_min / 10; 5881da177e4SLinus Torvalds tod_3000.minute2 = t->tm_min % 10; 5891da177e4SLinus Torvalds tod_3000.hour1 = t->tm_hour / 10; 5901da177e4SLinus Torvalds tod_3000.hour2 = t->tm_hour % 10; 5911da177e4SLinus Torvalds tod_3000.day1 = t->tm_mday / 10; 5921da177e4SLinus Torvalds tod_3000.day2 = t->tm_mday % 10; 5931da177e4SLinus Torvalds if (t->tm_wday != -1) 5941da177e4SLinus Torvalds tod_3000.weekday = t->tm_wday; 5951da177e4SLinus Torvalds tod_3000.month1 = (t->tm_mon + 1) / 10; 5961da177e4SLinus Torvalds tod_3000.month2 = (t->tm_mon + 1) % 10; 5971da177e4SLinus Torvalds if (t->tm_year >= 100) 5981da177e4SLinus Torvalds t->tm_year -= 100; 5991da177e4SLinus Torvalds tod_3000.year1 = t->tm_year / 10; 6001da177e4SLinus Torvalds tod_3000.year2 = t->tm_year % 10; 6011da177e4SLinus Torvalds } 6021da177e4SLinus Torvalds 6031da177e4SLinus Torvalds tod_3000.cntrl1 = TOD3000_CNTRL1_FREE; 6041da177e4SLinus Torvalds 6051da177e4SLinus Torvalds return 0; 6061da177e4SLinus Torvalds } 6071da177e4SLinus Torvalds 6081da177e4SLinus Torvalds static int a2000_hwclk(int op, struct rtc_time *t) 6091da177e4SLinus Torvalds { 6101da177e4SLinus Torvalds int cnt = 5; 6111da177e4SLinus Torvalds 6121da177e4SLinus Torvalds tod_2000.cntrl1 = TOD2000_CNTRL1_HOLD; 6131da177e4SLinus Torvalds 6141da177e4SLinus Torvalds while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--) 6151da177e4SLinus Torvalds { 6161da177e4SLinus Torvalds tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; 6171da177e4SLinus Torvalds udelay(70); 6181da177e4SLinus Torvalds tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; 6191da177e4SLinus Torvalds } 6201da177e4SLinus Torvalds 6211da177e4SLinus Torvalds if (!cnt) 6221da177e4SLinus Torvalds printk(KERN_INFO "hwclk: timed out waiting for RTC (0x%x)\n", tod_2000.cntrl1); 6231da177e4SLinus Torvalds 6241da177e4SLinus Torvalds if (!op) { /* read */ 6251da177e4SLinus Torvalds t->tm_sec = tod_2000.second1 * 10 + tod_2000.second2; 6261da177e4SLinus Torvalds t->tm_min = tod_2000.minute1 * 10 + tod_2000.minute2; 6271da177e4SLinus Torvalds t->tm_hour = (tod_2000.hour1 & 3) * 10 + tod_2000.hour2; 6281da177e4SLinus Torvalds t->tm_mday = tod_2000.day1 * 10 + tod_2000.day2; 6291da177e4SLinus Torvalds t->tm_wday = tod_2000.weekday; 6301da177e4SLinus Torvalds t->tm_mon = tod_2000.month1 * 10 + tod_2000.month2 - 1; 6311da177e4SLinus Torvalds t->tm_year = tod_2000.year1 * 10 + tod_2000.year2; 6321da177e4SLinus Torvalds if (t->tm_year <= 69) 6331da177e4SLinus Torvalds t->tm_year += 100; 6341da177e4SLinus Torvalds 6351da177e4SLinus Torvalds if (!(tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE)){ 6361da177e4SLinus Torvalds if (!(tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour == 12) 6371da177e4SLinus Torvalds t->tm_hour = 0; 6381da177e4SLinus Torvalds else if ((tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour != 12) 6391da177e4SLinus Torvalds t->tm_hour += 12; 6401da177e4SLinus Torvalds } 6411da177e4SLinus Torvalds } else { 6421da177e4SLinus Torvalds tod_2000.second1 = t->tm_sec / 10; 6431da177e4SLinus Torvalds tod_2000.second2 = t->tm_sec % 10; 6441da177e4SLinus Torvalds tod_2000.minute1 = t->tm_min / 10; 6451da177e4SLinus Torvalds tod_2000.minute2 = t->tm_min % 10; 6461da177e4SLinus Torvalds if (tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE) 6471da177e4SLinus Torvalds tod_2000.hour1 = t->tm_hour / 10; 6481da177e4SLinus Torvalds else if (t->tm_hour >= 12) 6491da177e4SLinus Torvalds tod_2000.hour1 = TOD2000_HOUR1_PM + 6501da177e4SLinus Torvalds (t->tm_hour - 12) / 10; 6511da177e4SLinus Torvalds else 6521da177e4SLinus Torvalds tod_2000.hour1 = t->tm_hour / 10; 6531da177e4SLinus Torvalds tod_2000.hour2 = t->tm_hour % 10; 6541da177e4SLinus Torvalds tod_2000.day1 = t->tm_mday / 10; 6551da177e4SLinus Torvalds tod_2000.day2 = t->tm_mday % 10; 6561da177e4SLinus Torvalds if (t->tm_wday != -1) 6571da177e4SLinus Torvalds tod_2000.weekday = t->tm_wday; 6581da177e4SLinus Torvalds tod_2000.month1 = (t->tm_mon + 1) / 10; 6591da177e4SLinus Torvalds tod_2000.month2 = (t->tm_mon + 1) % 10; 6601da177e4SLinus Torvalds if (t->tm_year >= 100) 6611da177e4SLinus Torvalds t->tm_year -= 100; 6621da177e4SLinus Torvalds tod_2000.year1 = t->tm_year / 10; 6631da177e4SLinus Torvalds tod_2000.year2 = t->tm_year % 10; 6641da177e4SLinus Torvalds } 6651da177e4SLinus Torvalds 6661da177e4SLinus Torvalds tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; 6671da177e4SLinus Torvalds 6681da177e4SLinus Torvalds return 0; 6691da177e4SLinus Torvalds } 6701da177e4SLinus Torvalds 6711da177e4SLinus Torvalds static int amiga_set_clock_mmss (unsigned long nowtime) 6721da177e4SLinus Torvalds { 6731da177e4SLinus Torvalds short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; 6741da177e4SLinus Torvalds 6751da177e4SLinus Torvalds if (AMIGAHW_PRESENT(A3000_CLK)) { 6761da177e4SLinus Torvalds tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD; 6771da177e4SLinus Torvalds 6781da177e4SLinus Torvalds tod_3000.second1 = real_seconds / 10; 6791da177e4SLinus Torvalds tod_3000.second2 = real_seconds % 10; 6801da177e4SLinus Torvalds tod_3000.minute1 = real_minutes / 10; 6811da177e4SLinus Torvalds tod_3000.minute2 = real_minutes % 10; 6821da177e4SLinus Torvalds 6831da177e4SLinus Torvalds tod_3000.cntrl1 = TOD3000_CNTRL1_FREE; 6841da177e4SLinus Torvalds } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ { 6851da177e4SLinus Torvalds int cnt = 5; 6861da177e4SLinus Torvalds 6871da177e4SLinus Torvalds tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; 6881da177e4SLinus Torvalds 6891da177e4SLinus Torvalds while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--) 6901da177e4SLinus Torvalds { 6911da177e4SLinus Torvalds tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; 6921da177e4SLinus Torvalds udelay(70); 6931da177e4SLinus Torvalds tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; 6941da177e4SLinus Torvalds } 6951da177e4SLinus Torvalds 6961da177e4SLinus Torvalds if (!cnt) 6971da177e4SLinus Torvalds printk(KERN_INFO "set_clock_mmss: timed out waiting for RTC (0x%x)\n", tod_2000.cntrl1); 6981da177e4SLinus Torvalds 6991da177e4SLinus Torvalds tod_2000.second1 = real_seconds / 10; 7001da177e4SLinus Torvalds tod_2000.second2 = real_seconds % 10; 7011da177e4SLinus Torvalds tod_2000.minute1 = real_minutes / 10; 7021da177e4SLinus Torvalds tod_2000.minute2 = real_minutes % 10; 7031da177e4SLinus Torvalds 7041da177e4SLinus Torvalds tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; 7051da177e4SLinus Torvalds } 7061da177e4SLinus Torvalds 7071da177e4SLinus Torvalds return 0; 7081da177e4SLinus Torvalds } 7091da177e4SLinus Torvalds 7101da177e4SLinus Torvalds static unsigned int amiga_get_ss( void ) 7111da177e4SLinus Torvalds { 7121da177e4SLinus Torvalds unsigned int s; 7131da177e4SLinus Torvalds 7141da177e4SLinus Torvalds if (AMIGAHW_PRESENT(A3000_CLK)) { 7151da177e4SLinus Torvalds tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD; 7161da177e4SLinus Torvalds s = tod_3000.second1 * 10 + tod_3000.second2; 7171da177e4SLinus Torvalds tod_3000.cntrl1 = TOD3000_CNTRL1_FREE; 7181da177e4SLinus Torvalds } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ { 7191da177e4SLinus Torvalds s = tod_2000.second1 * 10 + tod_2000.second2; 7201da177e4SLinus Torvalds } 7211da177e4SLinus Torvalds return s; 7221da177e4SLinus Torvalds } 7231da177e4SLinus Torvalds 7241da177e4SLinus Torvalds static NORET_TYPE void amiga_reset( void ) 7251da177e4SLinus Torvalds ATTRIB_NORET; 7261da177e4SLinus Torvalds 7271da177e4SLinus Torvalds static void amiga_reset (void) 7281da177e4SLinus Torvalds { 7291da177e4SLinus Torvalds unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040); 7301da177e4SLinus Torvalds unsigned long jmp_addr = virt_to_phys(&&jmp_addr_label); 7311da177e4SLinus Torvalds 7321da177e4SLinus Torvalds local_irq_disable(); 7331da177e4SLinus Torvalds if (CPU_IS_040_OR_060) 7341da177e4SLinus Torvalds /* Setup transparent translation registers for mapping 7351da177e4SLinus Torvalds * of 16 MB kernel segment before disabling translation 7361da177e4SLinus Torvalds */ 7371da177e4SLinus Torvalds __asm__ __volatile__ 7381da177e4SLinus Torvalds ("movel %0,%/d0\n\t" 7391da177e4SLinus Torvalds "andl #0xff000000,%/d0\n\t" 7401da177e4SLinus Torvalds "orw #0xe020,%/d0\n\t" /* map 16 MB, enable, cacheable */ 7411da177e4SLinus Torvalds ".chip 68040\n\t" 7421da177e4SLinus Torvalds "movec %%d0,%%itt0\n\t" 7431da177e4SLinus Torvalds "movec %%d0,%%dtt0\n\t" 7441da177e4SLinus Torvalds ".chip 68k\n\t" 7451da177e4SLinus Torvalds "jmp %0@\n\t" 7461da177e4SLinus Torvalds : /* no outputs */ 7471da177e4SLinus Torvalds : "a" (jmp_addr040)); 7481da177e4SLinus Torvalds else 7491da177e4SLinus Torvalds /* for 680[23]0, just disable translation and jump to the physical 7501da177e4SLinus Torvalds * address of the label 7511da177e4SLinus Torvalds */ 7521da177e4SLinus Torvalds __asm__ __volatile__ 7531da177e4SLinus Torvalds ("pmove %/tc,%@\n\t" 7541da177e4SLinus Torvalds "bclr #7,%@\n\t" 7551da177e4SLinus Torvalds "pmove %@,%/tc\n\t" 7561da177e4SLinus Torvalds "jmp %0@\n\t" 7571da177e4SLinus Torvalds : /* no outputs */ 7581da177e4SLinus Torvalds : "a" (jmp_addr)); 7591da177e4SLinus Torvalds jmp_addr_label040: 7601da177e4SLinus Torvalds /* disable translation on '040 now */ 7611da177e4SLinus Torvalds __asm__ __volatile__ 7621da177e4SLinus Torvalds ("moveq #0,%/d0\n\t" 7631da177e4SLinus Torvalds ".chip 68040\n\t" 7641da177e4SLinus Torvalds "movec %%d0,%%tc\n\t" /* disable MMU */ 7651da177e4SLinus Torvalds ".chip 68k\n\t" 7661da177e4SLinus Torvalds : /* no outputs */ 7671da177e4SLinus Torvalds : /* no inputs */ 7681da177e4SLinus Torvalds : "d0"); 7691da177e4SLinus Torvalds 7701da177e4SLinus Torvalds jmp_addr_label: 7711da177e4SLinus Torvalds /* pickup reset address from AmigaOS ROM, reset devices and jump 7721da177e4SLinus Torvalds * to reset address 7731da177e4SLinus Torvalds */ 7741da177e4SLinus Torvalds __asm__ __volatile__ 7751da177e4SLinus Torvalds ("movew #0x2700,%/sr\n\t" 7761da177e4SLinus Torvalds "leal 0x01000000,%/a0\n\t" 7771da177e4SLinus Torvalds "subl %/a0@(-0x14),%/a0\n\t" 7781da177e4SLinus Torvalds "movel %/a0@(4),%/a0\n\t" 7791da177e4SLinus Torvalds "subql #2,%/a0\n\t" 7801da177e4SLinus Torvalds "bra 1f\n\t" 7811da177e4SLinus Torvalds /* align on a longword boundary */ 7821da177e4SLinus Torvalds __ALIGN_STR "\n" 7831da177e4SLinus Torvalds "1:\n\t" 7841da177e4SLinus Torvalds "reset\n\t" 7851da177e4SLinus Torvalds "jmp %/a0@" : /* Just that gcc scans it for % escapes */ ); 7861da177e4SLinus Torvalds 7871da177e4SLinus Torvalds for (;;); 7881da177e4SLinus Torvalds 7891da177e4SLinus Torvalds } 7901da177e4SLinus Torvalds 7911da177e4SLinus Torvalds 7921da177e4SLinus Torvalds /* 7931da177e4SLinus Torvalds * Debugging 7941da177e4SLinus Torvalds */ 7951da177e4SLinus Torvalds 7961da177e4SLinus Torvalds #define SAVEKMSG_MAXMEM 128*1024 7971da177e4SLinus Torvalds 7981da177e4SLinus Torvalds #define SAVEKMSG_MAGIC1 0x53415645 /* 'SAVE' */ 7991da177e4SLinus Torvalds #define SAVEKMSG_MAGIC2 0x4B4D5347 /* 'KMSG' */ 8001da177e4SLinus Torvalds 8011da177e4SLinus Torvalds struct savekmsg { 8021da177e4SLinus Torvalds unsigned long magic1; /* SAVEKMSG_MAGIC1 */ 8031da177e4SLinus Torvalds unsigned long magic2; /* SAVEKMSG_MAGIC2 */ 8041da177e4SLinus Torvalds unsigned long magicptr; /* address of magic1 */ 8051da177e4SLinus Torvalds unsigned long size; 8061da177e4SLinus Torvalds char data[0]; 8071da177e4SLinus Torvalds }; 8081da177e4SLinus Torvalds 8091da177e4SLinus Torvalds static struct savekmsg *savekmsg; 8101da177e4SLinus Torvalds 8111da177e4SLinus Torvalds static void amiga_mem_console_write(struct console *co, const char *s, 8121da177e4SLinus Torvalds unsigned int count) 8131da177e4SLinus Torvalds { 8141da177e4SLinus Torvalds if (savekmsg->size+count <= SAVEKMSG_MAXMEM-sizeof(struct savekmsg)) { 8151da177e4SLinus Torvalds memcpy(savekmsg->data+savekmsg->size, s, count); 8161da177e4SLinus Torvalds savekmsg->size += count; 8171da177e4SLinus Torvalds } 8181da177e4SLinus Torvalds } 8191da177e4SLinus Torvalds 8201da177e4SLinus Torvalds static void amiga_savekmsg_init(void) 8211da177e4SLinus Torvalds { 8221da177e4SLinus Torvalds static struct resource debug_res = { .name = "Debug" }; 8231da177e4SLinus Torvalds 8241da177e4SLinus Torvalds savekmsg = amiga_chip_alloc_res(SAVEKMSG_MAXMEM, &debug_res); 8251da177e4SLinus Torvalds savekmsg->magic1 = SAVEKMSG_MAGIC1; 8261da177e4SLinus Torvalds savekmsg->magic2 = SAVEKMSG_MAGIC2; 8271da177e4SLinus Torvalds savekmsg->magicptr = ZTWO_PADDR(savekmsg); 8281da177e4SLinus Torvalds savekmsg->size = 0; 8291da177e4SLinus Torvalds } 8301da177e4SLinus Torvalds 8311da177e4SLinus Torvalds static void amiga_serial_putc(char c) 8321da177e4SLinus Torvalds { 833*b4290a23SAl Viro amiga_custom.serdat = (unsigned char)c | 0x100; 834*b4290a23SAl Viro while (!(amiga_custom.serdatr & 0x2000)) 8351da177e4SLinus Torvalds ; 8361da177e4SLinus Torvalds } 8371da177e4SLinus Torvalds 8381da177e4SLinus Torvalds void amiga_serial_console_write(struct console *co, const char *s, 8391da177e4SLinus Torvalds unsigned int count) 8401da177e4SLinus Torvalds { 8411da177e4SLinus Torvalds while (count--) { 8421da177e4SLinus Torvalds if (*s == '\n') 8431da177e4SLinus Torvalds amiga_serial_putc('\r'); 8441da177e4SLinus Torvalds amiga_serial_putc(*s++); 8451da177e4SLinus Torvalds } 8461da177e4SLinus Torvalds } 8471da177e4SLinus Torvalds 8481da177e4SLinus Torvalds #ifdef CONFIG_SERIAL_CONSOLE 8491da177e4SLinus Torvalds void amiga_serial_puts(const char *s) 8501da177e4SLinus Torvalds { 8511da177e4SLinus Torvalds amiga_serial_console_write(NULL, s, strlen(s)); 8521da177e4SLinus Torvalds } 8531da177e4SLinus Torvalds 8541da177e4SLinus Torvalds int amiga_serial_console_wait_key(struct console *co) 8551da177e4SLinus Torvalds { 8561da177e4SLinus Torvalds int ch; 8571da177e4SLinus Torvalds 858*b4290a23SAl Viro while (!(amiga_custom.intreqr & IF_RBF)) 8591da177e4SLinus Torvalds barrier(); 860*b4290a23SAl Viro ch = amiga_custom.serdatr & 0xff; 8611da177e4SLinus Torvalds /* clear the interrupt, so that another character can be read */ 862*b4290a23SAl Viro amiga_custom.intreq = IF_RBF; 8631da177e4SLinus Torvalds return ch; 8641da177e4SLinus Torvalds } 8651da177e4SLinus Torvalds 8661da177e4SLinus Torvalds void amiga_serial_gets(struct console *co, char *s, int len) 8671da177e4SLinus Torvalds { 8681da177e4SLinus Torvalds int ch, cnt = 0; 8691da177e4SLinus Torvalds 8701da177e4SLinus Torvalds while (1) { 8711da177e4SLinus Torvalds ch = amiga_serial_console_wait_key(co); 8721da177e4SLinus Torvalds 8731da177e4SLinus Torvalds /* Check for backspace. */ 8741da177e4SLinus Torvalds if (ch == 8 || ch == 127) { 8751da177e4SLinus Torvalds if (cnt == 0) { 8761da177e4SLinus Torvalds amiga_serial_putc('\007'); 8771da177e4SLinus Torvalds continue; 8781da177e4SLinus Torvalds } 8791da177e4SLinus Torvalds cnt--; 8801da177e4SLinus Torvalds amiga_serial_puts("\010 \010"); 8811da177e4SLinus Torvalds continue; 8821da177e4SLinus Torvalds } 8831da177e4SLinus Torvalds 8841da177e4SLinus Torvalds /* Check for enter. */ 8851da177e4SLinus Torvalds if (ch == 10 || ch == 13) 8861da177e4SLinus Torvalds break; 8871da177e4SLinus Torvalds 8881da177e4SLinus Torvalds /* See if line is too long. */ 8891da177e4SLinus Torvalds if (cnt >= len + 1) { 8901da177e4SLinus Torvalds amiga_serial_putc(7); 8911da177e4SLinus Torvalds cnt--; 8921da177e4SLinus Torvalds continue; 8931da177e4SLinus Torvalds } 8941da177e4SLinus Torvalds 8951da177e4SLinus Torvalds /* Store and echo character. */ 8961da177e4SLinus Torvalds s[cnt++] = ch; 8971da177e4SLinus Torvalds amiga_serial_putc(ch); 8981da177e4SLinus Torvalds } 8991da177e4SLinus Torvalds /* Print enter. */ 9001da177e4SLinus Torvalds amiga_serial_puts("\r\n"); 9011da177e4SLinus Torvalds s[cnt] = 0; 9021da177e4SLinus Torvalds } 9031da177e4SLinus Torvalds #endif 9041da177e4SLinus Torvalds 9051da177e4SLinus Torvalds static void __init amiga_debug_init(void) 9061da177e4SLinus Torvalds { 9071da177e4SLinus Torvalds if (!strcmp( m68k_debug_device, "ser" )) { 9081da177e4SLinus Torvalds /* no initialization required (?) */ 9091da177e4SLinus Torvalds amiga_console_driver.write = amiga_serial_console_write; 9101da177e4SLinus Torvalds register_console(&amiga_console_driver); 9111da177e4SLinus Torvalds } 9121da177e4SLinus Torvalds } 9131da177e4SLinus Torvalds 9141da177e4SLinus Torvalds #ifdef CONFIG_HEARTBEAT 9151da177e4SLinus Torvalds static void amiga_heartbeat(int on) 9161da177e4SLinus Torvalds { 9171da177e4SLinus Torvalds if (on) 9181da177e4SLinus Torvalds ciaa.pra &= ~2; 9191da177e4SLinus Torvalds else 9201da177e4SLinus Torvalds ciaa.pra |= 2; 9211da177e4SLinus Torvalds } 9221da177e4SLinus Torvalds #endif 9231da177e4SLinus Torvalds 9241da177e4SLinus Torvalds /* 9251da177e4SLinus Torvalds * Amiga specific parts of /proc 9261da177e4SLinus Torvalds */ 9271da177e4SLinus Torvalds 9281da177e4SLinus Torvalds static void amiga_get_model(char *model) 9291da177e4SLinus Torvalds { 9301da177e4SLinus Torvalds strcpy(model, amiga_model_name); 9311da177e4SLinus Torvalds } 9321da177e4SLinus Torvalds 9331da177e4SLinus Torvalds 9341da177e4SLinus Torvalds static int amiga_get_hardware_list(char *buffer) 9351da177e4SLinus Torvalds { 9361da177e4SLinus Torvalds int len = 0; 9371da177e4SLinus Torvalds 9381da177e4SLinus Torvalds if (AMIGAHW_PRESENT(CHIP_RAM)) 9391da177e4SLinus Torvalds len += sprintf(buffer+len, "Chip RAM:\t%ldK\n", amiga_chip_size>>10); 9401da177e4SLinus Torvalds len += sprintf(buffer+len, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n", 9411da177e4SLinus Torvalds amiga_psfreq, amiga_eclock); 9421da177e4SLinus Torvalds if (AMIGAHW_PRESENT(AMI_VIDEO)) { 9431da177e4SLinus Torvalds char *type; 9441da177e4SLinus Torvalds switch(amiga_chipset) { 9451da177e4SLinus Torvalds case CS_OCS: 9461da177e4SLinus Torvalds type = "OCS"; 9471da177e4SLinus Torvalds break; 9481da177e4SLinus Torvalds case CS_ECS: 9491da177e4SLinus Torvalds type = "ECS"; 9501da177e4SLinus Torvalds break; 9511da177e4SLinus Torvalds case CS_AGA: 9521da177e4SLinus Torvalds type = "AGA"; 9531da177e4SLinus Torvalds break; 9541da177e4SLinus Torvalds default: 9551da177e4SLinus Torvalds type = "Old or Unknown"; 9561da177e4SLinus Torvalds break; 9571da177e4SLinus Torvalds } 9581da177e4SLinus Torvalds len += sprintf(buffer+len, "Graphics:\t%s\n", type); 9591da177e4SLinus Torvalds } 9601da177e4SLinus Torvalds 9611da177e4SLinus Torvalds #define AMIGAHW_ANNOUNCE(name, str) \ 9621da177e4SLinus Torvalds if (AMIGAHW_PRESENT(name)) \ 9631da177e4SLinus Torvalds len += sprintf (buffer+len, "\t%s\n", str) 9641da177e4SLinus Torvalds 9651da177e4SLinus Torvalds len += sprintf (buffer + len, "Detected hardware:\n"); 9661da177e4SLinus Torvalds 9671da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_VIDEO, "Amiga Video"); 9681da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_BLITTER, "Blitter"); 9691da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMBER_FF, "Amber Flicker Fixer"); 9701da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_AUDIO, "Amiga Audio"); 9711da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_FLOPPY, "Floppy Controller"); 9721da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A3000_SCSI, "SCSI Controller WD33C93 (A3000 style)"); 9731da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A4000_SCSI, "SCSI Controller NCR53C710 (A4000T style)"); 9741da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A1200_IDE, "IDE Interface (A1200 style)"); 9751da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A4000_IDE, "IDE Interface (A4000 style)"); 9761da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(CD_ROM, "Internal CD ROM drive"); 9771da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "Keyboard"); 9781da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_MOUSE, "Mouse Port"); 9791da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_SERIAL, "Serial Port"); 9801da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AMI_PARALLEL, "Parallel Port"); 9811da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A2000_CLK, "Hardware Clock (A2000 style)"); 9821da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(A3000_CLK, "Hardware Clock (A3000 style)"); 9831da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(CHIP_RAM, "Chip RAM"); 9841da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(PAULA, "Paula 8364"); 9851da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(DENISE, "Denise 8362"); 9861da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(DENISE_HR, "Denise 8373"); 9871da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(LISA, "Lisa 8375"); 9881da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_PAL, "Normal/Fat PAL Agnus 8367/8371"); 9891da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_NTSC, "Normal/Fat NTSC Agnus 8361/8370"); 9901da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "Fat Hires PAL Agnus 8372"); 9911da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "Fat Hires NTSC Agnus 8372"); 9921da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(ALICE_PAL, "PAL Alice 8374"); 9931da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(ALICE_NTSC, "NTSC Alice 8374"); 9941da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(MAGIC_REKICK, "Magic Hard Rekick"); 9951da177e4SLinus Torvalds AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA Slot"); 9961da177e4SLinus Torvalds #ifdef CONFIG_ZORRO 9971da177e4SLinus Torvalds if (AMIGAHW_PRESENT(ZORRO)) 9981da177e4SLinus Torvalds len += sprintf(buffer+len, "\tZorro II%s AutoConfig: %d Expansion " 9991da177e4SLinus Torvalds "Device%s\n", 10001da177e4SLinus Torvalds AMIGAHW_PRESENT(ZORRO3) ? "I" : "", 10011da177e4SLinus Torvalds zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s"); 10021da177e4SLinus Torvalds #endif /* CONFIG_ZORRO */ 10031da177e4SLinus Torvalds 10041da177e4SLinus Torvalds #undef AMIGAHW_ANNOUNCE 10051da177e4SLinus Torvalds 10061da177e4SLinus Torvalds return(len); 10071da177e4SLinus Torvalds } 1008