phy-exynos-dp-video.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Samsung EXYNOS SoC series Display Port PHY driver
  3. *
  4. * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  5. * Author: Jingoo Han <jg1.han@samsung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/err.h>
  12. #include <linux/io.h>
  13. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/mfd/syscon.h>
  16. #include <linux/of.h>
  17. #include <linux/of_address.h>
  18. #include <linux/of_device.h>
  19. #include <linux/phy/phy.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/regmap.h>
  22. #include <linux/soc/samsung/exynos-regs-pmu.h>
  23. struct exynos_dp_video_phy_drvdata {
  24. u32 phy_ctrl_offset;
  25. };
  26. struct exynos_dp_video_phy {
  27. struct regmap *regs;
  28. const struct exynos_dp_video_phy_drvdata *drvdata;
  29. };
  30. static int exynos_dp_video_phy_power_on(struct phy *phy)
  31. {
  32. struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
  33. /* Disable power isolation on DP-PHY */
  34. return regmap_update_bits(state->regs, state->drvdata->phy_ctrl_offset,
  35. EXYNOS4_PHY_ENABLE, EXYNOS4_PHY_ENABLE);
  36. }
  37. static int exynos_dp_video_phy_power_off(struct phy *phy)
  38. {
  39. struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
  40. /* Enable power isolation on DP-PHY */
  41. return regmap_update_bits(state->regs, state->drvdata->phy_ctrl_offset,
  42. EXYNOS4_PHY_ENABLE, 0);
  43. }
  44. static const struct phy_ops exynos_dp_video_phy_ops = {
  45. .power_on = exynos_dp_video_phy_power_on,
  46. .power_off = exynos_dp_video_phy_power_off,
  47. .owner = THIS_MODULE,
  48. };
  49. static const struct exynos_dp_video_phy_drvdata exynos5250_dp_video_phy = {
  50. .phy_ctrl_offset = EXYNOS5_DPTX_PHY_CONTROL,
  51. };
  52. static const struct exynos_dp_video_phy_drvdata exynos5420_dp_video_phy = {
  53. .phy_ctrl_offset = EXYNOS5420_DPTX_PHY_CONTROL,
  54. };
  55. static const struct of_device_id exynos_dp_video_phy_of_match[] = {
  56. {
  57. .compatible = "samsung,exynos5250-dp-video-phy",
  58. .data = &exynos5250_dp_video_phy,
  59. }, {
  60. .compatible = "samsung,exynos5420-dp-video-phy",
  61. .data = &exynos5420_dp_video_phy,
  62. },
  63. { },
  64. };
  65. MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match);
  66. static int exynos_dp_video_phy_probe(struct platform_device *pdev)
  67. {
  68. struct exynos_dp_video_phy *state;
  69. struct device *dev = &pdev->dev;
  70. struct phy_provider *phy_provider;
  71. struct phy *phy;
  72. state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL);
  73. if (!state)
  74. return -ENOMEM;
  75. state->regs = syscon_regmap_lookup_by_phandle(dev->of_node,
  76. "samsung,pmu-syscon");
  77. if (IS_ERR(state->regs)) {
  78. dev_err(dev, "Failed to lookup PMU regmap\n");
  79. return PTR_ERR(state->regs);
  80. }
  81. state->drvdata = of_device_get_match_data(dev);
  82. phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops);
  83. if (IS_ERR(phy)) {
  84. dev_err(dev, "failed to create Display Port PHY\n");
  85. return PTR_ERR(phy);
  86. }
  87. phy_set_drvdata(phy, state);
  88. phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
  89. return PTR_ERR_OR_ZERO(phy_provider);
  90. }
  91. static struct platform_driver exynos_dp_video_phy_driver = {
  92. .probe = exynos_dp_video_phy_probe,
  93. .driver = {
  94. .name = "exynos-dp-video-phy",
  95. .of_match_table = exynos_dp_video_phy_of_match,
  96. }
  97. };
  98. module_platform_driver(exynos_dp_video_phy_driver);
  99. MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");
  100. MODULE_DESCRIPTION("Samsung EXYNOS SoC DP PHY driver");
  101. MODULE_LICENSE("GPL v2");