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