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