mach-imx6sx.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright 2014 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/of_platform.h>
  10. #include <linux/phy.h>
  11. #include <linux/regmap.h>
  12. #include <linux/mfd/syscon.h>
  13. #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
  14. #include <asm/mach/arch.h>
  15. #include <asm/mach/map.h>
  16. #include "common.h"
  17. #include "cpuidle.h"
  18. static int ar8031_phy_fixup(struct phy_device *dev)
  19. {
  20. u16 val;
  21. /* Set RGMII IO voltage to 1.8V */
  22. phy_write(dev, 0x1d, 0x1f);
  23. phy_write(dev, 0x1e, 0x8);
  24. /* introduce tx clock delay */
  25. phy_write(dev, 0x1d, 0x5);
  26. val = phy_read(dev, 0x1e);
  27. val |= 0x0100;
  28. phy_write(dev, 0x1e, val);
  29. return 0;
  30. }
  31. #define PHY_ID_AR8031 0x004dd074
  32. static void __init imx6sx_enet_phy_init(void)
  33. {
  34. if (IS_BUILTIN(CONFIG_PHYLIB))
  35. phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffff,
  36. ar8031_phy_fixup);
  37. }
  38. static void __init imx6sx_enet_clk_sel(void)
  39. {
  40. struct regmap *gpr;
  41. gpr = syscon_regmap_lookup_by_compatible("fsl,imx6sx-iomuxc-gpr");
  42. if (!IS_ERR(gpr)) {
  43. regmap_update_bits(gpr, IOMUXC_GPR1,
  44. IMX6SX_GPR1_FEC_CLOCK_MUX_SEL_MASK, 0);
  45. regmap_update_bits(gpr, IOMUXC_GPR1,
  46. IMX6SX_GPR1_FEC_CLOCK_PAD_DIR_MASK, 0);
  47. } else {
  48. pr_err("failed to find fsl,imx6sx-iomux-gpr regmap\n");
  49. }
  50. }
  51. static inline void imx6sx_enet_init(void)
  52. {
  53. imx6sx_enet_phy_init();
  54. imx6sx_enet_clk_sel();
  55. }
  56. static void __init imx6sx_init_machine(void)
  57. {
  58. struct device *parent;
  59. parent = imx_soc_device_init();
  60. if (parent == NULL)
  61. pr_warn("failed to initialize soc device\n");
  62. of_platform_default_populate(NULL, NULL, parent);
  63. imx6sx_enet_init();
  64. imx_anatop_init();
  65. imx6sx_pm_init();
  66. }
  67. static void __init imx6sx_init_irq(void)
  68. {
  69. imx_gpc_check_dt();
  70. imx_init_revision_from_anatop();
  71. imx_init_l2cache();
  72. imx_src_init();
  73. irqchip_init();
  74. imx6_pm_ccm_init("fsl,imx6sx-ccm");
  75. }
  76. static void __init imx6sx_init_late(void)
  77. {
  78. imx6sx_cpuidle_init();
  79. if (IS_ENABLED(CONFIG_ARM_IMX6Q_CPUFREQ))
  80. platform_device_register_simple("imx6q-cpufreq", -1, NULL, 0);
  81. }
  82. static const char * const imx6sx_dt_compat[] __initconst = {
  83. "fsl,imx6sx",
  84. NULL,
  85. };
  86. DT_MACHINE_START(IMX6SX, "Freescale i.MX6 SoloX (Device Tree)")
  87. .l2c_aux_val = 0,
  88. .l2c_aux_mask = ~0,
  89. .init_irq = imx6sx_init_irq,
  90. .init_machine = imx6sx_init_machine,
  91. .dt_compat = imx6sx_dt_compat,
  92. .init_late = imx6sx_init_late,
  93. MACHINE_END