mpc86xx_hpcn.c 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. /*
  2. * MPC86xx HPCN board specific routines
  3. *
  4. * Recode: ZHANG WEI <wei.zhang@freescale.com>
  5. * Initial author: Xianghua Xiao <x.xiao@freescale.com>
  6. *
  7. * Copyright 2006 Freescale Semiconductor Inc.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. */
  14. #include <linux/stddef.h>
  15. #include <linux/kernel.h>
  16. #include <linux/pci.h>
  17. #include <linux/kdev_t.h>
  18. #include <linux/delay.h>
  19. #include <linux/seq_file.h>
  20. #include <linux/root_dev.h>
  21. #include <asm/system.h>
  22. #include <asm/time.h>
  23. #include <asm/machdep.h>
  24. #include <asm/pci-bridge.h>
  25. #include <asm/mpc86xx.h>
  26. #include <asm/prom.h>
  27. #include <mm/mmu_decl.h>
  28. #include <asm/udbg.h>
  29. #include <asm/i8259.h>
  30. #include <asm/mpic.h>
  31. #include <sysdev/fsl_soc.h>
  32. #include "mpc86xx.h"
  33. #ifndef CONFIG_PCI
  34. unsigned long isa_io_base = 0;
  35. unsigned long isa_mem_base = 0;
  36. unsigned long pci_dram_offset = 0;
  37. #endif
  38. /*
  39. * Internal interrupts are all Level Sensitive, and Positive Polarity
  40. */
  41. static u_char mpc86xx_hpcn_openpic_initsenses[] __initdata = {
  42. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 0: Reserved */
  43. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 1: MCM */
  44. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 2: DDR DRAM */
  45. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 3: LBIU */
  46. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 4: DMA 0 */
  47. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 5: DMA 1 */
  48. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 6: DMA 2 */
  49. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 7: DMA 3 */
  50. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 8: PCIE1 */
  51. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 9: PCIE2 */
  52. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 10: Reserved */
  53. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 11: Reserved */
  54. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 12: DUART2 */
  55. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 13: TSEC 1 Transmit */
  56. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 14: TSEC 1 Receive */
  57. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 15: TSEC 3 transmit */
  58. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 16: TSEC 3 receive */
  59. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 17: TSEC 3 error */
  60. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 18: TSEC 1 Receive/Transmit Error */
  61. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 19: TSEC 2 Transmit */
  62. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 20: TSEC 2 Receive */
  63. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 21: TSEC 4 transmit */
  64. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 22: TSEC 4 receive */
  65. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 23: TSEC 4 error */
  66. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 24: TSEC 2 Receive/Transmit Error */
  67. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 25: Unused */
  68. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 26: DUART1 */
  69. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 27: I2C */
  70. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 28: Performance Monitor */
  71. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 29: Unused */
  72. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 30: Unused */
  73. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 31: Unused */
  74. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 32: SRIO error/write-port unit */
  75. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 33: SRIO outbound doorbell */
  76. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 34: SRIO inbound doorbell */
  77. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 35: Unused */
  78. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 36: Unused */
  79. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 37: SRIO outbound message unit 1 */
  80. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 38: SRIO inbound message unit 1 */
  81. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 39: SRIO outbound message unit 2 */
  82. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 40: SRIO inbound message unit 2 */
  83. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 41: Unused */
  84. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 42: Unused */
  85. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 43: Unused */
  86. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 44: Unused */
  87. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 45: Unused */
  88. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 46: Unused */
  89. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 47: Unused */
  90. 0x0, /* External 0: */
  91. 0x0, /* External 1: */
  92. 0x0, /* External 2: */
  93. 0x0, /* External 3: */
  94. 0x0, /* External 4: */
  95. 0x0, /* External 5: */
  96. 0x0, /* External 6: */
  97. 0x0, /* External 7: */
  98. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 8: Pixis FPGA */
  99. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* External 9: ULI 8259 INTR Cascade */
  100. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 10: Quad ETH PHY */
  101. 0x0, /* External 11: */
  102. 0x0,
  103. 0x0,
  104. 0x0,
  105. 0x0,
  106. };
  107. void __init
  108. mpc86xx_hpcn_init_irq(void)
  109. {
  110. struct mpic *mpic1;
  111. phys_addr_t openpic_paddr;
  112. /* Determine the Physical Address of the OpenPIC regs */
  113. openpic_paddr = get_immrbase() + MPC86xx_OPENPIC_OFFSET;
  114. /* Alloc mpic structure and per isu has 16 INT entries. */
  115. mpic1 = mpic_alloc(openpic_paddr,
  116. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  117. 16, MPC86xx_OPENPIC_IRQ_OFFSET, 0, 250,
  118. mpc86xx_hpcn_openpic_initsenses,
  119. sizeof(mpc86xx_hpcn_openpic_initsenses),
  120. " MPIC ");
  121. BUG_ON(mpic1 == NULL);
  122. /* 48 Internal Interrupts */
  123. mpic_assign_isu(mpic1, 0, openpic_paddr + 0x10200);
  124. mpic_assign_isu(mpic1, 1, openpic_paddr + 0x10400);
  125. mpic_assign_isu(mpic1, 2, openpic_paddr + 0x10600);
  126. /* 16 External interrupts */
  127. mpic_assign_isu(mpic1, 3, openpic_paddr + 0x10000);
  128. mpic_init(mpic1);
  129. #ifdef CONFIG_PCI
  130. mpic_setup_cascade(MPC86xx_IRQ_EXT9, i8259_irq_cascade, NULL);
  131. i8259_init(0, I8259_OFFSET);
  132. #endif
  133. }
  134. #ifdef CONFIG_PCI
  135. /*
  136. * interrupt routing
  137. */
  138. int
  139. mpc86xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  140. {
  141. static char pci_irq_table[][4] = {
  142. /*
  143. * PCI IDSEL/INTPIN->INTLINE
  144. * A B C D
  145. */
  146. {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 17 -- PCI Slot 1 */
  147. {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 18 -- PCI Slot 2 */
  148. {0, 0, 0, 0}, /* IDSEL 19 */
  149. {0, 0, 0, 0}, /* IDSEL 20 */
  150. {0, 0, 0, 0}, /* IDSEL 21 */
  151. {0, 0, 0, 0}, /* IDSEL 22 */
  152. {0, 0, 0, 0}, /* IDSEL 23 */
  153. {0, 0, 0, 0}, /* IDSEL 24 */
  154. {0, 0, 0, 0}, /* IDSEL 25 */
  155. {PIRQD, PIRQA, PIRQB, PIRQC}, /* IDSEL 26 -- PCI Bridge*/
  156. {PIRQC, 0, 0, 0}, /* IDSEL 27 -- LAN */
  157. {PIRQE, PIRQF, PIRQH, PIRQ7}, /* IDSEL 28 -- USB 1.1 */
  158. {PIRQE, PIRQF, PIRQG, 0}, /* IDSEL 29 -- Audio & Modem */
  159. {PIRQH, 0, 0, 0}, /* IDSEL 30 -- LPC & PMU*/
  160. {PIRQD, 0, 0, 0}, /* IDSEL 31 -- ATA */
  161. };
  162. const long min_idsel = 17, max_idsel = 31, irqs_per_slot = 4;
  163. return PCI_IRQ_TABLE_LOOKUP + I8259_OFFSET;
  164. }
  165. int
  166. mpc86xx_exclude_device(u_char bus, u_char devfn)
  167. {
  168. #if !defined(CONFIG_PCI)
  169. if (bus == 0 && PCI_SLOT(devfn) == 0)
  170. return PCIBIOS_DEVICE_NOT_FOUND;
  171. #endif
  172. return PCIBIOS_SUCCESSFUL;
  173. }
  174. #endif /* CONFIG_PCI */
  175. static void __init
  176. mpc86xx_hpcn_setup_arch(void)
  177. {
  178. struct device_node *np;
  179. if (ppc_md.progress)
  180. ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
  181. np = of_find_node_by_type(NULL, "cpu");
  182. if (np != 0) {
  183. unsigned int *fp;
  184. fp = (int *)get_property(np, "clock-frequency", NULL);
  185. if (fp != 0)
  186. loops_per_jiffy = *fp / HZ;
  187. else
  188. loops_per_jiffy = 50000000 / HZ;
  189. of_node_put(np);
  190. }
  191. #ifdef CONFIG_PCI
  192. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  193. add_bridge(np);
  194. ppc_md.pci_swizzle = common_swizzle;
  195. ppc_md.pci_map_irq = mpc86xx_map_irq;
  196. ppc_md.pci_exclude_device = mpc86xx_exclude_device;
  197. #endif
  198. printk("MPC86xx HPCN board from Freescale Semiconductor\n");
  199. #ifdef CONFIG_ROOT_NFS
  200. ROOT_DEV = Root_NFS;
  201. #else
  202. ROOT_DEV = Root_HDA1;
  203. #endif
  204. #ifdef CONFIG_SMP
  205. mpc86xx_smp_init();
  206. #endif
  207. }
  208. void
  209. mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
  210. {
  211. struct device_node *root;
  212. uint memsize = total_memory;
  213. const char *model = "";
  214. uint svid = mfspr(SPRN_SVR);
  215. seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
  216. root = of_find_node_by_path("/");
  217. if (root)
  218. model = get_property(root, "model", NULL);
  219. seq_printf(m, "Machine\t\t: %s\n", model);
  220. of_node_put(root);
  221. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  222. seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
  223. }
  224. /*
  225. * Called very early, device-tree isn't unflattened
  226. */
  227. static int __init mpc86xx_hpcn_probe(void)
  228. {
  229. unsigned long root = of_get_flat_dt_root();
  230. if (of_flat_dt_is_compatible(root, "mpc86xx"))
  231. return 1; /* Looks good */
  232. return 0;
  233. }
  234. void
  235. mpc86xx_restart(char *cmd)
  236. {
  237. void __iomem *rstcr;
  238. rstcr = ioremap(get_immrbase() + MPC86XX_RSTCR_OFFSET, 0x100);
  239. local_irq_disable();
  240. /* Assert reset request to Reset Control Register */
  241. out_be32(rstcr, 0x2);
  242. /* not reached */
  243. }
  244. long __init
  245. mpc86xx_time_init(void)
  246. {
  247. unsigned int temp;
  248. /* Set the time base to zero */
  249. mtspr(SPRN_TBWL, 0);
  250. mtspr(SPRN_TBWU, 0);
  251. temp = mfspr(SPRN_HID0);
  252. temp |= HID0_TBEN;
  253. mtspr(SPRN_HID0, temp);
  254. asm volatile("isync");
  255. return 0;
  256. }
  257. define_machine(mpc86xx_hpcn) {
  258. .name = "MPC86xx HPCN",
  259. .probe = mpc86xx_hpcn_probe,
  260. .setup_arch = mpc86xx_hpcn_setup_arch,
  261. .init_IRQ = mpc86xx_hpcn_init_irq,
  262. .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo,
  263. .get_irq = mpic_get_irq,
  264. .restart = mpc86xx_restart,
  265. .time_init = mpc86xx_time_init,
  266. .calibrate_decr = generic_calibrate_decr,
  267. .progress = udbg_progress,
  268. };