zmx25.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * (c) 2011 Graf-Syteco, Matthias Weisser
  3. * <weisserm@arcor.de>
  4. *
  5. * Based on tx25.c:
  6. * (C) Copyright 2009 DENX Software Engineering
  7. * Author: John Rigby <jrigby@gmail.com>
  8. *
  9. * Based on imx27lite.c:
  10. * Copyright (C) 2008,2009 Eric Jarrige <jorasse@users.sourceforge.net>
  11. * Copyright (C) 2009 Ilya Yanok <yanok@emcraft.com>
  12. * And:
  13. * RedBoot tx25_misc.c Copyright (C) 2009 Red Hat
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28. * MA 02111-1307 USA
  29. *
  30. */
  31. #include <common.h>
  32. #include <asm/gpio.h>
  33. #include <asm/io.h>
  34. #include <asm/arch/imx-regs.h>
  35. #include <asm/arch/imx25-pinmux.h>
  36. DECLARE_GLOBAL_DATA_PTR;
  37. int board_init()
  38. {
  39. struct iomuxc_mux_ctl *muxctl;
  40. struct iomuxc_pad_ctl *padctl;
  41. struct iomuxc_pad_input_select *inputselect;
  42. u32 gpio_mux_mode0_sion = MX25_PIN_MUX_MODE(0) | MX25_PIN_MUX_SION;
  43. u32 gpio_mux_mode1 = MX25_PIN_MUX_MODE(1);
  44. u32 gpio_mux_mode5 = MX25_PIN_MUX_MODE(5);
  45. u32 gpio_mux_mode6 = MX25_PIN_MUX_MODE(6);
  46. u32 input_select1 = MX25_PAD_INPUT_SELECT_DAISY(1);
  47. u32 input_select2 = MX25_PAD_INPUT_SELECT_DAISY(2);
  48. icache_enable();
  49. muxctl = (struct iomuxc_mux_ctl *)IMX_IOPADMUX_BASE;
  50. padctl = (struct iomuxc_pad_ctl *)IMX_IOPADCTL_BASE;
  51. inputselect = (struct iomuxc_pad_input_select *)IMX_IOPADINPUTSEL_BASE;
  52. /* Setup of core volatage selection pin to run at 1.4V */
  53. writel(gpio_mux_mode5, &muxctl->pad_ext_armclk); /* VCORE GPIO3[15] */
  54. gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 15), 1);
  55. /* Setup of input daisy chains for SD card pins*/
  56. writel(gpio_mux_mode0_sion, &muxctl->pad_sd1_cmd);
  57. writel(gpio_mux_mode0_sion, &muxctl->pad_sd1_clk);
  58. writel(gpio_mux_mode0_sion, &muxctl->pad_sd1_data0);
  59. writel(gpio_mux_mode0_sion, &muxctl->pad_sd1_data1);
  60. writel(gpio_mux_mode0_sion, &muxctl->pad_sd1_data2);
  61. writel(gpio_mux_mode0_sion, &muxctl->pad_sd1_data3);
  62. /* Setup of digital output for USB power and OC */
  63. writel(gpio_mux_mode5, &muxctl->pad_csi_d3); /* USB Power GPIO1[28] */
  64. gpio_direction_output(MXC_GPIO_PORT_TO_NUM(1, 28), 1);
  65. writel(gpio_mux_mode5, &muxctl->pad_csi_d2); /* USB OC GPIO1[27] */
  66. gpio_direction_input(MXC_GPIO_PORT_TO_NUM(1, 18));
  67. /* Setup of digital output control pins */
  68. writel(gpio_mux_mode5, &muxctl->pad_csi_d8); /* Ouput 1 Ctrl GPIO1[7] */
  69. writel(gpio_mux_mode5, &muxctl->pad_csi_d7); /* Ouput 2 Ctrl GPIO1[6] */
  70. writel(gpio_mux_mode5, &muxctl->pad_csi_d6); /* Ouput 1 Stat GPIO1[31]*/
  71. writel(gpio_mux_mode5, &muxctl->pad_csi_d5); /* Ouput 2 Stat GPIO1[30]*/
  72. writel(0, &padctl->pad_csi_d6); /* Ouput 1 Stat pull up off */
  73. writel(0, &padctl->pad_csi_d5); /* Ouput 2 Stat pull up off */
  74. /* Switch both output drivers off */
  75. gpio_direction_output(MXC_GPIO_PORT_TO_NUM(1, 7), 0);
  76. gpio_direction_output(MXC_GPIO_PORT_TO_NUM(1, 6), 0);
  77. /* Setup of key input pin GPIO2[29]*/
  78. writel(gpio_mux_mode5 | MX25_PIN_MUX_SION, &muxctl->pad_kpp_row0);
  79. writel(0, &padctl->pad_kpp_row0); /* Key pull up off */
  80. gpio_direction_input(MXC_GPIO_PORT_TO_NUM(2, 29));
  81. /* Setup of status LED outputs */
  82. writel(gpio_mux_mode5, &muxctl->pad_csi_d9); /* GPIO4[21] */
  83. writel(gpio_mux_mode5, &muxctl->pad_csi_d4); /* GPIO1[29] */
  84. /* Switch both LEDs off */
  85. gpio_direction_output(MXC_GPIO_PORT_TO_NUM(4, 21), 0);
  86. gpio_direction_output(MXC_GPIO_PORT_TO_NUM(1, 29), 0);
  87. /* Setup of CAN1 and CAN2 signals */
  88. writel(gpio_mux_mode6, &muxctl->pad_gpio_a); /* CAN1 TX */
  89. writel(gpio_mux_mode6, &muxctl->pad_gpio_b); /* CAN1 RX */
  90. writel(gpio_mux_mode6, &muxctl->pad_gpio_c); /* CAN2 TX */
  91. writel(gpio_mux_mode6, &muxctl->pad_gpio_d); /* CAN2 RX */
  92. /* Setup of input daisy chains for CAN signals*/
  93. writel(input_select1, &inputselect->can1_ipp_ind_canrx); /* CAN1 RX */
  94. writel(input_select1, &inputselect->can2_ipp_ind_canrx); /* CAN2 RX */
  95. /* Setup of I2C3 signals */
  96. writel(gpio_mux_mode1, &muxctl->pad_cspi1_ss1); /* I2C3 SDA */
  97. writel(gpio_mux_mode1, &muxctl->pad_gpio_e); /* I2C3 SCL */
  98. /* Setup of input daisy chains for I2C3 signals*/
  99. writel(input_select1, &inputselect->i2c3_ipp_sda_in); /* I2C3 SDA */
  100. writel(input_select2, &inputselect->i2c3_ipp_scl_in); /* I2C3 SCL */
  101. gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
  102. return 0;
  103. }
  104. int board_late_init(void)
  105. {
  106. const char *e;
  107. #ifdef CONFIG_FEC_MXC
  108. struct iomuxc_mux_ctl *muxctl;
  109. struct iomuxc_pad_ctl *padctl;
  110. u32 gpio_mux_mode2 = MX25_PIN_MUX_MODE(2);
  111. u32 gpio_mux_mode5 = MX25_PIN_MUX_MODE(5);
  112. /*
  113. * fec pin init is generic
  114. */
  115. mx25_fec_init_pins();
  116. /*
  117. * Set up LAN-RESET and FEC_RX_ERR
  118. *
  119. * LAN-RESET: GPIO3[16] is ALT 5 mode of pin U20
  120. * FEC_RX_ERR: FEC_RX_ERR is ALT 2 mode of pin R2
  121. */
  122. muxctl = (struct iomuxc_mux_ctl *)IMX_IOPADMUX_BASE;
  123. padctl = (struct iomuxc_pad_ctl *)IMX_IOPADCTL_BASE;
  124. writel(gpio_mux_mode5, &muxctl->pad_upll_bypclk);
  125. writel(gpio_mux_mode2, &muxctl->pad_uart2_cts);
  126. /* assert PHY reset (low) */
  127. gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 16), 0);
  128. udelay(5000);
  129. /* deassert PHY reset */
  130. gpio_set_value(MXC_GPIO_PORT_TO_NUM(3, 16), 1);
  131. udelay(5000);
  132. #endif
  133. e = getenv("gs_base_board");
  134. if (e != NULL) {
  135. if (strcmp(e, "G283") == 0) {
  136. int key = gpio_get_value(MXC_GPIO_PORT_TO_NUM(2, 29));
  137. if (key) {
  138. /* Switch on both LEDs to inidcate boot mode */
  139. gpio_set_value(MXC_GPIO_PORT_TO_NUM(1, 29), 0);
  140. gpio_set_value(MXC_GPIO_PORT_TO_NUM(4, 21), 0);
  141. setenv("preboot", "run gs_slow_boot");
  142. } else
  143. setenv("preboot", "run gs_fast_boot");
  144. }
  145. }
  146. return 0;
  147. }
  148. int dram_init(void)
  149. {
  150. /* dram_init must store complete ramsize in gd->ram_size */
  151. gd->ram_size = get_ram_size((void *)PHYS_SDRAM,
  152. PHYS_SDRAM_SIZE);
  153. return 0;
  154. }