mach-mx28evk.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #include <linux/delay.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/gpio.h>
  17. #include <linux/irq.h>
  18. #include <linux/clk.h>
  19. #include <asm/mach-types.h>
  20. #include <asm/mach/arch.h>
  21. #include <asm/mach/time.h>
  22. #include <mach/common.h>
  23. #include <mach/iomux-mx28.h>
  24. #include "devices-mx28.h"
  25. #include "gpio.h"
  26. #define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15)
  27. #define MX28EVK_FEC_PHY_RESET MXS_GPIO_NR(4, 13)
  28. static const iomux_cfg_t mx28evk_pads[] __initconst = {
  29. /* duart */
  30. MX28_PAD_PWM0__DUART_RX |
  31. (MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL),
  32. MX28_PAD_PWM1__DUART_TX |
  33. (MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL),
  34. /* fec0 */
  35. MX28_PAD_ENET0_MDC__ENET0_MDC |
  36. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  37. MX28_PAD_ENET0_MDIO__ENET0_MDIO |
  38. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  39. MX28_PAD_ENET0_RX_EN__ENET0_RX_EN |
  40. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  41. MX28_PAD_ENET0_RXD0__ENET0_RXD0 |
  42. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  43. MX28_PAD_ENET0_RXD1__ENET0_RXD1 |
  44. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  45. MX28_PAD_ENET0_TX_EN__ENET0_TX_EN |
  46. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  47. MX28_PAD_ENET0_TXD0__ENET0_TXD0 |
  48. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  49. MX28_PAD_ENET0_TXD1__ENET0_TXD1 |
  50. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  51. MX28_PAD_ENET_CLK__CLKCTRL_ENET |
  52. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  53. /* fec1 */
  54. MX28_PAD_ENET0_CRS__ENET1_RX_EN |
  55. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  56. MX28_PAD_ENET0_RXD2__ENET1_RXD0 |
  57. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  58. MX28_PAD_ENET0_RXD3__ENET1_RXD1 |
  59. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  60. MX28_PAD_ENET0_COL__ENET1_TX_EN |
  61. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  62. MX28_PAD_ENET0_TXD2__ENET1_TXD0 |
  63. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  64. MX28_PAD_ENET0_TXD3__ENET1_TXD1 |
  65. (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
  66. /* phy power line */
  67. MX28_PAD_SSP1_DATA3__GPIO_2_15 |
  68. (MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL),
  69. /* phy reset line */
  70. MX28_PAD_ENET0_RX_CLK__GPIO_4_13 |
  71. (MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL),
  72. };
  73. /* fec */
  74. static void __init mx28evk_fec_reset(void)
  75. {
  76. int ret;
  77. struct clk *clk;
  78. /* Enable fec phy clock */
  79. clk = clk_get_sys("pll2", NULL);
  80. if (!IS_ERR(clk))
  81. clk_enable(clk);
  82. /* Power up fec phy */
  83. ret = gpio_request(MX28EVK_FEC_PHY_POWER, "fec-phy-power");
  84. if (ret) {
  85. pr_err("Failed to request gpio fec-phy-%s: %d\n", "power", ret);
  86. return;
  87. }
  88. ret = gpio_direction_output(MX28EVK_FEC_PHY_POWER, 0);
  89. if (ret) {
  90. pr_err("Failed to drive gpio fec-phy-%s: %d\n", "power", ret);
  91. return;
  92. }
  93. /* Reset fec phy */
  94. ret = gpio_request(MX28EVK_FEC_PHY_RESET, "fec-phy-reset");
  95. if (ret) {
  96. pr_err("Failed to request gpio fec-phy-%s: %d\n", "reset", ret);
  97. return;
  98. }
  99. gpio_direction_output(MX28EVK_FEC_PHY_RESET, 0);
  100. if (ret) {
  101. pr_err("Failed to drive gpio fec-phy-%s: %d\n", "reset", ret);
  102. return;
  103. }
  104. mdelay(1);
  105. gpio_set_value(MX28EVK_FEC_PHY_RESET, 1);
  106. }
  107. static struct fec_platform_data mx28_fec_pdata[] = {
  108. {
  109. /* fec0 */
  110. .phy = PHY_INTERFACE_MODE_RMII,
  111. }, {
  112. /* fec1 */
  113. .phy = PHY_INTERFACE_MODE_RMII,
  114. },
  115. };
  116. static void __init mx28evk_init(void)
  117. {
  118. mxs_iomux_setup_multiple_pads(mx28evk_pads, ARRAY_SIZE(mx28evk_pads));
  119. mx28_add_duart();
  120. mx28evk_fec_reset();
  121. mx28_add_fec(0, &mx28_fec_pdata[0]);
  122. mx28_add_fec(1, &mx28_fec_pdata[1]);
  123. }
  124. static void __init mx28evk_timer_init(void)
  125. {
  126. mx28_clocks_init();
  127. }
  128. static struct sys_timer mx28evk_timer = {
  129. .init = mx28evk_timer_init,
  130. };
  131. MACHINE_START(MX28EVK, "Freescale MX28 EVK")
  132. /* Maintainer: Freescale Semiconductor, Inc. */
  133. .map_io = mx28_map_io,
  134. .init_irq = mx28_init_irq,
  135. .init_machine = mx28evk_init,
  136. .timer = &mx28evk_timer,
  137. MACHINE_END