vserver 1.9.5.x5
[linux-2.6.git] / arch / parisc / kernel / setup.c
1 /*    $Id: setup.c,v 1.8 2000/02/02 04:42:38 prumpf Exp $
2  *
3  *    Initial setup-routines for HP 9000 based hardware.
4  *
5  *    Copyright (C) 1991, 1992, 1995  Linus Torvalds
6  *    Modifications for PA-RISC (C) 1999 Helge Deller <deller@gmx.de>
7  *    Modifications copyright 1999 SuSE GmbH (Philipp Rumpf)
8  *    Modifications copyright 2000 Martin K. Petersen <mkp@mkp.net>
9  *    Modifications copyright 2000 Philipp Rumpf <prumpf@tux.org>
10  *    Modifications copyright 2001 Ryan Bradetich <rbradetich@uswest.net>
11  *
12  *    Initial PA-RISC Version: 04-23-1999 by Helge Deller
13  *
14  *    This program is free software; you can redistribute it and/or modify
15  *    it under the terms of the GNU General Public License as published by
16  *    the Free Software Foundation; either version 2, or (at your option)
17  *    any later version.
18  *
19  *    This program is distributed in the hope that it will be useful,
20  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
21  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  *    GNU General Public License for more details.
23  *
24  *    You should have received a copy of the GNU General Public License
25  *    along with this program; if not, write to the Free Software
26  *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27  *
28  */
29
30 #include <linux/config.h>
31 #include <linux/kernel.h>
32 #include <linux/initrd.h>
33 #include <linux/init.h>
34 #include <linux/console.h>
35 #include <linux/seq_file.h>
36 #define PCI_DEBUG
37 #include <linux/pci.h>
38 #undef PCI_DEBUG
39 #include <linux/proc_fs.h>
40
41 #include <asm/processor.h>
42 #include <asm/pdc.h>
43 #include <asm/led.h>
44 #include <asm/machdep.h>        /* for pa7300lc_init() proto */
45 #include <asm/pdc_chassis.h>
46 #include <asm/io.h>
47 #include <asm/setup.h>
48
49 char    command_line[COMMAND_LINE_SIZE];
50
51 /* Intended for ccio/sba/cpu statistics under /proc/bus/{runway|gsc} */
52 struct proc_dir_entry * proc_runway_root = NULL;
53 struct proc_dir_entry * proc_gsc_root = NULL;
54 struct proc_dir_entry * proc_mckinley_root = NULL;
55
56
57 void __init setup_cmdline(char **cmdline_p)
58 {
59         extern unsigned int boot_args[];
60
61         /* Collect stuff passed in from the boot loader */
62
63         /* boot_args[0] is free-mem start, boot_args[1] is ptr to command line */
64         if (boot_args[0] < 64) {
65                 /* called from hpux boot loader */
66                 saved_command_line[0] = '\0';
67         } else {
68                 strcpy(saved_command_line, (char *)__va(boot_args[1]));
69
70 #ifdef CONFIG_BLK_DEV_INITRD
71                 if (boot_args[2] != 0) /* did palo pass us a ramdisk? */
72                 {
73                     initrd_start = (unsigned long)__va(boot_args[2]);
74                     initrd_end = (unsigned long)__va(boot_args[3]);
75                 }
76 #endif
77         }
78
79         strcpy(command_line, saved_command_line);
80         *cmdline_p = command_line;
81 }
82
83 #ifdef CONFIG_PA11
84 void __init dma_ops_init(void)
85 {
86         switch (boot_cpu_data.cpu_type) {
87         case pcx:
88                 /*
89                  * We've got way too many dependencies on 1.1 semantics
90                  * to support 1.0 boxes at this point.
91                  */
92                 panic(  "PA-RISC Linux currently only supports machines that conform to\n"
93                         "the PA-RISC 1.1 or 2.0 architecture specification.\n");
94
95         case pcxs:
96         case pcxt:
97                 hppa_dma_ops = &pcx_dma_ops;
98                 break;
99         case pcxl2:
100                 pa7300lc_init();
101         case pcxl: /* falls through */
102                 hppa_dma_ops = &pcxl_dma_ops;
103                 break;
104         default:
105                 break;
106         }
107 }
108 #endif
109
110 extern int init_per_cpu(int cpuid);
111 extern void collect_boot_cpu_data(void);
112
113 void __init setup_arch(char **cmdline_p)
114 {
115         init_per_cpu(smp_processor_id());       /* Set Modes & Enable FP */
116
117 #ifdef __LP64__
118         printk(KERN_INFO "The 64-bit Kernel has started...\n");
119 #else
120         printk(KERN_INFO "The 32-bit Kernel has started...\n");
121 #endif
122
123         pdc_console_init();
124
125 #ifdef __LP64__
126         extern int parisc_narrow_firmware;
127         if(parisc_narrow_firmware) {
128                 printk(KERN_INFO "Kernel is using PDC in 32-bit mode.\n");
129         }
130 #endif
131         setup_pdc();
132         setup_cmdline(cmdline_p);
133         collect_boot_cpu_data();
134         do_memory_inventory();  /* probe for physical memory */
135         parisc_cache_init();
136         paging_init();
137
138 #ifdef CONFIG_CHASSIS_LCD_LED
139         /* initialize the LCD/LED after boot_cpu_data is available ! */
140         led_init();             /* LCD/LED initialization */
141 #endif
142
143 #ifdef CONFIG_PA11
144         dma_ops_init();
145 #endif
146
147 #if defined(CONFIG_VT) && defined(CONFIG_DUMMY_CONSOLE)
148         conswitchp = &dummy_con;        /* we use take_over_console() later ! */
149 #endif
150
151 }
152
153 /*
154  * Display cpu info for all cpu's.
155  * for parisc this is in processor.c
156  */
157 extern int show_cpuinfo (struct seq_file *m, void *v);
158
159 static void *
160 c_start (struct seq_file *m, loff_t *pos)
161 {
162         /* Looks like the caller will call repeatedly until we return
163          * 0, signaling EOF perhaps.  This could be used to sequence
164          * through CPUs for example.  Since we print all cpu info in our
165          * show_cpuinfo() disregarding 'pos' (which I assume is 'v' above)
166          * we only allow for one "position".  */
167         return ((long)*pos < 1) ? (void *)1 : NULL;
168 }
169
170 static void *
171 c_next (struct seq_file *m, void *v, loff_t *pos)
172 {
173         ++*pos;
174         return c_start(m, pos);
175 }
176
177 static void
178 c_stop (struct seq_file *m, void *v)
179 {
180 }
181
182 struct seq_operations cpuinfo_op = {
183         .start  = c_start,
184         .next   = c_next,
185         .stop   = c_stop,
186         .show   = show_cpuinfo
187 };
188
189 static void __init parisc_proc_mkdir(void)
190 {
191         /*
192         ** Can't call proc_mkdir() until after proc_root_init() has been
193         ** called by start_kernel(). In other words, this code can't
194         ** live in arch/.../setup.c because start_parisc() calls
195         ** start_kernel().
196         */
197         switch (boot_cpu_data.cpu_type) {
198         case pcxl:
199         case pcxl2:
200                 if (NULL == proc_gsc_root)
201                 {
202                         proc_gsc_root = proc_mkdir("bus/gsc", 0);
203                 }
204                 break;
205         case pcxt_:
206         case pcxu:
207         case pcxu_:
208         case pcxw:
209         case pcxw_:
210         case pcxw2:
211                 if (NULL == proc_runway_root)
212                 {
213                         proc_runway_root = proc_mkdir("bus/runway", 0);
214                 }
215                 break;
216         case mako:
217                 if (NULL == proc_mckinley_root)
218                 {
219                         proc_mckinley_root = proc_mkdir("bus/mckinley", 0);
220                 }
221                 break;
222         default:
223                 /* FIXME: this was added to prevent the compiler 
224                  * complaining about missing pcx, pcxs and pcxt
225                  * I'm assuming they have neither gsc nor runway */
226                 break;
227         }
228 }
229
230 static struct resource central_bus = {
231         .name   = "Central Bus",
232         .start  = F_EXTEND(0xfff80000),
233         .end    = F_EXTEND(0xfffaffff),
234         .flags  = IORESOURCE_MEM,
235 };
236
237 static struct resource local_broadcast = {
238         .name   = "Local Broadcast",
239         .start  = F_EXTEND(0xfffb0000),
240         .end    = F_EXTEND(0xfffdffff),
241         .flags  = IORESOURCE_MEM,
242 };
243
244 static struct resource global_broadcast = {
245         .name   = "Global Broadcast",
246         .start  = F_EXTEND(0xfffe0000),
247         .end    = F_EXTEND(0xffffffff),
248         .flags  = IORESOURCE_MEM,
249 };
250
251 static int __init parisc_init_resources(void)
252 {
253         int result;
254
255         result = request_resource(&iomem_resource, &central_bus);
256         if (result < 0) {
257                 printk(KERN_ERR 
258                        "%s: failed to claim %s address space!\n", 
259                        __FILE__, central_bus.name);
260                 return result;
261         }
262
263         result = request_resource(&iomem_resource, &local_broadcast);
264         if (result < 0) {
265                 printk(KERN_ERR 
266                        "%s: failed to claim %saddress space!\n", 
267                        __FILE__, local_broadcast.name);
268                 return result;
269         }
270
271         result = request_resource(&iomem_resource, &global_broadcast);
272         if (result < 0) {
273                 printk(KERN_ERR 
274                        "%s: failed to claim %s address space!\n", 
275                        __FILE__, global_broadcast.name);
276                 return result;
277         }
278
279         return 0;
280 }
281
282 extern void gsc_init(void);
283 extern void processor_init(void);
284 extern void ccio_init(void);
285 extern void hppb_init(void);
286 extern void dino_init(void);
287 extern void iosapic_init(void);
288 extern void lba_init(void);
289 extern void sba_init(void);
290 extern void eisa_init(void);
291
292 static int __init parisc_init(void)
293 {
294         parisc_proc_mkdir();
295         parisc_init_resources();
296         do_device_inventory();                  /* probe for hardware */
297
298         parisc_pdc_chassis_init();
299         
300         /* set up a new led state on systems shipped LED State panel */
301         pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BSTART);
302         
303         processor_init();
304         printk(KERN_INFO "CPU(s): %d x %s at %d.%06d MHz\n",
305                         boot_cpu_data.cpu_count,
306                         boot_cpu_data.cpu_name,
307                         boot_cpu_data.cpu_hz / 1000000,
308                         boot_cpu_data.cpu_hz % 1000000  );
309
310         parisc_setup_cache_timing();
311
312         /* These are in a non-obvious order, will fix when we have an iotree */
313 #if defined(CONFIG_IOSAPIC)
314         iosapic_init();
315 #endif
316 #if defined(CONFIG_IOMMU_SBA)
317         sba_init();
318 #endif
319 #if defined(CONFIG_PCI_LBA)
320         lba_init();
321 #endif
322
323         /* CCIO before any potential subdevices */
324 #if defined(CONFIG_IOMMU_CCIO)
325         ccio_init();
326 #endif
327
328         /*
329          * Need to register Asp & Wax before the EISA adapters for the IRQ
330          * regions.  EISA must come before PCI to be sure it gets IRQ region
331          * 0.
332          */
333 #if defined(CONFIG_GSC_LASI) || defined(CONFIG_GSC_WAX)
334         gsc_init();
335 #endif
336 #ifdef CONFIG_EISA
337         eisa_init();
338 #endif
339
340 #if defined(CONFIG_HPPB)
341         hppb_init();
342 #endif
343
344 #if defined(CONFIG_GSC_DINO)
345         dino_init();
346 #endif
347
348 #ifdef CONFIG_CHASSIS_LCD_LED
349         register_led_regions(); /* register LED port info in procfs */
350 #endif
351
352         return 0;
353 }
354
355 arch_initcall(parisc_init);
356