mpc85xx_ads.c 6.6 KB

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