1 /* 2 * Initial setup-routines for HP 9000 based hardware. 3 * 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> 10 * 11 * Initial PA-RISC Version: 04-23-1999 by Helge Deller 12 * 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) 16 * any later version. 17 * 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. 22 * 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. 26 * 27 */ 28 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> 34 #define PCI_DEBUG 35 #include <linux/pci.h> 36 #undef PCI_DEBUG 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> 42 43 #include <asm/processor.h> 44 #include <asm/sections.h> 45 #include <asm/pdc.h> 46 #include <asm/led.h> 47 #include <asm/machdep.h> /* for pa7300lc_init() proto */ 48 #include <asm/pdc_chassis.h> 49 #include <asm/io.h> 50 #include <asm/setup.h> 51 #include <asm/unwind.h> 52 #include <asm/smp.h> 53 54 static char __initdata command_line[COMMAND_LINE_SIZE]; 55 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; 60 61 void __init setup_cmdline(char **cmdline_p) 62 { 63 extern unsigned int boot_args[]; 64 65 /* Collect stuff passed in from the boot loader */ 66 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'; 71 } else { 72 strlcpy(boot_command_line, (char *)__va(boot_args[1]), 73 COMMAND_LINE_SIZE); 74 75 #ifdef CONFIG_BLK_DEV_INITRD 76 if (boot_args[2] != 0) /* did palo pass us a ramdisk? */ 77 { 78 initrd_start = (unsigned long)__va(boot_args[2]); 79 initrd_end = (unsigned long)__va(boot_args[3]); 80 } 81 #endif 82 } 83 84 strcpy(command_line, boot_command_line); 85 *cmdline_p = command_line; 86 } 87 88 #ifdef CONFIG_PA11 89 void __init dma_ops_init(void) 90 { 91 switch (boot_cpu_data.cpu_type) { 92 case pcx: 93 /* 94 * We've got way too many dependencies on 1.1 semantics 95 * to support 1.0 boxes at this point. 96 */ 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"); 99 100 case pcxl2: 101 pa7300lc_init(); 102 break; 103 default: 104 break; 105 } 106 } 107 #endif 108 109 extern void collect_boot_cpu_data(void); 110 111 void __init setup_arch(char **cmdline_p) 112 { 113 #ifdef CONFIG_64BIT 114 extern int parisc_narrow_firmware; 115 #endif 116 unwind_init(); 117 118 init_per_cpu(smp_processor_id()); /* Set Modes & Enable FP */ 119 120 #ifdef CONFIG_64BIT 121 printk(KERN_INFO "The 64-bit Kernel has started...\n"); 122 #else 123 printk(KERN_INFO "The 32-bit Kernel has started...\n"); 124 #endif 125 126 printk(KERN_INFO "Kernel default page size is %d KB. Huge pages ", 127 (int)(PAGE_SIZE / 1024)); 128 #ifdef CONFIG_HUGETLB_PAGE 129 printk(KERN_CONT "enabled with %d MB physical and %d MB virtual size", 130 1 << (REAL_HPAGE_SHIFT - 20), 1 << (HPAGE_SHIFT - 20)); 131 #else 132 printk(KERN_CONT "disabled"); 133 #endif 134 printk(KERN_CONT ".\n"); 135 136 /* 137 * Check if initial kernel page mappings are sufficient. 138 * panic early if not, else we may access kernel functions 139 * and variables which can't be reached. 140 */ 141 if (__pa((unsigned long) &_end) >= KERNEL_INITIAL_SIZE) 142 panic("KERNEL_INITIAL_ORDER too small!"); 143 144 pdc_console_init(); 145 146 #ifdef CONFIG_64BIT 147 if(parisc_narrow_firmware) { 148 printk(KERN_INFO "Kernel is using PDC in 32-bit mode.\n"); 149 } 150 #endif 151 setup_pdc(); 152 setup_cmdline(cmdline_p); 153 collect_boot_cpu_data(); 154 do_memory_inventory(); /* probe for physical memory */ 155 parisc_cache_init(); 156 paging_init(); 157 158 #ifdef CONFIG_CHASSIS_LCD_LED 159 /* initialize the LCD/LED after boot_cpu_data is available ! */ 160 led_init(); /* LCD/LED initialization */ 161 #endif 162 163 #ifdef CONFIG_PA11 164 dma_ops_init(); 165 #endif 166 167 #if defined(CONFIG_VT) && defined(CONFIG_DUMMY_CONSOLE) 168 conswitchp = &dummy_con; /* we use do_take_over_console() later ! */ 169 #endif 170 171 clear_sched_clock_stable(); 172 } 173 174 /* 175 * Display CPU info for all CPUs. 176 * for parisc this is in processor.c 177 */ 178 extern int show_cpuinfo (struct seq_file *m, void *v); 179 180 static void * 181 c_start (struct seq_file *m, loff_t *pos) 182 { 183 /* Looks like the caller will call repeatedly until we return 184 * 0, signaling EOF perhaps. This could be used to sequence 185 * through CPUs for example. Since we print all cpu info in our 186 * show_cpuinfo() disregarding 'pos' (which I assume is 'v' above) 187 * we only allow for one "position". */ 188 return ((long)*pos < 1) ? (void *)1 : NULL; 189 } 190 191 static void * 192 c_next (struct seq_file *m, void *v, loff_t *pos) 193 { 194 ++*pos; 195 return c_start(m, pos); 196 } 197 198 static void 199 c_stop (struct seq_file *m, void *v) 200 { 201 } 202 203 const struct seq_operations cpuinfo_op = { 204 .start = c_start, 205 .next = c_next, 206 .stop = c_stop, 207 .show = show_cpuinfo 208 }; 209 210 static void __init parisc_proc_mkdir(void) 211 { 212 /* 213 ** Can't call proc_mkdir() until after proc_root_init() has been 214 ** called by start_kernel(). In other words, this code can't 215 ** live in arch/.../setup.c because start_parisc() calls 216 ** start_kernel(). 217 */ 218 switch (boot_cpu_data.cpu_type) { 219 case pcxl: 220 case pcxl2: 221 if (NULL == proc_gsc_root) 222 { 223 proc_gsc_root = proc_mkdir("bus/gsc", NULL); 224 } 225 break; 226 case pcxt_: 227 case pcxu: 228 case pcxu_: 229 case pcxw: 230 case pcxw_: 231 case pcxw2: 232 if (NULL == proc_runway_root) 233 { 234 proc_runway_root = proc_mkdir("bus/runway", NULL); 235 } 236 break; 237 case mako: 238 case mako2: 239 if (NULL == proc_mckinley_root) 240 { 241 proc_mckinley_root = proc_mkdir("bus/mckinley", NULL); 242 } 243 break; 244 default: 245 /* FIXME: this was added to prevent the compiler 246 * complaining about missing pcx, pcxs and pcxt 247 * I'm assuming they have neither gsc nor runway */ 248 break; 249 } 250 } 251 252 static struct resource central_bus = { 253 .name = "Central Bus", 254 .start = F_EXTEND(0xfff80000), 255 .end = F_EXTEND(0xfffaffff), 256 .flags = IORESOURCE_MEM, 257 }; 258 259 static struct resource local_broadcast = { 260 .name = "Local Broadcast", 261 .start = F_EXTEND(0xfffb0000), 262 .end = F_EXTEND(0xfffdffff), 263 .flags = IORESOURCE_MEM, 264 }; 265 266 static struct resource global_broadcast = { 267 .name = "Global Broadcast", 268 .start = F_EXTEND(0xfffe0000), 269 .end = F_EXTEND(0xffffffff), 270 .flags = IORESOURCE_MEM, 271 }; 272 273 static int __init parisc_init_resources(void) 274 { 275 int result; 276 277 result = request_resource(&iomem_resource, ¢ral_bus); 278 if (result < 0) { 279 printk(KERN_ERR 280 "%s: failed to claim %s address space!\n", 281 __FILE__, central_bus.name); 282 return result; 283 } 284 285 result = request_resource(&iomem_resource, &local_broadcast); 286 if (result < 0) { 287 printk(KERN_ERR 288 "%s: failed to claim %saddress space!\n", 289 __FILE__, local_broadcast.name); 290 return result; 291 } 292 293 result = request_resource(&iomem_resource, &global_broadcast); 294 if (result < 0) { 295 printk(KERN_ERR 296 "%s: failed to claim %s address space!\n", 297 __FILE__, global_broadcast.name); 298 return result; 299 } 300 301 return 0; 302 } 303 304 extern void gsc_init(void); 305 extern void processor_init(void); 306 extern void ccio_init(void); 307 extern void hppb_init(void); 308 extern void dino_init(void); 309 extern void iosapic_init(void); 310 extern void lba_init(void); 311 extern void sba_init(void); 312 extern void eisa_init(void); 313 314 static int __init parisc_init(void) 315 { 316 u32 osid = (OS_ID_LINUX << 16); 317 318 parisc_proc_mkdir(); 319 parisc_init_resources(); 320 do_device_inventory(); /* probe for hardware */ 321 322 parisc_pdc_chassis_init(); 323 324 /* set up a new led state on systems shipped LED State panel */ 325 pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BSTART); 326 327 /* tell PDC we're Linux. Nevermind failure. */ 328 pdc_stable_write(0x40, &osid, sizeof(osid)); 329 330 /* start with known state */ 331 flush_cache_all_local(); 332 flush_tlb_all_local(NULL); 333 334 processor_init(); 335 #ifdef CONFIG_SMP 336 pr_info("CPU(s): %d out of %d %s at %d.%06d MHz online\n", 337 num_online_cpus(), num_present_cpus(), 338 #else 339 pr_info("CPU(s): 1 x %s at %d.%06d MHz\n", 340 #endif 341 boot_cpu_data.cpu_name, 342 boot_cpu_data.cpu_hz / 1000000, 343 boot_cpu_data.cpu_hz % 1000000 ); 344 345 apply_alternatives_all(); 346 parisc_setup_cache_timing(); 347 348 /* These are in a non-obvious order, will fix when we have an iotree */ 349 #if defined(CONFIG_IOSAPIC) 350 iosapic_init(); 351 #endif 352 #if defined(CONFIG_IOMMU_SBA) 353 sba_init(); 354 #endif 355 #if defined(CONFIG_PCI_LBA) 356 lba_init(); 357 #endif 358 359 /* CCIO before any potential subdevices */ 360 #if defined(CONFIG_IOMMU_CCIO) 361 ccio_init(); 362 #endif 363 364 /* 365 * Need to register Asp & Wax before the EISA adapters for the IRQ 366 * regions. EISA must come before PCI to be sure it gets IRQ region 367 * 0. 368 */ 369 #if defined(CONFIG_GSC_LASI) || defined(CONFIG_GSC_WAX) 370 gsc_init(); 371 #endif 372 #ifdef CONFIG_EISA 373 eisa_init(); 374 #endif 375 376 #if defined(CONFIG_HPPB) 377 hppb_init(); 378 #endif 379 380 #if defined(CONFIG_GSC_DINO) 381 dino_init(); 382 #endif 383 384 #ifdef CONFIG_CHASSIS_LCD_LED 385 register_led_regions(); /* register LED port info in procfs */ 386 #endif 387 388 return 0; 389 } 390 arch_initcall(parisc_init); 391 392 void __init start_parisc(void) 393 { 394 extern void early_trap_init(void); 395 396 int ret, cpunum; 397 struct pdc_coproc_cfg coproc_cfg; 398 399 cpunum = smp_processor_id(); 400 401 init_cpu_topology(); 402 403 set_firmware_width_unlocked(); 404 405 ret = pdc_coproc_cfg_unlocked(&coproc_cfg); 406 if (ret >= 0 && coproc_cfg.ccr_functional) { 407 mtctl(coproc_cfg.ccr_functional, 10); 408 409 per_cpu(cpu_data, cpunum).fp_rev = coproc_cfg.revision; 410 per_cpu(cpu_data, cpunum).fp_model = coproc_cfg.model; 411 412 asm volatile ("fstd %fr0,8(%sp)"); 413 } else { 414 panic("must have an fpu to boot linux"); 415 } 416 417 early_trap_init(); /* initialize checksum of fault_vector */ 418 419 start_kernel(); 420 // not reached 421 } 422