mpc85xx_ads.c 7.2 KB

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