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)
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>
35 #include <linux/pci.h>
37 #include <linux/proc_fs.h>
38 #include <linux/export.h>
39 #include <linux/sched.h>
40 #include <linux/sched/clock.h>
41 #include <linux/start_kernel.h>
43 #include <asm/processor.h>
44 #include <asm/sections.h>
47 #include <asm/machdep.h> /* for pa7300lc_init() proto */
48 #include <asm/pdc_chassis.h>
50 #include <asm/setup.h>
51 #include <asm/unwind.h>
54 static char __initdata command_line[COMMAND_LINE_SIZE];
56 /* Intended for ccio/sba/cpu statistics under /proc/bus/{runway|gsc} */
57 struct proc_dir_entry * proc_runway_root __read_mostly = NULL;
58 struct proc_dir_entry * proc_gsc_root __read_mostly = NULL;
59 struct proc_dir_entry * proc_mckinley_root __read_mostly = NULL;
61 void __init setup_cmdline(char **cmdline_p)
63 extern unsigned int boot_args[];
65 /* Collect stuff passed in from the boot loader */
67 /* boot_args[0] is free-mem start, boot_args[1] is ptr to command line */
68 if (boot_args[0] < 64) {
69 /* called from hpux boot loader */
70 boot_command_line[0] = '\0';
72 strlcpy(boot_command_line, (char *)__va(boot_args[1]),
75 #ifdef CONFIG_BLK_DEV_INITRD
76 if (boot_args[2] != 0) /* did palo pass us a ramdisk? */
78 initrd_start = (unsigned long)__va(boot_args[2]);
79 initrd_end = (unsigned long)__va(boot_args[3]);
84 strcpy(command_line, boot_command_line);
85 *cmdline_p = command_line;
89 void __init dma_ops_init(void)
91 switch (boot_cpu_data.cpu_type) {
94 * We've got way too many dependencies on 1.1 semantics
95 * to support 1.0 boxes at this point.
97 panic( "PA-RISC Linux currently only supports machines that conform to\n"
98 "the PA-RISC 1.1 or 2.0 architecture specification.\n");
102 case pcxl: /* falls through */
105 hppa_dma_ops = &dma_direct_ops;
113 extern void collect_boot_cpu_data(void);
115 void __init setup_arch(char **cmdline_p)
118 extern int parisc_narrow_firmware;
122 init_per_cpu(smp_processor_id()); /* Set Modes & Enable FP */
125 printk(KERN_INFO "The 64-bit Kernel has started...\n");
127 printk(KERN_INFO "The 32-bit Kernel has started...\n");
130 printk(KERN_INFO "Kernel default page size is %d KB. Huge pages ",
131 (int)(PAGE_SIZE / 1024));
132 #ifdef CONFIG_HUGETLB_PAGE
133 printk(KERN_CONT "enabled with %d MB physical and %d MB virtual size",
134 1 << (REAL_HPAGE_SHIFT - 20), 1 << (HPAGE_SHIFT - 20));
136 printk(KERN_CONT "disabled");
138 printk(KERN_CONT ".\n");
141 * Check if initial kernel page mappings are sufficient.
142 * panic early if not, else we may access kernel functions
143 * and variables which can't be reached.
145 if (__pa((unsigned long) &_end) >= KERNEL_INITIAL_SIZE)
146 panic("KERNEL_INITIAL_ORDER too small!");
151 if(parisc_narrow_firmware) {
152 printk(KERN_INFO "Kernel is using PDC in 32-bit mode.\n");
156 setup_cmdline(cmdline_p);
157 collect_boot_cpu_data();
158 do_memory_inventory(); /* probe for physical memory */
162 #ifdef CONFIG_CHASSIS_LCD_LED
163 /* initialize the LCD/LED after boot_cpu_data is available ! */
164 led_init(); /* LCD/LED initialization */
171 #if defined(CONFIG_VT) && defined(CONFIG_DUMMY_CONSOLE)
172 conswitchp = &dummy_con; /* we use do_take_over_console() later ! */
175 clear_sched_clock_stable();
179 * Display CPU info for all CPUs.
180 * for parisc this is in processor.c
182 extern int show_cpuinfo (struct seq_file *m, void *v);
185 c_start (struct seq_file *m, loff_t *pos)
187 /* Looks like the caller will call repeatedly until we return
188 * 0, signaling EOF perhaps. This could be used to sequence
189 * through CPUs for example. Since we print all cpu info in our
190 * show_cpuinfo() disregarding 'pos' (which I assume is 'v' above)
191 * we only allow for one "position". */
192 return ((long)*pos < 1) ? (void *)1 : NULL;
196 c_next (struct seq_file *m, void *v, loff_t *pos)
199 return c_start(m, pos);
203 c_stop (struct seq_file *m, void *v)
207 const struct seq_operations cpuinfo_op = {
214 static void __init parisc_proc_mkdir(void)
217 ** Can't call proc_mkdir() until after proc_root_init() has been
218 ** called by start_kernel(). In other words, this code can't
219 ** live in arch/.../setup.c because start_parisc() calls
222 switch (boot_cpu_data.cpu_type) {
225 if (NULL == proc_gsc_root)
227 proc_gsc_root = proc_mkdir("bus/gsc", NULL);
236 if (NULL == proc_runway_root)
238 proc_runway_root = proc_mkdir("bus/runway", NULL);
243 if (NULL == proc_mckinley_root)
245 proc_mckinley_root = proc_mkdir("bus/mckinley", NULL);
249 /* FIXME: this was added to prevent the compiler
250 * complaining about missing pcx, pcxs and pcxt
251 * I'm assuming they have neither gsc nor runway */
256 static struct resource central_bus = {
257 .name = "Central Bus",
258 .start = F_EXTEND(0xfff80000),
259 .end = F_EXTEND(0xfffaffff),
260 .flags = IORESOURCE_MEM,
263 static struct resource local_broadcast = {
264 .name = "Local Broadcast",
265 .start = F_EXTEND(0xfffb0000),
266 .end = F_EXTEND(0xfffdffff),
267 .flags = IORESOURCE_MEM,
270 static struct resource global_broadcast = {
271 .name = "Global Broadcast",
272 .start = F_EXTEND(0xfffe0000),
273 .end = F_EXTEND(0xffffffff),
274 .flags = IORESOURCE_MEM,
277 static int __init parisc_init_resources(void)
281 result = request_resource(&iomem_resource, ¢ral_bus);
284 "%s: failed to claim %s address space!\n",
285 __FILE__, central_bus.name);
289 result = request_resource(&iomem_resource, &local_broadcast);
292 "%s: failed to claim %saddress space!\n",
293 __FILE__, local_broadcast.name);
297 result = request_resource(&iomem_resource, &global_broadcast);
300 "%s: failed to claim %s address space!\n",
301 __FILE__, global_broadcast.name);
308 static int no_alternatives __initdata;
309 static int __init setup_no_alternatives(char *str)
314 __setup("no-alternatives", setup_no_alternatives);
316 static void __init apply_alternatives_all(void)
318 struct alt_instr *entry;
319 int index = 0, applied = 0;
322 pr_info("alternatives: %spatching kernel code\n",
323 no_alternatives ? "NOT " : "");
327 set_kernel_text_rw(1);
329 for (entry = (struct alt_instr *) &__alt_instructions;
330 entry < (struct alt_instr *) &__alt_instructions_end;
333 u32 *from, len, cond, replacement;
335 from = (u32 *)((ulong)&entry->orig_offset + entry->orig_offset);
338 replacement = entry->replacement;
341 pr_debug("Check %d: Cond 0x%x, Replace %02d instructions @ 0x%px with 0x%08x\n",
342 index, cond, len, from, replacement);
344 if ((cond & ALT_COND_NO_SMP) && (num_online_cpus() != 1))
346 if ((cond & ALT_COND_NO_DCACHE) && (cache_info.dc_size != 0))
348 if ((cond & ALT_COND_NO_ICACHE) && (cache_info.ic_size != 0))
352 * If the PDC_MODEL capabilities has Non-coherent IO-PDIR bit
353 * set (bit #61, big endian), we have to flush and sync every
354 * time IO-PDIR is changed in Ike/Astro.
356 if ((cond & ALT_COND_NO_IOC_FDC) &&
357 (boot_cpu_data.pdc.capabilities & PDC_MODEL_IOPDIR_FDC))
360 /* Want to replace pdtlb by a pdtlb,l instruction? */
361 if (replacement == INSN_PxTLB) {
363 if (boot_cpu_data.cpu_type >= pcxu) /* >= pa2.0 ? */
364 replacement |= (1 << 10); /* set el bit */
368 * Replace instruction with NOPs?
369 * For long distance insert a branch instruction instead.
371 if (replacement == INSN_NOP && len > 1)
372 replacement = 0xe8000002 + (len-2)*8; /* "b,n .+8" */
374 pr_debug("Do %d: Cond 0x%x, Replace %02d instructions @ 0x%px with 0x%08x\n",
375 index, cond, len, from, replacement);
377 /* Replace instruction */
382 pr_info("alternatives: applied %d out of %d patches\n", applied, index);
384 set_kernel_text_rw(0);
388 extern void gsc_init(void);
389 extern void processor_init(void);
390 extern void ccio_init(void);
391 extern void hppb_init(void);
392 extern void dino_init(void);
393 extern void iosapic_init(void);
394 extern void lba_init(void);
395 extern void sba_init(void);
396 extern void eisa_init(void);
398 static int __init parisc_init(void)
400 u32 osid = (OS_ID_LINUX << 16);
403 parisc_init_resources();
404 do_device_inventory(); /* probe for hardware */
406 parisc_pdc_chassis_init();
408 /* set up a new led state on systems shipped LED State panel */
409 pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BSTART);
411 /* tell PDC we're Linux. Nevermind failure. */
412 pdc_stable_write(0x40, &osid, sizeof(osid));
414 /* start with known state */
415 flush_cache_all_local();
416 flush_tlb_all_local(NULL);
420 pr_info("CPU(s): %d out of %d %s at %d.%06d MHz online\n",
421 num_online_cpus(), num_present_cpus(),
423 pr_info("CPU(s): 1 x %s at %d.%06d MHz\n",
425 boot_cpu_data.cpu_name,
426 boot_cpu_data.cpu_hz / 1000000,
427 boot_cpu_data.cpu_hz % 1000000 );
429 apply_alternatives_all();
430 parisc_setup_cache_timing();
432 /* These are in a non-obvious order, will fix when we have an iotree */
433 #if defined(CONFIG_IOSAPIC)
436 #if defined(CONFIG_IOMMU_SBA)
439 #if defined(CONFIG_PCI_LBA)
443 /* CCIO before any potential subdevices */
444 #if defined(CONFIG_IOMMU_CCIO)
449 * Need to register Asp & Wax before the EISA adapters for the IRQ
450 * regions. EISA must come before PCI to be sure it gets IRQ region
453 #if defined(CONFIG_GSC_LASI) || defined(CONFIG_GSC_WAX)
460 #if defined(CONFIG_HPPB)
464 #if defined(CONFIG_GSC_DINO)
468 #ifdef CONFIG_CHASSIS_LCD_LED
469 register_led_regions(); /* register LED port info in procfs */
474 arch_initcall(parisc_init);
476 void __init start_parisc(void)
478 extern void early_trap_init(void);
481 struct pdc_coproc_cfg coproc_cfg;
483 cpunum = smp_processor_id();
487 set_firmware_width_unlocked();
489 ret = pdc_coproc_cfg_unlocked(&coproc_cfg);
490 if (ret >= 0 && coproc_cfg.ccr_functional) {
491 mtctl(coproc_cfg.ccr_functional, 10);
493 per_cpu(cpu_data, cpunum).fp_rev = coproc_cfg.revision;
494 per_cpu(cpu_data, cpunum).fp_model = coproc_cfg.model;
496 asm volatile ("fstd %fr0,8(%sp)");
498 panic("must have an fpu to boot linux");
501 early_trap_init(); /* initialize checksum of fault_vector */