2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * PROM library initialisation code.
8 * Copyright (C) 1999,2000,2004,2005,2012 MIPS Technologies, Inc.
10 * Authors: Carsten Langgaard <carstenl@mips.com>
11 * Maciej W. Rozycki <macro@mips.com>
12 * Steven J. Hill <sjhill@mips.com>
14 #include <linux/init.h>
15 #include <linux/string.h>
16 #include <linux/kernel.h>
17 #include <linux/pci_regs.h>
18 #include <linux/serial_core.h>
20 #include <asm/cacheflush.h>
21 #include <asm/smp-ops.h>
22 #include <asm/traps.h>
23 #include <asm/fw/fw.h>
24 #include <asm/mips-cm.h>
25 #include <asm/mips-cpc.h>
26 #include <asm/mips-boards/generic.h>
27 #include <asm/mips-boards/malta.h>
29 static int mips_revision_corid
;
30 int mips_revision_sconid
;
32 /* Bonito64 system controller register base. */
33 unsigned long _pcictrl_bonito
;
34 unsigned long _pcictrl_bonito_pcicfg
;
36 /* GT64120 system controller register base */
37 unsigned long _pcictrl_gt64120
;
39 /* MIPS System controller register base */
40 unsigned long _pcictrl_msc
;
42 #ifdef CONFIG_SERIAL_8250_CONSOLE
43 static void __init
console_config(void)
45 char console_string
[40];
47 char parity
= '\0', bits
= '\0', flow
= '\0';
50 s
= fw_getenv("modetty0");
52 while (*s
>= '0' && *s
<= '9')
53 baud
= baud
*10 + *s
++ - '0';
69 if (parity
!= 'n' && parity
!= 'o' && parity
!= 'e')
71 if (bits
!= '7' && bits
!= '8')
76 if ((strstr(fw_getcmdline(), "earlycon=")) == NULL
) {
77 sprintf(console_string
, "uart8250,io,0x3f8,%d%c%c", baud
,
79 setup_earlycon(console_string
);
82 if ((strstr(fw_getcmdline(), "console=")) == NULL
) {
83 sprintf(console_string
, " console=ttyS0,%d%c%c%c", baud
,
85 strcat(fw_getcmdline(), console_string
);
86 pr_info("Config serial console:%s\n", console_string
);
91 static void __init
mips_nmi_setup(void)
94 extern char except_vec_nmi
;
97 (void *)(CAC_BASE
+ 0xa80) :
98 (void *)(CAC_BASE
+ 0x380);
99 memcpy(base
, &except_vec_nmi
, 0x80);
100 flush_icache_range((unsigned long)base
, (unsigned long)base
+ 0x80);
103 static void __init
mips_ejtag_setup(void)
106 extern char except_vec_ejtag_debug
;
108 base
= cpu_has_veic
?
109 (void *)(CAC_BASE
+ 0xa00) :
110 (void *)(CAC_BASE
+ 0x300);
111 memcpy(base
, &except_vec_ejtag_debug
, 0x80);
112 flush_icache_range((unsigned long)base
, (unsigned long)base
+ 0x80);
115 phys_addr_t
mips_cpc_default_phys_base(void)
117 return CPC_BASE_ADDR
;
120 void __init
prom_init(void)
122 mips_display_message("LINUX");
125 * early setup of _pcictrl_bonito so that we can determine
126 * the system controller on a CORE_EMUL board
128 _pcictrl_bonito
= (unsigned long)ioremap(BONITO_REG_BASE
, BONITO_REG_SIZE
);
130 mips_revision_corid
= MIPS_REVISION_CORID
;
132 if (mips_revision_corid
== MIPS_REVISION_CORID_CORE_EMUL
) {
133 if (BONITO_PCIDID
== 0x0001df53 ||
134 BONITO_PCIDID
== 0x0003df53)
135 mips_revision_corid
= MIPS_REVISION_CORID_CORE_EMUL_BON
;
137 mips_revision_corid
= MIPS_REVISION_CORID_CORE_EMUL_MSC
;
140 mips_revision_sconid
= MIPS_REVISION_SCONID
;
141 if (mips_revision_sconid
== MIPS_REVISION_SCON_OTHER
) {
142 switch (mips_revision_corid
) {
143 case MIPS_REVISION_CORID_QED_RM5261
:
144 case MIPS_REVISION_CORID_CORE_LV
:
145 case MIPS_REVISION_CORID_CORE_FPGA
:
146 case MIPS_REVISION_CORID_CORE_FPGAR2
:
147 mips_revision_sconid
= MIPS_REVISION_SCON_GT64120
;
149 case MIPS_REVISION_CORID_CORE_EMUL_BON
:
150 case MIPS_REVISION_CORID_BONITO64
:
151 case MIPS_REVISION_CORID_CORE_20K
:
152 mips_revision_sconid
= MIPS_REVISION_SCON_BONITO
;
154 case MIPS_REVISION_CORID_CORE_MSC
:
155 case MIPS_REVISION_CORID_CORE_FPGA2
:
156 case MIPS_REVISION_CORID_CORE_24K
:
158 * SOCit/ROCit support is essentially identical
159 * but make an attempt to distinguish them
161 mips_revision_sconid
= MIPS_REVISION_SCON_SOCIT
;
163 case MIPS_REVISION_CORID_CORE_FPGA3
:
164 case MIPS_REVISION_CORID_CORE_FPGA4
:
165 case MIPS_REVISION_CORID_CORE_FPGA5
:
166 case MIPS_REVISION_CORID_CORE_EMUL_MSC
:
169 mips_revision_sconid
= MIPS_REVISION_SCON_ROCIT
;
174 switch (mips_revision_sconid
) {
175 u32 start
, map
, mask
, data
;
177 case MIPS_REVISION_SCON_GT64120
:
179 * Setup the North bridge to do Master byte-lane swapping
180 * when running in bigendian.
182 _pcictrl_gt64120
= (unsigned long)ioremap(MIPS_GT_BASE
, 0x2000);
184 #ifdef CONFIG_CPU_LITTLE_ENDIAN
185 GT_WRITE(GT_PCI0_CMD_OFS
, GT_PCI0_CMD_MBYTESWAP_BIT
|
186 GT_PCI0_CMD_SBYTESWAP_BIT
);
188 GT_WRITE(GT_PCI0_CMD_OFS
, 0);
190 /* Fix up PCI I/O mapping if necessary (for Atlas). */
191 start
= GT_READ(GT_PCI0IOLD_OFS
);
192 map
= GT_READ(GT_PCI0IOREMAP_OFS
);
193 if ((start
& map
) != 0) {
195 GT_WRITE(GT_PCI0IOREMAP_OFS
, map
);
198 set_io_port_base(MALTA_GT_PORT_BASE
);
201 case MIPS_REVISION_SCON_BONITO
:
202 _pcictrl_bonito_pcicfg
= (unsigned long)ioremap(BONITO_PCICFG_BASE
, BONITO_PCICFG_SIZE
);
205 * Disable Bonito IOBC.
207 BONITO_PCIMEMBASECFG
= BONITO_PCIMEMBASECFG
&
208 ~(BONITO_PCIMEMBASECFG_MEMBASE0_CACHED
|
209 BONITO_PCIMEMBASECFG_MEMBASE1_CACHED
);
212 * Setup the North bridge to do Master byte-lane swapping
213 * when running in bigendian.
215 #ifdef CONFIG_CPU_LITTLE_ENDIAN
216 BONITO_BONGENCFG
= BONITO_BONGENCFG
&
217 ~(BONITO_BONGENCFG_MSTRBYTESWAP
|
218 BONITO_BONGENCFG_BYTESWAP
);
220 BONITO_BONGENCFG
= BONITO_BONGENCFG
|
221 BONITO_BONGENCFG_MSTRBYTESWAP
|
222 BONITO_BONGENCFG_BYTESWAP
;
225 set_io_port_base(MALTA_BONITO_PORT_BASE
);
228 case MIPS_REVISION_SCON_SOCIT
:
229 case MIPS_REVISION_SCON_ROCIT
:
230 _pcictrl_msc
= (unsigned long)ioremap(MIPS_MSC01_PCI_REG_BASE
, 0x2000);
233 MSC_READ(MSC01_PCI_CFG
, data
);
234 MSC_WRITE(MSC01_PCI_CFG
, data
& ~MSC01_PCI_CFG_EN_BIT
);
237 /* Fix up lane swapping. */
238 #ifdef CONFIG_CPU_LITTLE_ENDIAN
239 MSC_WRITE(MSC01_PCI_SWAP
, MSC01_PCI_SWAP_NOSWAP
);
241 MSC_WRITE(MSC01_PCI_SWAP
,
242 MSC01_PCI_SWAP_BYTESWAP
<< MSC01_PCI_SWAP_IO_SHF
|
243 MSC01_PCI_SWAP_BYTESWAP
<< MSC01_PCI_SWAP_MEM_SHF
|
244 MSC01_PCI_SWAP_BYTESWAP
<< MSC01_PCI_SWAP_BAR0_SHF
);
248 * Setup the Malta max (2GB) memory for PCI DMA in host bridge
249 * in transparent addressing mode.
251 mask
= PHYS_OFFSET
| PCI_BASE_ADDRESS_MEM_PREFETCH
;
252 MSC_WRITE(MSC01_PCI_BAR0
, mask
);
253 MSC_WRITE(MSC01_PCI_HEAD4
, mask
);
255 mask
&= MSC01_PCI_BAR0_SIZE_MSK
;
256 MSC_WRITE(MSC01_PCI_P2SCMSKL
, mask
);
257 MSC_WRITE(MSC01_PCI_P2SCMAPL
, mask
);
259 /* Don't handle target retries indefinitely. */
260 if ((data
& MSC01_PCI_CFG_MAXRTRY_MSK
) ==
261 MSC01_PCI_CFG_MAXRTRY_MSK
)
262 data
= (data
& ~(MSC01_PCI_CFG_MAXRTRY_MSK
<<
263 MSC01_PCI_CFG_MAXRTRY_SHF
)) |
264 ((MSC01_PCI_CFG_MAXRTRY_MSK
- 1) <<
265 MSC01_PCI_CFG_MAXRTRY_SHF
);
268 MSC_WRITE(MSC01_PCI_CFG
, data
);
271 set_io_port_base(MALTA_MSC_PORT_BASE
);
274 case MIPS_REVISION_SCON_SOCITSC
:
275 case MIPS_REVISION_SCON_SOCITSCP
:
276 _pcictrl_msc
= (unsigned long)ioremap(MIPS_SOCITSC_PCI_REG_BASE
, 0x2000);
277 goto mips_pci_controller
;
280 /* Unknown system controller */
281 mips_display_message("SC Error");
282 while (1); /* We die here... */
284 board_nmi_handler_setup
= mips_nmi_setup
;
285 board_ejtag_handler_setup
= mips_ejtag_setup
;
289 #ifdef CONFIG_SERIAL_8250_CONSOLE
292 /* Early detection of CMP support */
295 if (!register_cps_smp_ops())
297 if (!register_cmp_smp_ops())
299 if (!register_vsmp_smp_ops())
301 register_up_smp_ops();