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