2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
4 * Copyright (C) 2008 Dmitri Vorobiev
6 * This program is free software; you can distribute it and/or modify it
7 * under the terms of the GNU General Public License (Version 2) as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
19 #include <linux/cpu.h>
20 #include <linux/init.h>
21 #include <linux/sched.h>
22 #include <linux/ioport.h>
23 #include <linux/irq.h>
24 #include <linux/of_fdt.h>
25 #include <linux/pci.h>
26 #include <linux/screen_info.h>
27 #include <linux/time.h>
29 #include <asm/fw/fw.h>
30 #include <asm/mips-cm.h>
31 #include <asm/mips-boards/generic.h>
32 #include <asm/mips-boards/malta.h>
33 #include <asm/mips-boards/maltaint.h>
36 #include <asm/traps.h>
38 #include <linux/console.h>
41 extern void malta_be_init(void);
42 extern int malta_be_handler(struct pt_regs
*regs
, int is_fixup
);
44 static struct resource standard_io_resources
[] = {
49 .flags
= IORESOURCE_BUSY
55 .flags
= IORESOURCE_BUSY
61 .flags
= IORESOURCE_BUSY
64 .name
= "dma page reg",
67 .flags
= IORESOURCE_BUSY
73 .flags
= IORESOURCE_BUSY
77 const char *get_system_type(void)
82 const char display_string
[] = " LINUX ON MALTA ";
84 #ifdef CONFIG_BLK_DEV_FD
85 static void __init
fd_activate(void)
88 * Activate Floppy Controller in the SMSC FDC37M817 Super I/O
90 * Done by YAMON 2.00 onwards
92 /* Entering config state. */
93 SMSC_WRITE(SMSC_CONFIG_ENTER
, SMSC_CONFIG_REG
);
95 /* Activate floppy controller. */
96 SMSC_WRITE(SMSC_CONFIG_DEVNUM
, SMSC_CONFIG_REG
);
97 SMSC_WRITE(SMSC_CONFIG_DEVNUM_FLOPPY
, SMSC_DATA_REG
);
98 SMSC_WRITE(SMSC_CONFIG_ACTIVATE
, SMSC_CONFIG_REG
);
99 SMSC_WRITE(SMSC_CONFIG_ACTIVATE_ENABLE
, SMSC_DATA_REG
);
101 /* Exit config state. */
102 SMSC_WRITE(SMSC_CONFIG_EXIT
, SMSC_CONFIG_REG
);
106 static int __init
plat_enable_iocoherency(void)
109 if (mips_revision_sconid
== MIPS_REVISION_SCON_BONITO
) {
110 if (BONITO_PCICACHECTRL
& BONITO_PCICACHECTRL_CPUCOH_PRES
) {
111 BONITO_PCICACHECTRL
|= BONITO_PCICACHECTRL_CPUCOH_EN
;
112 pr_info("Enabled Bonito CPU coherency\n");
115 if (strstr(fw_getcmdline(), "iobcuncached")) {
116 BONITO_PCICACHECTRL
&= ~BONITO_PCICACHECTRL_IOBCCOH_EN
;
117 BONITO_PCIMEMBASECFG
= BONITO_PCIMEMBASECFG
&
118 ~(BONITO_PCIMEMBASECFG_MEMBASE0_CACHED
|
119 BONITO_PCIMEMBASECFG_MEMBASE1_CACHED
);
120 pr_info("Disabled Bonito IOBC coherency\n");
122 BONITO_PCICACHECTRL
|= BONITO_PCICACHECTRL_IOBCCOH_EN
;
123 BONITO_PCIMEMBASECFG
|=
124 (BONITO_PCIMEMBASECFG_MEMBASE0_CACHED
|
125 BONITO_PCIMEMBASECFG_MEMBASE1_CACHED
);
126 pr_info("Enabled Bonito IOBC coherency\n");
128 } else if (mips_cm_numiocu() != 0) {
129 /* Nothing special needs to be done to enable coherency */
130 pr_info("CMP IOCU detected\n");
131 if ((*(unsigned int *)0xbf403000 & 0x81) != 0x81) {
132 pr_crit("IOCU OPERATION DISABLED BY SWITCH - DEFAULTING TO SW IO COHERENCY\n");
137 hw_coherentio
= supported
;
141 static void __init
plat_setup_iocoherency(void)
143 #ifdef CONFIG_DMA_NONCOHERENT
145 * Kernel has been configured with software coherency
146 * but we might choose to turn it off and use hardware
149 if (plat_enable_iocoherency()) {
151 pr_info("Hardware DMA cache coherency disabled\n");
153 pr_info("Hardware DMA cache coherency enabled\n");
156 pr_info("Hardware DMA cache coherency unsupported, but enabled from command line!\n");
158 pr_info("Software DMA cache coherency enabled\n");
161 if (!plat_enable_iocoherency())
162 panic("Hardware DMA cache coherency not supported!");
166 static void __init
pci_clock_check(void)
168 unsigned int __iomem
*jmpr_p
=
169 (unsigned int *) ioremap(MALTA_JMPRS_REG
, sizeof(unsigned int));
170 int jmpr
= (__raw_readl(jmpr_p
) >> 2) & 0x07;
171 static const int pciclocks
[] __initconst
= {
172 33, 20, 25, 30, 12, 16, 37, 10
174 int pciclock
= pciclocks
[jmpr
];
175 char *optptr
, *argptr
= fw_getcmdline();
178 * If user passed a pci_clock= option, don't tack on another one
180 optptr
= strstr(argptr
, "pci_clock=");
181 if (optptr
&& (optptr
== argptr
|| optptr
[-1] == ' '))
184 if (pciclock
!= 33) {
185 pr_warn("WARNING: PCI clock is %dMHz, setting pci_clock\n",
187 argptr
+= strlen(argptr
);
188 sprintf(argptr
, " pci_clock=%d", pciclock
);
189 if (pciclock
< 20 || pciclock
> 66)
190 pr_warn("WARNING: IDE timing calculations will be "
195 #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
196 static void __init
screen_info_setup(void)
198 screen_info
= (struct screen_info
) {
202 .orig_video_page
= 0,
203 .orig_video_mode
= 0,
204 .orig_video_cols
= 80,
206 .orig_video_ega_bx
= 0,
208 .orig_video_lines
= 25,
209 .orig_video_isVGA
= VIDEO_TYPE_VGAC
,
210 .orig_video_points
= 16
215 static void __init
bonito_quirks_setup(void)
219 argptr
= fw_getcmdline();
220 if (strstr(argptr
, "debug")) {
221 BONITO_BONGENCFG
|= BONITO_BONGENCFG_DEBUGMODE
;
222 pr_info("Enabled Bonito debug mode\n");
224 BONITO_BONGENCFG
&= ~BONITO_BONGENCFG_DEBUGMODE
;
226 #ifdef CONFIG_DMA_COHERENT
227 if (BONITO_PCICACHECTRL
& BONITO_PCICACHECTRL_CPUCOH_PRES
) {
228 BONITO_PCICACHECTRL
|= BONITO_PCICACHECTRL_CPUCOH_EN
;
229 pr_info("Enabled Bonito CPU coherency\n");
231 argptr
= fw_getcmdline();
232 if (strstr(argptr
, "iobcuncached")) {
233 BONITO_PCICACHECTRL
&= ~BONITO_PCICACHECTRL_IOBCCOH_EN
;
234 BONITO_PCIMEMBASECFG
= BONITO_PCIMEMBASECFG
&
235 ~(BONITO_PCIMEMBASECFG_MEMBASE0_CACHED
|
236 BONITO_PCIMEMBASECFG_MEMBASE1_CACHED
);
237 pr_info("Disabled Bonito IOBC coherency\n");
239 BONITO_PCICACHECTRL
|= BONITO_PCICACHECTRL_IOBCCOH_EN
;
240 BONITO_PCIMEMBASECFG
|=
241 (BONITO_PCIMEMBASECFG_MEMBASE0_CACHED
|
242 BONITO_PCIMEMBASECFG_MEMBASE1_CACHED
);
243 pr_info("Enabled Bonito IOBC coherency\n");
246 panic("Hardware DMA cache coherency not supported");
250 void __init
plat_mem_setup(void)
254 __dt_setup_arch(__dtb_start
);
256 if (config_enabled(CONFIG_EVA
))
257 /* EVA has already been configured in mach-malta/kernel-init.h */
258 pr_info("Enhanced Virtual Addressing (EVA) activated\n");
262 /* Request I/O space for devices used on the Malta board. */
263 for (i
= 0; i
< ARRAY_SIZE(standard_io_resources
); i
++)
264 request_resource(&ioport_resource
, standard_io_resources
+i
);
267 * Enable DMA channel 4 (cascade channel) in the PIIX4 south bridge.
271 #ifdef CONFIG_DMA_COHERENT
272 if (mips_revision_sconid
!= MIPS_REVISION_SCON_BONITO
)
273 panic("Hardware DMA cache coherency not supported");
276 if (mips_revision_sconid
== MIPS_REVISION_SCON_BONITO
)
277 bonito_quirks_setup();
279 plat_setup_iocoherency();
283 #ifdef CONFIG_BLK_DEV_FD
287 #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
291 board_be_init
= malta_be_init
;
292 board_be_handler
= malta_be_handler
;