mx28evk.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Freescale MX28EVK board
  3. *
  4. * (C) Copyright 2011 Freescale Semiconductor, Inc.
  5. *
  6. * Author: Fabio Estevam <fabio.estevam@freescale.com>
  7. *
  8. * Based on m28evk.c:
  9. * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
  10. * on behalf of DENX Software Engineering GmbH
  11. *
  12. * See file CREDITS for list of people who contributed to this
  13. * project.
  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. #include <common.h>
  26. #include <asm/gpio.h>
  27. #include <asm/io.h>
  28. #include <asm/arch/imx-regs.h>
  29. #include <asm/arch/iomux-mx28.h>
  30. #include <asm/arch/clock.h>
  31. #include <asm/arch/sys_proto.h>
  32. #include <linux/mii.h>
  33. #include <miiphy.h>
  34. #include <netdev.h>
  35. #include <errno.h>
  36. DECLARE_GLOBAL_DATA_PTR;
  37. /*
  38. * Functions
  39. */
  40. int board_early_init_f(void)
  41. {
  42. /* IO0 clock at 480MHz */
  43. mxs_set_ioclk(MXC_IOCLK0, 480000);
  44. /* IO1 clock at 480MHz */
  45. mxs_set_ioclk(MXC_IOCLK1, 480000);
  46. /* SSP0 clock at 96MHz */
  47. mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
  48. /* SSP2 clock at 160MHz */
  49. mxs_set_sspclk(MXC_SSPCLK2, 160000, 0);
  50. #ifdef CONFIG_CMD_USB
  51. mxs_iomux_setup_pad(MX28_PAD_SSP2_SS1__USB1_OVERCURRENT);
  52. mxs_iomux_setup_pad(MX28_PAD_AUART2_RX__GPIO_3_8 |
  53. MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL);
  54. gpio_direction_output(MX28_PAD_AUART2_RX__GPIO_3_8, 1);
  55. #endif
  56. /* Power on LCD */
  57. gpio_direction_output(MX28_PAD_LCD_RESET__GPIO_3_30, 1);
  58. /* Set contrast to maximum */
  59. gpio_direction_output(MX28_PAD_PWM2__GPIO_3_18, 1);
  60. return 0;
  61. }
  62. int dram_init(void)
  63. {
  64. return mxs_dram_init();
  65. }
  66. int board_init(void)
  67. {
  68. /* Adress of boot parameters */
  69. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  70. return 0;
  71. }
  72. #ifdef CONFIG_CMD_MMC
  73. static int mx28evk_mmc_wp(int id)
  74. {
  75. if (id != 0) {
  76. printf("MXS MMC: Invalid card selected (card id = %d)\n", id);
  77. return 1;
  78. }
  79. return gpio_get_value(MX28_PAD_SSP1_SCK__GPIO_2_12);
  80. }
  81. int board_mmc_init(bd_t *bis)
  82. {
  83. /* Configure WP as input */
  84. gpio_direction_input(MX28_PAD_SSP1_SCK__GPIO_2_12);
  85. /* Configure MMC0 Power Enable */
  86. gpio_direction_output(MX28_PAD_PWM3__GPIO_3_28, 0);
  87. return mxsmmc_initialize(bis, 0, mx28evk_mmc_wp, NULL);
  88. }
  89. #endif
  90. #ifdef CONFIG_CMD_NET
  91. int board_eth_init(bd_t *bis)
  92. {
  93. struct mxs_clkctrl_regs *clkctrl_regs =
  94. (struct mxs_clkctrl_regs *)MXS_CLKCTRL_BASE;
  95. struct eth_device *dev;
  96. int ret;
  97. ret = cpu_eth_init(bis);
  98. /* MX28EVK uses ENET_CLK PAD to drive FEC clock */
  99. writel(CLKCTRL_ENET_TIME_SEL_RMII_CLK | CLKCTRL_ENET_CLK_OUT_EN,
  100. &clkctrl_regs->hw_clkctrl_enet);
  101. /* Power-on FECs */
  102. gpio_direction_output(MX28_PAD_SSP1_DATA3__GPIO_2_15, 0);
  103. /* Reset FEC PHYs */
  104. gpio_direction_output(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 0);
  105. udelay(200);
  106. gpio_set_value(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 1);
  107. ret = fecmxc_initialize_multi(bis, 0, 0, MXS_ENET0_BASE);
  108. if (ret) {
  109. puts("FEC MXS: Unable to init FEC0\n");
  110. return ret;
  111. }
  112. ret = fecmxc_initialize_multi(bis, 1, 3, MXS_ENET1_BASE);
  113. if (ret) {
  114. puts("FEC MXS: Unable to init FEC1\n");
  115. return ret;
  116. }
  117. dev = eth_get_dev_by_name("FEC0");
  118. if (!dev) {
  119. puts("FEC MXS: Unable to get FEC0 device entry\n");
  120. return -EINVAL;
  121. }
  122. dev = eth_get_dev_by_name("FEC1");
  123. if (!dev) {
  124. puts("FEC MXS: Unable to get FEC1 device entry\n");
  125. return -EINVAL;
  126. }
  127. return ret;
  128. }
  129. #endif