mach-imx7d.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2015 Freescale Semiconductor, Inc.
  4. */
  5. #include <linux/irqchip.h>
  6. #include <linux/mfd/syscon.h>
  7. #include <linux/mfd/syscon/imx7-iomuxc-gpr.h>
  8. #include <linux/of_platform.h>
  9. #include <linux/phy.h>
  10. #include <linux/regmap.h>
  11. #include <asm/mach/arch.h>
  12. #include <asm/mach/map.h>
  13. #include "common.h"
  14. static int bcm54220_phy_fixup(struct phy_device *dev)
  15. {
  16. /* enable RXC skew select RGMII copper mode */
  17. phy_write(dev, 0x1e, 0x21);
  18. phy_write(dev, 0x1f, 0x7ea8);
  19. phy_write(dev, 0x1e, 0x2f);
  20. phy_write(dev, 0x1f, 0x71b7);
  21. return 0;
  22. }
  23. #define PHY_ID_BCM54220 0x600d8589
  24. static void __init imx7d_enet_phy_init(void)
  25. {
  26. if (IS_BUILTIN(CONFIG_PHYLIB)) {
  27. phy_register_fixup_for_uid(PHY_ID_BCM54220, 0xffffffff,
  28. bcm54220_phy_fixup);
  29. }
  30. }
  31. static void __init imx7d_enet_clk_sel(void)
  32. {
  33. struct regmap *gpr;
  34. gpr = syscon_regmap_lookup_by_compatible("fsl,imx7d-iomuxc-gpr");
  35. if (!IS_ERR(gpr)) {
  36. regmap_update_bits(gpr, IOMUXC_GPR1, IMX7D_GPR1_ENET_TX_CLK_SEL_MASK, 0);
  37. regmap_update_bits(gpr, IOMUXC_GPR1, IMX7D_GPR1_ENET_CLK_DIR_MASK, 0);
  38. } else {
  39. pr_err("failed to find fsl,imx7d-iomux-gpr regmap\n");
  40. }
  41. }
  42. static inline void imx7d_enet_init(void)
  43. {
  44. imx7d_enet_phy_init();
  45. imx7d_enet_clk_sel();
  46. }
  47. static void __init imx7d_init_machine(void)
  48. {
  49. imx_anatop_init();
  50. imx7d_enet_init();
  51. }
  52. static void __init imx7d_init_late(void)
  53. {
  54. if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT))
  55. platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
  56. }
  57. static void __init imx7d_init_irq(void)
  58. {
  59. imx_init_revision_from_anatop();
  60. imx7_src_init();
  61. irqchip_init();
  62. }
  63. static const char *const imx7d_dt_compat[] __initconst = {
  64. "fsl,imx7d",
  65. "fsl,imx7s",
  66. NULL,
  67. };
  68. DT_MACHINE_START(IMX7D, "Freescale i.MX7 Dual (Device Tree)")
  69. .smp = smp_ops(imx7_smp_ops),
  70. .init_irq = imx7d_init_irq,
  71. .init_machine = imx7d_init_machine,
  72. .init_late = imx7d_init_late,
  73. .dt_compat = imx7d_dt_compat,
  74. MACHINE_END