mx25pdk.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2011 Freescale Semiconductor, Inc.
  4. *
  5. * Author: Fabio Estevam <fabio.estevam@freescale.com>
  6. */
  7. #include <common.h>
  8. #include <asm/io.h>
  9. #include <asm/gpio.h>
  10. #include <asm/arch/imx-regs.h>
  11. #include <asm/arch/iomux-mx25.h>
  12. #include <asm/arch/clock.h>
  13. #include <mmc.h>
  14. #include <fsl_esdhc.h>
  15. #include <i2c.h>
  16. #include <power/pmic.h>
  17. #include <fsl_pmic.h>
  18. #include <mc34704.h>
  19. #define FEC_RESET_B IMX_GPIO_NR(4, 8)
  20. #define FEC_ENABLE_B IMX_GPIO_NR(2, 3)
  21. #define CARD_DETECT IMX_GPIO_NR(2, 1)
  22. DECLARE_GLOBAL_DATA_PTR;
  23. #ifdef CONFIG_FSL_ESDHC
  24. struct fsl_esdhc_cfg esdhc_cfg[1] = {
  25. {IMX_MMC_SDHC1_BASE},
  26. };
  27. #endif
  28. /*
  29. * FIXME: need to revisit this
  30. * The original code enabled PUE and 100-k pull-down without PKE, so the right
  31. * value here is likely:
  32. * 0 for no pull
  33. * or:
  34. * PAD_CTL_PUS_100K_DOWN for 100-k pull-down
  35. */
  36. #define FEC_OUT_PAD_CTRL 0
  37. #define I2C_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_100K_UP | \
  38. PAD_CTL_ODE)
  39. static void mx25pdk_fec_init(void)
  40. {
  41. static const iomux_v3_cfg_t fec_pads[] = {
  42. MX25_PAD_FEC_TX_CLK__FEC_TX_CLK,
  43. MX25_PAD_FEC_RX_DV__FEC_RX_DV,
  44. MX25_PAD_FEC_RDATA0__FEC_RDATA0,
  45. NEW_PAD_CTRL(MX25_PAD_FEC_TDATA0__FEC_TDATA0, FEC_OUT_PAD_CTRL),
  46. NEW_PAD_CTRL(MX25_PAD_FEC_TX_EN__FEC_TX_EN, FEC_OUT_PAD_CTRL),
  47. NEW_PAD_CTRL(MX25_PAD_FEC_MDC__FEC_MDC, FEC_OUT_PAD_CTRL),
  48. MX25_PAD_FEC_MDIO__FEC_MDIO,
  49. MX25_PAD_FEC_RDATA1__FEC_RDATA1,
  50. NEW_PAD_CTRL(MX25_PAD_FEC_TDATA1__FEC_TDATA1, FEC_OUT_PAD_CTRL),
  51. NEW_PAD_CTRL(MX25_PAD_D12__GPIO_4_8, 0), /* FEC_RESET_B */
  52. NEW_PAD_CTRL(MX25_PAD_A17__GPIO_2_3, 0), /* FEC_ENABLE_B */
  53. };
  54. static const iomux_v3_cfg_t i2c_pads[] = {
  55. NEW_PAD_CTRL(MX25_PAD_I2C1_CLK__I2C1_CLK, I2C_PAD_CTRL),
  56. NEW_PAD_CTRL(MX25_PAD_I2C1_DAT__I2C1_DAT, I2C_PAD_CTRL),
  57. };
  58. imx_iomux_v3_setup_multiple_pads(fec_pads, ARRAY_SIZE(fec_pads));
  59. /* Assert RESET and ENABLE low */
  60. gpio_direction_output(FEC_RESET_B, 0);
  61. gpio_direction_output(FEC_ENABLE_B, 0);
  62. udelay(10);
  63. /* Deassert RESET and ENABLE */
  64. gpio_set_value(FEC_RESET_B, 1);
  65. gpio_set_value(FEC_ENABLE_B, 1);
  66. /* Setup I2C pins so that PMIC can turn on PHY supply */
  67. imx_iomux_v3_setup_multiple_pads(i2c_pads, ARRAY_SIZE(i2c_pads));
  68. }
  69. int dram_init(void)
  70. {
  71. /* dram_init must store complete ramsize in gd->ram_size */
  72. gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
  73. PHYS_SDRAM_1_SIZE);
  74. return 0;
  75. }
  76. /*
  77. * Set up input pins with hysteresis and 100-k pull-ups
  78. */
  79. #define UART1_IN_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_100K_UP)
  80. /*
  81. * FIXME: need to revisit this
  82. * The original code enabled PUE and 100-k pull-down without PKE, so the right
  83. * value here is likely:
  84. * 0 for no pull
  85. * or:
  86. * PAD_CTL_PUS_100K_DOWN for 100-k pull-down
  87. */
  88. #define UART1_OUT_PAD_CTRL 0
  89. static void mx25pdk_uart1_init(void)
  90. {
  91. static const iomux_v3_cfg_t uart1_pads[] = {
  92. NEW_PAD_CTRL(MX25_PAD_UART1_RXD__UART1_RXD, UART1_IN_PAD_CTRL),
  93. NEW_PAD_CTRL(MX25_PAD_UART1_TXD__UART1_TXD, UART1_OUT_PAD_CTRL),
  94. NEW_PAD_CTRL(MX25_PAD_UART1_RTS__UART1_RTS, UART1_OUT_PAD_CTRL),
  95. NEW_PAD_CTRL(MX25_PAD_UART1_CTS__UART1_CTS, UART1_IN_PAD_CTRL),
  96. };
  97. imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
  98. }
  99. int board_early_init_f(void)
  100. {
  101. mx25pdk_uart1_init();
  102. return 0;
  103. }
  104. int board_init(void)
  105. {
  106. /* address of boot parameters */
  107. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  108. return 0;
  109. }
  110. int board_late_init(void)
  111. {
  112. struct pmic *p;
  113. int ret;
  114. mx25pdk_fec_init();
  115. ret = pmic_init(I2C_0);
  116. if (ret)
  117. return ret;
  118. p = pmic_get("FSL_PMIC");
  119. if (!p)
  120. return -ENODEV;
  121. /* Turn on Ethernet PHY and LCD supplies */
  122. pmic_reg_write(p, MC34704_GENERAL2_REG, ONOFFE | ONOFFA);
  123. return 0;
  124. }
  125. #ifdef CONFIG_FSL_ESDHC
  126. int board_mmc_getcd(struct mmc *mmc)
  127. {
  128. /* Set up the Card Detect pin. */
  129. imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX25_PAD_A15__GPIO_2_1, 0));
  130. gpio_direction_input(CARD_DETECT);
  131. return !gpio_get_value(CARD_DETECT);
  132. }
  133. int board_mmc_init(bd_t *bis)
  134. {
  135. static const iomux_v3_cfg_t sdhc1_pads[] = {
  136. NEW_PAD_CTRL(MX25_PAD_SD1_CMD__SD1_CMD, NO_PAD_CTRL),
  137. NEW_PAD_CTRL(MX25_PAD_SD1_CLK__SD1_CLK, NO_PAD_CTRL),
  138. NEW_PAD_CTRL(MX25_PAD_SD1_DATA0__SD1_DATA0, NO_PAD_CTRL),
  139. NEW_PAD_CTRL(MX25_PAD_SD1_DATA1__SD1_DATA1, NO_PAD_CTRL),
  140. NEW_PAD_CTRL(MX25_PAD_SD1_DATA2__SD1_DATA2, NO_PAD_CTRL),
  141. NEW_PAD_CTRL(MX25_PAD_SD1_DATA3__SD1_DATA3, NO_PAD_CTRL),
  142. };
  143. imx_iomux_v3_setup_multiple_pads(sdhc1_pads, ARRAY_SIZE(sdhc1_pads));
  144. /*
  145. * Set the eSDHC1 PER clock to the maximum frequency lower than or equal
  146. * to 50 MHz that can be obtained, which requires to use UPLL as the
  147. * clock source. This actually gives 48 MHz.
  148. */
  149. imx_set_perclk(MXC_ESDHC1_CLK, true, 50000000);
  150. esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC1_CLK);
  151. return fsl_esdhc_initialize(bis, &esdhc_cfg[0]);
  152. }
  153. #endif
  154. int checkboard(void)
  155. {
  156. puts("Board: MX25PDK\n");
  157. return 0;
  158. }
  159. /* Lowlevel init isn't used on mx25pdk, so just provide a dummy one here */
  160. void lowlevel_init(void) {}