mpc85xx_ads.c 6.9 KB

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