mpc85xx_ads.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. #ifndef CONFIG_PCI
  32. unsigned long isa_io_base = 0;
  33. unsigned long isa_mem_base = 0;
  34. #endif
  35. /*
  36. * Internal interrupts are all Level Sensitive, and Positive Polarity
  37. *
  38. * Note: Likely, this table and the following function should be
  39. * obtained and derived from the OF Device Tree.
  40. */
  41. static u_char mpc85xx_ads_openpic_initsenses[] __initdata = {
  42. MPC85XX_INTERNAL_IRQ_SENSES,
  43. 0x0, /* External 0: */
  44. #if defined(CONFIG_PCI)
  45. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext 1: PCI slot 0 */
  46. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext 2: PCI slot 1 */
  47. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext 3: PCI slot 2 */
  48. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext 4: PCI slot 3 */
  49. #else
  50. 0x0, /* External 1: */
  51. 0x0, /* External 2: */
  52. 0x0, /* External 3: */
  53. 0x0, /* External 4: */
  54. #endif
  55. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 5: PHY */
  56. 0x0, /* External 6: */
  57. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 7: PHY */
  58. 0x0, /* External 8: */
  59. 0x0, /* External 9: */
  60. 0x0, /* External 10: */
  61. 0x0, /* External 11: */
  62. };
  63. #ifdef CONFIG_PCI
  64. /*
  65. * interrupt routing
  66. */
  67. int
  68. mpc85xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  69. {
  70. static char pci_irq_table[][4] =
  71. /*
  72. * This is little evil, but works around the fact
  73. * that revA boards have IDSEL starting at 18
  74. * and others boards (older) start at 12
  75. *
  76. * PCI IDSEL/INTPIN->INTLINE
  77. * A B C D
  78. */
  79. {
  80. {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 2 */
  81. {PIRQD, PIRQA, PIRQB, PIRQC},
  82. {PIRQC, PIRQD, PIRQA, PIRQB},
  83. {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 5 */
  84. {0, 0, 0, 0}, /* -- */
  85. {0, 0, 0, 0}, /* -- */
  86. {0, 0, 0, 0}, /* -- */
  87. {0, 0, 0, 0}, /* -- */
  88. {0, 0, 0, 0}, /* -- */
  89. {0, 0, 0, 0}, /* -- */
  90. {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 12 */
  91. {PIRQD, PIRQA, PIRQB, PIRQC},
  92. {PIRQC, PIRQD, PIRQA, PIRQB},
  93. {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 15 */
  94. {0, 0, 0, 0}, /* -- */
  95. {0, 0, 0, 0}, /* -- */
  96. {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 18 */
  97. {PIRQD, PIRQA, PIRQB, PIRQC},
  98. {PIRQC, PIRQD, PIRQA, PIRQB},
  99. {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 21 */
  100. };
  101. const long min_idsel = 2, max_idsel = 21, irqs_per_slot = 4;
  102. return PCI_IRQ_TABLE_LOOKUP;
  103. }
  104. int
  105. mpc85xx_exclude_device(u_char bus, u_char devfn)
  106. {
  107. if (bus == 0 && PCI_SLOT(devfn) == 0)
  108. return PCIBIOS_DEVICE_NOT_FOUND;
  109. else
  110. return PCIBIOS_SUCCESSFUL;
  111. }
  112. #endif /* CONFIG_PCI */
  113. void __init mpc85xx_ads_pic_init(void)
  114. {
  115. struct mpic *mpic1;
  116. phys_addr_t OpenPIC_PAddr;
  117. /* Determine the Physical Address of the OpenPIC regs */
  118. OpenPIC_PAddr = get_immrbase() + MPC85xx_OPENPIC_OFFSET;
  119. mpic1 = mpic_alloc(OpenPIC_PAddr,
  120. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  121. 4, MPC85xx_OPENPIC_IRQ_OFFSET, 0, 250,
  122. mpc85xx_ads_openpic_initsenses,
  123. sizeof(mpc85xx_ads_openpic_initsenses),
  124. " OpenPIC ");
  125. BUG_ON(mpic1 == NULL);
  126. mpic_assign_isu(mpic1, 0, OpenPIC_PAddr + 0x10200);
  127. mpic_assign_isu(mpic1, 1, OpenPIC_PAddr + 0x10280);
  128. mpic_assign_isu(mpic1, 2, OpenPIC_PAddr + 0x10300);
  129. mpic_assign_isu(mpic1, 3, OpenPIC_PAddr + 0x10380);
  130. mpic_assign_isu(mpic1, 4, OpenPIC_PAddr + 0x10400);
  131. mpic_assign_isu(mpic1, 5, OpenPIC_PAddr + 0x10480);
  132. mpic_assign_isu(mpic1, 6, OpenPIC_PAddr + 0x10500);
  133. mpic_assign_isu(mpic1, 7, OpenPIC_PAddr + 0x10580);
  134. /* dummy mappings to get to 48 */
  135. mpic_assign_isu(mpic1, 8, OpenPIC_PAddr + 0x10600);
  136. mpic_assign_isu(mpic1, 9, OpenPIC_PAddr + 0x10680);
  137. mpic_assign_isu(mpic1, 10, OpenPIC_PAddr + 0x10700);
  138. mpic_assign_isu(mpic1, 11, OpenPIC_PAddr + 0x10780);
  139. /* External ints */
  140. mpic_assign_isu(mpic1, 12, OpenPIC_PAddr + 0x10000);
  141. mpic_assign_isu(mpic1, 13, OpenPIC_PAddr + 0x10080);
  142. mpic_assign_isu(mpic1, 14, OpenPIC_PAddr + 0x10100);
  143. mpic_init(mpic1);
  144. }
  145. /*
  146. * Setup the architecture
  147. */
  148. static void __init mpc85xx_ads_setup_arch(void)
  149. {
  150. struct device_node *cpu;
  151. struct device_node *np;
  152. if (ppc_md.progress)
  153. ppc_md.progress("mpc85xx_ads_setup_arch()", 0);
  154. cpu = of_find_node_by_type(NULL, "cpu");
  155. if (cpu != 0) {
  156. unsigned int *fp;
  157. fp = (int *)get_property(cpu, "clock-frequency", NULL);
  158. if (fp != 0)
  159. loops_per_jiffy = *fp / HZ;
  160. else
  161. loops_per_jiffy = 50000000 / HZ;
  162. of_node_put(cpu);
  163. }
  164. #ifdef CONFIG_PCI
  165. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  166. add_bridge(np);
  167. ppc_md.pci_swizzle = common_swizzle;
  168. ppc_md.pci_map_irq = mpc85xx_map_irq;
  169. ppc_md.pci_exclude_device = mpc85xx_exclude_device;
  170. #endif
  171. #ifdef CONFIG_ROOT_NFS
  172. ROOT_DEV = Root_NFS;
  173. #else
  174. ROOT_DEV = Root_HDA1;
  175. #endif
  176. }
  177. void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
  178. {
  179. uint pvid, svid, phid1;
  180. uint memsize = total_memory;
  181. pvid = mfspr(SPRN_PVR);
  182. svid = mfspr(SPRN_SVR);
  183. seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
  184. seq_printf(m, "Machine\t\t: mpc85xx\n");
  185. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  186. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  187. /* Display cpu Pll setting */
  188. phid1 = mfspr(SPRN_HID1);
  189. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  190. /* Display the amount of memory */
  191. seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
  192. }
  193. /*
  194. * Called very early, device-tree isn't unflattened
  195. */
  196. static int __init mpc85xx_ads_probe(void)
  197. {
  198. /* We always match for now, eventually we should look at the flat
  199. dev tree to ensure this is the board we are suppose to run on
  200. */
  201. return 1;
  202. }
  203. define_machine(mpc85xx_ads) {
  204. .name = "MPC85xx ADS",
  205. .probe = mpc85xx_ads_probe,
  206. .setup_arch = mpc85xx_ads_setup_arch,
  207. .init_IRQ = mpc85xx_ads_pic_init,
  208. .show_cpuinfo = mpc85xx_ads_show_cpuinfo,
  209. .get_irq = mpic_get_irq,
  210. .restart = mpc85xx_restart,
  211. .calibrate_decr = generic_calibrate_decr,
  212. .progress = udbg_progress,
  213. };