mpc85xx_ads.c 7.2 KB

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