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