RT-AC56 3.0.0.4.374.37 core
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / parisc / kernel / setup.c
blobcf803727653892db7d21b67d2301f06ffa06a289
1 /*
2 * Initial setup-routines for HP 9000 based hardware.
4 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
5 * Modifications for PA-RISC (C) 1999 Helge Deller <deller@gmx.de>
6 * Modifications copyright 1999 SuSE GmbH (Philipp Rumpf)
7 * Modifications copyright 2000 Martin K. Petersen <mkp@mkp.net>
8 * Modifications copyright 2000 Philipp Rumpf <prumpf@tux.org>
9 * Modifications copyright 2001 Ryan Bradetich <rbradetich@uswest.net>
11 * Initial PA-RISC Version: 04-23-1999 by Helge Deller
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
16 * any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include <linux/kernel.h>
30 #include <linux/initrd.h>
31 #include <linux/init.h>
32 #include <linux/console.h>
33 #include <linux/seq_file.h>
34 #define PCI_DEBUG
35 #include <linux/pci.h>
36 #undef PCI_DEBUG
37 #include <linux/proc_fs.h>
39 #include <asm/processor.h>
40 #include <asm/pdc.h>
41 #include <asm/led.h>
42 #include <asm/machdep.h> /* for pa7300lc_init() proto */
43 #include <asm/pdc_chassis.h>
44 #include <asm/io.h>
45 #include <asm/setup.h>
46 #include <asm/unwind.h>
48 static char __initdata command_line[COMMAND_LINE_SIZE];
50 /* Intended for ccio/sba/cpu statistics under /proc/bus/{runway|gsc} */
51 struct proc_dir_entry * proc_runway_root __read_mostly = NULL;
52 struct proc_dir_entry * proc_gsc_root __read_mostly = NULL;
53 struct proc_dir_entry * proc_mckinley_root __read_mostly = NULL;
55 #if !defined(CONFIG_PA20) && (defined(CONFIG_IOMMU_CCIO) || defined(CONFIG_IOMMU_SBA))
56 int parisc_bus_is_phys __read_mostly = 1; /* Assume no IOMMU is present */
57 EXPORT_SYMBOL(parisc_bus_is_phys);
58 #endif
60 void __init setup_cmdline(char **cmdline_p)
62 extern unsigned int boot_args[];
64 /* Collect stuff passed in from the boot loader */
66 /* boot_args[0] is free-mem start, boot_args[1] is ptr to command line */
67 if (boot_args[0] < 64) {
68 /* called from hpux boot loader */
69 boot_command_line[0] = '\0';
70 } else {
71 strcpy(boot_command_line, (char *)__va(boot_args[1]));
73 #ifdef CONFIG_BLK_DEV_INITRD
74 if (boot_args[2] != 0) /* did palo pass us a ramdisk? */
76 initrd_start = (unsigned long)__va(boot_args[2]);
77 initrd_end = (unsigned long)__va(boot_args[3]);
79 #endif
82 strcpy(command_line, boot_command_line);
83 *cmdline_p = command_line;
86 #ifdef CONFIG_PA11
87 void __init dma_ops_init(void)
89 switch (boot_cpu_data.cpu_type) {
90 case pcx:
92 * We've got way too many dependencies on 1.1 semantics
93 * to support 1.0 boxes at this point.
95 panic( "PA-RISC Linux currently only supports machines that conform to\n"
96 "the PA-RISC 1.1 or 2.0 architecture specification.\n");
98 case pcxs:
99 case pcxt:
100 hppa_dma_ops = &pcx_dma_ops;
101 break;
102 case pcxl2:
103 pa7300lc_init();
104 case pcxl: /* falls through */
105 hppa_dma_ops = &pcxl_dma_ops;
106 break;
107 default:
108 break;
111 #endif
113 extern int init_per_cpu(int cpuid);
114 extern void collect_boot_cpu_data(void);
116 void __init setup_arch(char **cmdline_p)
118 #ifdef CONFIG_64BIT
119 extern int parisc_narrow_firmware;
120 #endif
121 unwind_init();
123 init_per_cpu(smp_processor_id()); /* Set Modes & Enable FP */
125 #ifdef CONFIG_64BIT
126 printk(KERN_INFO "The 64-bit Kernel has started...\n");
127 #else
128 printk(KERN_INFO "The 32-bit Kernel has started...\n");
129 #endif
131 pdc_console_init();
133 #ifdef CONFIG_64BIT
134 if(parisc_narrow_firmware) {
135 printk(KERN_INFO "Kernel is using PDC in 32-bit mode.\n");
137 #endif
138 setup_pdc();
139 setup_cmdline(cmdline_p);
140 collect_boot_cpu_data();
141 do_memory_inventory(); /* probe for physical memory */
142 parisc_cache_init();
143 paging_init();
145 #ifdef CONFIG_CHASSIS_LCD_LED
146 /* initialize the LCD/LED after boot_cpu_data is available ! */
147 led_init(); /* LCD/LED initialization */
148 #endif
150 #ifdef CONFIG_PA11
151 dma_ops_init();
152 #endif
154 #if defined(CONFIG_VT) && defined(CONFIG_DUMMY_CONSOLE)
155 conswitchp = &dummy_con; /* we use take_over_console() later ! */
156 #endif
161 * Display CPU info for all CPUs.
162 * for parisc this is in processor.c
164 extern int show_cpuinfo (struct seq_file *m, void *v);
166 static void *
167 c_start (struct seq_file *m, loff_t *pos)
169 /* Looks like the caller will call repeatedly until we return
170 * 0, signaling EOF perhaps. This could be used to sequence
171 * through CPUs for example. Since we print all cpu info in our
172 * show_cpuinfo() disregarding 'pos' (which I assume is 'v' above)
173 * we only allow for one "position". */
174 return ((long)*pos < 1) ? (void *)1 : NULL;
177 static void *
178 c_next (struct seq_file *m, void *v, loff_t *pos)
180 ++*pos;
181 return c_start(m, pos);
184 static void
185 c_stop (struct seq_file *m, void *v)
189 const struct seq_operations cpuinfo_op = {
190 .start = c_start,
191 .next = c_next,
192 .stop = c_stop,
193 .show = show_cpuinfo
196 static void __init parisc_proc_mkdir(void)
199 ** Can't call proc_mkdir() until after proc_root_init() has been
200 ** called by start_kernel(). In other words, this code can't
201 ** live in arch/.../setup.c because start_parisc() calls
202 ** start_kernel().
204 switch (boot_cpu_data.cpu_type) {
205 case pcxl:
206 case pcxl2:
207 if (NULL == proc_gsc_root)
209 proc_gsc_root = proc_mkdir("bus/gsc", NULL);
211 break;
212 case pcxt_:
213 case pcxu:
214 case pcxu_:
215 case pcxw:
216 case pcxw_:
217 case pcxw2:
218 if (NULL == proc_runway_root)
220 proc_runway_root = proc_mkdir("bus/runway", NULL);
222 break;
223 case mako:
224 case mako2:
225 if (NULL == proc_mckinley_root)
227 proc_mckinley_root = proc_mkdir("bus/mckinley", NULL);
229 break;
230 default:
231 break;
235 static struct resource central_bus = {
236 .name = "Central Bus",
237 .start = F_EXTEND(0xfff80000),
238 .end = F_EXTEND(0xfffaffff),
239 .flags = IORESOURCE_MEM,
242 static struct resource local_broadcast = {
243 .name = "Local Broadcast",
244 .start = F_EXTEND(0xfffb0000),
245 .end = F_EXTEND(0xfffdffff),
246 .flags = IORESOURCE_MEM,
249 static struct resource global_broadcast = {
250 .name = "Global Broadcast",
251 .start = F_EXTEND(0xfffe0000),
252 .end = F_EXTEND(0xffffffff),
253 .flags = IORESOURCE_MEM,
256 static int __init parisc_init_resources(void)
258 int result;
260 result = request_resource(&iomem_resource, &central_bus);
261 if (result < 0) {
262 printk(KERN_ERR
263 "%s: failed to claim %s address space!\n",
264 __FILE__, central_bus.name);
265 return result;
268 result = request_resource(&iomem_resource, &local_broadcast);
269 if (result < 0) {
270 printk(KERN_ERR
271 "%s: failed to claim %saddress space!\n",
272 __FILE__, local_broadcast.name);
273 return result;
276 result = request_resource(&iomem_resource, &global_broadcast);
277 if (result < 0) {
278 printk(KERN_ERR
279 "%s: failed to claim %s address space!\n",
280 __FILE__, global_broadcast.name);
281 return result;
284 return 0;
287 extern void gsc_init(void);
288 extern void processor_init(void);
289 extern void ccio_init(void);
290 extern void hppb_init(void);
291 extern void dino_init(void);
292 extern void iosapic_init(void);
293 extern void lba_init(void);
294 extern void sba_init(void);
295 extern void eisa_init(void);
297 static int __init parisc_init(void)
299 u32 osid = (OS_ID_LINUX << 16);
301 parisc_proc_mkdir();
302 parisc_init_resources();
303 do_device_inventory(); /* probe for hardware */
305 parisc_pdc_chassis_init();
307 /* set up a new led state on systems shipped LED State panel */
308 pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BSTART);
310 /* tell PDC we're Linux. Nevermind failure. */
311 pdc_stable_write(0x40, &osid, sizeof(osid));
313 processor_init();
314 printk(KERN_INFO "CPU(s): %d x %s at %d.%06d MHz\n",
315 num_present_cpus(),
316 boot_cpu_data.cpu_name,
317 boot_cpu_data.cpu_hz / 1000000,
318 boot_cpu_data.cpu_hz % 1000000 );
320 parisc_setup_cache_timing();
322 /* These are in a non-obvious order, will fix when we have an iotree */
323 #if defined(CONFIG_IOSAPIC)
324 iosapic_init();
325 #endif
326 #if defined(CONFIG_IOMMU_SBA)
327 sba_init();
328 #endif
329 #if defined(CONFIG_PCI_LBA)
330 lba_init();
331 #endif
333 /* CCIO before any potential subdevices */
334 #if defined(CONFIG_IOMMU_CCIO)
335 ccio_init();
336 #endif
339 * Need to register Asp & Wax before the EISA adapters for the IRQ
340 * regions. EISA must come before PCI to be sure it gets IRQ region
341 * 0.
343 #if defined(CONFIG_GSC_LASI) || defined(CONFIG_GSC_WAX)
344 gsc_init();
345 #endif
346 #ifdef CONFIG_EISA
347 eisa_init();
348 #endif
350 #if defined(CONFIG_HPPB)
351 hppb_init();
352 #endif
354 #if defined(CONFIG_GSC_DINO)
355 dino_init();
356 #endif
358 #ifdef CONFIG_CHASSIS_LCD_LED
359 register_led_regions(); /* register LED port info in procfs */
360 #endif
362 return 0;
364 arch_initcall(parisc_init);
366 void start_parisc(void)
368 extern void start_kernel(void);
370 int ret, cpunum;
371 struct pdc_coproc_cfg coproc_cfg;
373 cpunum = smp_processor_id();
375 set_firmware_width_unlocked();
377 ret = pdc_coproc_cfg_unlocked(&coproc_cfg);
378 if (ret >= 0 && coproc_cfg.ccr_functional) {
379 mtctl(coproc_cfg.ccr_functional, 10);
381 per_cpu(cpu_data, cpunum).fp_rev = coproc_cfg.revision;
382 per_cpu(cpu_data, cpunum).fp_model = coproc_cfg.model;
384 asm volatile ("fstd %fr0,8(%sp)");
385 } else {
386 panic("must have an fpu to boot linux");
389 start_kernel();
390 // not reached