ea20.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. DECLARE_GLOBAL_DATA_PTR;
  38. #define pinmux(x) (&davinci_syscfg_regs->pinmux[x])
  39. /* SPI0 pin muxer settings */
  40. static const struct pinmux_config spi1_pins[] = {
  41. { pinmux(5), 1, 1 },
  42. { pinmux(5), 1, 2 },
  43. { pinmux(5), 1, 4 },
  44. { pinmux(5), 1, 5 }
  45. };
  46. /* UART pin muxer settings */
  47. static const struct pinmux_config uart_pins[] = {
  48. { pinmux(0), 4, 6 },
  49. { pinmux(0), 4, 7 },
  50. { pinmux(4), 2, 4 },
  51. { pinmux(4), 2, 5 }
  52. };
  53. #ifdef CONFIG_DRIVER_TI_EMAC
  54. #define HAS_RMII 1
  55. static const struct pinmux_config emac_pins[] = {
  56. { pinmux(14), 8, 2 },
  57. { pinmux(14), 8, 3 },
  58. { pinmux(14), 8, 4 },
  59. { pinmux(14), 8, 5 },
  60. { pinmux(14), 8, 6 },
  61. { pinmux(14), 8, 7 },
  62. { pinmux(15), 8, 1 },
  63. { pinmux(4), 8, 0 },
  64. { pinmux(4), 8, 1 }
  65. };
  66. #endif
  67. #ifdef CONFIG_NAND_DAVINCI
  68. const struct pinmux_config nand_pins[] = {
  69. { pinmux(7), 1, 1 },
  70. { pinmux(7), 1, 2 },
  71. { pinmux(7), 1, 4 },
  72. { pinmux(7), 1, 5 },
  73. { pinmux(9), 1, 0 },
  74. { pinmux(9), 1, 1 },
  75. { pinmux(9), 1, 2 },
  76. { pinmux(9), 1, 3 },
  77. { pinmux(9), 1, 4 },
  78. { pinmux(9), 1, 5 },
  79. { pinmux(9), 1, 6 },
  80. { pinmux(9), 1, 7 },
  81. { pinmux(12), 1, 5 },
  82. { pinmux(12), 1, 6 }
  83. };
  84. #endif
  85. static const struct pinmux_resource pinmuxes[] = {
  86. #ifdef CONFIG_SPI_FLASH
  87. PINMUX_ITEM(spi1_pins),
  88. #endif
  89. PINMUX_ITEM(uart_pins),
  90. #ifdef CONFIG_NAND_DAVINCI
  91. PINMUX_ITEM(nand_pins),
  92. #endif
  93. };
  94. static const struct lpsc_resource lpsc[] = {
  95. { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
  96. { DAVINCI_LPSC_SPI1 }, /* Serial Flash */
  97. { DAVINCI_LPSC_EMAC }, /* image download */
  98. { DAVINCI_LPSC_UART2 }, /* console */
  99. { DAVINCI_LPSC_GPIO },
  100. };
  101. int board_init(void)
  102. {
  103. #ifndef CONFIG_USE_IRQ
  104. irq_init();
  105. #endif
  106. #ifdef CONFIG_NAND_DAVINCI
  107. /*
  108. * NAND CS setup - cycle counts based on da850evm NAND timings in the
  109. * Linux kernel @ 25MHz EMIFA
  110. */
  111. writel((DAVINCI_ABCR_WSETUP(0) |
  112. DAVINCI_ABCR_WSTROBE(0) |
  113. DAVINCI_ABCR_WHOLD(0) |
  114. DAVINCI_ABCR_RSETUP(0) |
  115. DAVINCI_ABCR_RSTROBE(1) |
  116. DAVINCI_ABCR_RHOLD(0) |
  117. DAVINCI_ABCR_TA(0) |
  118. DAVINCI_ABCR_ASIZE_8BIT),
  119. &davinci_emif_regs->ab2cr); /* CS3 */
  120. #endif
  121. /* arch number of the board */
  122. gd->bd->bi_arch_number = MACH_TYPE_EA20;
  123. /* address of boot parameters */
  124. gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
  125. /*
  126. * Power on required peripherals
  127. * ARM does not have access by default to PSC0 and PSC1
  128. * assuming here that the DSP bootloader has set the IOPU
  129. * such that PSC access is available to ARM
  130. */
  131. if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)))
  132. return 1;
  133. /* setup the SUSPSRC for ARM to control emulation suspend */
  134. writel(readl(&davinci_syscfg_regs->suspsrc) &
  135. ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
  136. DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
  137. DAVINCI_SYSCFG_SUSPSRC_UART2),
  138. &davinci_syscfg_regs->suspsrc);
  139. /* configure pinmux settings */
  140. if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
  141. return 1;
  142. #ifdef CONFIG_DRIVER_TI_EMAC
  143. if (davinci_configure_pin_mux(emac_pins, ARRAY_SIZE(emac_pins)) != 0)
  144. return 1;
  145. davinci_emac_mii_mode_sel(HAS_RMII);
  146. #endif /* CONFIG_DRIVER_TI_EMAC */
  147. /* enable the console UART */
  148. writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
  149. DAVINCI_UART_PWREMU_MGMT_UTRST),
  150. &davinci_uart2_ctrl_regs->pwremu_mgmt);
  151. return 0;
  152. }
  153. #ifdef CONFIG_DRIVER_TI_EMAC
  154. /*
  155. * Initializes on-board ethernet controllers.
  156. */
  157. int board_eth_init(bd_t *bis)
  158. {
  159. if (!davinci_emac_initialize()) {
  160. printf("Error: Ethernet init failed!\n");
  161. return -1;
  162. }
  163. /*
  164. * This board has a RMII PHY. However, the MDC line on the SOM
  165. * must not be disabled (there is no MII PHY on the
  166. * baseboard) via the GPIO2[6], because this pin
  167. * disables at the same time the SPI flash.
  168. */
  169. return 0;
  170. }
  171. #endif /* CONFIG_DRIVER_TI_EMAC */