mx28evk.c 3.1 KB

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