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