mpc85xx_ads.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /*
  2. * MPC85xx setup and early boot code plus other random bits.
  3. *
  4. * Maintained by Kumar Gala (see MAINTAINERS for contact information)
  5. *
  6. * Copyright 2005 Freescale Semiconductor Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. */
  13. #include <linux/stddef.h>
  14. #include <linux/kernel.h>
  15. #include <linux/pci.h>
  16. #include <linux/kdev_t.h>
  17. #include <linux/delay.h>
  18. #include <linux/seq_file.h>
  19. #include <asm/system.h>
  20. #include <asm/time.h>
  21. #include <asm/machdep.h>
  22. #include <asm/pci-bridge.h>
  23. #include <asm/mpc85xx.h>
  24. #include <asm/prom.h>
  25. #include <asm/mpic.h>
  26. #include <mm/mmu_decl.h>
  27. #include <asm/udbg.h>
  28. #include <sysdev/fsl_soc.h>
  29. #include "mpc85xx.h"
  30. #ifdef CONFIG_CPM2
  31. #include <linux/fs_enet_pd.h>
  32. #include <asm/cpm2.h>
  33. #include <sysdev/cpm2_pic.h>
  34. #include <asm/fs_pd.h>
  35. #endif
  36. #ifdef CONFIG_PCI
  37. static int mpc85xx_exclude_device(struct pci_controller *hose,
  38. u_char bus, u_char devfn)
  39. {
  40. if (bus == 0 && PCI_SLOT(devfn) == 0)
  41. return PCIBIOS_DEVICE_NOT_FOUND;
  42. else
  43. return PCIBIOS_SUCCESSFUL;
  44. }
  45. #endif /* CONFIG_PCI */
  46. #ifdef CONFIG_CPM2
  47. static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
  48. {
  49. int cascade_irq;
  50. while ((cascade_irq = cpm2_get_irq()) >= 0) {
  51. generic_handle_irq(cascade_irq);
  52. }
  53. desc->chip->eoi(irq);
  54. }
  55. #endif /* CONFIG_CPM2 */
  56. static void __init mpc85xx_ads_pic_init(void)
  57. {
  58. struct mpic *mpic;
  59. struct resource r;
  60. struct device_node *np = NULL;
  61. #ifdef CONFIG_CPM2
  62. int irq;
  63. #endif
  64. np = of_find_node_by_type(np, "open-pic");
  65. if (np == NULL) {
  66. printk(KERN_ERR "Could not find open-pic node\n");
  67. return;
  68. }
  69. if(of_address_to_resource(np, 0, &r)) {
  70. printk(KERN_ERR "Could not map mpic register space\n");
  71. of_node_put(np);
  72. return;
  73. }
  74. mpic = mpic_alloc(np, r.start,
  75. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  76. 4, 0, " OpenPIC ");
  77. BUG_ON(mpic == NULL);
  78. of_node_put(np);
  79. mpic_assign_isu(mpic, 0, r.start + 0x10200);
  80. mpic_assign_isu(mpic, 1, r.start + 0x10280);
  81. mpic_assign_isu(mpic, 2, r.start + 0x10300);
  82. mpic_assign_isu(mpic, 3, r.start + 0x10380);
  83. mpic_assign_isu(mpic, 4, r.start + 0x10400);
  84. mpic_assign_isu(mpic, 5, r.start + 0x10480);
  85. mpic_assign_isu(mpic, 6, r.start + 0x10500);
  86. mpic_assign_isu(mpic, 7, r.start + 0x10580);
  87. /* Unused on this platform (leave room for 8548) */
  88. mpic_assign_isu(mpic, 8, r.start + 0x10600);
  89. mpic_assign_isu(mpic, 9, r.start + 0x10680);
  90. mpic_assign_isu(mpic, 10, r.start + 0x10700);
  91. mpic_assign_isu(mpic, 11, r.start + 0x10780);
  92. /* External Interrupts */
  93. mpic_assign_isu(mpic, 12, r.start + 0x10000);
  94. mpic_assign_isu(mpic, 13, r.start + 0x10080);
  95. mpic_assign_isu(mpic, 14, r.start + 0x10100);
  96. mpic_init(mpic);
  97. #ifdef CONFIG_CPM2
  98. /* Setup CPM2 PIC */
  99. np = of_find_node_by_type(NULL, "cpm-pic");
  100. if (np == NULL) {
  101. printk(KERN_ERR "PIC init: can not find cpm-pic node\n");
  102. return;
  103. }
  104. irq = irq_of_parse_and_map(np, 0);
  105. cpm2_pic_init(np);
  106. set_irq_chained_handler(irq, cpm2_cascade);
  107. #endif
  108. }
  109. /*
  110. * Setup the architecture
  111. */
  112. #ifdef CONFIG_CPM2
  113. void init_fcc_ioports(struct fs_platform_info *fpi)
  114. {
  115. struct io_port *io = cpm2_map(im_ioport);
  116. int fcc_no = fs_get_fcc_index(fpi->fs_no);
  117. int target;
  118. u32 tempval;
  119. switch(fcc_no) {
  120. case 1:
  121. tempval = in_be32(&io->iop_pdirb);
  122. tempval &= ~PB2_DIRB0;
  123. tempval |= PB2_DIRB1;
  124. out_be32(&io->iop_pdirb, tempval);
  125. tempval = in_be32(&io->iop_psorb);
  126. tempval &= ~PB2_PSORB0;
  127. tempval |= PB2_PSORB1;
  128. out_be32(&io->iop_psorb, tempval);
  129. tempval = in_be32(&io->iop_pparb);
  130. tempval |= (PB2_DIRB0 | PB2_DIRB1);
  131. out_be32(&io->iop_pparb, tempval);
  132. target = CPM_CLK_FCC2;
  133. break;
  134. case 2:
  135. tempval = in_be32(&io->iop_pdirb);
  136. tempval &= ~PB3_DIRB0;
  137. tempval |= PB3_DIRB1;
  138. out_be32(&io->iop_pdirb, tempval);
  139. tempval = in_be32(&io->iop_psorb);
  140. tempval &= ~PB3_PSORB0;
  141. tempval |= PB3_PSORB1;
  142. out_be32(&io->iop_psorb, tempval);
  143. tempval = in_be32(&io->iop_pparb);
  144. tempval |= (PB3_DIRB0 | PB3_DIRB1);
  145. out_be32(&io->iop_pparb, tempval);
  146. tempval = in_be32(&io->iop_pdirc);
  147. tempval |= PC3_DIRC1;
  148. out_be32(&io->iop_pdirc, tempval);
  149. tempval = in_be32(&io->iop_pparc);
  150. tempval |= PC3_DIRC1;
  151. out_be32(&io->iop_pparc, tempval);
  152. target = CPM_CLK_FCC3;
  153. break;
  154. default:
  155. printk(KERN_ERR "init_fcc_ioports: invalid FCC number\n");
  156. return;
  157. }
  158. /* Port C has clocks...... */
  159. tempval = in_be32(&io->iop_psorc);
  160. tempval &= ~(PC_CLK(fpi->clk_rx - 8) | PC_CLK(fpi->clk_tx - 8));
  161. out_be32(&io->iop_psorc, tempval);
  162. tempval = in_be32(&io->iop_pdirc);
  163. tempval &= ~(PC_CLK(fpi->clk_rx - 8) | PC_CLK(fpi->clk_tx - 8));
  164. out_be32(&io->iop_pdirc, tempval);
  165. tempval = in_be32(&io->iop_pparc);
  166. tempval |= (PC_CLK(fpi->clk_rx - 8) | PC_CLK(fpi->clk_tx - 8));
  167. out_be32(&io->iop_pparc, tempval);
  168. cpm2_unmap(io);
  169. /* Configure Serial Interface clock routing.
  170. * First, clear FCC bits to zero,
  171. * then set the ones we want.
  172. */
  173. cpm2_clk_setup(target, fpi->clk_rx, CPM_CLK_RX);
  174. cpm2_clk_setup(target, fpi->clk_tx, CPM_CLK_TX);
  175. }
  176. #endif
  177. static void __init mpc85xx_ads_setup_arch(void)
  178. {
  179. struct device_node *cpu;
  180. #ifdef CONFIG_PCI
  181. struct device_node *np;
  182. #endif
  183. if (ppc_md.progress)
  184. ppc_md.progress("mpc85xx_ads_setup_arch()", 0);
  185. cpu = of_find_node_by_type(NULL, "cpu");
  186. if (cpu != 0) {
  187. const unsigned int *fp;
  188. fp = of_get_property(cpu, "clock-frequency", NULL);
  189. if (fp != 0)
  190. loops_per_jiffy = *fp / HZ;
  191. else
  192. loops_per_jiffy = 50000000 / HZ;
  193. of_node_put(cpu);
  194. }
  195. #ifdef CONFIG_CPM2
  196. cpm2_reset();
  197. #endif
  198. #ifdef CONFIG_PCI
  199. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  200. mpc85xx_add_bridge(np);
  201. ppc_md.pci_exclude_device = mpc85xx_exclude_device;
  202. #endif
  203. }
  204. static void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
  205. {
  206. uint pvid, svid, phid1;
  207. uint memsize = total_memory;
  208. pvid = mfspr(SPRN_PVR);
  209. svid = mfspr(SPRN_SVR);
  210. seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
  211. seq_printf(m, "Machine\t\t: mpc85xx\n");
  212. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  213. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  214. /* Display cpu Pll setting */
  215. phid1 = mfspr(SPRN_HID1);
  216. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  217. /* Display the amount of memory */
  218. seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
  219. }
  220. /*
  221. * Called very early, device-tree isn't unflattened
  222. */
  223. static int __init mpc85xx_ads_probe(void)
  224. {
  225. unsigned long root = of_get_flat_dt_root();
  226. return of_flat_dt_is_compatible(root, "MPC85xxADS");
  227. }
  228. define_machine(mpc85xx_ads) {
  229. .name = "MPC85xx ADS",
  230. .probe = mpc85xx_ads_probe,
  231. .setup_arch = mpc85xx_ads_setup_arch,
  232. .init_IRQ = mpc85xx_ads_pic_init,
  233. .show_cpuinfo = mpc85xx_ads_show_cpuinfo,
  234. .get_irq = mpic_get_irq,
  235. .restart = mpc85xx_restart,
  236. .calibrate_decr = generic_calibrate_decr,
  237. .progress = udbg_progress,
  238. };