mpc85xx_ads.c 7.0 KB

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