Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/m68k/atari/config.c |
| 3 | * |
| 4 | * Copyright (C) 1994 Bjoern Brauel |
| 5 | * |
| 6 | * 5/2/94 Roman Hodek: |
| 7 | * Added setting of time_adj to get a better clock. |
| 8 | * |
| 9 | * 5/14/94 Roman Hodek: |
| 10 | * gettod() for TT |
| 11 | * |
| 12 | * 5/15/94 Roman Hodek: |
| 13 | * hard_reset_now() for Atari (and others?) |
| 14 | * |
| 15 | * 94/12/30 Andreas Schwab: |
| 16 | * atari_sched_init fixed to get precise clock. |
| 17 | * |
| 18 | * This file is subject to the terms and conditions of the GNU General Public |
| 19 | * License. See the file COPYING in the main directory of this archive |
| 20 | * for more details. |
| 21 | */ |
| 22 | |
| 23 | /* |
| 24 | * Miscellaneous atari stuff |
| 25 | */ |
| 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/types.h> |
| 28 | #include <linux/mm.h> |
| 29 | #include <linux/console.h> |
| 30 | #include <linux/init.h> |
| 31 | #include <linux/delay.h> |
| 32 | #include <linux/ioport.h> |
| 33 | #include <linux/vt_kern.h> |
| 34 | |
| 35 | #include <asm/bootinfo.h> |
| 36 | #include <asm/setup.h> |
| 37 | #include <asm/atarihw.h> |
| 38 | #include <asm/atariints.h> |
| 39 | #include <asm/atari_stram.h> |
| 40 | #include <asm/system.h> |
| 41 | #include <asm/machdep.h> |
| 42 | #include <asm/hwtest.h> |
| 43 | #include <asm/io.h> |
| 44 | |
| 45 | u_long atari_mch_cookie; |
| 46 | u_long atari_mch_type; |
| 47 | struct atari_hw_present atari_hw_present; |
| 48 | u_long atari_switches; |
| 49 | int atari_dont_touch_floppy_select; |
| 50 | int atari_rtc_year_offset; |
| 51 | |
| 52 | /* local function prototypes */ |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 53 | static void atari_reset(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | static void atari_get_model(char *model); |
| 55 | static int atari_get_hardware_list(char *buffer); |
| 56 | |
| 57 | /* atari specific irq functions */ |
| 58 | extern void atari_init_IRQ (void); |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 59 | extern void atari_mksound(unsigned int count, unsigned int ticks); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | #ifdef CONFIG_HEARTBEAT |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 61 | static void atari_heartbeat(int on); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | #endif |
| 63 | |
| 64 | /* atari specific timer functions (in time.c) */ |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 65 | extern void atari_sched_init(irq_handler_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | extern unsigned long atari_gettimeoffset (void); |
| 67 | extern int atari_mste_hwclk (int, struct rtc_time *); |
| 68 | extern int atari_tt_hwclk (int, struct rtc_time *); |
| 69 | extern int atari_mste_set_clock_mmss (unsigned long); |
| 70 | extern int atari_tt_set_clock_mmss (unsigned long); |
| 71 | |
| 72 | /* atari specific debug functions (in debug.c) */ |
| 73 | extern void atari_debug_init(void); |
| 74 | |
| 75 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | /* ++roman: This is a more elaborate test for an SCC chip, since the plain |
| 77 | * Medusa board generates DTACK at the SCC's standard addresses, but a SCC |
| 78 | * board in the Medusa is possible. Also, the addresses where the ST_ESCC |
| 79 | * resides generate DTACK without the chip, too. |
| 80 | * The method is to write values into the interrupt vector register, that |
| 81 | * should be readable without trouble (from channel A!). |
| 82 | */ |
| 83 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 84 | static int __init scc_test(volatile char *ctla) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 86 | if (!hwreg_present(ctla)) |
| 87 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | MFPDELAY(); |
| 89 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 90 | *ctla = 2; |
| 91 | MFPDELAY(); |
| 92 | *ctla = 0x40; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | MFPDELAY(); |
| 94 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 95 | *ctla = 2; |
| 96 | MFPDELAY(); |
| 97 | if (*ctla != 0x40) |
| 98 | return 0; |
| 99 | MFPDELAY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 101 | *ctla = 2; |
| 102 | MFPDELAY(); |
| 103 | *ctla = 0x60; |
| 104 | MFPDELAY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 106 | *ctla = 2; |
| 107 | MFPDELAY(); |
| 108 | if (*ctla != 0x60) |
| 109 | return 0; |
| 110 | |
| 111 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | |
| 115 | /* |
| 116 | * Parse an Atari-specific record in the bootinfo |
| 117 | */ |
| 118 | |
| 119 | int __init atari_parse_bootinfo(const struct bi_record *record) |
| 120 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 121 | int unknown = 0; |
| 122 | const u_long *data = record->data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 124 | switch (record->tag) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | case BI_ATARI_MCH_COOKIE: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 126 | atari_mch_cookie = *data; |
| 127 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | case BI_ATARI_MCH_TYPE: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 129 | atari_mch_type = *data; |
| 130 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | default: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 132 | unknown = 1; |
| 133 | break; |
| 134 | } |
| 135 | return unknown; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | |
| 139 | /* Parse the Atari-specific switches= option. */ |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 140 | void __init atari_switches_setup(const char *str, unsigned len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 142 | char switches[len+1]; |
| 143 | char *p; |
| 144 | int ovsc_shift; |
| 145 | char *args = switches; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 147 | /* copy string to local array, strsep works destructively... */ |
| 148 | strlcpy(switches, str, sizeof(switches)); |
| 149 | atari_switches = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 151 | /* parse the options */ |
| 152 | while ((p = strsep(&args, ",")) != NULL) { |
| 153 | if (!*p) |
| 154 | continue; |
| 155 | ovsc_shift = 0; |
| 156 | if (strncmp(p, "ov_", 3) == 0) { |
| 157 | p += 3; |
| 158 | ovsc_shift = ATARI_SWITCH_OVSC_SHIFT; |
| 159 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 161 | if (strcmp(p, "ikbd") == 0) { |
| 162 | /* RTS line of IKBD ACIA */ |
| 163 | atari_switches |= ATARI_SWITCH_IKBD << ovsc_shift; |
| 164 | } else if (strcmp(p, "midi") == 0) { |
| 165 | /* RTS line of MIDI ACIA */ |
| 166 | atari_switches |= ATARI_SWITCH_MIDI << ovsc_shift; |
| 167 | } else if (strcmp(p, "snd6") == 0) { |
| 168 | atari_switches |= ATARI_SWITCH_SND6 << ovsc_shift; |
| 169 | } else if (strcmp(p, "snd7") == 0) { |
| 170 | atari_switches |= ATARI_SWITCH_SND7 << ovsc_shift; |
| 171 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | |
| 176 | /* |
| 177 | * Setup the Atari configuration info |
| 178 | */ |
| 179 | |
| 180 | void __init config_atari(void) |
| 181 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 182 | unsigned short tos_version; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 184 | memset(&atari_hw_present, 0, sizeof(atari_hw_present)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 186 | atari_debug_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 188 | /* Change size of I/O space from 64KB to 4GB. */ |
| 189 | ioport_resource.end = 0xFFFFFFFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 191 | mach_sched_init = atari_sched_init; |
| 192 | mach_init_IRQ = atari_init_IRQ; |
| 193 | mach_get_model = atari_get_model; |
| 194 | mach_get_hardware_list = atari_get_hardware_list; |
| 195 | mach_gettimeoffset = atari_gettimeoffset; |
| 196 | mach_reset = atari_reset; |
| 197 | mach_max_dma_address = 0xffffff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 199 | mach_beep = atari_mksound; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | #endif |
| 201 | #ifdef CONFIG_HEARTBEAT |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 202 | mach_heartbeat = atari_heartbeat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | #endif |
| 204 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 205 | /* Set switches as requested by the user */ |
| 206 | if (atari_switches & ATARI_SWITCH_IKBD) |
| 207 | acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID; |
| 208 | if (atari_switches & ATARI_SWITCH_MIDI) |
| 209 | acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID; |
| 210 | if (atari_switches & (ATARI_SWITCH_SND6|ATARI_SWITCH_SND7)) { |
| 211 | sound_ym.rd_data_reg_sel = 14; |
| 212 | sound_ym.wd_data = sound_ym.rd_data_reg_sel | |
| 213 | ((atari_switches&ATARI_SWITCH_SND6) ? 0x40 : 0) | |
| 214 | ((atari_switches&ATARI_SWITCH_SND7) ? 0x80 : 0); |
| 215 | } |
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 | /* ++bjoern: |
| 218 | * Determine hardware present |
| 219 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 221 | printk("Atari hardware found: "); |
| 222 | if (MACH_IS_MEDUSA || MACH_IS_HADES) { |
| 223 | /* There's no Atari video hardware on the Medusa, but all the |
| 224 | * addresses below generate a DTACK so no bus error occurs! */ |
| 225 | } else if (hwreg_present(f030_xreg)) { |
| 226 | ATARIHW_SET(VIDEL_SHIFTER); |
| 227 | printk("VIDEL "); |
| 228 | /* This is a temporary hack: If there is Falcon video |
| 229 | * hardware, we assume that the ST-DMA serves SCSI instead of |
| 230 | * ACSI. In the future, there should be a better method for |
| 231 | * this... |
| 232 | */ |
| 233 | ATARIHW_SET(ST_SCSI); |
| 234 | printk("STDMA-SCSI "); |
| 235 | } else if (hwreg_present(tt_palette)) { |
| 236 | ATARIHW_SET(TT_SHIFTER); |
| 237 | printk("TT_SHIFTER "); |
| 238 | } else if (hwreg_present(&shifter.bas_hi)) { |
| 239 | if (hwreg_present(&shifter.bas_lo) && |
| 240 | (shifter.bas_lo = 0x0aau, shifter.bas_lo == 0x0aau)) { |
| 241 | ATARIHW_SET(EXTD_SHIFTER); |
| 242 | printk("EXTD_SHIFTER "); |
| 243 | } else { |
| 244 | ATARIHW_SET(STND_SHIFTER); |
| 245 | printk("STND_SHIFTER "); |
| 246 | } |
| 247 | } |
| 248 | if (hwreg_present(&mfp.par_dt_reg)) { |
| 249 | ATARIHW_SET(ST_MFP); |
| 250 | printk("ST_MFP "); |
| 251 | } |
| 252 | if (hwreg_present(&tt_mfp.par_dt_reg)) { |
| 253 | ATARIHW_SET(TT_MFP); |
| 254 | printk("TT_MFP "); |
| 255 | } |
| 256 | if (hwreg_present(&tt_scsi_dma.dma_addr_hi)) { |
| 257 | ATARIHW_SET(SCSI_DMA); |
| 258 | printk("TT_SCSI_DMA "); |
| 259 | } |
| 260 | if (!MACH_IS_HADES && hwreg_present(&st_dma.dma_hi)) { |
| 261 | ATARIHW_SET(STND_DMA); |
| 262 | printk("STND_DMA "); |
| 263 | } |
| 264 | /* |
| 265 | * The ST-DMA address registers aren't readable |
| 266 | * on all Medusas, so the test below may fail |
| 267 | */ |
| 268 | if (MACH_IS_MEDUSA || |
| 269 | (hwreg_present(&st_dma.dma_vhi) && |
| 270 | (st_dma.dma_vhi = 0x55) && (st_dma.dma_hi = 0xaa) && |
| 271 | st_dma.dma_vhi == 0x55 && st_dma.dma_hi == 0xaa && |
| 272 | (st_dma.dma_vhi = 0xaa) && (st_dma.dma_hi = 0x55) && |
| 273 | st_dma.dma_vhi == 0xaa && st_dma.dma_hi == 0x55)) { |
| 274 | ATARIHW_SET(EXTD_DMA); |
| 275 | printk("EXTD_DMA "); |
| 276 | } |
| 277 | if (hwreg_present(&tt_scsi.scsi_data)) { |
| 278 | ATARIHW_SET(TT_SCSI); |
| 279 | printk("TT_SCSI "); |
| 280 | } |
| 281 | if (hwreg_present(&sound_ym.rd_data_reg_sel)) { |
| 282 | ATARIHW_SET(YM_2149); |
| 283 | printk("YM2149 "); |
| 284 | } |
| 285 | if (!MACH_IS_MEDUSA && !MACH_IS_HADES && |
| 286 | hwreg_present(&tt_dmasnd.ctrl)) { |
| 287 | ATARIHW_SET(PCM_8BIT); |
| 288 | printk("PCM "); |
| 289 | } |
| 290 | if (!MACH_IS_HADES && hwreg_present(&falcon_codec.unused5)) { |
| 291 | ATARIHW_SET(CODEC); |
| 292 | printk("CODEC "); |
| 293 | } |
| 294 | if (hwreg_present(&dsp56k_host_interface.icr)) { |
| 295 | ATARIHW_SET(DSP56K); |
| 296 | printk("DSP56K "); |
| 297 | } |
| 298 | if (hwreg_present(&tt_scc_dma.dma_ctrl) && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | #if 0 |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 300 | /* This test sucks! Who knows some better? */ |
| 301 | (tt_scc_dma.dma_ctrl = 0x01, (tt_scc_dma.dma_ctrl & 1) == 1) && |
| 302 | (tt_scc_dma.dma_ctrl = 0x00, (tt_scc_dma.dma_ctrl & 1) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | #else |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 304 | !MACH_IS_MEDUSA && !MACH_IS_HADES |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | #endif |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 306 | ) { |
| 307 | ATARIHW_SET(SCC_DMA); |
| 308 | printk("SCC_DMA "); |
| 309 | } |
| 310 | if (scc_test(&scc.cha_a_ctrl)) { |
| 311 | ATARIHW_SET(SCC); |
| 312 | printk("SCC "); |
| 313 | } |
| 314 | if (scc_test(&st_escc.cha_b_ctrl)) { |
| 315 | ATARIHW_SET(ST_ESCC); |
| 316 | printk("ST_ESCC "); |
| 317 | } |
| 318 | if (MACH_IS_HADES) { |
| 319 | ATARIHW_SET(VME); |
| 320 | printk("VME "); |
| 321 | } else if (hwreg_present(&tt_scu.sys_mask)) { |
| 322 | ATARIHW_SET(SCU); |
| 323 | /* Assume a VME bus if there's a SCU */ |
| 324 | ATARIHW_SET(VME); |
| 325 | printk("VME SCU "); |
| 326 | } |
| 327 | if (hwreg_present((void *)(0xffff9210))) { |
| 328 | ATARIHW_SET(ANALOG_JOY); |
| 329 | printk("ANALOG_JOY "); |
| 330 | } |
| 331 | if (!MACH_IS_HADES && hwreg_present(blitter.halftone)) { |
| 332 | ATARIHW_SET(BLITTER); |
| 333 | printk("BLITTER "); |
| 334 | } |
| 335 | if (hwreg_present((void *)0xfff00039)) { |
| 336 | ATARIHW_SET(IDE); |
| 337 | printk("IDE "); |
| 338 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | #if 1 /* This maybe wrong */ |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 340 | if (!MACH_IS_MEDUSA && !MACH_IS_HADES && |
| 341 | hwreg_present(&tt_microwire.data) && |
| 342 | hwreg_present(&tt_microwire.mask) && |
| 343 | (tt_microwire.mask = 0x7ff, |
| 344 | udelay(1), |
| 345 | tt_microwire.data = MW_LM1992_PSG_HIGH | MW_LM1992_ADDR, |
| 346 | udelay(1), |
| 347 | tt_microwire.data != 0)) { |
| 348 | ATARIHW_SET(MICROWIRE); |
| 349 | while (tt_microwire.mask != 0x7ff) |
| 350 | ; |
| 351 | printk("MICROWIRE "); |
| 352 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | #endif |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 354 | if (hwreg_present(&tt_rtc.regsel)) { |
| 355 | ATARIHW_SET(TT_CLK); |
| 356 | printk("TT_CLK "); |
| 357 | mach_hwclk = atari_tt_hwclk; |
| 358 | mach_set_clock_mmss = atari_tt_set_clock_mmss; |
| 359 | } |
| 360 | if (!MACH_IS_HADES && hwreg_present(&mste_rtc.sec_ones)) { |
| 361 | ATARIHW_SET(MSTE_CLK); |
| 362 | printk("MSTE_CLK "); |
| 363 | mach_hwclk = atari_mste_hwclk; |
| 364 | mach_set_clock_mmss = atari_mste_set_clock_mmss; |
| 365 | } |
| 366 | if (!MACH_IS_MEDUSA && !MACH_IS_HADES && |
| 367 | hwreg_present(&dma_wd.fdc_speed) && |
| 368 | hwreg_write(&dma_wd.fdc_speed, 0)) { |
| 369 | ATARIHW_SET(FDCSPEED); |
| 370 | printk("FDC_SPEED "); |
| 371 | } |
| 372 | if (!MACH_IS_HADES && !ATARIHW_PRESENT(ST_SCSI)) { |
| 373 | ATARIHW_SET(ACSI); |
| 374 | printk("ACSI "); |
| 375 | } |
| 376 | printk("\n"); |
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 | if (CPU_IS_040_OR_060) |
| 379 | /* Now it seems to be safe to turn of the tt0 transparent |
| 380 | * translation (the one that must not be turned off in |
| 381 | * head.S...) |
| 382 | */ |
| 383 | asm volatile ("\n" |
| 384 | " moveq #0,%%d0\n" |
| 385 | " .chip 68040\n" |
| 386 | " movec %%d0,%%itt0\n" |
| 387 | " movec %%d0,%%dtt0\n" |
| 388 | " .chip 68k" |
| 389 | : /* no outputs */ |
| 390 | : /* no inputs */ |
| 391 | : "d0"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 393 | /* allocator for memory that must reside in st-ram */ |
| 394 | atari_stram_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 396 | /* Set up a mapping for the VMEbus address region: |
| 397 | * |
| 398 | * VME is either at phys. 0xfexxxxxx (TT) or 0xa00000..0xdfffff |
| 399 | * (MegaSTE) In both cases, the whole 16 MB chunk is mapped at |
| 400 | * 0xfe000000 virt., because this can be done with a single |
| 401 | * transparent translation. On the 68040, lots of often unused |
| 402 | * page tables would be needed otherwise. On a MegaSTE or similar, |
| 403 | * the highest byte is stripped off by hardware due to the 24 bit |
| 404 | * design of the bus. |
| 405 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 407 | if (CPU_IS_020_OR_030) { |
| 408 | unsigned long tt1_val; |
| 409 | tt1_val = 0xfe008543; /* Translate 0xfexxxxxx, enable, cache |
| 410 | * inhibit, read and write, FDC mask = 3, |
| 411 | * FDC val = 4 -> Supervisor only */ |
| 412 | asm volatile ("\n" |
| 413 | " .chip 68030\n" |
| 414 | " pmove %0@,%/tt1\n" |
| 415 | " .chip 68k" |
| 416 | : : "a" (&tt1_val)); |
| 417 | } else { |
| 418 | asm volatile ("\n" |
| 419 | " .chip 68040\n" |
| 420 | " movec %0,%%itt1\n" |
| 421 | " movec %0,%%dtt1\n" |
| 422 | " .chip 68k" |
| 423 | : |
| 424 | : "d" (0xfe00a040)); /* Translate 0xfexxxxxx, enable, |
| 425 | * supervisor only, non-cacheable/ |
| 426 | * serialized, writable */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [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 | /* Fetch tos version at Physical 2 */ |
| 431 | /* |
| 432 | * We my not be able to access this address if the kernel is |
| 433 | * loaded to st ram, since the first page is unmapped. On the |
| 434 | * Medusa this is always the case and there is nothing we can do |
| 435 | * about this, so we just assume the smaller offset. For the TT |
| 436 | * we use the fact that in head.S we have set up a mapping |
| 437 | * 0xFFxxxxxx -> 0x00xxxxxx, so that the first 16MB is accessible |
| 438 | * in the last 16MB of the address space. |
| 439 | */ |
| 440 | tos_version = (MACH_IS_MEDUSA || MACH_IS_HADES) ? |
| 441 | 0xfff : *(unsigned short *)0xff000002; |
| 442 | atari_rtc_year_offset = (tos_version < 0x306) ? 70 : 68; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | #ifdef CONFIG_HEARTBEAT |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 446 | static void atari_heartbeat(int on) |
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 | unsigned char tmp; |
| 449 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 451 | if (atari_dont_touch_floppy_select) |
| 452 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 454 | local_irq_save(flags); |
| 455 | sound_ym.rd_data_reg_sel = 14; /* Select PSG Port A */ |
| 456 | tmp = sound_ym.rd_data_reg_sel; |
| 457 | sound_ym.wd_data = on ? (tmp & ~0x02) : (tmp | 0x02); |
| 458 | local_irq_restore(flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | } |
| 460 | #endif |
| 461 | |
| 462 | /* ++roman: |
| 463 | * |
| 464 | * This function does a reset on machines that lack the ability to |
| 465 | * assert the processor's _RESET signal somehow via hardware. It is |
| 466 | * based on the fact that you can find the initial SP and PC values |
| 467 | * after a reset at physical addresses 0 and 4. This works pretty well |
| 468 | * for Atari machines, since the lowest 8 bytes of physical memory are |
| 469 | * really ROM (mapped by hardware). For other 680x0 machines: don't |
| 470 | * know if it works... |
| 471 | * |
| 472 | * To get the values at addresses 0 and 4, the MMU better is turned |
| 473 | * off first. After that, we have to jump into physical address space |
| 474 | * (the PC before the pmove statement points to the virtual address of |
| 475 | * the code). Getting that physical address is not hard, but the code |
| 476 | * becomes a bit complex since I've tried to ensure that the jump |
| 477 | * statement after the pmove is in the cache already (otherwise the |
| 478 | * processor can't fetch it!). For that, the code first jumps to the |
| 479 | * jump statement with the (virtual) address of the pmove section in |
| 480 | * an address register . The jump statement is surely in the cache |
| 481 | * now. After that, that physical address of the reset code is loaded |
| 482 | * into the same address register, pmove is done and the same jump |
| 483 | * statements goes to the reset code. Since there are not many |
| 484 | * statements between the two jumps, I hope it stays in the cache. |
| 485 | * |
| 486 | * The C code makes heavy use of the GCC features that you can get the |
| 487 | * address of a C label. No hope to compile this with another compiler |
| 488 | * than GCC! |
| 489 | */ |
| 490 | |
| 491 | /* ++andreas: no need for complicated code, just depend on prefetch */ |
| 492 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 493 | static void atari_reset(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 495 | long tc_val = 0; |
| 496 | long reset_addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 498 | /* |
| 499 | * On the Medusa, phys. 0x4 may contain garbage because it's no |
| 500 | * ROM. See above for explanation why we cannot use PTOV(4). |
| 501 | */ |
| 502 | reset_addr = MACH_IS_HADES ? 0x7fe00030 : |
| 503 | MACH_IS_MEDUSA || MACH_IS_AB40 ? 0xe00030 : |
| 504 | *(unsigned long *) 0xff000004; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 506 | /* reset ACIA for switch off OverScan, if it's active */ |
| 507 | if (atari_switches & ATARI_SWITCH_OVSC_IKBD) |
| 508 | acia.key_ctrl = ACIA_RESET; |
| 509 | if (atari_switches & ATARI_SWITCH_OVSC_MIDI) |
| 510 | acia.mid_ctrl = ACIA_RESET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 512 | /* processor independent: turn off interrupts and reset the VBR; |
| 513 | * the caches must be left enabled, else prefetching the final jump |
| 514 | * instruction doesn't work. |
| 515 | */ |
| 516 | local_irq_disable(); |
| 517 | asm volatile ("movec %0,%%vbr" |
| 518 | : : "d" (0)); |
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 | if (CPU_IS_040_OR_060) { |
| 521 | unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040); |
| 522 | if (CPU_IS_060) { |
| 523 | /* 68060: clear PCR to turn off superscalar operation */ |
| 524 | asm volatile ("\n" |
| 525 | " .chip 68060\n" |
| 526 | " movec %0,%%pcr\n" |
| 527 | " .chip 68k" |
| 528 | : : "d" (0)); |
| 529 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 531 | asm volatile ("\n" |
| 532 | " move.l %0,%%d0\n" |
| 533 | " and.l #0xff000000,%%d0\n" |
| 534 | " or.w #0xe020,%%d0\n" /* map 16 MB, enable, cacheable */ |
| 535 | " .chip 68040\n" |
| 536 | " movec %%d0,%%itt0\n" |
| 537 | " movec %%d0,%%dtt0\n" |
| 538 | " .chip 68k\n" |
| 539 | " jmp %0@" |
| 540 | : : "a" (jmp_addr040) |
| 541 | : "d0"); |
| 542 | jmp_addr_label040: |
| 543 | asm volatile ("\n" |
| 544 | " moveq #0,%%d0\n" |
| 545 | " nop\n" |
| 546 | " .chip 68040\n" |
| 547 | " cinva %%bc\n" |
| 548 | " nop\n" |
| 549 | " pflusha\n" |
| 550 | " nop\n" |
| 551 | " movec %%d0,%%tc\n" |
| 552 | " nop\n" |
| 553 | /* the following setup of transparent translations is needed on the |
| 554 | * Afterburner040 to successfully reboot. Other machines shouldn't |
| 555 | * care about a different tt regs setup, they also didn't care in |
| 556 | * the past that the regs weren't turned off. */ |
| 557 | " move.l #0xffc000,%%d0\n" /* whole insn space cacheable */ |
| 558 | " movec %%d0,%%itt0\n" |
| 559 | " movec %%d0,%%itt1\n" |
| 560 | " or.w #0x40,%/d0\n" /* whole data space non-cacheable/ser. */ |
| 561 | " movec %%d0,%%dtt0\n" |
| 562 | " movec %%d0,%%dtt1\n" |
| 563 | " .chip 68k\n" |
| 564 | " jmp %0@" |
| 565 | : /* no outputs */ |
| 566 | : "a" (reset_addr) |
| 567 | : "d0"); |
| 568 | } else |
| 569 | asm volatile ("\n" |
| 570 | " pmove %0@,%%tc\n" |
| 571 | " jmp %1@" |
| 572 | : /* no outputs */ |
| 573 | : "a" (&tc_val), "a" (reset_addr)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | |
| 577 | static void atari_get_model(char *model) |
| 578 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 579 | strcpy(model, "Atari "); |
| 580 | switch (atari_mch_cookie >> 16) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | case ATARI_MCH_ST: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 582 | if (ATARIHW_PRESENT(MSTE_CLK)) |
| 583 | strcat(model, "Mega ST"); |
| 584 | else |
| 585 | strcat(model, "ST"); |
| 586 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | case ATARI_MCH_STE: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 588 | if (MACH_IS_MSTE) |
| 589 | strcat(model, "Mega STE"); |
| 590 | else |
| 591 | strcat(model, "STE"); |
| 592 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | case ATARI_MCH_TT: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 594 | if (MACH_IS_MEDUSA) |
| 595 | /* Medusa has TT _MCH cookie */ |
| 596 | strcat(model, "Medusa"); |
| 597 | else if (MACH_IS_HADES) |
| 598 | strcat(model, "Hades"); |
| 599 | else |
| 600 | strcat(model, "TT"); |
| 601 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | case ATARI_MCH_FALCON: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 603 | strcat(model, "Falcon"); |
| 604 | if (MACH_IS_AB40) |
| 605 | strcat(model, " (with Afterburner040)"); |
| 606 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | default: |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 608 | sprintf(model + strlen(model), "(unknown mach cookie 0x%lx)", |
| 609 | atari_mch_cookie); |
| 610 | break; |
| 611 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | |
| 615 | static int atari_get_hardware_list(char *buffer) |
| 616 | { |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 617 | int len = 0, i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 619 | for (i = 0; i < m68k_num_memory; i++) |
| 620 | len += sprintf(buffer+len, "\t%3ld MB at 0x%08lx (%s)\n", |
| 621 | m68k_memory[i].size >> 20, m68k_memory[i].addr, |
| 622 | (m68k_memory[i].addr & 0xff000000 ? |
| 623 | "alternate RAM" : "ST-RAM")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 625 | #define ATARIHW_ANNOUNCE(name, str) \ |
| 626 | if (ATARIHW_PRESENT(name)) \ |
| 627 | len += sprintf(buffer + len, "\t%s\n", str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 629 | len += sprintf(buffer + len, "Detected hardware:\n"); |
| 630 | ATARIHW_ANNOUNCE(STND_SHIFTER, "ST Shifter"); |
| 631 | ATARIHW_ANNOUNCE(EXTD_SHIFTER, "STe Shifter"); |
| 632 | ATARIHW_ANNOUNCE(TT_SHIFTER, "TT Shifter"); |
| 633 | ATARIHW_ANNOUNCE(VIDEL_SHIFTER, "Falcon Shifter"); |
| 634 | ATARIHW_ANNOUNCE(YM_2149, "Programmable Sound Generator"); |
| 635 | ATARIHW_ANNOUNCE(PCM_8BIT, "PCM 8 Bit Sound"); |
| 636 | ATARIHW_ANNOUNCE(CODEC, "CODEC Sound"); |
| 637 | ATARIHW_ANNOUNCE(TT_SCSI, "SCSI Controller NCR5380 (TT style)"); |
| 638 | ATARIHW_ANNOUNCE(ST_SCSI, "SCSI Controller NCR5380 (Falcon style)"); |
| 639 | ATARIHW_ANNOUNCE(ACSI, "ACSI Interface"); |
| 640 | ATARIHW_ANNOUNCE(IDE, "IDE Interface"); |
| 641 | ATARIHW_ANNOUNCE(FDCSPEED, "8/16 Mhz Switch for FDC"); |
| 642 | ATARIHW_ANNOUNCE(ST_MFP, "Multi Function Peripheral MFP 68901"); |
| 643 | ATARIHW_ANNOUNCE(TT_MFP, "Second Multi Function Peripheral MFP 68901"); |
| 644 | ATARIHW_ANNOUNCE(SCC, "Serial Communications Controller SCC 8530"); |
| 645 | ATARIHW_ANNOUNCE(ST_ESCC, "Extended Serial Communications Controller SCC 85230"); |
| 646 | ATARIHW_ANNOUNCE(ANALOG_JOY, "Paddle Interface"); |
| 647 | ATARIHW_ANNOUNCE(MICROWIRE, "MICROWIRE(tm) Interface"); |
| 648 | ATARIHW_ANNOUNCE(STND_DMA, "DMA Controller (24 bit)"); |
| 649 | ATARIHW_ANNOUNCE(EXTD_DMA, "DMA Controller (32 bit)"); |
| 650 | ATARIHW_ANNOUNCE(SCSI_DMA, "DMA Controller for NCR5380"); |
| 651 | ATARIHW_ANNOUNCE(SCC_DMA, "DMA Controller for SCC"); |
| 652 | ATARIHW_ANNOUNCE(TT_CLK, "Clock Chip MC146818A"); |
| 653 | ATARIHW_ANNOUNCE(MSTE_CLK, "Clock Chip RP5C15"); |
| 654 | ATARIHW_ANNOUNCE(SCU, "System Control Unit"); |
| 655 | ATARIHW_ANNOUNCE(BLITTER, "Blitter"); |
| 656 | ATARIHW_ANNOUNCE(VME, "VME Bus"); |
| 657 | ATARIHW_ANNOUNCE(DSP56K, "DSP56001 processor"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | |
Roman Zippel | 6ff5801 | 2007-05-01 22:32:43 +0200 | [diff] [blame^] | 659 | return len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | } |