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