mpc85xx_ads_common.c 5.3 KB

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