tx25.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. relocate_code(CONFIG_SPL_TEXT_BASE);
  37. asm volatile("ldr pc, =nand_boot");
  38. }
  39. #endif
  40. #ifdef CONFIG_FEC_MXC
  41. /*
  42. * FIXME: need to revisit this
  43. * The original code enabled PUE and 100-k pull-down without PKE, so the right
  44. * value here is likely:
  45. * 0 for no pull
  46. * or:
  47. * PAD_CTL_PUS_100K_DOWN for 100-k pull-down
  48. */
  49. #define FEC_OUT_PAD_CTRL 0
  50. #define GPIO_FEC_RESET_B IMX_GPIO_NR(4, 7)
  51. #define GPIO_FEC_ENABLE_B IMX_GPIO_NR(4, 9)
  52. void tx25_fec_init(void)
  53. {
  54. static const iomux_v3_cfg_t fec_pads[] = {
  55. MX25_PAD_FEC_TX_CLK__FEC_TX_CLK,
  56. MX25_PAD_FEC_RX_DV__FEC_RX_DV,
  57. MX25_PAD_FEC_RDATA0__FEC_RDATA0,
  58. NEW_PAD_CTRL(MX25_PAD_FEC_TDATA0__FEC_TDATA0, FEC_OUT_PAD_CTRL),
  59. NEW_PAD_CTRL(MX25_PAD_FEC_TX_EN__FEC_TX_EN, FEC_OUT_PAD_CTRL),
  60. NEW_PAD_CTRL(MX25_PAD_FEC_MDC__FEC_MDC, FEC_OUT_PAD_CTRL),
  61. MX25_PAD_FEC_MDIO__FEC_MDIO,
  62. MX25_PAD_FEC_RDATA1__FEC_RDATA1,
  63. NEW_PAD_CTRL(MX25_PAD_FEC_TDATA1__FEC_TDATA1, FEC_OUT_PAD_CTRL),
  64. NEW_PAD_CTRL(MX25_PAD_D13__GPIO_4_7, 0), /* FEC_RESET_B */
  65. NEW_PAD_CTRL(MX25_PAD_D11__GPIO_4_9, 0), /* FEC_ENABLE_B */
  66. };
  67. static const iomux_v3_cfg_t fec_cfg_pads[] = {
  68. MX25_PAD_FEC_RDATA0__GPIO_3_10,
  69. MX25_PAD_FEC_RDATA1__GPIO_3_11,
  70. MX25_PAD_FEC_RX_DV__GPIO_3_12,
  71. };
  72. debug("tx25_fec_init\n");
  73. imx_iomux_v3_setup_multiple_pads(fec_pads, ARRAY_SIZE(fec_pads));
  74. /* drop PHY power and assert reset (low) */
  75. gpio_direction_output(GPIO_FEC_RESET_B, 0);
  76. gpio_direction_output(GPIO_FEC_ENABLE_B, 0);
  77. mdelay(5);
  78. debug("resetting phy\n");
  79. /* turn on PHY power leaving reset asserted */
  80. gpio_set_value(GPIO_FEC_ENABLE_B, 1);
  81. mdelay(10);
  82. /*
  83. * Setup some strapping pins that are latched by the PHY
  84. * as reset goes high.
  85. *
  86. * Set PHY mode to 111
  87. * mode0 comes from FEC_RDATA0 which is GPIO 3_10 in mux mode 5
  88. * mode1 comes from FEC_RDATA1 which is GPIO 3_11 in mux mode 5
  89. * mode2 is tied high so nothing to do
  90. *
  91. * Turn on RMII mode
  92. * RMII mode is selected by FEC_RX_DV which is GPIO 3_12 in mux mode
  93. */
  94. /*
  95. * set each mux mode to gpio mode
  96. */
  97. imx_iomux_v3_setup_multiple_pads(fec_cfg_pads,
  98. ARRAY_SIZE(fec_cfg_pads));
  99. /*
  100. * set each to 1 and make each an output
  101. */
  102. gpio_direction_output(IMX_GPIO_NR(3, 10), 1);
  103. gpio_direction_output(IMX_GPIO_NR(3, 11), 1);
  104. gpio_direction_output(IMX_GPIO_NR(3, 12), 1);
  105. mdelay(22); /* this value came from RedBoot */
  106. /*
  107. * deassert PHY reset
  108. */
  109. gpio_set_value(GPIO_FEC_RESET_B, 1);
  110. mdelay(5);
  111. /*
  112. * set FEC pins back
  113. */
  114. imx_iomux_v3_setup_multiple_pads(fec_pads, ARRAY_SIZE(fec_pads));
  115. }
  116. #else
  117. #define tx25_fec_init()
  118. #endif
  119. #ifdef CONFIG_MXC_UART
  120. /*
  121. * Set up input pins with hysteresis and 100-k pull-ups
  122. */
  123. #define UART1_IN_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_100K_UP)
  124. /*
  125. * FIXME: need to revisit this
  126. * The original code enabled PUE and 100-k pull-down without PKE, so the right
  127. * value here is likely:
  128. * 0 for no pull
  129. * or:
  130. * PAD_CTL_PUS_100K_DOWN for 100-k pull-down
  131. */
  132. #define UART1_OUT_PAD_CTRL 0
  133. static void tx25_uart1_init(void)
  134. {
  135. static const iomux_v3_cfg_t uart1_pads[] = {
  136. NEW_PAD_CTRL(MX25_PAD_UART1_RXD__UART1_RXD, UART1_IN_PAD_CTRL),
  137. NEW_PAD_CTRL(MX25_PAD_UART1_TXD__UART1_TXD, UART1_OUT_PAD_CTRL),
  138. NEW_PAD_CTRL(MX25_PAD_UART1_RTS__UART1_RTS, UART1_OUT_PAD_CTRL),
  139. NEW_PAD_CTRL(MX25_PAD_UART1_CTS__UART1_CTS, UART1_IN_PAD_CTRL),
  140. };
  141. imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
  142. }
  143. #else
  144. #define tx25_uart1_init()
  145. #endif
  146. int board_init()
  147. {
  148. tx25_uart1_init();
  149. /* board id for linux */
  150. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  151. return 0;
  152. }
  153. int board_late_init(void)
  154. {
  155. tx25_fec_init();
  156. return 0;
  157. }
  158. int dram_init(void)
  159. {
  160. /* dram_init must store complete ramsize in gd->ram_size */
  161. gd->ram_size = get_ram_size((void *)PHYS_SDRAM_1,
  162. PHYS_SDRAM_1_SIZE);
  163. return 0;
  164. }
  165. void dram_init_banksize(void)
  166. {
  167. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  168. gd->bd->bi_dram[0].size = get_ram_size((void *)PHYS_SDRAM_1,
  169. PHYS_SDRAM_1_SIZE);
  170. #if CONFIG_NR_DRAM_BANKS > 1
  171. gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
  172. gd->bd->bi_dram[1].size = get_ram_size((void *)PHYS_SDRAM_2,
  173. PHYS_SDRAM_2_SIZE);
  174. #else
  175. #endif
  176. }
  177. int checkboard(void)
  178. {
  179. printf("KARO TX25\n");
  180. return 0;
  181. }