x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub
[linux/fpc-iii.git] / arch / mips / netlogic / xlr / setup.c
blob214d123b79faf7f6659ae4127ffe938257fb26ae
1 /*
2 * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights
3 * reserved.
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the NetLogic
9 * license below:
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
22 * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <linux/kernel.h>
36 #include <linux/serial_8250.h>
37 #include <linux/pm.h>
39 #include <asm/idle.h>
40 #include <asm/reboot.h>
41 #include <asm/time.h>
42 #include <asm/bootinfo.h>
44 #include <asm/netlogic/interrupt.h>
45 #include <asm/netlogic/psb-bootinfo.h>
46 #include <asm/netlogic/haldefs.h>
47 #include <asm/netlogic/common.h>
49 #include <asm/netlogic/xlr/xlr.h>
50 #include <asm/netlogic/xlr/iomap.h>
51 #include <asm/netlogic/xlr/pic.h>
52 #include <asm/netlogic/xlr/gpio.h>
53 #include <asm/netlogic/xlr/fmn.h>
55 uint64_t nlm_io_base = DEFAULT_NETLOGIC_IO_BASE;
56 struct psb_info nlm_prom_info;
58 /* default to uniprocessor */
59 unsigned int nlm_threads_per_core = 1;
60 struct nlm_soc_info nlm_nodes[NLM_NR_NODES];
61 cpumask_t nlm_cpumask = CPU_MASK_CPU0;
63 static void __init nlm_early_serial_setup(void)
65 struct uart_port s;
66 unsigned long uart_base;
68 uart_base = (unsigned long)nlm_mmio_base(NETLOGIC_IO_UART_0_OFFSET);
69 memset(&s, 0, sizeof(s));
70 s.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;
71 s.iotype = UPIO_MEM32;
72 s.regshift = 2;
73 s.irq = PIC_UART_0_IRQ;
74 s.uartclk = PIC_CLK_HZ;
75 s.serial_in = nlm_xlr_uart_in;
76 s.serial_out = nlm_xlr_uart_out;
77 s.mapbase = uart_base;
78 s.membase = (unsigned char __iomem *)uart_base;
79 early_serial_setup(&s);
82 static void nlm_linux_exit(void)
84 uint64_t gpiobase;
86 gpiobase = nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET);
87 /* trigger a chip reset by writing 1 to GPIO_SWRESET_REG */
88 nlm_write_reg(gpiobase, GPIO_SWRESET_REG, 1);
89 for ( ; ; )
90 cpu_wait();
93 void __init plat_mem_setup(void)
95 panic_timeout = 5;
96 _machine_restart = (void (*)(char *))nlm_linux_exit;
97 _machine_halt = nlm_linux_exit;
98 pm_power_off = nlm_linux_exit;
101 const char *get_system_type(void)
103 return "Netlogic XLR/XLS Series";
106 unsigned int nlm_get_cpu_frequency(void)
108 return (unsigned int)nlm_prom_info.cpu_frequency;
111 void __init prom_free_prom_memory(void)
113 /* Nothing yet */
116 void nlm_percpu_init(int hwcpuid)
118 if (hwcpuid % 4 == 0)
119 xlr_percpu_fmn_init();
122 static void __init build_arcs_cmdline(int *argv)
124 int i, remain, len;
125 char *arg;
127 remain = sizeof(arcs_cmdline) - 1;
128 arcs_cmdline[0] = '\0';
129 for (i = 0; argv[i] != 0; i++) {
130 arg = (char *)(long)argv[i];
131 len = strlen(arg);
132 if (len + 1 > remain)
133 break;
134 strcat(arcs_cmdline, arg);
135 strcat(arcs_cmdline, " ");
136 remain -= len + 1;
139 /* Add the default options here */
140 if ((strstr(arcs_cmdline, "console=")) == NULL) {
141 arg = "console=ttyS0,38400 ";
142 len = strlen(arg);
143 if (len > remain)
144 goto fail;
145 strcat(arcs_cmdline, arg);
146 remain -= len;
148 #ifdef CONFIG_BLK_DEV_INITRD
149 if ((strstr(arcs_cmdline, "rdinit=")) == NULL) {
150 arg = "rdinit=/sbin/init ";
151 len = strlen(arg);
152 if (len > remain)
153 goto fail;
154 strcat(arcs_cmdline, arg);
155 remain -= len;
157 #endif
158 return;
159 fail:
160 panic("Cannot add %s, command line too big!", arg);
163 static void prom_add_memory(void)
165 struct nlm_boot_mem_map *bootm;
166 u64 start, size;
167 u64 pref_backup = 512; /* avoid pref walking beyond end */
168 int i;
170 bootm = (void *)(long)nlm_prom_info.psb_mem_map;
171 for (i = 0; i < bootm->nr_map; i++) {
172 if (bootm->map[i].type != BOOT_MEM_RAM)
173 continue;
174 start = bootm->map[i].addr;
175 size = bootm->map[i].size;
177 /* Work around for using bootloader mem */
178 if (i == 0 && start == 0 && size == 0x0c000000)
179 size = 0x0ff00000;
181 add_memory_region(start, size - pref_backup, BOOT_MEM_RAM);
185 static void nlm_init_node(void)
187 struct nlm_soc_info *nodep;
189 nodep = nlm_current_node();
190 nodep->picbase = nlm_mmio_base(NETLOGIC_IO_PIC_OFFSET);
191 nodep->ebase = read_c0_ebase() & (~((1 << 12) - 1));
192 spin_lock_init(&nodep->piclock);
195 void __init prom_init(void)
197 int *argv, *envp; /* passed as 32 bit ptrs */
198 struct psb_info *prom_infop;
199 void *reset_vec;
200 #ifdef CONFIG_SMP
201 int i;
202 #endif
204 /* truncate to 32 bit and sign extend all args */
205 argv = (int *)(long)(int)fw_arg1;
206 envp = (int *)(long)(int)fw_arg2;
207 prom_infop = (struct psb_info *)(long)(int)fw_arg3;
209 nlm_prom_info = *prom_infop;
210 nlm_init_node();
212 /* Update reset entry point with CPU init code */
213 reset_vec = (void *)CKSEG1ADDR(RESET_VEC_PHYS);
214 memset(reset_vec, 0, RESET_VEC_SIZE);
215 memcpy(reset_vec, (void *)nlm_reset_entry,
216 (nlm_reset_entry_end - nlm_reset_entry));
218 nlm_early_serial_setup();
219 build_arcs_cmdline(argv);
220 prom_add_memory();
222 #ifdef CONFIG_SMP
223 for (i = 0; i < 32; i++)
224 if (nlm_prom_info.online_cpu_map & (1 << i))
225 cpumask_set_cpu(i, &nlm_cpumask);
226 nlm_wakeup_secondary_cpus();
227 register_smp_ops(&nlm_smp_ops);
228 #endif
229 xlr_board_info_setup();
230 xlr_percpu_fmn_init();