mpc85xx_ads.c 6.1 KB

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