setup.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /*
  2. * Copyright (C) 2006-2007 PA Semi, Inc
  3. *
  4. * Authors: Kip Walker, PA Semi
  5. * Olof Johansson, PA Semi
  6. *
  7. * Maintained by: Olof Johansson <olof@lixom.net>
  8. *
  9. * Based on arch/powerpc/platforms/maple/setup.c
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. #include <linux/errno.h>
  25. #include <linux/kernel.h>
  26. #include <linux/delay.h>
  27. #include <linux/console.h>
  28. #include <linux/pci.h>
  29. #include <asm/prom.h>
  30. #include <asm/system.h>
  31. #include <asm/iommu.h>
  32. #include <asm/machdep.h>
  33. #include <asm/mpic.h>
  34. #include <asm/smp.h>
  35. #include <asm/time.h>
  36. #include <asm/of_platform.h>
  37. #include "pasemi.h"
  38. static void __iomem *reset_reg;
  39. static void pas_restart(char *cmd)
  40. {
  41. printk("Restarting...\n");
  42. while (1)
  43. out_le32(reset_reg, 0x6000000);
  44. }
  45. #ifdef CONFIG_SMP
  46. static DEFINE_SPINLOCK(timebase_lock);
  47. static void __devinit pas_give_timebase(void)
  48. {
  49. unsigned long tb;
  50. spin_lock(&timebase_lock);
  51. mtspr(SPRN_TBCTL, TBCTL_FREEZE);
  52. tb = mftb();
  53. mtspr(SPRN_TBCTL, TBCTL_UPDATE_LOWER | (tb & 0xffffffff));
  54. mtspr(SPRN_TBCTL, TBCTL_UPDATE_UPPER | (tb >> 32));
  55. mtspr(SPRN_TBCTL, TBCTL_RESTART);
  56. spin_unlock(&timebase_lock);
  57. pr_debug("pas_give_timebase: cpu %d gave tb %lx\n",
  58. smp_processor_id(), tb);
  59. }
  60. static void __devinit pas_take_timebase(void)
  61. {
  62. pr_debug("pas_take_timebase: cpu %d has tb %lx\n",
  63. smp_processor_id(), mftb());
  64. }
  65. struct smp_ops_t pas_smp_ops = {
  66. .probe = smp_mpic_probe,
  67. .message_pass = smp_mpic_message_pass,
  68. .kick_cpu = smp_generic_kick_cpu,
  69. .setup_cpu = smp_mpic_setup_cpu,
  70. .give_timebase = pas_give_timebase,
  71. .take_timebase = pas_take_timebase,
  72. };
  73. #endif /* CONFIG_SMP */
  74. void __init pas_setup_arch(void)
  75. {
  76. #ifdef CONFIG_SMP
  77. /* Setup SMP callback */
  78. smp_ops = &pas_smp_ops;
  79. #endif
  80. /* Lookup PCI hosts */
  81. pas_pci_init();
  82. #ifdef CONFIG_DUMMY_CONSOLE
  83. conswitchp = &dummy_con;
  84. #endif
  85. /* Remap SDC register for doing reset */
  86. /* XXXOJN This should maybe come out of the device tree */
  87. reset_reg = ioremap(0xfc101100, 4);
  88. pasemi_idle_init();
  89. }
  90. static __init void pas_init_IRQ(void)
  91. {
  92. struct device_node *np;
  93. struct device_node *root, *mpic_node;
  94. unsigned long openpic_addr;
  95. const unsigned int *opprop;
  96. int naddr, opplen;
  97. struct mpic *mpic;
  98. mpic_node = NULL;
  99. for_each_node_by_type(np, "interrupt-controller")
  100. if (of_device_is_compatible(np, "open-pic")) {
  101. mpic_node = np;
  102. break;
  103. }
  104. if (!mpic_node)
  105. for_each_node_by_type(np, "open-pic") {
  106. mpic_node = np;
  107. break;
  108. }
  109. if (!mpic_node) {
  110. printk(KERN_ERR
  111. "Failed to locate the MPIC interrupt controller\n");
  112. return;
  113. }
  114. /* Find address list in /platform-open-pic */
  115. root = of_find_node_by_path("/");
  116. naddr = of_n_addr_cells(root);
  117. opprop = of_get_property(root, "platform-open-pic", &opplen);
  118. if (!opprop) {
  119. printk(KERN_ERR "No platform-open-pic property.\n");
  120. of_node_put(root);
  121. return;
  122. }
  123. openpic_addr = of_read_number(opprop, naddr);
  124. printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
  125. mpic = mpic_alloc(mpic_node, openpic_addr,
  126. MPIC_PRIMARY|MPIC_LARGE_VECTORS|MPIC_WANTS_RESET,
  127. 0, 0, " PAS-OPIC ");
  128. BUG_ON(!mpic);
  129. mpic_assign_isu(mpic, 0, openpic_addr + 0x10000);
  130. mpic_init(mpic);
  131. of_node_put(mpic_node);
  132. of_node_put(root);
  133. }
  134. static void __init pas_progress(char *s, unsigned short hex)
  135. {
  136. printk("[%04x] : %s\n", hex, s ? s : "");
  137. }
  138. static int pas_machine_check_handler(struct pt_regs *regs)
  139. {
  140. int cpu = smp_processor_id();
  141. unsigned long srr0, srr1, dsisr;
  142. srr0 = regs->nip;
  143. srr1 = regs->msr;
  144. dsisr = mfspr(SPRN_DSISR);
  145. printk(KERN_ERR "Machine Check on CPU %d\n", cpu);
  146. printk(KERN_ERR "SRR0 0x%016lx SRR1 0x%016lx\n", srr0, srr1);
  147. printk(KERN_ERR "DSISR 0x%016lx DAR 0x%016lx\n", dsisr, regs->dar);
  148. printk(KERN_ERR "Cause:\n");
  149. if (srr1 & 0x200000)
  150. printk(KERN_ERR "Signalled by SDC\n");
  151. if (srr1 & 0x100000) {
  152. printk(KERN_ERR "Load/Store detected error:\n");
  153. if (dsisr & 0x8000)
  154. printk(KERN_ERR "D-cache ECC double-bit error or bus error\n");
  155. if (dsisr & 0x4000)
  156. printk(KERN_ERR "LSU snoop response error\n");
  157. if (dsisr & 0x2000)
  158. printk(KERN_ERR "MMU SLB multi-hit or invalid B field\n");
  159. if (dsisr & 0x1000)
  160. printk(KERN_ERR "Recoverable Duptags\n");
  161. if (dsisr & 0x800)
  162. printk(KERN_ERR "Recoverable D-cache parity error count overflow\n");
  163. if (dsisr & 0x400)
  164. printk(KERN_ERR "TLB parity error count overflow\n");
  165. }
  166. if (srr1 & 0x80000)
  167. printk(KERN_ERR "Bus Error\n");
  168. if (srr1 & 0x40000)
  169. printk(KERN_ERR "I-side SLB multiple hit\n");
  170. if (srr1 & 0x20000)
  171. printk(KERN_ERR "I-cache parity error hit\n");
  172. /* SRR1[62] is from MSR[62] if recoverable, so pass that back */
  173. return !!(srr1 & 0x2);
  174. }
  175. static void __init pas_init_early(void)
  176. {
  177. iommu_init_early_pasemi();
  178. }
  179. static struct of_device_id pasemi_bus_ids[] = {
  180. { .type = "sdc", },
  181. {},
  182. };
  183. static int __init pasemi_publish_devices(void)
  184. {
  185. if (!machine_is(pasemi))
  186. return 0;
  187. /* Publish OF platform devices for SDC and other non-PCI devices */
  188. of_platform_bus_probe(NULL, pasemi_bus_ids, NULL);
  189. return 0;
  190. }
  191. device_initcall(pasemi_publish_devices);
  192. /*
  193. * Called very early, MMU is off, device-tree isn't unflattened
  194. */
  195. static int __init pas_probe(void)
  196. {
  197. unsigned long root = of_get_flat_dt_root();
  198. if (!of_flat_dt_is_compatible(root, "PA6T-1682M"))
  199. return 0;
  200. hpte_init_native();
  201. alloc_iobmap_l2();
  202. return 1;
  203. }
  204. define_machine(pasemi) {
  205. .name = "PA Semi PA6T-1682M",
  206. .probe = pas_probe,
  207. .setup_arch = pas_setup_arch,
  208. .init_early = pas_init_early,
  209. .init_IRQ = pas_init_IRQ,
  210. .get_irq = mpic_get_irq,
  211. .restart = pas_restart,
  212. .get_boot_time = pas_get_boot_time,
  213. .calibrate_decr = generic_calibrate_decr,
  214. .progress = pas_progress,
  215. .machine_check_exception = pas_machine_check_handler,
  216. };