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