setup.c 9.9 KB

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