Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/m68k/amiga/config.c |
| 3 | * |
| 4 | * Copyright (C) 1993 Hamish Macdonald |
| 5 | * |
| 6 | * This file is subject to the terms and conditions of the GNU General Public |
| 7 | * License. See the file COPYING in the main directory of this archive |
| 8 | * for more details. |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * Miscellaneous Amiga stuff |
| 13 | */ |
| 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/types.h> |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/mm.h> |
Alexey Dobriyan | 813dcf7 | 2008-10-03 22:42:36 +0400 | [diff] [blame] | 18 | #include <linux/seq_file.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/tty.h> |
| 20 | #include <linux/console.h> |
| 21 | #include <linux/rtc.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/vt_kern.h> |
| 24 | #include <linux/delay.h> |
| 25 | #include <linux/interrupt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/zorro.h> |
Adrian Bunk | 8b169fa | 2008-02-04 22:30:25 -0800 | [diff] [blame] | 27 | #include <linux/module.h> |
Geert Uytterhoeven | 39d2d99 | 2008-10-13 21:58:53 +0200 | [diff] [blame] | 28 | #include <linux/keyboard.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
| 30 | #include <asm/bootinfo.h> |
| 31 | #include <asm/setup.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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); |
Alexey Dobriyan | 813dcf7 | 2008-10-03 22:42:36 +0400 | [diff] [blame] | 96 | static void amiga_get_hardware_list(struct seq_file *m); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | /* amiga specific timer functions */ |
Stephen Warren | c8d5ba1 | 2012-11-08 11:34:55 -0700 | [diff] [blame] | 98 | static u32 amiga_gettimeoffset(void); |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 99 | extern void amiga_mksound(unsigned int count, unsigned int ticks); |
| 100 | static void amiga_reset(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | extern void amiga_init_sound(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | static void amiga_mem_console_write(struct console *co, const char *b, |
| 103 | unsigned int count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | #ifdef CONFIG_HEARTBEAT |
| 105 | static void amiga_heartbeat(int on); |
| 106 | #endif |
| 107 | |
| 108 | static struct console amiga_console_driver = { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 109 | .name = "debug", |
| 110 | .flags = CON_PRINTBUFFER, |
| 111 | .index = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | |
| 115 | /* |
| 116 | * Motherboard Resources present in all Amiga models |
| 117 | */ |
| 118 | |
| 119 | static struct { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 120 | struct resource _ciab, _ciaa, _custom, _kickstart; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | } mb_resources = { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 122 | ._ciab = { |
| 123 | .name = "CIA B", .start = 0x00bfd000, .end = 0x00bfdfff |
| 124 | }, |
| 125 | ._ciaa = { |
| 126 | .name = "CIA A", .start = 0x00bfe000, .end = 0x00bfefff |
| 127 | }, |
| 128 | ._custom = { |
| 129 | .name = "Custom I/O", .start = 0x00dff000, .end = 0x00dfffff |
| 130 | }, |
| 131 | ._kickstart = { |
| 132 | .name = "Kickstart ROM", .start = 0x00f80000, .end = 0x00ffffff |
| 133 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | }; |
| 135 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | static struct resource ram_resource[NUM_MEMINFO]; |
| 137 | |
| 138 | |
| 139 | /* |
| 140 | * Parse an Amiga-specific record in the bootinfo |
| 141 | */ |
| 142 | |
Geert Uytterhoeven | a4df02a | 2013-06-25 21:15:24 +0200 | [diff] [blame^] | 143 | int __init amiga_parse_bootinfo(const struct bi_record *record) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 145 | int unknown = 0; |
| 146 | const unsigned long *data = record->data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 148 | switch (record->tag) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | case BI_AMIGA_MODEL: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 150 | amiga_model = *data; |
| 151 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
| 153 | case BI_AMIGA_ECLOCK: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 154 | amiga_eclock = *data; |
| 155 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | |
| 157 | case BI_AMIGA_CHIPSET: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 158 | amiga_chipset = *data; |
| 159 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
| 161 | case BI_AMIGA_CHIP_SIZE: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 162 | amiga_chip_size = *(const int *)data; |
| 163 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
| 165 | case BI_AMIGA_VBLANK: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 166 | amiga_vblank = *(const unsigned char *)data; |
| 167 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | |
| 169 | case BI_AMIGA_PSFREQ: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 170 | amiga_psfreq = *(const unsigned char *)data; |
| 171 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
| 173 | case BI_AMIGA_AUTOCON: |
| 174 | #ifdef CONFIG_ZORRO |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 175 | if (zorro_num_autocon < ZORRO_NUM_AUTO) { |
| 176 | const struct ConfigDev *cd = (struct ConfigDev *)data; |
| 177 | struct zorro_dev *dev = &zorro_autocon[zorro_num_autocon++]; |
| 178 | dev->rom = cd->cd_Rom; |
| 179 | dev->slotaddr = cd->cd_SlotAddr; |
| 180 | dev->slotsize = cd->cd_SlotSize; |
| 181 | dev->resource.start = (unsigned long)cd->cd_BoardAddr; |
| 182 | dev->resource.end = dev->resource.start + cd->cd_BoardSize - 1; |
| 183 | } else |
| 184 | printk("amiga_parse_bootinfo: too many AutoConfig devices\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | #endif /* CONFIG_ZORRO */ |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 186 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | |
| 188 | case BI_AMIGA_SERPER: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 189 | /* serial port period: ignored here */ |
| 190 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | |
| 192 | default: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 193 | unknown = 1; |
| 194 | } |
| 195 | return unknown; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | /* |
| 199 | * Identify builtin hardware |
| 200 | */ |
| 201 | |
| 202 | static void __init amiga_identify(void) |
| 203 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 204 | /* Fill in some default values, if necessary */ |
| 205 | if (amiga_eclock == 0) |
| 206 | amiga_eclock = 709379; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 208 | memset(&amiga_hw_present, 0, sizeof(amiga_hw_present)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 210 | printk("Amiga hardware found: "); |
| 211 | if (amiga_model >= AMI_500 && amiga_model <= AMI_DRACO) { |
| 212 | printk("[%s] ", amiga_models[amiga_model-AMI_500]); |
| 213 | strcat(amiga_model_name, amiga_models[amiga_model-AMI_500]); |
| 214 | } |
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 | switch (amiga_model) { |
| 217 | case AMI_UNKNOWN: |
| 218 | goto Generic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 220 | case AMI_600: |
| 221 | case AMI_1200: |
| 222 | AMIGAHW_SET(A1200_IDE); |
| 223 | AMIGAHW_SET(PCMCIA); |
| 224 | case AMI_500: |
| 225 | case AMI_500PLUS: |
| 226 | case AMI_1000: |
| 227 | case AMI_2000: |
| 228 | case AMI_2500: |
| 229 | AMIGAHW_SET(A2000_CLK); /* Is this correct for all models? */ |
| 230 | goto Generic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 232 | case AMI_3000: |
| 233 | case AMI_3000T: |
| 234 | AMIGAHW_SET(AMBER_FF); |
| 235 | AMIGAHW_SET(MAGIC_REKICK); |
| 236 | /* fall through */ |
| 237 | case AMI_3000PLUS: |
| 238 | AMIGAHW_SET(A3000_SCSI); |
| 239 | AMIGAHW_SET(A3000_CLK); |
| 240 | AMIGAHW_SET(ZORRO3); |
| 241 | goto Generic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 243 | case AMI_4000T: |
| 244 | AMIGAHW_SET(A4000_SCSI); |
| 245 | /* fall through */ |
| 246 | case AMI_4000: |
| 247 | AMIGAHW_SET(A4000_IDE); |
| 248 | AMIGAHW_SET(A3000_CLK); |
| 249 | AMIGAHW_SET(ZORRO3); |
| 250 | goto Generic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 252 | case AMI_CDTV: |
| 253 | case AMI_CD32: |
| 254 | AMIGAHW_SET(CD_ROM); |
| 255 | AMIGAHW_SET(A2000_CLK); /* Is this correct? */ |
| 256 | goto Generic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 258 | Generic: |
| 259 | AMIGAHW_SET(AMI_VIDEO); |
| 260 | AMIGAHW_SET(AMI_BLITTER); |
| 261 | AMIGAHW_SET(AMI_AUDIO); |
| 262 | AMIGAHW_SET(AMI_FLOPPY); |
| 263 | AMIGAHW_SET(AMI_KEYBOARD); |
| 264 | AMIGAHW_SET(AMI_MOUSE); |
| 265 | AMIGAHW_SET(AMI_SERIAL); |
| 266 | AMIGAHW_SET(AMI_PARALLEL); |
| 267 | AMIGAHW_SET(CHIP_RAM); |
| 268 | AMIGAHW_SET(PAULA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 270 | switch (amiga_chipset) { |
| 271 | case CS_OCS: |
| 272 | case CS_ECS: |
| 273 | case CS_AGA: |
| 274 | switch (amiga_custom.deniseid & 0xf) { |
| 275 | case 0x0c: |
| 276 | AMIGAHW_SET(DENISE_HR); |
| 277 | break; |
| 278 | case 0x08: |
| 279 | AMIGAHW_SET(LISA); |
| 280 | break; |
| 281 | } |
| 282 | break; |
| 283 | default: |
| 284 | AMIGAHW_SET(DENISE); |
| 285 | break; |
| 286 | } |
| 287 | switch ((amiga_custom.vposr>>8) & 0x7f) { |
| 288 | case 0x00: |
| 289 | AMIGAHW_SET(AGNUS_PAL); |
| 290 | break; |
| 291 | case 0x10: |
| 292 | AMIGAHW_SET(AGNUS_NTSC); |
| 293 | break; |
| 294 | case 0x20: |
| 295 | case 0x21: |
| 296 | AMIGAHW_SET(AGNUS_HR_PAL); |
| 297 | break; |
| 298 | case 0x30: |
| 299 | case 0x31: |
| 300 | AMIGAHW_SET(AGNUS_HR_NTSC); |
| 301 | break; |
| 302 | case 0x22: |
| 303 | case 0x23: |
| 304 | AMIGAHW_SET(ALICE_PAL); |
| 305 | break; |
| 306 | case 0x32: |
| 307 | case 0x33: |
| 308 | AMIGAHW_SET(ALICE_NTSC); |
| 309 | break; |
| 310 | } |
| 311 | AMIGAHW_SET(ZORRO); |
| 312 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 314 | case AMI_DRACO: |
| 315 | panic("No support for Draco yet"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 317 | default: |
| 318 | panic("Unknown Amiga Model"); |
| 319 | } |
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 | #define AMIGAHW_ANNOUNCE(name, str) \ |
| 322 | if (AMIGAHW_PRESENT(name)) \ |
| 323 | printk(str) |
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 | AMIGAHW_ANNOUNCE(AMI_VIDEO, "VIDEO "); |
| 326 | AMIGAHW_ANNOUNCE(AMI_BLITTER, "BLITTER "); |
| 327 | AMIGAHW_ANNOUNCE(AMBER_FF, "AMBER_FF "); |
| 328 | AMIGAHW_ANNOUNCE(AMI_AUDIO, "AUDIO "); |
| 329 | AMIGAHW_ANNOUNCE(AMI_FLOPPY, "FLOPPY "); |
| 330 | AMIGAHW_ANNOUNCE(A3000_SCSI, "A3000_SCSI "); |
| 331 | AMIGAHW_ANNOUNCE(A4000_SCSI, "A4000_SCSI "); |
| 332 | AMIGAHW_ANNOUNCE(A1200_IDE, "A1200_IDE "); |
| 333 | AMIGAHW_ANNOUNCE(A4000_IDE, "A4000_IDE "); |
| 334 | AMIGAHW_ANNOUNCE(CD_ROM, "CD_ROM "); |
| 335 | AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "KEYBOARD "); |
| 336 | AMIGAHW_ANNOUNCE(AMI_MOUSE, "MOUSE "); |
| 337 | AMIGAHW_ANNOUNCE(AMI_SERIAL, "SERIAL "); |
| 338 | AMIGAHW_ANNOUNCE(AMI_PARALLEL, "PARALLEL "); |
| 339 | AMIGAHW_ANNOUNCE(A2000_CLK, "A2000_CLK "); |
| 340 | AMIGAHW_ANNOUNCE(A3000_CLK, "A3000_CLK "); |
| 341 | AMIGAHW_ANNOUNCE(CHIP_RAM, "CHIP_RAM "); |
| 342 | AMIGAHW_ANNOUNCE(PAULA, "PAULA "); |
| 343 | AMIGAHW_ANNOUNCE(DENISE, "DENISE "); |
| 344 | AMIGAHW_ANNOUNCE(DENISE_HR, "DENISE_HR "); |
| 345 | AMIGAHW_ANNOUNCE(LISA, "LISA "); |
| 346 | AMIGAHW_ANNOUNCE(AGNUS_PAL, "AGNUS_PAL "); |
| 347 | AMIGAHW_ANNOUNCE(AGNUS_NTSC, "AGNUS_NTSC "); |
| 348 | AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "AGNUS_HR_PAL "); |
| 349 | AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "AGNUS_HR_NTSC "); |
| 350 | AMIGAHW_ANNOUNCE(ALICE_PAL, "ALICE_PAL "); |
| 351 | AMIGAHW_ANNOUNCE(ALICE_NTSC, "ALICE_NTSC "); |
| 352 | AMIGAHW_ANNOUNCE(MAGIC_REKICK, "MAGIC_REKICK "); |
| 353 | AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA "); |
| 354 | if (AMIGAHW_PRESENT(ZORRO)) |
| 355 | printk("ZORRO%s ", AMIGAHW_PRESENT(ZORRO3) ? "3" : ""); |
| 356 | printk("\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | |
| 358 | #undef AMIGAHW_ANNOUNCE |
| 359 | } |
| 360 | |
| 361 | /* |
| 362 | * Setup the Amiga configuration info |
| 363 | */ |
| 364 | |
| 365 | void __init config_amiga(void) |
| 366 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 367 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 369 | amiga_identify(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 371 | /* Yuk, we don't have PCI memory */ |
| 372 | iomem_resource.name = "Memory"; |
| 373 | for (i = 0; i < 4; i++) |
| 374 | request_resource(&iomem_resource, &((struct resource *)&mb_resources)[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 | mach_sched_init = amiga_sched_init; |
| 377 | mach_init_IRQ = amiga_init_IRQ; |
| 378 | mach_get_model = amiga_get_model; |
| 379 | mach_get_hardware_list = amiga_get_hardware_list; |
Stephen Warren | c8d5ba1 | 2012-11-08 11:34:55 -0700 | [diff] [blame] | 380 | arch_gettimeoffset = amiga_gettimeoffset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 382 | /* |
| 383 | * default MAX_DMA=0xffffffff on all machines. If we don't do so, the SCSI |
| 384 | * code will not be able to allocate any mem for transfers, unless we are |
| 385 | * dealing with a Z2 mem only system. /Jes |
| 386 | */ |
| 387 | mach_max_dma_address = 0xffffffff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 389 | mach_reset = amiga_reset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 391 | mach_beep = amiga_mksound; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | #endif |
| 393 | |
| 394 | #ifdef CONFIG_HEARTBEAT |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 395 | mach_heartbeat = amiga_heartbeat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | #endif |
| 397 | |
Adrian Bunk | 0795dbc | 2008-07-17 21:16:23 +0200 | [diff] [blame] | 398 | /* Fill in the clock value (based on the 700 kHz E-Clock) */ |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 399 | amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 401 | /* clear all DMA bits */ |
| 402 | amiga_custom.dmacon = DMAF_ALL; |
| 403 | /* ensure that the DMA master bit is set */ |
| 404 | amiga_custom.dmacon = DMAF_SETCLR | DMAF_MASTER; |
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 | /* don't use Z2 RAM as system memory on Z3 capable machines */ |
| 407 | if (AMIGAHW_PRESENT(ZORRO3)) { |
| 408 | int i, j; |
| 409 | u32 disabled_z2mem = 0; |
| 410 | |
| 411 | for (i = 0; i < m68k_num_memory; i++) { |
| 412 | if (m68k_memory[i].addr < 16*1024*1024) { |
| 413 | if (i == 0) { |
| 414 | /* don't cut off the branch we're sitting on */ |
| 415 | printk("Warning: kernel runs in Zorro II memory\n"); |
| 416 | continue; |
| 417 | } |
| 418 | disabled_z2mem += m68k_memory[i].size; |
| 419 | m68k_num_memory--; |
| 420 | for (j = i; j < m68k_num_memory; j++) |
| 421 | m68k_memory[j] = m68k_memory[j+1]; |
| 422 | i--; |
| 423 | } |
| 424 | } |
| 425 | if (disabled_z2mem) |
| 426 | printk("%dK of Zorro II memory will not be used as system memory\n", |
| 427 | disabled_z2mem>>10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 430 | /* request all RAM */ |
| 431 | for (i = 0; i < m68k_num_memory; i++) { |
| 432 | ram_resource[i].name = |
| 433 | (m68k_memory[i].addr >= 0x01000000) ? "32-bit Fast RAM" : |
| 434 | (m68k_memory[i].addr < 0x00c00000) ? "16-bit Fast RAM" : |
| 435 | "16-bit Slow RAM"; |
| 436 | ram_resource[i].start = m68k_memory[i].addr; |
| 437 | ram_resource[i].end = m68k_memory[i].addr+m68k_memory[i].size-1; |
| 438 | request_resource(&iomem_resource, &ram_resource[i]); |
| 439 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 441 | /* initialize chipram allocator */ |
| 442 | amiga_chip_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 444 | /* our beloved beeper */ |
| 445 | if (AMIGAHW_PRESENT(AMI_AUDIO)) |
| 446 | amiga_init_sound(); |
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 | /* |
| 449 | * if it is an A3000, set the magic bit that forces |
| 450 | * a hard rekick |
| 451 | */ |
| 452 | if (AMIGAHW_PRESENT(MAGIC_REKICK)) |
| 453 | *(unsigned char *)ZTWO_VADDR(0xde0002) |= 0x80; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | static unsigned short jiffy_ticks; |
| 457 | |
David Howells | 40220c1 | 2006-10-09 12:19:47 +0100 | [diff] [blame] | 458 | static void __init amiga_sched_init(irq_handler_t timer_routine) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | { |
| 460 | static struct resource sched_res = { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 461 | .name = "timer", .start = 0x00bfd400, .end = 0x00bfd5ff, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | }; |
Julia Lawall | 1a0caf4 | 2009-08-02 10:47:47 +0200 | [diff] [blame] | 463 | jiffy_ticks = DIV_ROUND_CLOSEST(amiga_eclock, HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | |
| 465 | if (request_resource(&mb_resources._ciab, &sched_res)) |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 466 | printk("Cannot allocate ciab.ta{lo,hi}\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | ciab.cra &= 0xC0; /* turn off timer A, continuous mode, from Eclk */ |
| 468 | ciab.talo = jiffy_ticks % 256; |
| 469 | ciab.tahi = jiffy_ticks / 256; |
| 470 | |
| 471 | /* install interrupt service routine for CIAB Timer A |
| 472 | * |
| 473 | * Please don't change this to use ciaa, as it interferes with the |
| 474 | * SCSI code. We'll have to take a look at this later |
| 475 | */ |
Geert Uytterhoeven | 66acd25 | 2008-12-30 14:00:34 +0100 | [diff] [blame] | 476 | if (request_irq(IRQ_AMIGA_CIAB_TA, timer_routine, 0, "timer", NULL)) |
| 477 | pr_err("Couldn't register timer interrupt\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | /* start timer */ |
| 479 | ciab.cra |= 0x11; |
| 480 | } |
| 481 | |
| 482 | #define TICK_SIZE 10000 |
| 483 | |
| 484 | /* This is always executed with interrupts disabled. */ |
Stephen Warren | c8d5ba1 | 2012-11-08 11:34:55 -0700 | [diff] [blame] | 485 | static u32 amiga_gettimeoffset(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | { |
| 487 | unsigned short hi, lo, hi2; |
Stephen Warren | c8d5ba1 | 2012-11-08 11:34:55 -0700 | [diff] [blame] | 488 | u32 ticks, offset = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | |
| 490 | /* read CIA B timer A current value */ |
| 491 | hi = ciab.tahi; |
| 492 | lo = ciab.talo; |
| 493 | hi2 = ciab.tahi; |
| 494 | |
| 495 | if (hi != hi2) { |
| 496 | lo = ciab.talo; |
| 497 | hi = hi2; |
| 498 | } |
| 499 | |
| 500 | ticks = hi << 8 | lo; |
| 501 | |
| 502 | if (ticks > jiffy_ticks / 2) |
| 503 | /* check for pending interrupt */ |
| 504 | if (cia_set_irq(&ciab_base, 0) & CIA_ICR_TA) |
| 505 | offset = 10000; |
| 506 | |
| 507 | ticks = jiffy_ticks - ticks; |
| 508 | ticks = (10000 * ticks) / jiffy_ticks; |
| 509 | |
Stephen Warren | c8d5ba1 | 2012-11-08 11:34:55 -0700 | [diff] [blame] | 510 | return (ticks + offset) * 1000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | } |
| 512 | |
Joe Perches | ff2d8b1 | 2012-01-12 17:17:21 -0800 | [diff] [blame] | 513 | static void amiga_reset(void) __noreturn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 515 | static void amiga_reset(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 517 | unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040); |
| 518 | unsigned long jmp_addr = virt_to_phys(&&jmp_addr_label); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 520 | local_irq_disable(); |
| 521 | if (CPU_IS_040_OR_060) |
| 522 | /* Setup transparent translation registers for mapping |
| 523 | * of 16 MB kernel segment before disabling translation |
| 524 | */ |
| 525 | asm volatile ("\n" |
| 526 | " move.l %0,%%d0\n" |
| 527 | " and.l #0xff000000,%%d0\n" |
| 528 | " or.w #0xe020,%%d0\n" /* map 16 MB, enable, cacheable */ |
| 529 | " .chip 68040\n" |
| 530 | " movec %%d0,%%itt0\n" |
| 531 | " movec %%d0,%%dtt0\n" |
| 532 | " .chip 68k\n" |
| 533 | " jmp %0@\n" |
| 534 | : /* no outputs */ |
| 535 | : "a" (jmp_addr040) |
| 536 | : "d0"); |
| 537 | else |
| 538 | /* for 680[23]0, just disable translation and jump to the physical |
| 539 | * address of the label |
| 540 | */ |
| 541 | asm volatile ("\n" |
| 542 | " pmove %%tc,%@\n" |
| 543 | " bclr #7,%@\n" |
| 544 | " pmove %@,%%tc\n" |
| 545 | " jmp %0@\n" |
| 546 | : /* no outputs */ |
| 547 | : "a" (jmp_addr)); |
| 548 | jmp_addr_label040: |
| 549 | /* disable translation on '040 now */ |
| 550 | asm volatile ("\n" |
| 551 | " moveq #0,%%d0\n" |
| 552 | " .chip 68040\n" |
| 553 | " movec %%d0,%%tc\n" /* disable MMU */ |
| 554 | " .chip 68k\n" |
| 555 | : /* no outputs */ |
| 556 | : /* no inputs */ |
| 557 | : "d0"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 559 | jmp_addr_label: |
| 560 | /* pickup reset address from AmigaOS ROM, reset devices and jump |
| 561 | * to reset address |
| 562 | */ |
| 563 | asm volatile ("\n" |
| 564 | " move.w #0x2700,%sr\n" |
| 565 | " lea 0x01000000,%a0\n" |
| 566 | " sub.l %a0@(-0x14),%a0\n" |
| 567 | " move.l %a0@(4),%a0\n" |
| 568 | " subq.l #2,%a0\n" |
| 569 | " jra 1f\n" |
| 570 | /* align on a longword boundary */ |
| 571 | " " __ALIGN_STR "\n" |
| 572 | "1:\n" |
| 573 | " reset\n" |
| 574 | " jmp %a0@"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 576 | for (;;) |
| 577 | ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | |
| 581 | /* |
| 582 | * Debugging |
| 583 | */ |
| 584 | |
| 585 | #define SAVEKMSG_MAXMEM 128*1024 |
| 586 | |
| 587 | #define SAVEKMSG_MAGIC1 0x53415645 /* 'SAVE' */ |
| 588 | #define SAVEKMSG_MAGIC2 0x4B4D5347 /* 'KMSG' */ |
| 589 | |
| 590 | struct savekmsg { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 591 | unsigned long magic1; /* SAVEKMSG_MAGIC1 */ |
| 592 | unsigned long magic2; /* SAVEKMSG_MAGIC2 */ |
| 593 | unsigned long magicptr; /* address of magic1 */ |
| 594 | unsigned long size; |
| 595 | char data[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | }; |
| 597 | |
| 598 | static struct savekmsg *savekmsg; |
| 599 | |
| 600 | static void amiga_mem_console_write(struct console *co, const char *s, |
| 601 | unsigned int count) |
| 602 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 603 | if (savekmsg->size + count <= SAVEKMSG_MAXMEM-sizeof(struct savekmsg)) { |
| 604 | memcpy(savekmsg->data + savekmsg->size, s, count); |
| 605 | savekmsg->size += count; |
| 606 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | } |
| 608 | |
Roman Zippel | d6713b4 | 2007-05-01 22:32:45 +0200 | [diff] [blame] | 609 | static int __init amiga_savekmsg_setup(char *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | { |
Roman Zippel | d6713b4 | 2007-05-01 22:32:45 +0200 | [diff] [blame] | 611 | if (!MACH_IS_AMIGA || strcmp(arg, "mem")) |
Geert Uytterhoeven | 5df1abd | 2011-01-07 13:25:29 +0100 | [diff] [blame] | 612 | return 0; |
Roman Zippel | d6713b4 | 2007-05-01 22:32:45 +0200 | [diff] [blame] | 613 | |
Geert Uytterhoeven | 5df1abd | 2011-01-07 13:25:29 +0100 | [diff] [blame] | 614 | if (amiga_chip_size < SAVEKMSG_MAXMEM) { |
| 615 | pr_err("Not enough chipram for debugging\n"); |
| 616 | return -ENOMEM; |
Roman Zippel | d6713b4 | 2007-05-01 22:32:45 +0200 | [diff] [blame] | 617 | } |
| 618 | |
Geert Uytterhoeven | 5df1abd | 2011-01-07 13:25:29 +0100 | [diff] [blame] | 619 | /* Just steal the block, the chipram allocator isn't functional yet */ |
| 620 | amiga_chip_size -= SAVEKMSG_MAXMEM; |
| 621 | savekmsg = (void *)ZTWO_VADDR(CHIP_PHYSADDR + amiga_chip_size); |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 622 | savekmsg->magic1 = SAVEKMSG_MAGIC1; |
| 623 | savekmsg->magic2 = SAVEKMSG_MAGIC2; |
| 624 | savekmsg->magicptr = ZTWO_PADDR(savekmsg); |
| 625 | savekmsg->size = 0; |
Roman Zippel | d6713b4 | 2007-05-01 22:32:45 +0200 | [diff] [blame] | 626 | |
| 627 | amiga_console_driver.write = amiga_mem_console_write; |
| 628 | register_console(&amiga_console_driver); |
Roman Zippel | d6713b4 | 2007-05-01 22:32:45 +0200 | [diff] [blame] | 629 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | } |
| 631 | |
Roman Zippel | d6713b4 | 2007-05-01 22:32:45 +0200 | [diff] [blame] | 632 | early_param("debug", amiga_savekmsg_setup); |
| 633 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | static void amiga_serial_putc(char c) |
| 635 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 636 | amiga_custom.serdat = (unsigned char)c | 0x100; |
| 637 | while (!(amiga_custom.serdatr & 0x2000)) |
| 638 | ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | } |
| 640 | |
Adrian Bunk | 0795dbc | 2008-07-17 21:16:23 +0200 | [diff] [blame] | 641 | static void amiga_serial_console_write(struct console *co, const char *s, |
| 642 | unsigned int count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 644 | while (count--) { |
| 645 | if (*s == '\n') |
| 646 | amiga_serial_putc('\r'); |
| 647 | amiga_serial_putc(*s++); |
| 648 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | } |
| 650 | |
Adrian Bunk | 0795dbc | 2008-07-17 21:16:23 +0200 | [diff] [blame] | 651 | #if 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | void amiga_serial_puts(const char *s) |
| 653 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 654 | amiga_serial_console_write(NULL, s, strlen(s)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | int amiga_serial_console_wait_key(struct console *co) |
| 658 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 659 | int ch; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 661 | while (!(amiga_custom.intreqr & IF_RBF)) |
| 662 | barrier(); |
| 663 | ch = amiga_custom.serdatr & 0xff; |
| 664 | /* clear the interrupt, so that another character can be read */ |
| 665 | amiga_custom.intreq = IF_RBF; |
| 666 | return ch; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | void amiga_serial_gets(struct console *co, char *s, int len) |
| 670 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 671 | int ch, cnt = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 673 | while (1) { |
| 674 | ch = amiga_serial_console_wait_key(co); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 676 | /* Check for backspace. */ |
| 677 | if (ch == 8 || ch == 127) { |
| 678 | if (cnt == 0) { |
| 679 | amiga_serial_putc('\007'); |
| 680 | continue; |
| 681 | } |
| 682 | cnt--; |
| 683 | amiga_serial_puts("\010 \010"); |
| 684 | continue; |
| 685 | } |
| 686 | |
| 687 | /* Check for enter. */ |
| 688 | if (ch == 10 || ch == 13) |
| 689 | break; |
| 690 | |
| 691 | /* See if line is too long. */ |
| 692 | if (cnt >= len + 1) { |
| 693 | amiga_serial_putc(7); |
| 694 | cnt--; |
| 695 | continue; |
| 696 | } |
| 697 | |
| 698 | /* Store and echo character. */ |
| 699 | s[cnt++] = ch; |
| 700 | amiga_serial_putc(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | } |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 702 | /* Print enter. */ |
| 703 | amiga_serial_puts("\r\n"); |
| 704 | s[cnt] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | } |
| 706 | #endif |
| 707 | |
Roman Zippel | d6713b4 | 2007-05-01 22:32:45 +0200 | [diff] [blame] | 708 | static int __init amiga_debug_setup(char *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | { |
Roman Zippel | d6713b4 | 2007-05-01 22:32:45 +0200 | [diff] [blame] | 710 | if (MACH_IS_AMIGA && !strcmp(arg, "ser")) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | /* no initialization required (?) */ |
| 712 | amiga_console_driver.write = amiga_serial_console_write; |
| 713 | register_console(&amiga_console_driver); |
| 714 | } |
Roman Zippel | d6713b4 | 2007-05-01 22:32:45 +0200 | [diff] [blame] | 715 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | } |
| 717 | |
Roman Zippel | d6713b4 | 2007-05-01 22:32:45 +0200 | [diff] [blame] | 718 | early_param("debug", amiga_debug_setup); |
| 719 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | #ifdef CONFIG_HEARTBEAT |
| 721 | static void amiga_heartbeat(int on) |
| 722 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 723 | if (on) |
| 724 | ciaa.pra &= ~2; |
| 725 | else |
| 726 | ciaa.pra |= 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | } |
| 728 | #endif |
| 729 | |
| 730 | /* |
| 731 | * Amiga specific parts of /proc |
| 732 | */ |
| 733 | |
| 734 | static void amiga_get_model(char *model) |
| 735 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 736 | strcpy(model, amiga_model_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | |
Alexey Dobriyan | 813dcf7 | 2008-10-03 22:42:36 +0400 | [diff] [blame] | 740 | static void amiga_get_hardware_list(struct seq_file *m) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 741 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 742 | if (AMIGAHW_PRESENT(CHIP_RAM)) |
Alexey Dobriyan | 813dcf7 | 2008-10-03 22:42:36 +0400 | [diff] [blame] | 743 | seq_printf(m, "Chip RAM:\t%ldK\n", amiga_chip_size>>10); |
| 744 | seq_printf(m, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n", |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 745 | amiga_psfreq, amiga_eclock); |
| 746 | if (AMIGAHW_PRESENT(AMI_VIDEO)) { |
| 747 | char *type; |
| 748 | switch (amiga_chipset) { |
| 749 | case CS_OCS: |
| 750 | type = "OCS"; |
| 751 | break; |
| 752 | case CS_ECS: |
| 753 | type = "ECS"; |
| 754 | break; |
| 755 | case CS_AGA: |
| 756 | type = "AGA"; |
| 757 | break; |
| 758 | default: |
| 759 | type = "Old or Unknown"; |
| 760 | break; |
| 761 | } |
Alexey Dobriyan | 813dcf7 | 2008-10-03 22:42:36 +0400 | [diff] [blame] | 762 | seq_printf(m, "Graphics:\t%s\n", type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | |
| 765 | #define AMIGAHW_ANNOUNCE(name, str) \ |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 766 | if (AMIGAHW_PRESENT(name)) \ |
Alexey Dobriyan | 813dcf7 | 2008-10-03 22:42:36 +0400 | [diff] [blame] | 767 | seq_printf (m, "\t%s\n", str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | |
Alexey Dobriyan | 813dcf7 | 2008-10-03 22:42:36 +0400 | [diff] [blame] | 769 | seq_printf (m, "Detected hardware:\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 771 | AMIGAHW_ANNOUNCE(AMI_VIDEO, "Amiga Video"); |
| 772 | AMIGAHW_ANNOUNCE(AMI_BLITTER, "Blitter"); |
| 773 | AMIGAHW_ANNOUNCE(AMBER_FF, "Amber Flicker Fixer"); |
| 774 | AMIGAHW_ANNOUNCE(AMI_AUDIO, "Amiga Audio"); |
| 775 | AMIGAHW_ANNOUNCE(AMI_FLOPPY, "Floppy Controller"); |
| 776 | AMIGAHW_ANNOUNCE(A3000_SCSI, "SCSI Controller WD33C93 (A3000 style)"); |
| 777 | AMIGAHW_ANNOUNCE(A4000_SCSI, "SCSI Controller NCR53C710 (A4000T style)"); |
| 778 | AMIGAHW_ANNOUNCE(A1200_IDE, "IDE Interface (A1200 style)"); |
| 779 | AMIGAHW_ANNOUNCE(A4000_IDE, "IDE Interface (A4000 style)"); |
| 780 | AMIGAHW_ANNOUNCE(CD_ROM, "Internal CD ROM drive"); |
| 781 | AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "Keyboard"); |
| 782 | AMIGAHW_ANNOUNCE(AMI_MOUSE, "Mouse Port"); |
| 783 | AMIGAHW_ANNOUNCE(AMI_SERIAL, "Serial Port"); |
| 784 | AMIGAHW_ANNOUNCE(AMI_PARALLEL, "Parallel Port"); |
| 785 | AMIGAHW_ANNOUNCE(A2000_CLK, "Hardware Clock (A2000 style)"); |
| 786 | AMIGAHW_ANNOUNCE(A3000_CLK, "Hardware Clock (A3000 style)"); |
| 787 | AMIGAHW_ANNOUNCE(CHIP_RAM, "Chip RAM"); |
| 788 | AMIGAHW_ANNOUNCE(PAULA, "Paula 8364"); |
| 789 | AMIGAHW_ANNOUNCE(DENISE, "Denise 8362"); |
| 790 | AMIGAHW_ANNOUNCE(DENISE_HR, "Denise 8373"); |
| 791 | AMIGAHW_ANNOUNCE(LISA, "Lisa 8375"); |
| 792 | AMIGAHW_ANNOUNCE(AGNUS_PAL, "Normal/Fat PAL Agnus 8367/8371"); |
| 793 | AMIGAHW_ANNOUNCE(AGNUS_NTSC, "Normal/Fat NTSC Agnus 8361/8370"); |
| 794 | AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "Fat Hires PAL Agnus 8372"); |
| 795 | AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "Fat Hires NTSC Agnus 8372"); |
| 796 | AMIGAHW_ANNOUNCE(ALICE_PAL, "PAL Alice 8374"); |
| 797 | AMIGAHW_ANNOUNCE(ALICE_NTSC, "NTSC Alice 8374"); |
| 798 | AMIGAHW_ANNOUNCE(MAGIC_REKICK, "Magic Hard Rekick"); |
| 799 | AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA Slot"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | #ifdef CONFIG_ZORRO |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 801 | if (AMIGAHW_PRESENT(ZORRO)) |
Alexey Dobriyan | 813dcf7 | 2008-10-03 22:42:36 +0400 | [diff] [blame] | 802 | seq_printf(m, "\tZorro II%s AutoConfig: %d Expansion " |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame] | 803 | "Device%s\n", |
| 804 | AMIGAHW_PRESENT(ZORRO3) ? "I" : "", |
| 805 | zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | #endif /* CONFIG_ZORRO */ |
| 807 | |
| 808 | #undef AMIGAHW_ANNOUNCE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | } |
Geert Uytterhoeven | 39d2d99 | 2008-10-13 21:58:53 +0200 | [diff] [blame] | 810 | |
| 811 | /* |
| 812 | * The Amiga keyboard driver needs key_maps, but we cannot export it in |
| 813 | * drivers/char/defkeymap.c, as it is autogenerated |
| 814 | */ |
| 815 | #ifdef CONFIG_HW_CONSOLE |
| 816 | EXPORT_SYMBOL_GPL(key_maps); |
| 817 | #endif |