blob: 541f4e76747f0031ee02099890b6c141c2797954 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Vorobiev54bf0382008-01-24 19:52:49 +030018#include <linux/cpu.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/init.h>
20#include <linux/sched.h>
21#include <linux/ioport.h>
Dmitri Vorobiev54bf0382008-01-24 19:52:49 +030022#include <linux/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/pci.h>
Jon Smirl894673e2006-07-10 04:44:13 -070024#include <linux/screen_info.h>
Dmitri Vorobiev54bf0382008-01-24 19:52:49 +030025#include <linux/time.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <asm/bootinfo.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#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 Torvalds1da177e2005-04-16 15:20:36 -070033#include <asm/traps.h>
34#ifdef CONFIG_VT
35#include <linux/console.h>
36#endif
37
Linus Torvalds1da177e2005-04-16 15:20:36 -070038struct resource standard_io_resources[] = {
Dmitri Vorobiev4ca76512008-01-24 19:52:41 +030039 {
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 Torvalds1da177e2005-04-16 15:20:36 -070069};
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071const char *get_system_type(void)
72{
73 return "MIPS Malta";
74}
75
Ralf Baechle79894c72007-05-16 17:54:08 +020076#if defined(CONFIG_MIPS_MT_SMTC)
77const char display_string[] = " SMTC LINUX ON MALTA ";
78#else
79const char display_string[] = " LINUX ON MALTA ";
80#endif /* CONFIG_MIPS_MT_SMTC */
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#ifdef CONFIG_BLK_DEV_FD
Dmitri Vorobievef7645c2008-01-24 19:52:55 +030083static void __init fd_activate(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084{
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 Vorobievf3a4ce92008-01-24 19:52:43 +0300104#ifdef CONFIG_BLK_DEV_IDE
105static 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 Vorobieva3829632008-01-24 19:52:44 +0300128#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
129static 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 Baechle2925aba2006-06-18 01:32:22 +0100148void __init plat_mem_setup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149{
150 unsigned int i;
151
Ralf Baechlec83cfc92005-06-21 13:56:30 +0000152 mips_pcibios_init();
153
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 /* 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 Baechle49a89ef2007-10-11 23:46:15 +0100164 kgdb_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165#endif
166
Chris Dearmanb72c0522007-04-27 15:58:41 +0100167 if (mips_revision_sconid == MIPS_REVISION_SCON_BONITO) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 char *argptr;
169
170 argptr = prom_getcmdline();
171 if (strstr(argptr, "debug")) {
172 BONITO_BONGENCFG |= BONITO_BONGENCFG_DEBUGMODE;
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100173 printk("Enabled Bonito debug mode\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 }
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 Baechle42a3b4f2005-09-03 15:56:17 -0700186 BONITO_PCIMEMBASECFG = BONITO_PCIMEMBASECFG &
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 ~(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 Baechle42a3b4f2005-09-03 15:56:17 -0700193 BONITO_PCIMEMBASECFG |=
194 (BONITO_PCIMEMBASECFG_MEMBASE0_CACHED |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 BONITO_PCIMEMBASECFG_MEMBASE1_CACHED);
Ralf Baechle177b2922006-11-24 12:17:51 +0000196 printk("Enabled Bonito IOBC coherency\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 }
198 }
199 else
200 panic("Hardware DMA cache coherency not supported");
201
202#endif
203 }
204#ifdef CONFIG_DMA_COHERENT
Dmitri Vorobievcd80d542008-01-24 19:52:54 +0300205 else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 panic("Hardware DMA cache coherency not supported");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207#endif
208
209#ifdef CONFIG_BLK_DEV_IDE
Dmitri Vorobievf3a4ce92008-01-24 19:52:43 +0300210 pci_clock_check();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211#endif
212#ifdef CONFIG_BLK_DEV_FD
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100213 fd_activate();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214#endif
Dmitri Vorobieva3829632008-01-24 19:52:44 +0300215#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
216 screen_info_setup();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 mips_reboot_setup();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219}