Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Carsten Langgaard, carstenl@mips.com |
| 3 | * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can distribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License (Version 2) as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | * for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along |
| 15 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. |
| 17 | */ |
Dmitri Vorobiev | 54bf038 | 2008-01-24 19:52:49 +0300 | [diff] [blame] | 18 | #include <linux/cpu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/init.h> |
| 20 | #include <linux/sched.h> |
| 21 | #include <linux/ioport.h> |
Dmitri Vorobiev | 54bf038 | 2008-01-24 19:52:49 +0300 | [diff] [blame] | 22 | #include <linux/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/pci.h> |
Jon Smirl | 894673e | 2006-07-10 04:44:13 -0700 | [diff] [blame] | 24 | #include <linux/screen_info.h> |
Dmitri Vorobiev | 54bf038 | 2008-01-24 19:52:49 +0300 | [diff] [blame] | 25 | #include <linux/time.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <asm/bootinfo.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <asm/mips-boards/generic.h> |
| 29 | #include <asm/mips-boards/prom.h> |
| 30 | #include <asm/mips-boards/malta.h> |
| 31 | #include <asm/mips-boards/maltaint.h> |
| 32 | #include <asm/dma.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <asm/traps.h> |
| 34 | #ifdef CONFIG_VT |
| 35 | #include <linux/console.h> |
| 36 | #endif |
| 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | struct resource standard_io_resources[] = { |
Dmitri Vorobiev | 4ca7651 | 2008-01-24 19:52:41 +0300 | [diff] [blame] | 39 | { |
| 40 | .name = "dma1", |
| 41 | .start = 0x00, |
| 42 | .end = 0x1f, |
| 43 | .flags = IORESOURCE_BUSY |
| 44 | }, |
| 45 | { |
| 46 | .name = "timer", |
| 47 | .start = 0x40, |
| 48 | .end = 0x5f, |
| 49 | .flags = IORESOURCE_BUSY |
| 50 | }, |
| 51 | { |
| 52 | .name = "keyboard", |
| 53 | .start = 0x60, |
| 54 | .end = 0x6f, |
| 55 | .flags = IORESOURCE_BUSY |
| 56 | }, |
| 57 | { |
| 58 | .name = "dma page reg", |
| 59 | .start = 0x80, |
| 60 | .end = 0x8f, |
| 61 | .flags = IORESOURCE_BUSY |
| 62 | }, |
| 63 | { |
| 64 | .name = "dma2", |
| 65 | .start = 0xc0, |
| 66 | .end = 0xdf, |
| 67 | .flags = IORESOURCE_BUSY |
| 68 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | }; |
| 70 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | const char *get_system_type(void) |
| 72 | { |
| 73 | return "MIPS Malta"; |
| 74 | } |
| 75 | |
Ralf Baechle | 79894c7 | 2007-05-16 17:54:08 +0200 | [diff] [blame] | 76 | #if defined(CONFIG_MIPS_MT_SMTC) |
| 77 | const char display_string[] = " SMTC LINUX ON MALTA "; |
| 78 | #else |
| 79 | const char display_string[] = " LINUX ON MALTA "; |
| 80 | #endif /* CONFIG_MIPS_MT_SMTC */ |
| 81 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | #ifdef CONFIG_BLK_DEV_FD |
| 83 | void __init fd_activate(void) |
| 84 | { |
| 85 | /* |
| 86 | * Activate Floppy Controller in the SMSC FDC37M817 Super I/O |
| 87 | * Controller. |
| 88 | * Done by YAMON 2.00 onwards |
| 89 | */ |
| 90 | /* Entering config state. */ |
| 91 | SMSC_WRITE(SMSC_CONFIG_ENTER, SMSC_CONFIG_REG); |
| 92 | |
| 93 | /* Activate floppy controller. */ |
| 94 | SMSC_WRITE(SMSC_CONFIG_DEVNUM, SMSC_CONFIG_REG); |
| 95 | SMSC_WRITE(SMSC_CONFIG_DEVNUM_FLOPPY, SMSC_DATA_REG); |
| 96 | SMSC_WRITE(SMSC_CONFIG_ACTIVATE, SMSC_CONFIG_REG); |
| 97 | SMSC_WRITE(SMSC_CONFIG_ACTIVATE_ENABLE, SMSC_DATA_REG); |
| 98 | |
| 99 | /* Exit config state. */ |
| 100 | SMSC_WRITE(SMSC_CONFIG_EXIT, SMSC_CONFIG_REG); |
| 101 | } |
| 102 | #endif |
| 103 | |
Dmitri Vorobiev | f3a4ce9 | 2008-01-24 19:52:43 +0300 | [diff] [blame] | 104 | #ifdef CONFIG_BLK_DEV_IDE |
| 105 | static void __init pci_clock_check(void) |
| 106 | { |
| 107 | unsigned int __iomem *jmpr_p = |
| 108 | (unsigned int *) ioremap(MALTA_JMPRS_REG, sizeof(unsigned int)); |
| 109 | int jmpr = (__raw_readl(jmpr_p) >> 2) & 0x07; |
| 110 | static const int pciclocks[] __initdata = { |
| 111 | 33, 20, 25, 30, 12, 16, 37, 10 |
| 112 | }; |
| 113 | int pciclock = pciclocks[jmpr]; |
| 114 | char *argptr = prom_getcmdline(); |
| 115 | |
| 116 | if (pciclock != 33 && !strstr(argptr, "idebus=")) { |
| 117 | printk(KERN_WARNING "WARNING: PCI clock is %dMHz, " |
| 118 | "setting idebus\n", pciclock); |
| 119 | argptr += strlen(argptr); |
| 120 | sprintf(argptr, " idebus=%d", pciclock); |
| 121 | if (pciclock < 20 || pciclock > 66) |
| 122 | printk(KERN_WARNING "WARNING: IDE timing " |
| 123 | "calculations will be incorrect\n"); |
| 124 | } |
| 125 | } |
| 126 | #endif |
| 127 | |
Dmitri Vorobiev | a382963 | 2008-01-24 19:52:44 +0300 | [diff] [blame] | 128 | #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) |
| 129 | static void __init screen_info_setup(void) |
| 130 | { |
| 131 | screen_info = (struct screen_info) { |
| 132 | .orig_x = 0, |
| 133 | .orig_y = 25, |
| 134 | .ext_mem_k = 0, |
| 135 | .orig_video_page = 0, |
| 136 | .orig_video_mode = 0, |
| 137 | .orig_video_cols = 80, |
| 138 | .unused2 = 0, |
| 139 | .orig_video_ega_bx = 0, |
| 140 | .unused3 = 0, |
| 141 | .orig_video_lines = 25, |
| 142 | .orig_video_isVGA = VIDEO_TYPE_VGAC, |
| 143 | .orig_video_points = 16 |
| 144 | }; |
| 145 | } |
| 146 | #endif |
| 147 | |
Ralf Baechle | 2925aba | 2006-06-18 01:32:22 +0100 | [diff] [blame] | 148 | void __init plat_mem_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | { |
| 150 | unsigned int i; |
| 151 | |
Ralf Baechle | c83cfc9 | 2005-06-21 13:56:30 +0000 | [diff] [blame] | 152 | mips_pcibios_init(); |
| 153 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | /* Request I/O space for devices used on the Malta board. */ |
| 155 | for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++) |
| 156 | request_resource(&ioport_resource, standard_io_resources+i); |
| 157 | |
| 158 | /* |
| 159 | * Enable DMA channel 4 (cascade channel) in the PIIX4 south bridge. |
| 160 | */ |
| 161 | enable_dma(4); |
| 162 | |
| 163 | #ifdef CONFIG_KGDB |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 164 | kgdb_config(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | #endif |
| 166 | |
Chris Dearman | b72c052 | 2007-04-27 15:58:41 +0100 | [diff] [blame] | 167 | if (mips_revision_sconid == MIPS_REVISION_SCON_BONITO) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | char *argptr; |
| 169 | |
| 170 | argptr = prom_getcmdline(); |
| 171 | if (strstr(argptr, "debug")) { |
| 172 | BONITO_BONGENCFG |= BONITO_BONGENCFG_DEBUGMODE; |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 173 | printk("Enabled Bonito debug mode\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | } |
| 175 | else |
| 176 | BONITO_BONGENCFG &= ~BONITO_BONGENCFG_DEBUGMODE; |
| 177 | |
| 178 | #ifdef CONFIG_DMA_COHERENT |
| 179 | if (BONITO_PCICACHECTRL & BONITO_PCICACHECTRL_CPUCOH_PRES) { |
| 180 | BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_CPUCOH_EN; |
| 181 | printk("Enabled Bonito CPU coherency\n"); |
| 182 | |
| 183 | argptr = prom_getcmdline(); |
| 184 | if (strstr(argptr, "iobcuncached")) { |
| 185 | BONITO_PCICACHECTRL &= ~BONITO_PCICACHECTRL_IOBCCOH_EN; |
Ralf Baechle | 42a3b4f | 2005-09-03 15:56:17 -0700 | [diff] [blame] | 186 | BONITO_PCIMEMBASECFG = BONITO_PCIMEMBASECFG & |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | ~(BONITO_PCIMEMBASECFG_MEMBASE0_CACHED | |
| 188 | BONITO_PCIMEMBASECFG_MEMBASE1_CACHED); |
| 189 | printk("Disabled Bonito IOBC coherency\n"); |
| 190 | } |
| 191 | else { |
| 192 | BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_IOBCCOH_EN; |
Ralf Baechle | 42a3b4f | 2005-09-03 15:56:17 -0700 | [diff] [blame] | 193 | BONITO_PCIMEMBASECFG |= |
| 194 | (BONITO_PCIMEMBASECFG_MEMBASE0_CACHED | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | BONITO_PCIMEMBASECFG_MEMBASE1_CACHED); |
Ralf Baechle | 177b292 | 2006-11-24 12:17:51 +0000 | [diff] [blame] | 196 | printk("Enabled Bonito IOBC coherency\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | } |
| 198 | } |
| 199 | else |
| 200 | panic("Hardware DMA cache coherency not supported"); |
| 201 | |
| 202 | #endif |
| 203 | } |
| 204 | #ifdef CONFIG_DMA_COHERENT |
Dmitri Vorobiev | cd80d54 | 2008-01-24 19:52:54 +0300 | [diff] [blame^] | 205 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | panic("Hardware DMA cache coherency not supported"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | #endif |
| 208 | |
| 209 | #ifdef CONFIG_BLK_DEV_IDE |
Dmitri Vorobiev | f3a4ce9 | 2008-01-24 19:52:43 +0300 | [diff] [blame] | 210 | pci_clock_check(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | #endif |
| 212 | #ifdef CONFIG_BLK_DEV_FD |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 213 | fd_activate(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | #endif |
Dmitri Vorobiev | a382963 | 2008-01-24 19:52:44 +0300 | [diff] [blame] | 215 | #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) |
| 216 | screen_info_setup(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | mips_reboot_setup(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | } |