mpc85xx_ads.c 7.0 KB

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