mx28evk.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. * SPDX-License-Identifier: GPL-2.0+
  13. */
  14. #include <common.h>
  15. #include <asm/gpio.h>
  16. #include <asm/io.h>
  17. #include <asm/arch/imx-regs.h>
  18. #include <asm/arch/iomux-mx28.h>
  19. #include <asm/arch/clock.h>
  20. #include <asm/arch/sys_proto.h>
  21. #include <linux/mii.h>
  22. #include <miiphy.h>
  23. #include <netdev.h>
  24. #include <errno.h>
  25. DECLARE_GLOBAL_DATA_PTR;
  26. /*
  27. * Functions
  28. */
  29. int board_early_init_f(void)
  30. {
  31. /* IO0 clock at 480MHz */
  32. mxs_set_ioclk(MXC_IOCLK0, 480000);
  33. /* IO1 clock at 480MHz */
  34. mxs_set_ioclk(MXC_IOCLK1, 480000);
  35. /* SSP0 clock at 96MHz */
  36. mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
  37. /* SSP2 clock at 160MHz */
  38. mxs_set_sspclk(MXC_SSPCLK2, 160000, 0);
  39. #ifdef CONFIG_CMD_USB
  40. mxs_iomux_setup_pad(MX28_PAD_SSP2_SS1__USB1_OVERCURRENT);
  41. mxs_iomux_setup_pad(MX28_PAD_AUART2_RX__GPIO_3_8 |
  42. MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL);
  43. gpio_direction_output(MX28_PAD_AUART2_RX__GPIO_3_8, 1);
  44. #endif
  45. /* Power on LCD */
  46. gpio_direction_output(MX28_PAD_LCD_RESET__GPIO_3_30, 1);
  47. /* Set contrast to maximum */
  48. gpio_direction_output(MX28_PAD_PWM2__GPIO_3_18, 1);
  49. return 0;
  50. }
  51. int dram_init(void)
  52. {
  53. return mxs_dram_init();
  54. }
  55. int board_init(void)
  56. {
  57. /* Adress of boot parameters */
  58. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  59. return 0;
  60. }
  61. #ifdef CONFIG_CMD_MMC
  62. static int mx28evk_mmc_wp(int id)
  63. {
  64. if (id != 0) {
  65. printf("MXS MMC: Invalid card selected (card id = %d)\n", id);
  66. return 1;
  67. }
  68. return gpio_get_value(MX28_PAD_SSP1_SCK__GPIO_2_12);
  69. }
  70. int board_mmc_init(bd_t *bis)
  71. {
  72. /* Configure WP as input */
  73. gpio_direction_input(MX28_PAD_SSP1_SCK__GPIO_2_12);
  74. /* Configure MMC0 Power Enable */
  75. gpio_direction_output(MX28_PAD_PWM3__GPIO_3_28, 0);
  76. return mxsmmc_initialize(bis, 0, mx28evk_mmc_wp, NULL);
  77. }
  78. #endif
  79. #ifdef CONFIG_CMD_NET
  80. int board_eth_init(bd_t *bis)
  81. {
  82. struct mxs_clkctrl_regs *clkctrl_regs =
  83. (struct mxs_clkctrl_regs *)MXS_CLKCTRL_BASE;
  84. struct eth_device *dev;
  85. int ret;
  86. ret = cpu_eth_init(bis);
  87. if (ret)
  88. return ret;
  89. /* MX28EVK uses ENET_CLK PAD to drive FEC clock */
  90. writel(CLKCTRL_ENET_TIME_SEL_RMII_CLK | CLKCTRL_ENET_CLK_OUT_EN,
  91. &clkctrl_regs->hw_clkctrl_enet);
  92. /* Power-on FECs */
  93. gpio_direction_output(MX28_PAD_SSP1_DATA3__GPIO_2_15, 0);
  94. /* Reset FEC PHYs */
  95. gpio_direction_output(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 0);
  96. udelay(200);
  97. gpio_set_value(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 1);
  98. ret = fecmxc_initialize_multi(bis, 0, 0, MXS_ENET0_BASE);
  99. if (ret) {
  100. puts("FEC MXS: Unable to init FEC0\n");
  101. return ret;
  102. }
  103. ret = fecmxc_initialize_multi(bis, 1, 3, MXS_ENET1_BASE);
  104. if (ret) {
  105. puts("FEC MXS: Unable to init FEC1\n");
  106. return ret;
  107. }
  108. dev = eth_get_dev_by_name("FEC0");
  109. if (!dev) {
  110. puts("FEC MXS: Unable to get FEC0 device entry\n");
  111. return -EINVAL;
  112. }
  113. dev = eth_get_dev_by_name("FEC1");
  114. if (!dev) {
  115. puts("FEC MXS: Unable to get FEC1 device entry\n");
  116. return -EINVAL;
  117. }
  118. return ret;
  119. }
  120. #endif