bubinga.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /*
  2. * Support for IBM PPC 405EP evaluation board (Bubinga).
  3. *
  4. * Author: SAW (IBM), derived from walnut.c.
  5. * Maintained by MontaVista Software <source@mvista.com>
  6. *
  7. * 2003 (c) MontaVista Softare Inc. This file is licensed under the
  8. * terms of the GNU General Public License version 2. This program is
  9. * licensed "as is" without any warranty of any kind, whether express
  10. * or implied.
  11. */
  12. #include <linux/config.h>
  13. #include <linux/init.h>
  14. #include <linux/smp.h>
  15. #include <linux/threads.h>
  16. #include <linux/param.h>
  17. #include <linux/string.h>
  18. #include <linux/blkdev.h>
  19. #include <linux/pci.h>
  20. #include <linux/rtc.h>
  21. #include <linux/tty.h>
  22. #include <linux/serial.h>
  23. #include <linux/serial_core.h>
  24. #include <asm/system.h>
  25. #include <asm/pci-bridge.h>
  26. #include <asm/processor.h>
  27. #include <asm/machdep.h>
  28. #include <asm/page.h>
  29. #include <asm/time.h>
  30. #include <asm/io.h>
  31. #include <asm/todc.h>
  32. #include <asm/kgdb.h>
  33. #include <asm/ocp.h>
  34. #include <asm/ibm_ocp_pci.h>
  35. #include <platforms/4xx/ibm405ep.h>
  36. #undef DEBUG
  37. #ifdef DEBUG
  38. #define DBG(x...) printk(x)
  39. #else
  40. #define DBG(x...)
  41. #endif
  42. extern bd_t __res;
  43. void *bubinga_rtc_base;
  44. /* Some IRQs unique to the board
  45. * Used by the generic 405 PCI setup functions in ppc4xx_pci.c
  46. */
  47. int __init
  48. ppc405_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  49. {
  50. static char pci_irq_table[][4] =
  51. /*
  52. * PCI IDSEL/INTPIN->INTLINE
  53. * A B C D
  54. */
  55. {
  56. {28, 28, 28, 28}, /* IDSEL 1 - PCI slot 1 */
  57. {29, 29, 29, 29}, /* IDSEL 2 - PCI slot 2 */
  58. {30, 30, 30, 30}, /* IDSEL 3 - PCI slot 3 */
  59. {31, 31, 31, 31}, /* IDSEL 4 - PCI slot 4 */
  60. };
  61. const long min_idsel = 1, max_idsel = 4, irqs_per_slot = 4;
  62. return PCI_IRQ_TABLE_LOOKUP;
  63. };
  64. /* The serial clock for the chip is an internal clock determined by
  65. * different clock speeds/dividers.
  66. * Calculate the proper input baud rate and setup the serial driver.
  67. */
  68. static void __init
  69. bubinga_early_serial_map(void)
  70. {
  71. u32 uart_div;
  72. int uart_clock;
  73. struct uart_port port;
  74. /* Calculate the serial clock input frequency
  75. *
  76. * The base baud is the PLL OUTA (provided in the board info
  77. * structure) divided by the external UART Divisor, divided
  78. * by 16.
  79. */
  80. uart_div = (mfdcr(DCRN_CPC0_UCR_BASE) & DCRN_CPC0_UCR_U0DIV);
  81. uart_clock = __res.bi_pllouta_freq / uart_div;
  82. /* Setup serial port access */
  83. memset(&port, 0, sizeof(port));
  84. port.membase = (void*)ACTING_UART0_IO_BASE;
  85. port.irq = ACTING_UART0_INT;
  86. port.uartclk = uart_clock;
  87. port.regshift = 0;
  88. port.iotype = SERIAL_IO_MEM;
  89. port.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;
  90. port.line = 0;
  91. if (early_serial_setup(&port) != 0) {
  92. printk("Early serial init of port 0 failed\n");
  93. }
  94. port.membase = (void*)ACTING_UART1_IO_BASE;
  95. port.irq = ACTING_UART1_INT;
  96. port.line = 1;
  97. if (early_serial_setup(&port) != 0) {
  98. printk("Early serial init of port 1 failed\n");
  99. }
  100. }
  101. void __init
  102. bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
  103. {
  104. unsigned int bar_response, bar;
  105. /*
  106. * Expected PCI mapping:
  107. *
  108. * PLB addr PCI memory addr
  109. * --------------------- ---------------------
  110. * 0000'0000 - 7fff'ffff <--- 0000'0000 - 7fff'ffff
  111. * 8000'0000 - Bfff'ffff ---> 8000'0000 - Bfff'ffff
  112. *
  113. * PLB addr PCI io addr
  114. * --------------------- ---------------------
  115. * e800'0000 - e800'ffff ---> 0000'0000 - 0001'0000
  116. *
  117. * The following code is simplified by assuming that the bootrom
  118. * has been well behaved in following this mapping.
  119. */
  120. #ifdef DEBUG
  121. int i;
  122. printk("ioremap PCLIO_BASE = 0x%x\n", pcip);
  123. printk("PCI bridge regs before fixup \n");
  124. for (i = 0; i <= 3; i++) {
  125. printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].ma)));
  126. printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].la)));
  127. printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].pcila)));
  128. printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].pciha)));
  129. }
  130. printk(" ptm1ms\t0x%x\n", in_le32(&(pcip->ptm1ms)));
  131. printk(" ptm1la\t0x%x\n", in_le32(&(pcip->ptm1la)));
  132. printk(" ptm2ms\t0x%x\n", in_le32(&(pcip->ptm2ms)));
  133. printk(" ptm2la\t0x%x\n", in_le32(&(pcip->ptm2la)));
  134. #endif
  135. /* added for IBM boot rom version 1.15 bios bar changes -AK */
  136. /* Disable region first */
  137. out_le32((void *) &(pcip->pmm[0].ma), 0x00000000);
  138. /* PLB starting addr, PCI: 0x80000000 */
  139. out_le32((void *) &(pcip->pmm[0].la), 0x80000000);
  140. /* PCI start addr, 0x80000000 */
  141. out_le32((void *) &(pcip->pmm[0].pcila), PPC405_PCI_MEM_BASE);
  142. /* 512MB range of PLB to PCI */
  143. out_le32((void *) &(pcip->pmm[0].pciha), 0x00000000);
  144. /* Enable no pre-fetch, enable region */
  145. out_le32((void *) &(pcip->pmm[0].ma), ((0xffffffff -
  146. (PPC405_PCI_UPPER_MEM -
  147. PPC405_PCI_MEM_BASE)) | 0x01));
  148. /* Disable region one */
  149. out_le32((void *) &(pcip->pmm[1].ma), 0x00000000);
  150. out_le32((void *) &(pcip->pmm[1].la), 0x00000000);
  151. out_le32((void *) &(pcip->pmm[1].pcila), 0x00000000);
  152. out_le32((void *) &(pcip->pmm[1].pciha), 0x00000000);
  153. out_le32((void *) &(pcip->pmm[1].ma), 0x00000000);
  154. out_le32((void *) &(pcip->ptm1ms), 0x00000001);
  155. /* Disable region two */
  156. out_le32((void *) &(pcip->pmm[2].ma), 0x00000000);
  157. out_le32((void *) &(pcip->pmm[2].la), 0x00000000);
  158. out_le32((void *) &(pcip->pmm[2].pcila), 0x00000000);
  159. out_le32((void *) &(pcip->pmm[2].pciha), 0x00000000);
  160. out_le32((void *) &(pcip->pmm[2].ma), 0x00000000);
  161. out_le32((void *) &(pcip->ptm2ms), 0x00000000);
  162. out_le32((void *) &(pcip->ptm2la), 0x00000000);
  163. /* Zero config bars */
  164. for (bar = PCI_BASE_ADDRESS_1; bar <= PCI_BASE_ADDRESS_2; bar += 4) {
  165. early_write_config_dword(hose, hose->first_busno,
  166. PCI_FUNC(hose->first_busno), bar,
  167. 0x00000000);
  168. early_read_config_dword(hose, hose->first_busno,
  169. PCI_FUNC(hose->first_busno), bar,
  170. &bar_response);
  171. DBG("BUS %d, device %d, Function %d bar 0x%8.8x is 0x%8.8x\n",
  172. hose->first_busno, PCI_SLOT(hose->first_busno),
  173. PCI_FUNC(hose->first_busno), bar, bar_response);
  174. }
  175. /* end work arround */
  176. #ifdef DEBUG
  177. printk("PCI bridge regs after fixup \n");
  178. for (i = 0; i <= 3; i++) {
  179. printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].ma)));
  180. printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].la)));
  181. printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].pcila)));
  182. printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].pciha)));
  183. }
  184. printk(" ptm1ms\t0x%x\n", in_le32(&(pcip->ptm1ms)));
  185. printk(" ptm1la\t0x%x\n", in_le32(&(pcip->ptm1la)));
  186. printk(" ptm2ms\t0x%x\n", in_le32(&(pcip->ptm2ms)));
  187. printk(" ptm2la\t0x%x\n", in_le32(&(pcip->ptm2la)));
  188. #endif
  189. }
  190. void __init
  191. bubinga_setup_arch(void)
  192. {
  193. ppc4xx_setup_arch();
  194. ibm_ocp_set_emac(0, 1);
  195. bubinga_early_serial_map();
  196. /* RTC step for the evb405ep */
  197. bubinga_rtc_base = (void *) BUBINGA_RTC_VADDR;
  198. TODC_INIT(TODC_TYPE_DS1743, bubinga_rtc_base, bubinga_rtc_base,
  199. bubinga_rtc_base, 8);
  200. /* Identify the system */
  201. printk("IBM Bubinga port (MontaVista Software, Inc. <source@mvista.com>)\n");
  202. }
  203. void __init
  204. bubinga_map_io(void)
  205. {
  206. ppc4xx_map_io();
  207. io_block_mapping(BUBINGA_RTC_VADDR,
  208. BUBINGA_RTC_PADDR, BUBINGA_RTC_SIZE, _PAGE_IO);
  209. }
  210. void __init
  211. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  212. unsigned long r6, unsigned long r7)
  213. {
  214. ppc4xx_init(r3, r4, r5, r6, r7);
  215. ppc_md.setup_arch = bubinga_setup_arch;
  216. ppc_md.setup_io_mappings = bubinga_map_io;
  217. #ifdef CONFIG_GEN_RTC
  218. ppc_md.time_init = todc_time_init;
  219. ppc_md.set_rtc_time = todc_set_rtc_time;
  220. ppc_md.get_rtc_time = todc_get_rtc_time;
  221. ppc_md.nvram_read_val = todc_direct_read_val;
  222. ppc_md.nvram_write_val = todc_direct_write_val;
  223. #endif
  224. #ifdef CONFIG_KGDB
  225. ppc_md.early_serial_map = bubinga_early_serial_map;
  226. #endif
  227. }