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