tx25.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*
  2. * (C) Copyright 2009 DENX Software Engineering
  3. * Author: John Rigby <jrigby@gmail.com>
  4. *
  5. * Based on imx27lite.c:
  6. * Copyright (C) 2008,2009 Eric Jarrige <jorasse@users.sourceforge.net>
  7. * Copyright (C) 2009 Ilya Yanok <yanok@emcraft.com>
  8. * And:
  9. * RedBoot tx25_misc.c Copyright (C) 2009 Red Hat
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. *
  26. */
  27. #include <common.h>
  28. #include <asm/io.h>
  29. #include <asm/arch/imx-regs.h>
  30. #include <asm/arch/iomux-mx25.h>
  31. #include <asm/gpio.h>
  32. DECLARE_GLOBAL_DATA_PTR;
  33. #ifdef CONFIG_SPL_BUILD
  34. void board_init_f(ulong bootflag)
  35. {
  36. /*
  37. * copy ourselves from where we are running to where we were
  38. * linked at. Use ulong pointers as all addresses involved
  39. * are 4-byte-aligned.
  40. */
  41. ulong *start_ptr, *end_ptr, *link_ptr, *run_ptr, *dst;
  42. asm volatile ("ldr %0, =_start" : "=r"(start_ptr));
  43. asm volatile ("ldr %0, =_end" : "=r"(end_ptr));
  44. asm volatile ("ldr %0, =board_init_f" : "=r"(link_ptr));
  45. asm volatile ("adr %0, board_init_f" : "=r"(run_ptr));
  46. for (dst = start_ptr; dst < end_ptr; dst++)
  47. *dst = *(dst+(run_ptr-link_ptr));
  48. /*
  49. * branch to nand_boot's link-time address.
  50. */
  51. asm volatile("ldr pc, =nand_boot");
  52. }
  53. #endif
  54. #ifdef CONFIG_FEC_MXC
  55. /*
  56. * FIXME: need to revisit this
  57. * The original code enabled PUE and 100-k pull-down without PKE, so the right
  58. * value here is likely:
  59. * 0 for no pull
  60. * or:
  61. * PAD_CTL_PUS_100K_DOWN for 100-k pull-down
  62. */
  63. #define FEC_OUT_PAD_CTRL 0
  64. #define GPIO_FEC_RESET_B IMX_GPIO_NR(4, 7)
  65. #define GPIO_FEC_ENABLE_B IMX_GPIO_NR(4, 9)
  66. void tx25_fec_init(void)
  67. {
  68. static const iomux_v3_cfg_t fec_pads[] = {
  69. MX25_PAD_FEC_TX_CLK__FEC_TX_CLK,
  70. MX25_PAD_FEC_RX_DV__FEC_RX_DV,
  71. MX25_PAD_FEC_RDATA0__FEC_RDATA0,
  72. NEW_PAD_CTRL(MX25_PAD_FEC_TDATA0__FEC_TDATA0, FEC_OUT_PAD_CTRL),
  73. NEW_PAD_CTRL(MX25_PAD_FEC_TX_EN__FEC_TX_EN, FEC_OUT_PAD_CTRL),
  74. NEW_PAD_CTRL(MX25_PAD_FEC_MDC__FEC_MDC, FEC_OUT_PAD_CTRL),
  75. MX25_PAD_FEC_MDIO__FEC_MDIO,
  76. MX25_PAD_FEC_RDATA1__FEC_RDATA1,
  77. NEW_PAD_CTRL(MX25_PAD_FEC_TDATA1__FEC_TDATA1, FEC_OUT_PAD_CTRL),
  78. NEW_PAD_CTRL(MX25_PAD_D13__GPIO_4_7, 0), /* FEC_RESET_B */
  79. NEW_PAD_CTRL(MX25_PAD_D11__GPIO_4_9, 0), /* FEC_ENABLE_B */
  80. };
  81. static const iomux_v3_cfg_t fec_cfg_pads[] = {
  82. MX25_PAD_FEC_RDATA0__GPIO_3_10,
  83. MX25_PAD_FEC_RDATA1__GPIO_3_11,
  84. MX25_PAD_FEC_RX_DV__GPIO_3_12,
  85. };
  86. debug("tx25_fec_init\n");
  87. imx_iomux_v3_setup_multiple_pads(fec_pads, ARRAY_SIZE(fec_pads));
  88. /* drop PHY power and assert reset (low) */
  89. gpio_direction_output(GPIO_FEC_RESET_B, 0);
  90. gpio_direction_output(GPIO_FEC_ENABLE_B, 0);
  91. mdelay(5);
  92. debug("resetting phy\n");
  93. /* turn on PHY power leaving reset asserted */
  94. gpio_set_value(GPIO_FEC_ENABLE_B, 1);
  95. mdelay(10);
  96. /*
  97. * Setup some strapping pins that are latched by the PHY
  98. * as reset goes high.
  99. *
  100. * Set PHY mode to 111
  101. * mode0 comes from FEC_RDATA0 which is GPIO 3_10 in mux mode 5
  102. * mode1 comes from FEC_RDATA1 which is GPIO 3_11 in mux mode 5
  103. * mode2 is tied high so nothing to do
  104. *
  105. * Turn on RMII mode
  106. * RMII mode is selected by FEC_RX_DV which is GPIO 3_12 in mux mode
  107. */
  108. /*
  109. * set each mux mode to gpio mode
  110. */
  111. imx_iomux_v3_setup_multiple_pads(fec_cfg_pads,
  112. ARRAY_SIZE(fec_cfg_pads));
  113. /*
  114. * set each to 1 and make each an output
  115. */
  116. gpio_direction_output(IMX_GPIO_NR(3, 10), 1);
  117. gpio_direction_output(IMX_GPIO_NR(3, 11), 1);
  118. gpio_direction_output(IMX_GPIO_NR(3, 12), 1);
  119. mdelay(22); /* this value came from RedBoot */
  120. /*
  121. * deassert PHY reset
  122. */
  123. gpio_set_value(GPIO_FEC_RESET_B, 1);
  124. mdelay(5);
  125. /*
  126. * set FEC pins back
  127. */
  128. imx_iomux_v3_setup_multiple_pads(fec_pads, ARRAY_SIZE(fec_pads));
  129. }
  130. #else
  131. #define tx25_fec_init()
  132. #endif
  133. #ifdef CONFIG_MXC_UART
  134. /*
  135. * Set up input pins with hysteresis and 100-k pull-ups
  136. */
  137. #define UART1_IN_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_100K_UP)
  138. /*
  139. * FIXME: need to revisit this
  140. * The original code enabled PUE and 100-k pull-down without PKE, so the right
  141. * value here is likely:
  142. * 0 for no pull
  143. * or:
  144. * PAD_CTL_PUS_100K_DOWN for 100-k pull-down
  145. */
  146. #define UART1_OUT_PAD_CTRL 0
  147. static void tx25_uart1_init(void)
  148. {
  149. static const iomux_v3_cfg_t uart1_pads[] = {
  150. NEW_PAD_CTRL(MX25_PAD_UART1_RXD__UART1_RXD, UART1_IN_PAD_CTRL),
  151. NEW_PAD_CTRL(MX25_PAD_UART1_TXD__UART1_TXD, UART1_OUT_PAD_CTRL),
  152. NEW_PAD_CTRL(MX25_PAD_UART1_RTS__UART1_RTS, UART1_OUT_PAD_CTRL),
  153. NEW_PAD_CTRL(MX25_PAD_UART1_CTS__UART1_CTS, UART1_IN_PAD_CTRL),
  154. };
  155. imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
  156. }
  157. #else
  158. #define tx25_uart1_init()
  159. #endif
  160. int board_init()
  161. {
  162. tx25_uart1_init();
  163. /* board id for linux */
  164. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  165. return 0;
  166. }
  167. int board_late_init(void)
  168. {
  169. tx25_fec_init();
  170. return 0;
  171. }
  172. int dram_init(void)
  173. {
  174. /* dram_init must store complete ramsize in gd->ram_size */
  175. gd->ram_size = get_ram_size((void *)PHYS_SDRAM_1,
  176. PHYS_SDRAM_1_SIZE);
  177. return 0;
  178. }
  179. void dram_init_banksize(void)
  180. {
  181. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  182. gd->bd->bi_dram[0].size = get_ram_size((void *)PHYS_SDRAM_1,
  183. PHYS_SDRAM_1_SIZE);
  184. #if CONFIG_NR_DRAM_BANKS > 1
  185. gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
  186. gd->bd->bi_dram[1].size = get_ram_size((void *)PHYS_SDRAM_2,
  187. PHYS_SDRAM_2_SIZE);
  188. #else
  189. #endif
  190. }
  191. int checkboard(void)
  192. {
  193. printf("KARO TX25\n");
  194. return 0;
  195. }