ash.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /*
  2. * arch/ppc/platforms/4xx/ash.c
  3. *
  4. * Support for the IBM NP405H ash eval board
  5. *
  6. * Author: Armin Kuster <akuster@mvista.com>
  7. *
  8. * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
  9. * the terms of the GNU General Public License version 2. This program
  10. * is licensed "as is" without any warranty of any kind, whether express
  11. * or implied.
  12. */
  13. #include <linux/config.h>
  14. #include <linux/init.h>
  15. #include <linux/pagemap.h>
  16. #include <linux/pci.h>
  17. #include <asm/machdep.h>
  18. #include <asm/pci-bridge.h>
  19. #include <asm/io.h>
  20. #include <asm/ocp.h>
  21. #include <asm/ibm_ocp_pci.h>
  22. #include <asm/todc.h>
  23. #ifdef DEBUG
  24. #define DBG(x...) printk(x)
  25. #else
  26. #define DBG(x...)
  27. #endif
  28. void *ash_rtc_base;
  29. /* Some IRQs unique to Walnut.
  30. * Used by the generic 405 PCI setup functions in ppc4xx_pci.c
  31. */
  32. int __init
  33. ppc405_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  34. {
  35. static char pci_irq_table[][4] =
  36. /*
  37. * PCI IDSEL/INTPIN->INTLINE
  38. * A B C D
  39. */
  40. {
  41. {24, 24, 24, 24}, /* IDSEL 1 - PCI slot 1 */
  42. {25, 25, 25, 25}, /* IDSEL 2 - PCI slot 2 */
  43. {26, 26, 26, 26}, /* IDSEL 3 - PCI slot 3 */
  44. {27, 27, 27, 27}, /* IDSEL 4 - PCI slot 4 */
  45. };
  46. const long min_idsel = 1, max_idsel = 4, irqs_per_slot = 4;
  47. return PCI_IRQ_TABLE_LOOKUP;
  48. }
  49. void __init
  50. ash_setup_arch(void)
  51. {
  52. ppc4xx_setup_arch();
  53. ibm_ocp_set_emac(0, 3);
  54. #ifdef CONFIG_DEBUG_BRINGUP
  55. int i;
  56. printk("\n");
  57. printk("machine\t: %s\n", PPC4xx_MACHINE_NAME);
  58. printk("\n");
  59. printk("bi_s_version\t %s\n", bip->bi_s_version);
  60. printk("bi_r_version\t %s\n", bip->bi_r_version);
  61. printk("bi_memsize\t 0x%8.8x\t %dMBytes\n", bip->bi_memsize,
  62. bip->bi_memsize / (1024 * 1000));
  63. for (i = 0; i < EMAC_NUMS; i++) {
  64. printk("bi_enetaddr %d\t %2.2x%2.2x%2.2x-%2.2x%2.2x%2.2x\n", i,
  65. bip->bi_enetaddr[i][0], bip->bi_enetaddr[i][1],
  66. bip->bi_enetaddr[i][2], bip->bi_enetaddr[i][3],
  67. bip->bi_enetaddr[i][4], bip->bi_enetaddr[i][5]);
  68. }
  69. printk("bi_pci_enetaddr %d\t %2.2x%2.2x%2.2x-%2.2x%2.2x%2.2x\n", 0,
  70. bip->bi_pci_enetaddr[0], bip->bi_pci_enetaddr[1],
  71. bip->bi_pci_enetaddr[2], bip->bi_pci_enetaddr[3],
  72. bip->bi_pci_enetaddr[4], bip->bi_pci_enetaddr[5]);
  73. printk("bi_intfreq\t 0x%8.8x\t clock:\t %dMhz\n",
  74. bip->bi_intfreq, bip->bi_intfreq / 1000000);
  75. printk("bi_busfreq\t 0x%8.8x\t plb bus clock:\t %dMHz\n",
  76. bip->bi_busfreq, bip->bi_busfreq / 1000000);
  77. printk("bi_pci_busfreq\t 0x%8.8x\t pci bus clock:\t %dMHz\n",
  78. bip->bi_pci_busfreq, bip->bi_pci_busfreq / 1000000);
  79. printk("\n");
  80. #endif
  81. /* RTC step for ash */
  82. ash_rtc_base = (void *) ASH_RTC_VADDR;
  83. TODC_INIT(TODC_TYPE_DS1743, ash_rtc_base, ash_rtc_base, ash_rtc_base,
  84. 8);
  85. }
  86. void __init
  87. bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
  88. {
  89. /*
  90. * Expected PCI mapping:
  91. *
  92. * PLB addr PCI memory addr
  93. * --------------------- ---------------------
  94. * 0000'0000 - 7fff'ffff <--- 0000'0000 - 7fff'ffff
  95. * 8000'0000 - Bfff'ffff ---> 8000'0000 - Bfff'ffff
  96. *
  97. * PLB addr PCI io addr
  98. * --------------------- ---------------------
  99. * e800'0000 - e800'ffff ---> 0000'0000 - 0001'0000
  100. *
  101. * The following code is simplified by assuming that the bootrom
  102. * has been well behaved in following this mapping.
  103. */
  104. #ifdef DEBUG
  105. int i;
  106. printk("ioremap PCLIO_BASE = 0x%x\n", pcip);
  107. printk("PCI bridge regs before fixup \n");
  108. for (i = 0; i <= 2; i++) {
  109. printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].ma)));
  110. printk(" pmm%dla\t0x%x\n", i, in_le32(&(pcip->pmm[i].la)));
  111. printk(" pmm%dpcila\t0x%x\n", i,
  112. in_le32(&(pcip->pmm[i].pcila)));
  113. printk(" pmm%dpciha\t0x%x\n", i,
  114. in_le32(&(pcip->pmm[i].pciha)));
  115. }
  116. printk(" ptm1ms\t0x%x\n", in_le32(&(pcip->ptm1ms)));
  117. printk(" ptm1la\t0x%x\n", in_le32(&(pcip->ptm1la)));
  118. printk(" ptm2ms\t0x%x\n", in_le32(&(pcip->ptm2ms)));
  119. printk(" ptm2la\t0x%x\n", in_le32(&(pcip->ptm2la)));
  120. for (bar = PCI_BASE_ADDRESS_1; bar <= PCI_BASE_ADDRESS_2; bar += 4) {
  121. early_read_config_dword(hose, hose->first_busno,
  122. PCI_FUNC(hose->first_busno), bar,
  123. &bar_response);
  124. DBG("BUS %d, device %d, Function %d bar 0x%8.8x is 0x%8.8x\n",
  125. hose->first_busno, PCI_SLOT(hose->first_busno),
  126. PCI_FUNC(hose->first_busno), bar, bar_response);
  127. }
  128. #endif
  129. if (ppc_md.progress)
  130. ppc_md.progress("bios_fixup(): enter", 0x800);
  131. /* added for IBM boot rom version 1.15 bios bar changes -AK */
  132. /* Disable region first */
  133. out_le32((void *) &(pcip->pmm[0].ma), 0x00000000);
  134. /* PLB starting addr, PCI: 0x80000000 */
  135. out_le32((void *) &(pcip->pmm[0].la), 0x80000000);
  136. /* PCI start addr, 0x80000000 */
  137. out_le32((void *) &(pcip->pmm[0].pcila), PPC405_PCI_MEM_BASE);
  138. /* 512MB range of PLB to PCI */
  139. out_le32((void *) &(pcip->pmm[0].pciha), 0x00000000);
  140. /* Enable no pre-fetch, enable region */
  141. out_le32((void *) &(pcip->pmm[0].ma), ((0xffffffff -
  142. (PPC405_PCI_UPPER_MEM -
  143. PPC405_PCI_MEM_BASE)) | 0x01));
  144. /* Disable region one */
  145. out_le32((void *) &(pcip->pmm[1].ma), 0x00000000);
  146. out_le32((void *) &(pcip->pmm[1].la), 0x00000000);
  147. out_le32((void *) &(pcip->pmm[1].pcila), 0x00000000);
  148. out_le32((void *) &(pcip->pmm[1].pciha), 0x00000000);
  149. out_le32((void *) &(pcip->pmm[1].ma), 0x00000000);
  150. /* Disable region two */
  151. out_le32((void *) &(pcip->pmm[2].ma), 0x00000000);
  152. out_le32((void *) &(pcip->pmm[2].la), 0x00000000);
  153. out_le32((void *) &(pcip->pmm[2].pcila), 0x00000000);
  154. out_le32((void *) &(pcip->pmm[2].pciha), 0x00000000);
  155. out_le32((void *) &(pcip->pmm[2].ma), 0x00000000);
  156. /* Enable PTM1 and PTM2, mapped to PLB address 0. */
  157. out_le32((void *) &(pcip->ptm1la), 0x00000000);
  158. out_le32((void *) &(pcip->ptm1ms), 0x00000001);
  159. out_le32((void *) &(pcip->ptm2la), 0x00000000);
  160. out_le32((void *) &(pcip->ptm2ms), 0x00000001);
  161. /* Write zero to PTM1 BAR. */
  162. early_write_config_dword(hose, hose->first_busno,
  163. PCI_FUNC(hose->first_busno),
  164. PCI_BASE_ADDRESS_1,
  165. 0x00000000);
  166. /* Disable PTM2 (unused) */
  167. out_le32((void *) &(pcip->ptm2la), 0x00000000);
  168. out_le32((void *) &(pcip->ptm2ms), 0x00000000);
  169. /* end work arround */
  170. if (ppc_md.progress)
  171. ppc_md.progress("bios_fixup(): done", 0x800);
  172. #ifdef DEBUG
  173. printk("PCI bridge regs after fixup \n");
  174. for (i = 0; i <= 2; i++) {
  175. printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].ma)));
  176. printk(" pmm%dla\t0x%x\n", i, in_le32(&(pcip->pmm[i].la)));
  177. printk(" pmm%dpcila\t0x%x\n", i,
  178. in_le32(&(pcip->pmm[i].pcila)));
  179. printk(" pmm%dpciha\t0x%x\n", i,
  180. in_le32(&(pcip->pmm[i].pciha)));
  181. }
  182. printk(" ptm1ms\t0x%x\n", in_le32(&(pcip->ptm1ms)));
  183. printk(" ptm1la\t0x%x\n", in_le32(&(pcip->ptm1la)));
  184. printk(" ptm2ms\t0x%x\n", in_le32(&(pcip->ptm2ms)));
  185. printk(" ptm2la\t0x%x\n", in_le32(&(pcip->ptm2la)));
  186. for (bar = PCI_BASE_ADDRESS_1; bar <= PCI_BASE_ADDRESS_2; bar += 4) {
  187. early_read_config_dword(hose, hose->first_busno,
  188. PCI_FUNC(hose->first_busno), bar,
  189. &bar_response);
  190. DBG("BUS %d, device %d, Function %d bar 0x%8.8x is 0x%8.8x\n",
  191. hose->first_busno, PCI_SLOT(hose->first_busno),
  192. PCI_FUNC(hose->first_busno), bar, bar_response);
  193. }
  194. #endif
  195. }
  196. void __init
  197. ash_map_io(void)
  198. {
  199. ppc4xx_map_io();
  200. io_block_mapping(ASH_RTC_VADDR, ASH_RTC_PADDR, ASH_RTC_SIZE, _PAGE_IO);
  201. }
  202. void __init
  203. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  204. unsigned long r6, unsigned long r7)
  205. {
  206. ppc4xx_init(r3, r4, r5, r6, r7);
  207. ppc_md.setup_arch = ash_setup_arch;
  208. ppc_md.setup_io_mappings = ash_map_io;
  209. #ifdef CONFIG_PPC_RTC
  210. ppc_md.time_init = todc_time_init;
  211. ppc_md.set_rtc_time = todc_set_rtc_time;
  212. ppc_md.get_rtc_time = todc_get_rtc_time;
  213. ppc_md.nvram_read_val = todc_direct_read_val;
  214. ppc_md.nvram_write_val = todc_direct_write_val;
  215. #endif
  216. }