maple_setup.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /*
  2. * arch/ppc64/kernel/maple_setup.c
  3. *
  4. * (c) Copyright 2004 Benjamin Herrenschmidt (benh@kernel.crashing.org),
  5. * IBM Corp.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. *
  12. */
  13. #define DEBUG
  14. #include <linux/config.h>
  15. #include <linux/init.h>
  16. #include <linux/errno.h>
  17. #include <linux/sched.h>
  18. #include <linux/kernel.h>
  19. #include <linux/mm.h>
  20. #include <linux/stddef.h>
  21. #include <linux/unistd.h>
  22. #include <linux/ptrace.h>
  23. #include <linux/slab.h>
  24. #include <linux/user.h>
  25. #include <linux/a.out.h>
  26. #include <linux/tty.h>
  27. #include <linux/string.h>
  28. #include <linux/delay.h>
  29. #include <linux/ioport.h>
  30. #include <linux/major.h>
  31. #include <linux/initrd.h>
  32. #include <linux/vt_kern.h>
  33. #include <linux/console.h>
  34. #include <linux/ide.h>
  35. #include <linux/pci.h>
  36. #include <linux/adb.h>
  37. #include <linux/cuda.h>
  38. #include <linux/pmu.h>
  39. #include <linux/irq.h>
  40. #include <linux/seq_file.h>
  41. #include <linux/root_dev.h>
  42. #include <linux/serial.h>
  43. #include <linux/smp.h>
  44. #include <asm/processor.h>
  45. #include <asm/sections.h>
  46. #include <asm/prom.h>
  47. #include <asm/system.h>
  48. #include <asm/pgtable.h>
  49. #include <asm/bitops.h>
  50. #include <asm/io.h>
  51. #include <asm/pci-bridge.h>
  52. #include <asm/iommu.h>
  53. #include <asm/machdep.h>
  54. #include <asm/dma.h>
  55. #include <asm/cputable.h>
  56. #include <asm/time.h>
  57. #include <asm/of_device.h>
  58. #include <asm/lmb.h>
  59. #include "mpic.h"
  60. #ifdef DEBUG
  61. #define DBG(fmt...) udbg_printf(fmt)
  62. #else
  63. #define DBG(fmt...)
  64. #endif
  65. extern int maple_set_rtc_time(struct rtc_time *tm);
  66. extern void maple_get_rtc_time(struct rtc_time *tm);
  67. extern void maple_get_boot_time(struct rtc_time *tm);
  68. extern void maple_calibrate_decr(void);
  69. extern void maple_pci_init(void);
  70. extern void maple_pcibios_fixup(void);
  71. extern int maple_pci_get_legacy_ide_irq(struct pci_dev *dev, int channel);
  72. extern void generic_find_legacy_serial_ports(u64 *physport,
  73. unsigned int *default_speed);
  74. static void maple_restart(char *cmd)
  75. {
  76. }
  77. static void maple_power_off(void)
  78. {
  79. }
  80. static void maple_halt(void)
  81. {
  82. }
  83. #ifdef CONFIG_SMP
  84. struct smp_ops_t maple_smp_ops = {
  85. .probe = smp_mpic_probe,
  86. .message_pass = smp_mpic_message_pass,
  87. .kick_cpu = smp_generic_kick_cpu,
  88. .setup_cpu = smp_mpic_setup_cpu,
  89. .give_timebase = smp_generic_give_timebase,
  90. .take_timebase = smp_generic_take_timebase,
  91. };
  92. #endif /* CONFIG_SMP */
  93. void __init maple_setup_arch(void)
  94. {
  95. /* init to some ~sane value until calibrate_delay() runs */
  96. loops_per_jiffy = 50000000;
  97. /* Setup SMP callback */
  98. #ifdef CONFIG_SMP
  99. smp_ops = &maple_smp_ops;
  100. #endif
  101. /* Lookup PCI hosts */
  102. maple_pci_init();
  103. #ifdef CONFIG_DUMMY_CONSOLE
  104. conswitchp = &dummy_con;
  105. #endif
  106. }
  107. /*
  108. * Early initialization.
  109. */
  110. static void __init maple_init_early(void)
  111. {
  112. unsigned int default_speed;
  113. u64 physport;
  114. DBG(" -> maple_init_early\n");
  115. /* Initialize hash table, from now on, we can take hash faults
  116. * and call ioremap
  117. */
  118. hpte_init_native();
  119. /* Find the serial port */
  120. generic_find_legacy_serial_ports(&physport, &default_speed);
  121. DBG("phys port addr: %lx\n", (long)physport);
  122. if (physport) {
  123. void *comport;
  124. /* Map the uart for udbg. */
  125. comport = (void *)ioremap(physport, 16);
  126. udbg_init_uart(comport, default_speed);
  127. ppc_md.udbg_putc = udbg_putc;
  128. ppc_md.udbg_getc = udbg_getc;
  129. ppc_md.udbg_getc_poll = udbg_getc_poll;
  130. DBG("Hello World !\n");
  131. }
  132. /* Setup interrupt mapping options */
  133. ppc64_interrupt_controller = IC_OPEN_PIC;
  134. iommu_init_early_u3();
  135. DBG(" <- maple_init_early\n");
  136. }
  137. static __init void maple_init_IRQ(void)
  138. {
  139. struct device_node *root;
  140. unsigned int *opprop;
  141. unsigned long opic_addr;
  142. struct mpic *mpic;
  143. unsigned char senses[128];
  144. int n;
  145. DBG(" -> maple_init_IRQ\n");
  146. /* XXX: Non standard, replace that with a proper openpic/mpic node
  147. * in the device-tree. Find the Open PIC if present */
  148. root = of_find_node_by_path("/");
  149. opprop = (unsigned int *) get_property(root,
  150. "platform-open-pic", NULL);
  151. if (opprop == 0)
  152. panic("OpenPIC not found !\n");
  153. n = prom_n_addr_cells(root);
  154. for (opic_addr = 0; n > 0; --n)
  155. opic_addr = (opic_addr << 32) + *opprop++;
  156. of_node_put(root);
  157. /* Obtain sense values from device-tree */
  158. prom_get_irq_senses(senses, 0, 128);
  159. mpic = mpic_alloc(opic_addr,
  160. MPIC_PRIMARY | MPIC_BIG_ENDIAN |
  161. MPIC_BROKEN_U3 | MPIC_WANTS_RESET,
  162. 0, 0, 128, 128, senses, 128, "U3-MPIC");
  163. BUG_ON(mpic == NULL);
  164. mpic_init(mpic);
  165. DBG(" <- maple_init_IRQ\n");
  166. }
  167. static void __init maple_progress(char *s, unsigned short hex)
  168. {
  169. printk("*** %04x : %s\n", hex, s ? s : "");
  170. }
  171. /*
  172. * Called very early, MMU is off, device-tree isn't unflattened
  173. */
  174. static int __init maple_probe(int platform)
  175. {
  176. if (platform != PLATFORM_MAPLE)
  177. return 0;
  178. /*
  179. * On U3, the DART (iommu) must be allocated now since it
  180. * has an impact on htab_initialize (due to the large page it
  181. * occupies having to be broken up so the DART itself is not
  182. * part of the cacheable linar mapping
  183. */
  184. alloc_u3_dart_table();
  185. return 1;
  186. }
  187. struct machdep_calls __initdata maple_md = {
  188. .probe = maple_probe,
  189. .setup_arch = maple_setup_arch,
  190. .init_early = maple_init_early,
  191. .init_IRQ = maple_init_IRQ,
  192. .get_irq = mpic_get_irq,
  193. .pcibios_fixup = maple_pcibios_fixup,
  194. .pci_get_legacy_ide_irq = maple_pci_get_legacy_ide_irq,
  195. .restart = maple_restart,
  196. .power_off = maple_power_off,
  197. .halt = maple_halt,
  198. .get_boot_time = maple_get_boot_time,
  199. .set_rtc_time = maple_set_rtc_time,
  200. .get_rtc_time = maple_get_rtc_time,
  201. .calibrate_decr = maple_calibrate_decr,
  202. .progress = maple_progress,
  203. };