mach-imx6ul.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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/imx6q-iomuxc-gpr.h>
  11. #include <linux/micrel_phy.h>
  12. #include <linux/of_platform.h>
  13. #include <linux/phy.h>
  14. #include <linux/regmap.h>
  15. #include <asm/mach/arch.h>
  16. #include <asm/mach/map.h>
  17. #include "common.h"
  18. #include "cpuidle.h"
  19. static void __init imx6ul_enet_clk_init(void)
  20. {
  21. struct regmap *gpr;
  22. gpr = syscon_regmap_lookup_by_compatible("fsl,imx6ul-iomuxc-gpr");
  23. if (!IS_ERR(gpr))
  24. regmap_update_bits(gpr, IOMUXC_GPR1, IMX6UL_GPR1_ENET_CLK_DIR,
  25. IMX6UL_GPR1_ENET_CLK_OUTPUT);
  26. else
  27. pr_err("failed to find fsl,imx6ul-iomux-gpr regmap\n");
  28. }
  29. static int ksz8081_phy_fixup(struct phy_device *dev)
  30. {
  31. if (dev && dev->interface == PHY_INTERFACE_MODE_MII) {
  32. phy_write(dev, 0x1f, 0x8110);
  33. phy_write(dev, 0x16, 0x201);
  34. } else if (dev && dev->interface == PHY_INTERFACE_MODE_RMII) {
  35. phy_write(dev, 0x1f, 0x8190);
  36. phy_write(dev, 0x16, 0x202);
  37. }
  38. return 0;
  39. }
  40. static void __init imx6ul_enet_phy_init(void)
  41. {
  42. if (IS_BUILTIN(CONFIG_PHYLIB))
  43. phy_register_fixup_for_uid(PHY_ID_KSZ8081, MICREL_PHY_ID_MASK,
  44. ksz8081_phy_fixup);
  45. }
  46. static inline void imx6ul_enet_init(void)
  47. {
  48. imx6ul_enet_clk_init();
  49. imx6ul_enet_phy_init();
  50. }
  51. static void __init imx6ul_init_machine(void)
  52. {
  53. struct device *parent;
  54. parent = imx_soc_device_init();
  55. if (parent == NULL)
  56. pr_warn("failed to initialize soc device\n");
  57. of_platform_default_populate(NULL, NULL, parent);
  58. imx6ul_enet_init();
  59. imx_anatop_init();
  60. imx6ul_pm_init();
  61. }
  62. static void __init imx6ul_init_irq(void)
  63. {
  64. imx_init_revision_from_anatop();
  65. imx_src_init();
  66. irqchip_init();
  67. imx6_pm_ccm_init("fsl,imx6ul-ccm");
  68. }
  69. static void __init imx6ul_init_late(void)
  70. {
  71. imx6sx_cpuidle_init();
  72. if (IS_ENABLED(CONFIG_ARM_IMX6Q_CPUFREQ))
  73. platform_device_register_simple("imx6q-cpufreq", -1, NULL, 0);
  74. }
  75. static const char * const imx6ul_dt_compat[] __initconst = {
  76. "fsl,imx6ul",
  77. NULL,
  78. };
  79. DT_MACHINE_START(IMX6UL, "Freescale i.MX6 Ultralite (Device Tree)")
  80. .init_irq = imx6ul_init_irq,
  81. .init_machine = imx6ul_init_machine,
  82. .init_late = imx6ul_init_late,
  83. .dt_compat = imx6ul_dt_compat,
  84. MACHINE_END