mach-mx28evk.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. /* phy power line */
  54. MX28_PAD_SSP1_DATA3__GPIO_2_15 |
  55. (MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL),
  56. /* phy reset line */
  57. MX28_PAD_ENET0_RX_CLK__GPIO_4_13 |
  58. (MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL),
  59. };
  60. /* fec */
  61. static void __init mx28evk_fec_reset(void)
  62. {
  63. int ret;
  64. struct clk *clk;
  65. /* Enable fec phy clock */
  66. clk = clk_get_sys("pll2", NULL);
  67. if (!IS_ERR(clk))
  68. clk_enable(clk);
  69. /* Power up fec phy */
  70. ret = gpio_request(MX28EVK_FEC_PHY_POWER, "fec-phy-power");
  71. if (ret) {
  72. pr_err("Failed to request gpio fec-phy-%s: %d\n", "power", ret);
  73. return;
  74. }
  75. ret = gpio_direction_output(MX28EVK_FEC_PHY_POWER, 0);
  76. if (ret) {
  77. pr_err("Failed to drive gpio fec-phy-%s: %d\n", "power", ret);
  78. return;
  79. }
  80. /* Reset fec phy */
  81. ret = gpio_request(MX28EVK_FEC_PHY_RESET, "fec-phy-reset");
  82. if (ret) {
  83. pr_err("Failed to request gpio fec-phy-%s: %d\n", "reset", ret);
  84. return;
  85. }
  86. gpio_direction_output(MX28EVK_FEC_PHY_RESET, 0);
  87. if (ret) {
  88. pr_err("Failed to drive gpio fec-phy-%s: %d\n", "reset", ret);
  89. return;
  90. }
  91. mdelay(1);
  92. gpio_set_value(MX28EVK_FEC_PHY_RESET, 1);
  93. }
  94. static const struct fec_platform_data mx28_fec_pdata __initconst = {
  95. .phy = PHY_INTERFACE_MODE_RMII,
  96. };
  97. static void __init mx28evk_init(void)
  98. {
  99. mxs_iomux_setup_multiple_pads(mx28evk_pads, ARRAY_SIZE(mx28evk_pads));
  100. mx28_add_duart();
  101. mx28evk_fec_reset();
  102. mx28_add_fec(0, &mx28_fec_pdata);
  103. }
  104. static void __init mx28evk_timer_init(void)
  105. {
  106. mx28_clocks_init();
  107. }
  108. static struct sys_timer mx28evk_timer = {
  109. .init = mx28evk_timer_init,
  110. };
  111. MACHINE_START(MX28EVK, "Freescale MX28 EVK")
  112. /* Maintainer: Freescale Semiconductor, Inc. */
  113. .map_io = mx28_map_io,
  114. .init_irq = mx28_init_irq,
  115. .init_machine = mx28evk_init,
  116. .timer = &mx28evk_timer,
  117. MACHINE_END