mpc85xx_ads_common.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * arch/ppc/platforms/85xx/mpc85xx_ads_common.c
  3. *
  4. * MPC85xx ADS board common routines
  5. *
  6. * Maintainer: Kumar Gala <kumar.gala@freescale.com>
  7. *
  8. * Copyright 2004 Freescale Semiconductor Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at your
  13. * option) any later version.
  14. */
  15. #include <linux/config.h>
  16. #include <linux/stddef.h>
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/errno.h>
  20. #include <linux/reboot.h>
  21. #include <linux/pci.h>
  22. #include <linux/kdev_t.h>
  23. #include <linux/major.h>
  24. #include <linux/console.h>
  25. #include <linux/delay.h>
  26. #include <linux/irq.h>
  27. #include <linux/seq_file.h>
  28. #include <linux/serial.h>
  29. #include <linux/module.h>
  30. #include <asm/system.h>
  31. #include <asm/pgtable.h>
  32. #include <asm/page.h>
  33. #include <asm/atomic.h>
  34. #include <asm/time.h>
  35. #include <asm/io.h>
  36. #include <asm/machdep.h>
  37. #include <asm/open_pic.h>
  38. #include <asm/bootinfo.h>
  39. #include <asm/pci-bridge.h>
  40. #include <asm/mpc85xx.h>
  41. #include <asm/irq.h>
  42. #include <asm/immap_85xx.h>
  43. #include <asm/ppc_sys.h>
  44. #include <mm/mmu_decl.h>
  45. #include <platforms/85xx/mpc85xx_ads_common.h>
  46. #ifndef CONFIG_PCI
  47. unsigned long isa_io_base = 0;
  48. unsigned long isa_mem_base = 0;
  49. #endif
  50. extern unsigned long total_memory; /* in mm/init */
  51. unsigned char __res[sizeof (bd_t)];
  52. /* Internal interrupts are all Level Sensitive, and Positive Polarity */
  53. static u_char mpc85xx_ads_openpic_initsenses[] __initdata = {
  54. MPC85XX_INTERNAL_IRQ_SENSES,
  55. 0x0, /* External 0: */
  56. #if defined(CONFIG_PCI)
  57. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 1: PCI slot 0 */
  58. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 2: PCI slot 1 */
  59. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 3: PCI slot 2 */
  60. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 4: PCI slot 3 */
  61. #else
  62. 0x0, /* External 1: */
  63. 0x0, /* External 2: */
  64. 0x0, /* External 3: */
  65. 0x0, /* External 4: */
  66. #endif
  67. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 5: PHY */
  68. 0x0, /* External 6: */
  69. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 7: PHY */
  70. 0x0, /* External 8: */
  71. 0x0, /* External 9: */
  72. 0x0, /* External 10: */
  73. 0x0, /* External 11: */
  74. };
  75. /* ************************************************************************ */
  76. int
  77. mpc85xx_ads_show_cpuinfo(struct seq_file *m)
  78. {
  79. uint pvid, svid, phid1;
  80. uint memsize = total_memory;
  81. bd_t *binfo = (bd_t *) __res;
  82. unsigned int freq;
  83. /* get the core frequency */
  84. freq = binfo->bi_intfreq;
  85. pvid = mfspr(SPRN_PVR);
  86. svid = mfspr(SPRN_SVR);
  87. seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
  88. seq_printf(m, "Machine\t\t: mpc%sads\n", cur_ppc_sys_spec->ppc_sys_name);
  89. seq_printf(m, "clock\t\t: %dMHz\n", freq / 1000000);
  90. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  91. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  92. /* Display cpu Pll setting */
  93. phid1 = mfspr(SPRN_HID1);
  94. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  95. /* Display the amount of memory */
  96. seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
  97. return 0;
  98. }
  99. void __init
  100. mpc85xx_ads_init_IRQ(void)
  101. {
  102. bd_t *binfo = (bd_t *) __res;
  103. /* Determine the Physical Address of the OpenPIC regs */
  104. phys_addr_t OpenPIC_PAddr =
  105. binfo->bi_immr_base + MPC85xx_OPENPIC_OFFSET;
  106. OpenPIC_Addr = ioremap(OpenPIC_PAddr, MPC85xx_OPENPIC_SIZE);
  107. OpenPIC_InitSenses = mpc85xx_ads_openpic_initsenses;
  108. OpenPIC_NumInitSenses = sizeof (mpc85xx_ads_openpic_initsenses);
  109. /* Skip reserved space and internal sources */
  110. openpic_set_sources(0, 32, OpenPIC_Addr + 0x10200);
  111. /* Map PIC IRQs 0-11 */
  112. openpic_set_sources(48, 12, OpenPIC_Addr + 0x10000);
  113. /* we let openpic interrupts starting from an offset, to
  114. * leave space for cascading interrupts underneath.
  115. */
  116. openpic_init(MPC85xx_OPENPIC_IRQ_OFFSET);
  117. return;
  118. }
  119. #ifdef CONFIG_PCI
  120. /*
  121. * interrupt routing
  122. */
  123. int
  124. mpc85xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  125. {
  126. static char pci_irq_table[][4] =
  127. /*
  128. * This is little evil, but works around the fact
  129. * that revA boards have IDSEL starting at 18
  130. * and others boards (older) start at 12
  131. *
  132. * PCI IDSEL/INTPIN->INTLINE
  133. * A B C D
  134. */
  135. {
  136. {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 2 */
  137. {PIRQD, PIRQA, PIRQB, PIRQC},
  138. {PIRQC, PIRQD, PIRQA, PIRQB},
  139. {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 5 */
  140. {0, 0, 0, 0}, /* -- */
  141. {0, 0, 0, 0}, /* -- */
  142. {0, 0, 0, 0}, /* -- */
  143. {0, 0, 0, 0}, /* -- */
  144. {0, 0, 0, 0}, /* -- */
  145. {0, 0, 0, 0}, /* -- */
  146. {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 12 */
  147. {PIRQD, PIRQA, PIRQB, PIRQC},
  148. {PIRQC, PIRQD, PIRQA, PIRQB},
  149. {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 15 */
  150. {0, 0, 0, 0}, /* -- */
  151. {0, 0, 0, 0}, /* -- */
  152. {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 18 */
  153. {PIRQD, PIRQA, PIRQB, PIRQC},
  154. {PIRQC, PIRQD, PIRQA, PIRQB},
  155. {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 21 */
  156. };
  157. const long min_idsel = 2, max_idsel = 21, irqs_per_slot = 4;
  158. return PCI_IRQ_TABLE_LOOKUP;
  159. }
  160. int
  161. mpc85xx_exclude_device(u_char bus, u_char devfn)
  162. {
  163. if (bus == 0 && PCI_SLOT(devfn) == 0)
  164. return PCIBIOS_DEVICE_NOT_FOUND;
  165. else
  166. return PCIBIOS_SUCCESSFUL;
  167. }
  168. #endif /* CONFIG_PCI */