setup.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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/pdc_chassis.h>
  33. #include <asm/io.h>
  34. #include <asm/setup.h>
  35. #include <asm/unwind.h>
  36. #include <asm/smp.h>
  37. static char __initdata command_line[COMMAND_LINE_SIZE];
  38. static void __init setup_cmdline(char **cmdline_p)
  39. {
  40. extern unsigned int boot_args[];
  41. char *p;
  42. *cmdline_p = command_line;
  43. /* boot_args[0] is free-mem start, boot_args[1] is ptr to command line */
  44. if (boot_args[0] < 64)
  45. return; /* return if called from hpux boot loader */
  46. /* Collect stuff passed in from the boot loader */
  47. strscpy(boot_command_line, (char *)__va(boot_args[1]),
  48. COMMAND_LINE_SIZE);
  49. /* autodetect console type (if not done by palo yet) */
  50. p = boot_command_line;
  51. if (!str_has_prefix(p, "console=") && !strstr(p, " console=")) {
  52. strlcat(p, " console=", COMMAND_LINE_SIZE);
  53. if (PAGE0->mem_cons.cl_class == CL_DUPLEX)
  54. strlcat(p, "ttyS0", COMMAND_LINE_SIZE);
  55. else
  56. strlcat(p, "tty0", COMMAND_LINE_SIZE);
  57. }
  58. /* default to use early console */
  59. if (!strstr(p, "earlycon"))
  60. strlcat(p, " earlycon=pdc", COMMAND_LINE_SIZE);
  61. #ifdef CONFIG_BLK_DEV_INITRD
  62. /* did palo pass us a ramdisk? */
  63. if (boot_args[2] != 0) {
  64. initrd_start = (unsigned long)__va(boot_args[2]);
  65. initrd_end = (unsigned long)__va(boot_args[3]);
  66. }
  67. #endif
  68. strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
  69. }
  70. #ifdef CONFIG_PA11
  71. static void __init dma_ops_init(void)
  72. {
  73. switch (boot_cpu_data.cpu_type) {
  74. case pcx:
  75. /*
  76. * We've got way too many dependencies on 1.1 semantics
  77. * to support 1.0 boxes at this point.
  78. */
  79. panic( "PA-RISC Linux currently only supports machines that conform to\n"
  80. "the PA-RISC 1.1 or 2.0 architecture specification.\n");
  81. case pcxl2:
  82. default:
  83. break;
  84. }
  85. }
  86. #endif
  87. void __init setup_arch(char **cmdline_p)
  88. {
  89. unwind_init();
  90. init_per_cpu(smp_processor_id()); /* Set Modes & Enable FP */
  91. #ifdef CONFIG_64BIT
  92. printk(KERN_INFO "The 64-bit Kernel has started...\n");
  93. #else
  94. printk(KERN_INFO "The 32-bit Kernel has started...\n");
  95. #endif
  96. printk(KERN_INFO "Kernel default page size is %d KB. Huge pages ",
  97. (int)(PAGE_SIZE / 1024));
  98. #ifdef CONFIG_HUGETLB_PAGE
  99. printk(KERN_CONT "enabled with %d MB physical and %d MB virtual size",
  100. 1 << (REAL_HPAGE_SHIFT - 20), 1 << (HPAGE_SHIFT - 20));
  101. #else
  102. printk(KERN_CONT "disabled");
  103. #endif
  104. printk(KERN_CONT ".\n");
  105. /*
  106. * Check if initial kernel page mappings are sufficient.
  107. * panic early if not, else we may access kernel functions
  108. * and variables which can't be reached.
  109. */
  110. if (__pa((unsigned long) &_end) >= KERNEL_INITIAL_SIZE)
  111. panic("KERNEL_INITIAL_ORDER too small!");
  112. #ifdef CONFIG_64BIT
  113. if(parisc_narrow_firmware) {
  114. printk(KERN_INFO "Kernel is using PDC in 32-bit mode.\n");
  115. }
  116. #endif
  117. setup_pdc();
  118. setup_cmdline(cmdline_p);
  119. collect_boot_cpu_data();
  120. do_memory_inventory(); /* probe for physical memory */
  121. parisc_cache_init();
  122. paging_init();
  123. #ifdef CONFIG_PA11
  124. dma_ops_init();
  125. #endif
  126. clear_sched_clock_stable();
  127. }
  128. /*
  129. * Display CPU info for all CPUs.
  130. */
  131. static void *
  132. c_start (struct seq_file *m, loff_t *pos)
  133. {
  134. /* Looks like the caller will call repeatedly until we return
  135. * 0, signaling EOF perhaps. This could be used to sequence
  136. * through CPUs for example. Since we print all cpu info in our
  137. * show_cpuinfo() disregarding 'pos' (which I assume is 'v' above)
  138. * we only allow for one "position". */
  139. return ((long)*pos < 1) ? (void *)1 : NULL;
  140. }
  141. static void *
  142. c_next (struct seq_file *m, void *v, loff_t *pos)
  143. {
  144. ++*pos;
  145. return c_start(m, pos);
  146. }
  147. static void
  148. c_stop (struct seq_file *m, void *v)
  149. {
  150. }
  151. const struct seq_operations cpuinfo_op = {
  152. .start = c_start,
  153. .next = c_next,
  154. .stop = c_stop,
  155. .show = show_cpuinfo
  156. };
  157. static struct resource central_bus = {
  158. .name = "Central Bus",
  159. .start = F_EXTEND(0xfff80000),
  160. .end = F_EXTEND(0xfffaffff),
  161. .flags = IORESOURCE_MEM,
  162. };
  163. static struct resource local_broadcast = {
  164. .name = "Local Broadcast",
  165. .start = F_EXTEND(0xfffb0000),
  166. .end = F_EXTEND(0xfffdffff),
  167. .flags = IORESOURCE_MEM,
  168. };
  169. static struct resource global_broadcast = {
  170. .name = "Global Broadcast",
  171. .start = F_EXTEND(0xfffe0000),
  172. .end = F_EXTEND(0xffffffff),
  173. .flags = IORESOURCE_MEM,
  174. };
  175. static int __init parisc_init_resources(void)
  176. {
  177. int result;
  178. result = request_resource(&iomem_resource, &central_bus);
  179. if (result < 0) {
  180. printk(KERN_ERR
  181. "%s: failed to claim %s address space!\n",
  182. __FILE__, central_bus.name);
  183. return result;
  184. }
  185. result = request_resource(&iomem_resource, &local_broadcast);
  186. if (result < 0) {
  187. printk(KERN_ERR
  188. "%s: failed to claim %s address space!\n",
  189. __FILE__, local_broadcast.name);
  190. return result;
  191. }
  192. result = request_resource(&iomem_resource, &global_broadcast);
  193. if (result < 0) {
  194. printk(KERN_ERR
  195. "%s: failed to claim %s address space!\n",
  196. __FILE__, global_broadcast.name);
  197. return result;
  198. }
  199. return 0;
  200. }
  201. static int __init parisc_init(void)
  202. {
  203. u32 osid = (OS_ID_LINUX << 16);
  204. parisc_init_resources();
  205. do_device_inventory(); /* probe for hardware */
  206. parisc_pdc_chassis_init();
  207. /* set up a new led state on systems shipped LED State panel */
  208. pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BSTART);
  209. /* tell PDC we're Linux. Nevermind failure. */
  210. pdc_stable_write(0x40, &osid, sizeof(osid));
  211. /* start with known state */
  212. flush_cache_all_local();
  213. flush_tlb_all_local(NULL);
  214. processor_init();
  215. #ifdef CONFIG_SMP
  216. pr_info("CPU(s): %d out of %d %s at %d.%06d MHz online\n",
  217. num_online_cpus(), num_present_cpus(),
  218. #else
  219. pr_info("CPU(s): 1 x %s at %d.%06d MHz\n",
  220. #endif
  221. boot_cpu_data.cpu_name,
  222. boot_cpu_data.cpu_hz / 1000000,
  223. boot_cpu_data.cpu_hz % 1000000 );
  224. #if defined(CONFIG_64BIT) && defined(CONFIG_SMP)
  225. /* Don't serialize TLB flushes if we run on one CPU only. */
  226. if (num_online_cpus() == 1)
  227. pa_serialize_tlb_flushes = 0;
  228. #endif
  229. apply_alternatives_all();
  230. parisc_setup_cache_timing();
  231. return 0;
  232. }
  233. arch_initcall(parisc_init);
  234. void __init start_parisc(void)
  235. {
  236. int ret, cpunum;
  237. struct pdc_coproc_cfg coproc_cfg;
  238. /* check QEMU/SeaBIOS marker in PAGE0 */
  239. running_on_qemu = (memcmp(&PAGE0->pad0, "SeaBIOS", 8) == 0);
  240. cpunum = smp_processor_id();
  241. init_cpu_topology();
  242. set_firmware_width_unlocked();
  243. ret = pdc_coproc_cfg_unlocked(&coproc_cfg);
  244. if (ret >= 0 && coproc_cfg.ccr_functional) {
  245. mtctl(coproc_cfg.ccr_functional, 10);
  246. per_cpu(cpu_data, cpunum).fp_rev = coproc_cfg.revision;
  247. per_cpu(cpu_data, cpunum).fp_model = coproc_cfg.model;
  248. asm volatile ("fstd %fr0,8(%sp)");
  249. } else {
  250. panic("must have an fpu to boot linux");
  251. }
  252. early_trap_init(); /* initialize checksum of fault_vector */
  253. start_kernel();
  254. // not reached
  255. }