phy-exynos-dp-video.c 3.4 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/mfd/syscon/exynos5-pmu.h>
  17. #include <linux/of.h>
  18. #include <linux/of_address.h>
  19. #include <linux/phy/phy.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/regmap.h>
  22. struct exynos_dp_video_phy_drvdata {
  23. u32 phy_ctrl_offset;
  24. };
  25. struct exynos_dp_video_phy {
  26. struct regmap *regs;
  27. const struct exynos_dp_video_phy_drvdata *drvdata;
  28. };
  29. static int exynos_dp_video_phy_power_on(struct phy *phy)
  30. {
  31. struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
  32. /* Disable power isolation on DP-PHY */
  33. return regmap_update_bits(state->regs, state->drvdata->phy_ctrl_offset,
  34. EXYNOS5_PHY_ENABLE, EXYNOS5_PHY_ENABLE);
  35. }
  36. static int exynos_dp_video_phy_power_off(struct phy *phy)
  37. {
  38. struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
  39. /* Enable power isolation on DP-PHY */
  40. return regmap_update_bits(state->regs, state->drvdata->phy_ctrl_offset,
  41. EXYNOS5_PHY_ENABLE, 0);
  42. }
  43. static const struct phy_ops exynos_dp_video_phy_ops = {
  44. .power_on = exynos_dp_video_phy_power_on,
  45. .power_off = exynos_dp_video_phy_power_off,
  46. .owner = THIS_MODULE,
  47. };
  48. static const struct exynos_dp_video_phy_drvdata exynos5250_dp_video_phy = {
  49. .phy_ctrl_offset = EXYNOS5_DPTX_PHY_CONTROL,
  50. };
  51. static const struct exynos_dp_video_phy_drvdata exynos5420_dp_video_phy = {
  52. .phy_ctrl_offset = EXYNOS5420_DPTX_PHY_CONTROL,
  53. };
  54. static const struct of_device_id exynos_dp_video_phy_of_match[] = {
  55. {
  56. .compatible = "samsung,exynos5250-dp-video-phy",
  57. .data = &exynos5250_dp_video_phy,
  58. }, {
  59. .compatible = "samsung,exynos5420-dp-video-phy",
  60. .data = &exynos5420_dp_video_phy,
  61. },
  62. { },
  63. };
  64. MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match);
  65. static int exynos_dp_video_phy_probe(struct platform_device *pdev)
  66. {
  67. struct exynos_dp_video_phy *state;
  68. struct device *dev = &pdev->dev;
  69. const struct of_device_id *match;
  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. match = of_match_node(exynos_dp_video_phy_of_match, dev->of_node);
  82. state->drvdata = match->data;
  83. phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops);
  84. if (IS_ERR(phy)) {
  85. dev_err(dev, "failed to create Display Port PHY\n");
  86. return PTR_ERR(phy);
  87. }
  88. phy_set_drvdata(phy, state);
  89. phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
  90. return PTR_ERR_OR_ZERO(phy_provider);
  91. }
  92. static struct platform_driver exynos_dp_video_phy_driver = {
  93. .probe = exynos_dp_video_phy_probe,
  94. .driver = {
  95. .name = "exynos-dp-video-phy",
  96. .of_match_table = exynos_dp_video_phy_of_match,
  97. }
  98. };
  99. module_platform_driver(exynos_dp_video_phy_driver);
  100. MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");
  101. MODULE_DESCRIPTION("Samsung EXYNOS SoC DP PHY driver");
  102. MODULE_LICENSE("GPL v2");