Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Setup pointers to hardware-dependent routines. |
| 3 | * |
| 4 | * This file is subject to the terms and conditions of the GNU General Public |
| 5 | * License. See the file "COPYING" in the main directory of this archive |
| 6 | * for more details. |
| 7 | * |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 8 | * Copyright (C) 1996, 97, 98, 2000, 03, 04, 06 Ralf Baechle (ralf@linux-mips.org) |
Thomas Bogendoerfer | 22df5bc | 2007-05-17 14:53:12 +0200 | [diff] [blame] | 9 | * Copyright (C) 2006,2007 Thomas Bogendoerfer (tsbogend@alpha.franken.de) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/eisa.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/init.h> |
Paul Gortmaker | f9ded56 | 2012-02-28 19:24:46 -0500 | [diff] [blame] | 13 | #include <linux/export.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/console.h> |
| 15 | #include <linux/fb.h> |
Jon Smirl | 894673e | 2006-07-10 04:44:13 -0700 | [diff] [blame] | 16 | #include <linux/screen_info.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
Thomas Bogendoerfer | 4a0312f | 2006-06-13 13:59:01 +0200 | [diff] [blame] | 18 | #ifdef CONFIG_ARC |
Aurelien Jarno | 2f56cfd | 2007-09-05 08:59:34 +0200 | [diff] [blame] | 19 | #include <asm/fw/arc/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <asm/sgialib.h> |
Thomas Bogendoerfer | 4a0312f | 2006-06-13 13:59:01 +0200 | [diff] [blame] | 21 | #endif |
| 22 | |
Thomas Bogendoerfer | 231a35d | 2008-01-04 23:31:07 +0100 | [diff] [blame] | 23 | #ifdef CONFIG_SNIPROM |
| 24 | #include <asm/mipsprom.h> |
| 25 | #endif |
| 26 | |
| 27 | #include <asm/bootinfo.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <asm/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <asm/reboot.h> |
| 30 | #include <asm/sni.h> |
Thomas Bogendoerfer | c066a32 | 2006-12-28 18:22:32 +0100 | [diff] [blame] | 31 | |
| 32 | unsigned int sni_brd_type; |
Thomas Bogendoerfer | 231a35d | 2008-01-04 23:31:07 +0100 | [diff] [blame] | 33 | EXPORT_SYMBOL(sni_brd_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | extern void sni_machine_restart(char *command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | extern void sni_machine_power_off(void); |
| 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | static void __init sni_display_setup(void) |
| 39 | { |
Thomas Bogendoerfer | 4a0312f | 2006-06-13 13:59:01 +0200 | [diff] [blame] | 40 | #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) && defined(CONFIG_ARC) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | struct screen_info *si = &screen_info; |
| 42 | DISPLAY_STATUS *di; |
| 43 | |
| 44 | di = ArcGetDisplayStatus(1); |
| 45 | |
| 46 | if (di) { |
| 47 | si->orig_x = di->CursorXPosition; |
| 48 | si->orig_y = di->CursorYPosition; |
| 49 | si->orig_video_cols = di->CursorMaxXPosition; |
| 50 | si->orig_video_lines = di->CursorMaxYPosition; |
| 51 | si->orig_video_isVGA = VIDEO_TYPE_VGAC; |
| 52 | si->orig_video_points = 16; |
| 53 | } |
| 54 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Thomas Bogendoerfer | 231a35d | 2008-01-04 23:31:07 +0100 | [diff] [blame] | 57 | static void __init sni_console_setup(void) |
| 58 | { |
| 59 | #ifndef CONFIG_ARC |
| 60 | char *ctype; |
| 61 | char *cdev; |
| 62 | char *baud; |
| 63 | int port; |
Dmitri Vorobiev | 599a894 | 2009-11-23 13:53:37 +0200 | [diff] [blame] | 64 | static char options[8] __initdata; |
Thomas Bogendoerfer | 231a35d | 2008-01-04 23:31:07 +0100 | [diff] [blame] | 65 | |
| 66 | cdev = prom_getenv("console_dev"); |
| 67 | if (strncmp(cdev, "tty", 3) == 0) { |
| 68 | ctype = prom_getenv("console"); |
| 69 | switch (*ctype) { |
| 70 | default: |
| 71 | case 'l': |
| 72 | port = 0; |
| 73 | baud = prom_getenv("lbaud"); |
| 74 | break; |
| 75 | case 'r': |
| 76 | port = 1; |
| 77 | baud = prom_getenv("rbaud"); |
| 78 | break; |
| 79 | } |
| 80 | if (baud) |
| 81 | strcpy(options, baud); |
| 82 | if (strncmp(cdev, "tty552", 6) == 0) |
| 83 | add_preferred_console("ttyS", port, |
| 84 | baud ? options : NULL); |
| 85 | else |
| 86 | add_preferred_console("ttySC", port, |
| 87 | baud ? options : NULL); |
| 88 | } |
| 89 | #endif |
| 90 | } |
| 91 | |
| 92 | #ifdef DEBUG |
| 93 | static void __init sni_idprom_dump(void) |
| 94 | { |
| 95 | int i; |
| 96 | |
| 97 | pr_debug("SNI IDProm dump:\n"); |
| 98 | for (i = 0; i < 256; i++) { |
| 99 | if (i%16 == 0) |
| 100 | pr_debug("%04x ", i); |
| 101 | |
| 102 | printk("%02x ", *(unsigned char *) (SNI_IDPROM_BASE + i)); |
| 103 | |
| 104 | if (i % 16 == 15) |
| 105 | printk("\n"); |
| 106 | } |
| 107 | } |
| 108 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | |
Ralf Baechle | 2925aba | 2006-06-18 01:32:22 +0100 | [diff] [blame] | 110 | void __init plat_mem_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | { |
Thomas Bogendoerfer | 231a35d | 2008-01-04 23:31:07 +0100 | [diff] [blame] | 112 | int cputype; |
| 113 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | set_io_port_base(SNI_PORT_BASE); |
Thomas Bogendoerfer | c066a32 | 2006-12-28 18:22:32 +0100 | [diff] [blame] | 115 | // ioport_resource.end = sni_io_resource.end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
| 117 | /* |
| 118 | * Setup (E)ISA I/O memory access stuff |
| 119 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | #ifdef CONFIG_EISA |
| 121 | EISA_bus = 1; |
| 122 | #endif |
| 123 | |
Thomas Bogendoerfer | 231a35d | 2008-01-04 23:31:07 +0100 | [diff] [blame] | 124 | sni_brd_type = *(unsigned char *)SNI_IDPROM_BRDTYPE; |
| 125 | cputype = *(unsigned char *)SNI_IDPROM_CPUTYPE; |
| 126 | switch (sni_brd_type) { |
| 127 | case SNI_BRD_TOWER_OASIC: |
| 128 | switch (cputype) { |
| 129 | case SNI_CPU_M8030: |
| 130 | system_type = "RM400-330"; |
| 131 | break; |
| 132 | case SNI_CPU_M8031: |
| 133 | system_type = "RM400-430"; |
| 134 | break; |
| 135 | case SNI_CPU_M8037: |
| 136 | system_type = "RM400-530"; |
| 137 | break; |
| 138 | case SNI_CPU_M8034: |
| 139 | system_type = "RM400-730"; |
| 140 | break; |
| 141 | default: |
| 142 | system_type = "RM400-xxx"; |
| 143 | break; |
| 144 | } |
| 145 | break; |
| 146 | case SNI_BRD_MINITOWER: |
| 147 | switch (cputype) { |
| 148 | case SNI_CPU_M8021: |
| 149 | case SNI_CPU_M8043: |
| 150 | system_type = "RM400-120"; |
| 151 | break; |
| 152 | case SNI_CPU_M8040: |
| 153 | system_type = "RM400-220"; |
| 154 | break; |
| 155 | case SNI_CPU_M8053: |
| 156 | system_type = "RM400-225"; |
| 157 | break; |
| 158 | case SNI_CPU_M8050: |
| 159 | system_type = "RM400-420"; |
| 160 | break; |
| 161 | default: |
| 162 | system_type = "RM400-xxx"; |
| 163 | break; |
| 164 | } |
| 165 | break; |
| 166 | case SNI_BRD_PCI_TOWER: |
| 167 | system_type = "RM400-Cxx"; |
| 168 | break; |
| 169 | case SNI_BRD_RM200: |
| 170 | system_type = "RM200-xxx"; |
| 171 | break; |
| 172 | case SNI_BRD_PCI_MTOWER: |
| 173 | system_type = "RM300-Cxx"; |
| 174 | break; |
| 175 | case SNI_BRD_PCI_DESKTOP: |
| 176 | switch (read_c0_prid() & 0xff00) { |
| 177 | case PRID_IMP_R4600: |
| 178 | case PRID_IMP_R4700: |
| 179 | system_type = "RM200-C20"; |
| 180 | break; |
| 181 | case PRID_IMP_R5000: |
| 182 | system_type = "RM200-C40"; |
| 183 | break; |
| 184 | default: |
| 185 | system_type = "RM200-Cxx"; |
| 186 | break; |
| 187 | } |
| 188 | break; |
| 189 | case SNI_BRD_PCI_TOWER_CPLUS: |
| 190 | system_type = "RM400-Exx"; |
| 191 | break; |
| 192 | case SNI_BRD_PCI_MTOWER_CPLUS: |
| 193 | system_type = "RM300-Exx"; |
| 194 | break; |
| 195 | } |
| 196 | pr_debug("Found SNI brdtype %02x name %s\n", sni_brd_type, system_type); |
| 197 | |
| 198 | #ifdef DEBUG |
| 199 | sni_idprom_dump(); |
| 200 | #endif |
| 201 | |
Thomas Bogendoerfer | c066a32 | 2006-12-28 18:22:32 +0100 | [diff] [blame] | 202 | switch (sni_brd_type) { |
| 203 | case SNI_BRD_10: |
| 204 | case SNI_BRD_10NEW: |
| 205 | case SNI_BRD_TOWER_OASIC: |
| 206 | case SNI_BRD_MINITOWER: |
| 207 | sni_a20r_init(); |
| 208 | break; |
| 209 | |
| 210 | case SNI_BRD_PCI_TOWER: |
| 211 | case SNI_BRD_PCI_TOWER_CPLUS: |
| 212 | sni_pcit_init(); |
| 213 | break; |
| 214 | |
| 215 | case SNI_BRD_RM200: |
| 216 | sni_rm200_init(); |
| 217 | break; |
| 218 | |
| 219 | case SNI_BRD_PCI_MTOWER: |
| 220 | case SNI_BRD_PCI_DESKTOP: |
| 221 | case SNI_BRD_PCI_MTOWER_CPLUS: |
| 222 | sni_pcimt_init(); |
| 223 | break; |
| 224 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | |
| 226 | _machine_restart = sni_machine_restart; |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 227 | pm_power_off = sni_machine_power_off; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | sni_display_setup(); |
Thomas Bogendoerfer | 231a35d | 2008-01-04 23:31:07 +0100 | [diff] [blame] | 230 | sni_console_setup(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | } |
Thomas Bogendoerfer | 22df5bc | 2007-05-17 14:53:12 +0200 | [diff] [blame] | 232 | |
Thomas Bogendoerfer | 231a35d | 2008-01-04 23:31:07 +0100 | [diff] [blame] | 233 | #ifdef CONFIG_PCI |
Thomas Bogendoerfer | 22df5bc | 2007-05-17 14:53:12 +0200 | [diff] [blame] | 234 | |
| 235 | #include <linux/pci.h> |
| 236 | #include <video/vga.h> |
| 237 | #include <video/cirrus.h> |
| 238 | |
| 239 | static void __devinit quirk_cirrus_ram_size(struct pci_dev *dev) |
| 240 | { |
| 241 | u16 cmd; |
| 242 | |
| 243 | /* |
| 244 | * firmware doesn't set the ram size correct, so we |
| 245 | * need to do it here, otherwise we get screen corruption |
| 246 | * on older Cirrus chips |
| 247 | */ |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 248 | pci_read_config_word(dev, PCI_COMMAND, &cmd); |
Thomas Bogendoerfer | 22df5bc | 2007-05-17 14:53:12 +0200 | [diff] [blame] | 249 | if ((cmd & (PCI_COMMAND_IO|PCI_COMMAND_MEMORY)) |
| 250 | == (PCI_COMMAND_IO|PCI_COMMAND_MEMORY)) { |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 251 | vga_wseq(NULL, CL_SEQR6, 0x12); /* unlock all extension registers */ |
| 252 | vga_wseq(NULL, CL_SEQRF, 0x18); |
Thomas Bogendoerfer | 22df5bc | 2007-05-17 14:53:12 +0200 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | |
| 256 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5434_8, |
| 257 | quirk_cirrus_ram_size); |
| 258 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5436, |
| 259 | quirk_cirrus_ram_size); |
| 260 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5446, |
| 261 | quirk_cirrus_ram_size); |
| 262 | #endif |