mpc86xx_hpcn.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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/config.h>
  15. #include <linux/stddef.h>
  16. #include <linux/kernel.h>
  17. #include <linux/pci.h>
  18. #include <linux/kdev_t.h>
  19. #include <linux/delay.h>
  20. #include <linux/seq_file.h>
  21. #include <linux/root_dev.h>
  22. #include <asm/system.h>
  23. #include <asm/time.h>
  24. #include <asm/machdep.h>
  25. #include <asm/pci-bridge.h>
  26. #include <asm/mpc86xx.h>
  27. #include <asm/prom.h>
  28. #include <mm/mmu_decl.h>
  29. #include <asm/udbg.h>
  30. #include <asm/i8259.h>
  31. #include <asm/mpic.h>
  32. #include <sysdev/fsl_soc.h>
  33. #include "mpc86xx.h"
  34. #include "mpc8641_hpcn.h"
  35. #ifndef CONFIG_PCI
  36. unsigned long isa_io_base = 0;
  37. unsigned long isa_mem_base = 0;
  38. unsigned long pci_dram_offset = 0;
  39. #endif
  40. /*
  41. * Internal interrupts are all Level Sensitive, and Positive Polarity
  42. */
  43. static u_char mpc86xx_hpcn_openpic_initsenses[] __initdata = {
  44. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 0: Reserved */
  45. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 1: MCM */
  46. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 2: DDR DRAM */
  47. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 3: LBIU */
  48. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 4: DMA 0 */
  49. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 5: DMA 1 */
  50. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 6: DMA 2 */
  51. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 7: DMA 3 */
  52. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 8: PCIE1 */
  53. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 9: PCIE2 */
  54. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 10: Reserved */
  55. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 11: Reserved */
  56. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 12: DUART2 */
  57. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 13: TSEC 1 Transmit */
  58. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 14: TSEC 1 Receive */
  59. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 15: TSEC 3 transmit */
  60. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 16: TSEC 3 receive */
  61. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 17: TSEC 3 error */
  62. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 18: TSEC 1 Receive/Transmit Error */
  63. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 19: TSEC 2 Transmit */
  64. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 20: TSEC 2 Receive */
  65. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 21: TSEC 4 transmit */
  66. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 22: TSEC 4 receive */
  67. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 23: TSEC 4 error */
  68. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 24: TSEC 2 Receive/Transmit Error */
  69. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 25: Unused */
  70. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 26: DUART1 */
  71. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 27: I2C */
  72. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 28: Performance Monitor */
  73. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 29: Unused */
  74. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 30: Unused */
  75. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 31: Unused */
  76. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 32: SRIO error/write-port unit */
  77. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 33: SRIO outbound doorbell */
  78. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 34: SRIO inbound doorbell */
  79. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 35: Unused */
  80. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 36: Unused */
  81. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 37: SRIO outbound message unit 1 */
  82. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 38: SRIO inbound message unit 1 */
  83. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 39: SRIO outbound message unit 2 */
  84. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 40: SRIO inbound message unit 2 */
  85. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 41: Unused */
  86. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 42: Unused */
  87. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 43: Unused */
  88. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 44: Unused */
  89. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 45: Unused */
  90. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 46: Unused */
  91. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 47: Unused */
  92. 0x0, /* External 0: */
  93. 0x0, /* External 1: */
  94. 0x0, /* External 2: */
  95. 0x0, /* External 3: */
  96. 0x0, /* External 4: */
  97. 0x0, /* External 5: */
  98. 0x0, /* External 6: */
  99. 0x0, /* External 7: */
  100. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 8: Pixis FPGA */
  101. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* External 9: ULI 8259 INTR Cascade */
  102. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 10: Quad ETH PHY */
  103. 0x0, /* External 11: */
  104. 0x0,
  105. 0x0,
  106. 0x0,
  107. 0x0,
  108. };
  109. void __init
  110. mpc86xx_hpcn_init_irq(void)
  111. {
  112. struct mpic *mpic1;
  113. phys_addr_t openpic_paddr;
  114. /* Determine the Physical Address of the OpenPIC regs */
  115. openpic_paddr = get_immrbase() + MPC86xx_OPENPIC_OFFSET;
  116. /* Alloc mpic structure and per isu has 16 INT entries. */
  117. mpic1 = mpic_alloc(openpic_paddr,
  118. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  119. 16, MPC86xx_OPENPIC_IRQ_OFFSET, 0, 250,
  120. mpc86xx_hpcn_openpic_initsenses,
  121. sizeof(mpc86xx_hpcn_openpic_initsenses),
  122. " MPIC ");
  123. BUG_ON(mpic1 == NULL);
  124. /* 48 Internal Interrupts */
  125. mpic_assign_isu(mpic1, 0, openpic_paddr + 0x10200);
  126. mpic_assign_isu(mpic1, 1, openpic_paddr + 0x10400);
  127. mpic_assign_isu(mpic1, 2, openpic_paddr + 0x10600);
  128. /* 16 External interrupts */
  129. mpic_assign_isu(mpic1, 3, openpic_paddr + 0x10000);
  130. mpic_init(mpic1);
  131. #ifdef CONFIG_PCI
  132. mpic_setup_cascade(MPC86xx_IRQ_EXT9, i8259_irq_cascade, NULL);
  133. i8259_init(0, I8259_OFFSET);
  134. #endif
  135. }
  136. #ifdef CONFIG_PCI
  137. /*
  138. * interrupt routing
  139. */
  140. int
  141. mpc86xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  142. {
  143. static char pci_irq_table[][4] = {
  144. /*
  145. * PCI IDSEL/INTPIN->INTLINE
  146. * A B C D
  147. */
  148. {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 17 -- PCI Slot 1 */
  149. {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 18 -- PCI Slot 2 */
  150. {0, 0, 0, 0}, /* IDSEL 19 */
  151. {0, 0, 0, 0}, /* IDSEL 20 */
  152. {0, 0, 0, 0}, /* IDSEL 21 */
  153. {0, 0, 0, 0}, /* IDSEL 22 */
  154. {0, 0, 0, 0}, /* IDSEL 23 */
  155. {0, 0, 0, 0}, /* IDSEL 24 */
  156. {0, 0, 0, 0}, /* IDSEL 25 */
  157. {PIRQD, PIRQA, PIRQB, PIRQC}, /* IDSEL 26 -- PCI Bridge*/
  158. {PIRQC, 0, 0, 0}, /* IDSEL 27 -- LAN */
  159. {PIRQE, PIRQF, PIRQH, PIRQ7}, /* IDSEL 28 -- USB 1.1 */
  160. {PIRQE, PIRQF, PIRQG, 0}, /* IDSEL 29 -- Audio & Modem */
  161. {PIRQH, 0, 0, 0}, /* IDSEL 30 -- LPC & PMU*/
  162. {PIRQD, 0, 0, 0}, /* IDSEL 31 -- ATA */
  163. };
  164. const long min_idsel = 17, max_idsel = 31, irqs_per_slot = 4;
  165. return PCI_IRQ_TABLE_LOOKUP + I8259_OFFSET;
  166. }
  167. static void __devinit quirk_ali1575(struct pci_dev *dev)
  168. {
  169. unsigned short temp;
  170. /*
  171. * ALI1575 interrupts route table setup:
  172. *
  173. * IRQ pin IRQ#
  174. * PIRQA ---- 3
  175. * PIRQB ---- 4
  176. * PIRQC ---- 5
  177. * PIRQD ---- 6
  178. * PIRQE ---- 9
  179. * PIRQF ---- 10
  180. * PIRQG ---- 11
  181. * PIRQH ---- 12
  182. *
  183. * interrupts for PCI slot0 -- PIRQA / PIRQB / PIRQC / PIRQD
  184. * PCI slot1 -- PIRQB / PIRQC / PIRQD / PIRQA
  185. */
  186. pci_write_config_dword(dev, 0x48, 0xb9317542);
  187. /* USB 1.1 OHCI controller 1, interrupt: PIRQE */
  188. pci_write_config_byte(dev, 0x86, 0x0c);
  189. /* USB 1.1 OHCI controller 2, interrupt: PIRQF */
  190. pci_write_config_byte(dev, 0x87, 0x0d);
  191. /* USB 1.1 OHCI controller 3, interrupt: PIRQH */
  192. pci_write_config_byte(dev, 0x88, 0x0f);
  193. /* USB 2.0 controller, interrupt: PIRQ7 */
  194. pci_write_config_byte(dev, 0x74, 0x06);
  195. /* Audio controller, interrupt: PIRQE */
  196. pci_write_config_byte(dev, 0x8a, 0x0c);
  197. /* Modem controller, interrupt: PIRQF */
  198. pci_write_config_byte(dev, 0x8b, 0x0d);
  199. /* HD audio controller, interrupt: PIRQG */
  200. pci_write_config_byte(dev, 0x8c, 0x0e);
  201. /* Serial ATA interrupt: PIRQD */
  202. pci_write_config_byte(dev, 0x8d, 0x0b);
  203. /* SMB interrupt: PIRQH */
  204. pci_write_config_byte(dev, 0x8e, 0x0f);
  205. /* PMU ACPI SCI interrupt: PIRQH */
  206. pci_write_config_byte(dev, 0x8f, 0x0f);
  207. /* Primary PATA IDE IRQ: 14
  208. * Secondary PATA IDE IRQ: 15
  209. */
  210. pci_write_config_byte(dev, 0x44, 0x3d);
  211. pci_write_config_byte(dev, 0x75, 0x0f);
  212. /* Set IRQ14 and IRQ15 to legacy IRQs */
  213. pci_read_config_word(dev, 0x46, &temp);
  214. temp |= 0xc000;
  215. pci_write_config_word(dev, 0x46, temp);
  216. /* Set i8259 interrupt trigger
  217. * IRQ 3: Level
  218. * IRQ 4: Level
  219. * IRQ 5: Level
  220. * IRQ 6: Level
  221. * IRQ 7: Level
  222. * IRQ 9: Level
  223. * IRQ 10: Level
  224. * IRQ 11: Level
  225. * IRQ 12: Level
  226. * IRQ 14: Edge
  227. * IRQ 15: Edge
  228. */
  229. outb(0xfa, 0x4d0);
  230. outb(0x1e, 0x4d1);
  231. }
  232. static void __devinit quirk_uli5288(struct pci_dev *dev)
  233. {
  234. unsigned char c;
  235. pci_read_config_byte(dev,0x83,&c);
  236. c |= 0x80;
  237. pci_write_config_byte(dev, 0x83, c);
  238. pci_write_config_byte(dev, 0x09, 0x01);
  239. pci_write_config_byte(dev, 0x0a, 0x06);
  240. pci_read_config_byte(dev,0x83,&c);
  241. c &= 0x7f;
  242. pci_write_config_byte(dev, 0x83, c);
  243. pci_read_config_byte(dev,0x84,&c);
  244. c |= 0x01;
  245. pci_write_config_byte(dev, 0x84, c);
  246. }
  247. static void __devinit quirk_uli5229(struct pci_dev *dev)
  248. {
  249. unsigned short temp;
  250. pci_write_config_word(dev, 0x04, 0x0405);
  251. pci_read_config_word(dev, 0x4a, &temp);
  252. temp |= 0x1000;
  253. pci_write_config_word(dev, 0x4a, temp);
  254. }
  255. static void __devinit early_uli5249(struct pci_dev *dev)
  256. {
  257. unsigned char temp;
  258. pci_write_config_word(dev, 0x04, 0x0007);
  259. pci_read_config_byte(dev, 0x7c, &temp);
  260. pci_write_config_byte(dev, 0x7c, 0x80);
  261. pci_write_config_byte(dev, 0x09, 0x01);
  262. pci_write_config_byte(dev, 0x7c, temp);
  263. dev->class |= 0x1;
  264. }
  265. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1575, quirk_ali1575);
  266. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5288, quirk_uli5288);
  267. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5229, quirk_uli5229);
  268. DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AL, 0x5249, early_uli5249);
  269. #endif /* CONFIG_PCI */
  270. static void __init
  271. mpc86xx_hpcn_setup_arch(void)
  272. {
  273. struct device_node *np;
  274. if (ppc_md.progress)
  275. ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
  276. np = of_find_node_by_type(NULL, "cpu");
  277. if (np != 0) {
  278. unsigned int *fp;
  279. fp = (int *)get_property(np, "clock-frequency", NULL);
  280. if (fp != 0)
  281. loops_per_jiffy = *fp / HZ;
  282. else
  283. loops_per_jiffy = 50000000 / HZ;
  284. of_node_put(np);
  285. }
  286. #ifdef CONFIG_PCI
  287. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  288. add_bridge(np);
  289. ppc_md.pci_swizzle = common_swizzle;
  290. ppc_md.pci_map_irq = mpc86xx_map_irq;
  291. ppc_md.pci_exclude_device = mpc86xx_exclude_device;
  292. #endif
  293. printk("MPC86xx HPCN board from Freescale Semiconductor\n");
  294. #ifdef CONFIG_ROOT_NFS
  295. ROOT_DEV = Root_NFS;
  296. #else
  297. ROOT_DEV = Root_HDA1;
  298. #endif
  299. #ifdef CONFIG_SMP
  300. mpc86xx_smp_init();
  301. #endif
  302. }
  303. void
  304. mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
  305. {
  306. struct device_node *root;
  307. uint memsize = total_memory;
  308. const char *model = "";
  309. uint svid = mfspr(SPRN_SVR);
  310. seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
  311. root = of_find_node_by_path("/");
  312. if (root)
  313. model = get_property(root, "model", NULL);
  314. seq_printf(m, "Machine\t\t: %s\n", model);
  315. of_node_put(root);
  316. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  317. seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
  318. }
  319. /*
  320. * Called very early, device-tree isn't unflattened
  321. */
  322. static int __init mpc86xx_hpcn_probe(void)
  323. {
  324. unsigned long root = of_get_flat_dt_root();
  325. if (of_flat_dt_is_compatible(root, "mpc86xx"))
  326. return 1; /* Looks good */
  327. return 0;
  328. }
  329. void
  330. mpc86xx_restart(char *cmd)
  331. {
  332. void __iomem *rstcr;
  333. rstcr = ioremap(get_immrbase() + MPC86XX_RSTCR_OFFSET, 0x100);
  334. local_irq_disable();
  335. /* Assert reset request to Reset Control Register */
  336. out_be32(rstcr, 0x2);
  337. /* not reached */
  338. }
  339. long __init
  340. mpc86xx_time_init(void)
  341. {
  342. unsigned int temp;
  343. /* Set the time base to zero */
  344. mtspr(SPRN_TBWL, 0);
  345. mtspr(SPRN_TBWU, 0);
  346. temp = mfspr(SPRN_HID0);
  347. temp |= HID0_TBEN;
  348. mtspr(SPRN_HID0, temp);
  349. asm volatile("isync");
  350. return 0;
  351. }
  352. define_machine(mpc86xx_hpcn) {
  353. .name = "MPC86xx HPCN",
  354. .probe = mpc86xx_hpcn_probe,
  355. .setup_arch = mpc86xx_hpcn_setup_arch,
  356. .init_IRQ = mpc86xx_hpcn_init_irq,
  357. .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo,
  358. .get_irq = mpic_get_irq,
  359. .restart = mpc86xx_restart,
  360. .time_init = mpc86xx_time_init,
  361. .calibrate_decr = generic_calibrate_decr,
  362. .progress = udbg_progress,
  363. };