setup.c 9.8 KB

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