mx53smd.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * (C) Copyright 2011 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <asm/io.h>
  24. #include <asm/arch/imx-regs.h>
  25. #include <asm/arch/sys_proto.h>
  26. #include <asm/arch/crm_regs.h>
  27. #include <asm/arch/clock.h>
  28. #include <asm/arch/iomux-mx53.h>
  29. #include <asm/errno.h>
  30. #include <netdev.h>
  31. #include <mmc.h>
  32. #include <fsl_esdhc.h>
  33. #include <asm/gpio.h>
  34. DECLARE_GLOBAL_DATA_PTR;
  35. int dram_init(void)
  36. {
  37. u32 size1, size2;
  38. size1 = get_ram_size((void *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
  39. size2 = get_ram_size((void *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
  40. gd->ram_size = size1 + size2;
  41. return 0;
  42. }
  43. void dram_init_banksize(void)
  44. {
  45. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  46. gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
  47. gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
  48. gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
  49. }
  50. #define UART_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_DSE_HIGH | \
  51. PAD_CTL_PUS_100K_UP | PAD_CTL_ODE)
  52. static void setup_iomux_uart(void)
  53. {
  54. static const iomux_v3_cfg_t uart_pads[] = {
  55. NEW_PAD_CTRL(MX53_PAD_CSI0_DAT11__UART1_RXD_MUX, UART_PAD_CTRL),
  56. NEW_PAD_CTRL(MX53_PAD_CSI0_DAT10__UART1_TXD_MUX, UART_PAD_CTRL),
  57. };
  58. imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
  59. }
  60. static void setup_iomux_fec(void)
  61. {
  62. static const iomux_v3_cfg_t fec_pads[] = {
  63. NEW_PAD_CTRL(MX53_PAD_FEC_MDIO__FEC_MDIO, PAD_CTL_HYS |
  64. PAD_CTL_DSE_HIGH | PAD_CTL_PUS_22K_UP | PAD_CTL_ODE),
  65. NEW_PAD_CTRL(MX53_PAD_FEC_MDC__FEC_MDC, PAD_CTL_DSE_HIGH),
  66. NEW_PAD_CTRL(MX53_PAD_FEC_RXD1__FEC_RDATA_1,
  67. PAD_CTL_HYS | PAD_CTL_PKE),
  68. NEW_PAD_CTRL(MX53_PAD_FEC_RXD0__FEC_RDATA_0,
  69. PAD_CTL_HYS | PAD_CTL_PKE),
  70. NEW_PAD_CTRL(MX53_PAD_FEC_TXD1__FEC_TDATA_1, PAD_CTL_DSE_HIGH),
  71. NEW_PAD_CTRL(MX53_PAD_FEC_TXD0__FEC_TDATA_0, PAD_CTL_DSE_HIGH),
  72. NEW_PAD_CTRL(MX53_PAD_FEC_TX_EN__FEC_TX_EN, PAD_CTL_DSE_HIGH),
  73. NEW_PAD_CTRL(MX53_PAD_FEC_REF_CLK__FEC_TX_CLK,
  74. PAD_CTL_HYS | PAD_CTL_PKE),
  75. NEW_PAD_CTRL(MX53_PAD_FEC_RX_ER__FEC_RX_ER,
  76. PAD_CTL_HYS | PAD_CTL_PKE),
  77. NEW_PAD_CTRL(MX53_PAD_FEC_CRS_DV__FEC_RX_DV,
  78. PAD_CTL_HYS | PAD_CTL_PKE),
  79. };
  80. imx_iomux_v3_setup_multiple_pads(fec_pads, ARRAY_SIZE(fec_pads));
  81. }
  82. #ifdef CONFIG_FSL_ESDHC
  83. struct fsl_esdhc_cfg esdhc_cfg[1] = {
  84. {MMC_SDHC1_BASE_ADDR},
  85. };
  86. int board_mmc_getcd(struct mmc *mmc)
  87. {
  88. imx_iomux_v3_setup_pad(MX53_PAD_EIM_DA13__GPIO3_13);
  89. gpio_direction_input(IMX_GPIO_NR(3, 13));
  90. return !gpio_get_value(IMX_GPIO_NR(3, 13));
  91. }
  92. #define SD_CMD_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_DSE_HIGH | \
  93. PAD_CTL_PUS_100K_UP)
  94. #define SD_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | \
  95. PAD_CTL_DSE_HIGH)
  96. int board_mmc_init(bd_t *bis)
  97. {
  98. static const iomux_v3_cfg_t sd1_pads[] = {
  99. NEW_PAD_CTRL(MX53_PAD_SD1_CMD__ESDHC1_CMD, SD_CMD_PAD_CTRL),
  100. NEW_PAD_CTRL(MX53_PAD_SD1_CLK__ESDHC1_CLK, SD_PAD_CTRL),
  101. NEW_PAD_CTRL(MX53_PAD_SD1_DATA0__ESDHC1_DAT0, SD_PAD_CTRL),
  102. NEW_PAD_CTRL(MX53_PAD_SD1_DATA1__ESDHC1_DAT1, SD_PAD_CTRL),
  103. NEW_PAD_CTRL(MX53_PAD_SD1_DATA2__ESDHC1_DAT2, SD_PAD_CTRL),
  104. NEW_PAD_CTRL(MX53_PAD_SD1_DATA3__ESDHC1_DAT3, SD_PAD_CTRL),
  105. MX53_PAD_EIM_DA13__GPIO3_13,
  106. };
  107. u32 index;
  108. s32 status = 0;
  109. esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
  110. for (index = 0; index < CONFIG_SYS_FSL_ESDHC_NUM; index++) {
  111. switch (index) {
  112. case 0:
  113. imx_iomux_v3_setup_multiple_pads(sd1_pads,
  114. ARRAY_SIZE(sd1_pads));
  115. break;
  116. default:
  117. printf("Warning: you configured more ESDHC controller"
  118. "(%d) as supported by the board(1)\n",
  119. CONFIG_SYS_FSL_ESDHC_NUM);
  120. return status;
  121. }
  122. status |= fsl_esdhc_initialize(bis, &esdhc_cfg[index]);
  123. }
  124. return status;
  125. }
  126. #endif
  127. int board_early_init_f(void)
  128. {
  129. setup_iomux_uart();
  130. setup_iomux_fec();
  131. return 0;
  132. }
  133. int board_init(void)
  134. {
  135. /* address of boot parameters */
  136. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  137. return 0;
  138. }
  139. int checkboard(void)
  140. {
  141. puts("Board: MX53SMD\n");
  142. return 0;
  143. }