patch-2_6_7-vs1_9_1_12
[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
48 #define COMMAND_LINE_SIZE 1024
49 char    saved_command_line[COMMAND_LINE_SIZE];
50 char    command_line[COMMAND_LINE_SIZE];
51
52 /* Intended for ccio/sba/cpu statistics under /proc/bus/{runway|gsc} */
53 struct proc_dir_entry * proc_runway_root = NULL;
54 struct proc_dir_entry * proc_gsc_root = NULL;
55
56 void __init setup_cmdline(char **cmdline_p)
57 {
58         extern unsigned int boot_args[];
59
60         /* Collect stuff passed in from the boot loader */
61
62         /* boot_args[0] is free-mem start, boot_args[1] is ptr to command line */
63         if (boot_args[0] < 64) {
64                 /* called from hpux boot loader */
65                 saved_command_line[0] = '\0';
66         } else {
67                 strcpy(saved_command_line, (char *)__va(boot_args[1]));
68
69 #ifdef CONFIG_BLK_DEV_INITRD
70                 if (boot_args[2] != 0) /* did palo pass us a ramdisk? */
71                 {
72                     initrd_start = (unsigned long)__va(boot_args[2]);
73                     initrd_end = (unsigned long)__va(boot_args[3]);
74                 }
75 #endif
76         }
77
78         strcpy(command_line, saved_command_line);
79         *cmdline_p = command_line;
80 }
81
82 #ifdef CONFIG_PA11
83 void __init dma_ops_init(void)
84 {
85         switch (boot_cpu_data.cpu_type) {
86         case pcx:
87                 /*
88                  * We've got way too many dependencies on 1.1 semantics
89                  * to support 1.0 boxes at this point.
90                  */
91                 panic(  "PA-RISC Linux currently only supports machines that conform to\n"
92                         "the PA-RISC 1.1 or 2.0 architecture specification.\n");
93
94         case pcxs:
95         case pcxt:
96                 hppa_dma_ops = &pcx_dma_ops;
97                 break;
98         case pcxl2:
99                 pa7300lc_init();
100         case pcxl: /* falls through */
101                 hppa_dma_ops = &pcxl_dma_ops;
102                 break;
103         default:
104                 break;
105         }
106 }
107 #endif
108
109 extern int init_per_cpu(int cpuid);
110 extern void collect_boot_cpu_data(void);
111
112 void __init setup_arch(char **cmdline_p)
113 {
114         init_per_cpu(smp_processor_id());       /* Set Modes & Enable FP */
115
116 #ifdef __LP64__
117         printk(KERN_INFO "The 64-bit Kernel has started...\n");
118 #else
119         printk(KERN_INFO "The 32-bit Kernel has started...\n");
120 #endif
121
122         pdc_console_init();
123
124 #ifdef __LP64__
125         extern int parisc_narrow_firmware;
126         if(parisc_narrow_firmware) {
127                 printk(KERN_INFO "Kernel is using PDC in 32-bit mode.\n");
128         }
129 #endif
130         setup_pdc();
131         setup_cmdline(cmdline_p);
132         collect_boot_cpu_data();
133         do_memory_inventory();  /* probe for physical memory */
134         parisc_cache_init();
135         paging_init();
136
137 #ifdef CONFIG_CHASSIS_LCD_LED
138         /* initialize the LCD/LED after boot_cpu_data is available ! */
139         led_init();             /* LCD/LED initialization */
140 #endif
141
142 #ifdef CONFIG_PA11
143         dma_ops_init();
144 #endif
145
146 #if defined(CONFIG_VT) && defined(CONFIG_DUMMY_CONSOLE)
147         conswitchp = &dummy_con;        /* we use take_over_console() later ! */
148 #endif
149
150 }
151
152 /*
153  * Display cpu info for all cpu's.
154  * for parisc this is in processor.c
155  */
156 extern int show_cpuinfo (struct seq_file *m, void *v);
157
158 static void *
159 c_start (struct seq_file *m, loff_t *pos)
160 {
161         /* Looks like the caller will call repeatedly until we return
162          * 0, signaling EOF perhaps.  This could be used to sequence
163          * through CPUs for example.  Since we print all cpu info in our
164          * show_cpuinfo() disregarding 'pos' (which I assume is 'v' above)
165          * we only allow for one "position".  */
166         return ((long)*pos < 1) ? (void *)1 : NULL;
167 }
168
169 static void *
170 c_next (struct seq_file *m, void *v, loff_t *pos)
171 {
172         ++*pos;
173         return c_start(m, pos);
174 }
175
176 static void
177 c_stop (struct seq_file *m, void *v)
178 {
179 }
180
181 struct seq_operations cpuinfo_op = {
182         .start  = c_start,
183         .next   = c_next,
184         .stop   = c_stop,
185         .show   = show_cpuinfo
186 };
187
188 static void __init parisc_proc_mkdir(void)
189 {
190         /*
191         ** Can't call proc_mkdir() until after proc_root_init() has been
192         ** called by start_kernel(). In other words, this code can't
193         ** live in arch/.../setup.c because start_parisc() calls
194         ** start_kernel().
195         */
196         switch (boot_cpu_data.cpu_type) {
197         case pcxl:
198         case pcxl2:
199                 if (NULL == proc_gsc_root)
200                 {
201                         proc_gsc_root = proc_mkdir("bus/gsc", 0);
202                 }
203                 break;
204         case pcxt_:
205         case pcxu:
206         case pcxu_:
207         case pcxw:
208         case pcxw_:
209         case pcxw2:
210         case mako:      /* XXX : this is really mckinley bus */
211                 if (NULL == proc_runway_root)
212                 {
213                         proc_runway_root = proc_mkdir("bus/runway", 0);
214                 }
215                 break;
216         default:
217                 /* FIXME: this was added to prevent the compiler 
218                  * complaining about missing pcx, pcxs and pcxt
219                  * I'm assuming they have neither gsc nor runway */
220                 break;
221         }
222 }
223
224 static struct resource central_bus = {
225         .name   = "Central Bus",
226         .start  = F_EXTEND(0xfff80000),
227         .end    = F_EXTEND(0xfffaffff),
228         .flags  = IORESOURCE_MEM,
229 };
230
231 static struct resource local_broadcast = {
232         .name   = "Local Broadcast",
233         .start  = F_EXTEND(0xfffb0000),
234         .end    = F_EXTEND(0xfffdffff),
235         .flags  = IORESOURCE_MEM,
236 };
237
238 static struct resource global_broadcast = {
239         .name   = "Global Broadcast",
240         .start  = F_EXTEND(0xfffe0000),
241         .end    = F_EXTEND(0xffffffff),
242         .flags  = IORESOURCE_MEM,
243 };
244
245 static int __init parisc_init_resources(void)
246 {
247         int result;
248
249         result = request_resource(&iomem_resource, &central_bus);
250         if (result < 0) {
251                 printk(KERN_ERR 
252                        "%s: failed to claim %s address space!\n", 
253                        __FILE__, central_bus.name);
254                 return result;
255         }
256
257         result = request_resource(&iomem_resource, &local_broadcast);
258         if (result < 0) {
259                 printk(KERN_ERR 
260                        "%s: failed to claim %saddress space!\n", 
261                        __FILE__, local_broadcast.name);
262                 return result;
263         }
264
265         result = request_resource(&iomem_resource, &global_broadcast);
266         if (result < 0) {
267                 printk(KERN_ERR 
268                        "%s: failed to claim %s address space!\n", 
269                        __FILE__, global_broadcast.name);
270                 return result;
271         }
272
273         return 0;
274 }
275
276 extern void gsc_init(void);
277 extern void processor_init(void);
278 extern void ccio_init(void);
279 extern void hppb_init(void);
280 extern void dino_init(void);
281 extern void iosapic_init(void);
282 extern void lba_init(void);
283 extern void sba_init(void);
284 extern void eisa_init(void);
285
286 static int __init parisc_init(void)
287 {
288         parisc_proc_mkdir();
289         parisc_init_resources();
290         do_device_inventory();                  /* probe for hardware */
291
292         parisc_pdc_chassis_init();
293         
294         /* set up a new led state on systems shipped LED State panel */
295         pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BSTART);
296         
297         processor_init();
298         printk(KERN_INFO "CPU(s): %d x %s at %d.%06d MHz\n",
299                         boot_cpu_data.cpu_count,
300                         boot_cpu_data.cpu_name,
301                         boot_cpu_data.cpu_hz / 1000000,
302                         boot_cpu_data.cpu_hz % 1000000  );
303
304         /* These are in a non-obvious order, will fix when we have an iotree */
305 #if defined(CONFIG_IOSAPIC)
306         iosapic_init();
307 #endif
308 #if defined(CONFIG_IOMMU_SBA)
309         sba_init();
310 #endif
311 #if defined(CONFIG_PCI_LBA)
312         lba_init();
313 #endif
314
315         /* CCIO before any potential subdevices */
316 #if defined(CONFIG_IOMMU_CCIO)
317         ccio_init();
318 #endif
319
320         /*
321          * Need to register Asp & Wax before the EISA adapters for the IRQ
322          * regions.  EISA must come before PCI to be sure it gets IRQ region
323          * 0.
324          */
325 #if defined(CONFIG_GSC_LASI) || defined(CONFIG_GSC_WAX)
326         gsc_init();
327 #endif
328 #ifdef CONFIG_EISA
329         eisa_init();
330 #endif
331
332 #if defined(CONFIG_HPPB)
333         hppb_init();
334 #endif
335
336 #if defined(CONFIG_GSC_DINO)
337         dino_init();
338 #endif
339
340 #ifdef CONFIG_CHASSIS_LCD_LED
341         register_led_regions(); /* register LED port info in procfs */
342 #endif
343
344         return 0;
345 }
346
347 arch_initcall(parisc_init);
348