mach-imx7d.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (C) 2015 Freescale Semiconductor, Inc.
  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 version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/irqchip.h>
  9. #include <linux/mfd/syscon.h>
  10. #include <linux/mfd/syscon/imx7-iomuxc-gpr.h>
  11. #include <linux/of_platform.h>
  12. #include <linux/phy.h>
  13. #include <linux/regmap.h>
  14. #include <asm/mach/arch.h>
  15. #include <asm/mach/map.h>
  16. #include "common.h"
  17. static int ar8031_phy_fixup(struct phy_device *dev)
  18. {
  19. u16 val;
  20. /* Set RGMII IO voltage to 1.8V */
  21. phy_write(dev, 0x1d, 0x1f);
  22. phy_write(dev, 0x1e, 0x8);
  23. /* disable phy AR8031 SmartEEE function. */
  24. phy_write(dev, 0xd, 0x3);
  25. phy_write(dev, 0xe, 0x805d);
  26. phy_write(dev, 0xd, 0x4003);
  27. val = phy_read(dev, 0xe);
  28. val &= ~(0x1 << 8);
  29. phy_write(dev, 0xe, val);
  30. /* introduce tx clock delay */
  31. phy_write(dev, 0x1d, 0x5);
  32. val = phy_read(dev, 0x1e);
  33. val |= 0x0100;
  34. phy_write(dev, 0x1e, val);
  35. return 0;
  36. }
  37. static int bcm54220_phy_fixup(struct phy_device *dev)
  38. {
  39. /* enable RXC skew select RGMII copper mode */
  40. phy_write(dev, 0x1e, 0x21);
  41. phy_write(dev, 0x1f, 0x7ea8);
  42. phy_write(dev, 0x1e, 0x2f);
  43. phy_write(dev, 0x1f, 0x71b7);
  44. return 0;
  45. }
  46. #define PHY_ID_AR8031 0x004dd074
  47. #define PHY_ID_BCM54220 0x600d8589
  48. static void __init imx7d_enet_phy_init(void)
  49. {
  50. if (IS_BUILTIN(CONFIG_PHYLIB)) {
  51. phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffff,
  52. ar8031_phy_fixup);
  53. phy_register_fixup_for_uid(PHY_ID_BCM54220, 0xffffffff,
  54. bcm54220_phy_fixup);
  55. }
  56. }
  57. static void __init imx7d_enet_clk_sel(void)
  58. {
  59. struct regmap *gpr;
  60. gpr = syscon_regmap_lookup_by_compatible("fsl,imx7d-iomuxc-gpr");
  61. if (!IS_ERR(gpr)) {
  62. regmap_update_bits(gpr, IOMUXC_GPR1, IMX7D_GPR1_ENET_TX_CLK_SEL_MASK, 0);
  63. regmap_update_bits(gpr, IOMUXC_GPR1, IMX7D_GPR1_ENET_CLK_DIR_MASK, 0);
  64. } else {
  65. pr_err("failed to find fsl,imx7d-iomux-gpr regmap\n");
  66. }
  67. }
  68. static inline void imx7d_enet_init(void)
  69. {
  70. imx7d_enet_phy_init();
  71. imx7d_enet_clk_sel();
  72. }
  73. static void __init imx7d_init_machine(void)
  74. {
  75. struct device *parent;
  76. parent = imx_soc_device_init();
  77. if (parent == NULL)
  78. pr_warn("failed to initialize soc device\n");
  79. imx_anatop_init();
  80. imx7d_enet_init();
  81. }
  82. static void __init imx7d_init_irq(void)
  83. {
  84. imx_init_revision_from_anatop();
  85. imx_src_init();
  86. irqchip_init();
  87. }
  88. static const char *const imx7d_dt_compat[] __initconst = {
  89. "fsl,imx7d",
  90. "fsl,imx7s",
  91. NULL,
  92. };
  93. DT_MACHINE_START(IMX7D, "Freescale i.MX7 Dual (Device Tree)")
  94. .init_irq = imx7d_init_irq,
  95. .init_machine = imx7d_init_machine,
  96. .dt_compat = imx7d_dt_compat,
  97. MACHINE_END