ea20.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*
  2. * (C) Copyright 2010
  3. * Stefano Babic, DENX Software Engineering, sbabic@denx.de
  4. *
  5. * Based on da850evm.c, original Copyrights follow:
  6. *
  7. * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
  8. *
  9. * Based on da830evm.c. Original Copyrights follow:
  10. *
  11. * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com>
  12. * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27. */
  28. #include <common.h>
  29. #include <i2c.h>
  30. #include <net.h>
  31. #include <netdev.h>
  32. #include <asm/arch/hardware.h>
  33. #include <asm/arch/emif_defs.h>
  34. #include <asm/arch/emac_defs.h>
  35. #include <asm/io.h>
  36. #include <asm/arch/davinci_misc.h>
  37. #include <asm/arch/gpio.h>
  38. DECLARE_GLOBAL_DATA_PTR;
  39. #define pinmux(x) (&davinci_syscfg_regs->pinmux[x])
  40. /* SPI0 pin muxer settings */
  41. static const struct pinmux_config spi1_pins[] = {
  42. { pinmux(5), 1, 1 },
  43. { pinmux(5), 1, 2 },
  44. { pinmux(5), 1, 4 },
  45. { pinmux(5), 1, 5 }
  46. };
  47. /* UART0 pin muxer settings */
  48. static const struct pinmux_config uart_pins[] = {
  49. { pinmux(3), 2, 7 },
  50. { pinmux(3), 2, 6 },
  51. { pinmux(3), 2, 4 },
  52. { pinmux(3), 2, 5 }
  53. };
  54. #ifdef CONFIG_DRIVER_TI_EMAC
  55. #define HAS_RMII 1
  56. static const struct pinmux_config emac_pins[] = {
  57. { pinmux(14), 8, 2 },
  58. { pinmux(14), 8, 3 },
  59. { pinmux(14), 8, 4 },
  60. { pinmux(14), 8, 5 },
  61. { pinmux(14), 8, 6 },
  62. { pinmux(14), 8, 7 },
  63. { pinmux(15), 8, 1 },
  64. { pinmux(4), 8, 0 },
  65. { pinmux(4), 8, 1 }
  66. };
  67. #endif
  68. #ifdef CONFIG_NAND_DAVINCI
  69. const struct pinmux_config nand_pins[] = {
  70. { pinmux(7), 1, 1 },
  71. { pinmux(7), 1, 2 },
  72. { pinmux(7), 1, 4 },
  73. { pinmux(7), 1, 5 },
  74. { pinmux(9), 1, 0 },
  75. { pinmux(9), 1, 1 },
  76. { pinmux(9), 1, 2 },
  77. { pinmux(9), 1, 3 },
  78. { pinmux(9), 1, 4 },
  79. { pinmux(9), 1, 5 },
  80. { pinmux(9), 1, 6 },
  81. { pinmux(9), 1, 7 },
  82. { pinmux(12), 1, 5 },
  83. { pinmux(12), 1, 6 }
  84. };
  85. #endif
  86. const struct pinmux_config gpio_pins[] = {
  87. { pinmux(13), 8, 0 }, /* GPIO6[15] RESETOUTn on SOM*/
  88. { pinmux(13), 8, 5 }, /* GPIO6[10] U0_SW0 on EA20-00101_2*/
  89. { pinmux(13), 8, 3 } /* GPIO6[12] U0_SW1 on EA20-00101_2*/
  90. };
  91. static const struct pinmux_resource pinmuxes[] = {
  92. #ifdef CONFIG_SPI_FLASH
  93. PINMUX_ITEM(spi1_pins),
  94. #endif
  95. PINMUX_ITEM(uart_pins),
  96. #ifdef CONFIG_NAND_DAVINCI
  97. PINMUX_ITEM(nand_pins),
  98. #endif
  99. };
  100. static const struct lpsc_resource lpsc[] = {
  101. { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
  102. { DAVINCI_LPSC_SPI1 }, /* Serial Flash */
  103. { DAVINCI_LPSC_EMAC }, /* image download */
  104. { DAVINCI_LPSC_UART0 }, /* console */
  105. { DAVINCI_LPSC_GPIO },
  106. };
  107. int board_init(void)
  108. {
  109. struct davinci_gpio *gpio6_base =
  110. (struct davinci_gpio *)DAVINCI_GPIO_BANK67;
  111. /* PinMux for GPIO */
  112. if (davinci_configure_pin_mux(gpio_pins, ARRAY_SIZE(gpio_pins)) != 0)
  113. return 1;
  114. /* Set the RESETOUTn low */
  115. writel((readl(&gpio6_base->set_data) & ~(1 << 15)),
  116. &gpio6_base->set_data);
  117. writel((readl(&gpio6_base->dir) & ~(1 << 15)), &gpio6_base->dir);
  118. /* Set U0_SW0 low for UART0 as console*/
  119. writel((readl(&gpio6_base->set_data) & ~(1 << 10)),
  120. &gpio6_base->set_data);
  121. writel((readl(&gpio6_base->dir) & ~(1 << 10)), &gpio6_base->dir);
  122. /* Set U0_SW1 low for UART0 as console*/
  123. writel((readl(&gpio6_base->set_data) & ~(1 << 12)),
  124. &gpio6_base->set_data);
  125. writel((readl(&gpio6_base->dir) & ~(1 << 12)), &gpio6_base->dir);
  126. #ifndef CONFIG_USE_IRQ
  127. irq_init();
  128. #endif
  129. #ifdef CONFIG_NAND_DAVINCI
  130. /*
  131. * NAND CS setup - cycle counts based on da850evm NAND timings in the
  132. * Linux kernel @ 25MHz EMIFA
  133. */
  134. writel((DAVINCI_ABCR_WSETUP(0) |
  135. DAVINCI_ABCR_WSTROBE(0) |
  136. DAVINCI_ABCR_WHOLD(0) |
  137. DAVINCI_ABCR_RSETUP(0) |
  138. DAVINCI_ABCR_RSTROBE(1) |
  139. DAVINCI_ABCR_RHOLD(0) |
  140. DAVINCI_ABCR_TA(0) |
  141. DAVINCI_ABCR_ASIZE_8BIT),
  142. &davinci_emif_regs->ab2cr); /* CS3 */
  143. #endif
  144. /* arch number of the board */
  145. gd->bd->bi_arch_number = MACH_TYPE_EA20;
  146. /* address of boot parameters */
  147. gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
  148. /*
  149. * Power on required peripherals
  150. * ARM does not have access by default to PSC0 and PSC1
  151. * assuming here that the DSP bootloader has set the IOPU
  152. * such that PSC access is available to ARM
  153. */
  154. if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)))
  155. return 1;
  156. /* setup the SUSPSRC for ARM to control emulation suspend */
  157. writel(readl(&davinci_syscfg_regs->suspsrc) &
  158. ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
  159. DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
  160. DAVINCI_SYSCFG_SUSPSRC_UART0),
  161. &davinci_syscfg_regs->suspsrc);
  162. /* configure pinmux settings */
  163. if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
  164. return 1;
  165. #ifdef CONFIG_DRIVER_TI_EMAC
  166. if (davinci_configure_pin_mux(emac_pins, ARRAY_SIZE(emac_pins)) != 0)
  167. return 1;
  168. davinci_emac_mii_mode_sel(HAS_RMII);
  169. #endif /* CONFIG_DRIVER_TI_EMAC */
  170. /* enable the console UART */
  171. writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
  172. DAVINCI_UART_PWREMU_MGMT_UTRST),
  173. &davinci_uart0_ctrl_regs->pwremu_mgmt);
  174. return 0;
  175. }
  176. #ifdef CONFIG_DRIVER_TI_EMAC
  177. /*
  178. * Initializes on-board ethernet controllers.
  179. */
  180. int board_eth_init(bd_t *bis)
  181. {
  182. if (!davinci_emac_initialize()) {
  183. printf("Error: Ethernet init failed!\n");
  184. return -1;
  185. }
  186. /*
  187. * This board has a RMII PHY. However, the MDC line on the SOM
  188. * must not be disabled (there is no MII PHY on the
  189. * baseboard) via the GPIO2[6], because this pin
  190. * disables at the same time the SPI flash.
  191. */
  192. return 0;
  193. }
  194. #endif /* CONFIG_DRIVER_TI_EMAC */