setup.c 9.4 KB

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