aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/phy/phy-exynos-dp-video.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/phy/phy-exynos-dp-video.c')
-rw-r--r--drivers/phy/phy-exynos-dp-video.c80
1 files changed, 54 insertions, 26 deletions
diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c
index 8b3026e2af7f..84f49e5a3f24 100644
--- a/drivers/phy/phy-exynos-dp-video.c
+++ b/drivers/phy/phy-exynos-dp-video.c
@@ -13,44 +13,55 @@
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/mfd/syscon.h>
17#include <linux/mfd/syscon/exynos5-pmu.h>
16#include <linux/of.h> 18#include <linux/of.h>
17#include <linux/of_address.h> 19#include <linux/of_address.h>
18#include <linux/phy/phy.h> 20#include <linux/phy/phy.h>
19#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/regmap.h>
20 23
21/* DPTX_PHY_CONTROL register */ 24struct exynos_dp_video_phy_drvdata {
22#define EXYNOS_DPTX_PHY_ENABLE (1 << 0) 25 u32 phy_ctrl_offset;
26};
23 27
24struct exynos_dp_video_phy { 28struct exynos_dp_video_phy {
25 void __iomem *regs; 29 struct regmap *regs;
30 const struct exynos_dp_video_phy_drvdata *drvdata;
26}; 31};
27 32
28static int __set_phy_state(struct exynos_dp_video_phy *state, unsigned int on) 33static void exynos_dp_video_phy_pwr_isol(struct exynos_dp_video_phy *state,
34 unsigned int on)
29{ 35{
30 u32 reg; 36 unsigned int val;
37
38 if (IS_ERR(state->regs))
39 return;
31 40
32 reg = readl(state->regs); 41 val = on ? 0 : EXYNOS5_PHY_ENABLE;
33 if (on)
34 reg |= EXYNOS_DPTX_PHY_ENABLE;
35 else
36 reg &= ~EXYNOS_DPTX_PHY_ENABLE;
37 writel(reg, state->regs);
38 42
39 return 0; 43 regmap_update_bits(state->regs, state->drvdata->phy_ctrl_offset,
44 EXYNOS5_PHY_ENABLE, val);
40} 45}
41 46
42static int exynos_dp_video_phy_power_on(struct phy *phy) 47static int exynos_dp_video_phy_power_on(struct phy *phy)
43{ 48{
44 struct exynos_dp_video_phy *state = phy_get_drvdata(phy); 49 struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
45 50
46 return __set_phy_state(state, 1); 51 /* Disable power isolation on DP-PHY */
52 exynos_dp_video_phy_pwr_isol(state, 0);
53
54 return 0;
47} 55}
48 56
49static int exynos_dp_video_phy_power_off(struct phy *phy) 57static int exynos_dp_video_phy_power_off(struct phy *phy)
50{ 58{
51 struct exynos_dp_video_phy *state = phy_get_drvdata(phy); 59 struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
52 60
53 return __set_phy_state(state, 0); 61 /* Enable power isolation on DP-PHY */
62 exynos_dp_video_phy_pwr_isol(state, 1);
63
64 return 0;
54} 65}
55 66
56static struct phy_ops exynos_dp_video_phy_ops = { 67static struct phy_ops exynos_dp_video_phy_ops = {
@@ -59,11 +70,31 @@ static struct phy_ops exynos_dp_video_phy_ops = {
59 .owner = THIS_MODULE, 70 .owner = THIS_MODULE,
60}; 71};
61 72
73static const struct exynos_dp_video_phy_drvdata exynos5250_dp_video_phy = {
74 .phy_ctrl_offset = EXYNOS5_DPTX_PHY_CONTROL,
75};
76
77static const struct exynos_dp_video_phy_drvdata exynos5420_dp_video_phy = {
78 .phy_ctrl_offset = EXYNOS5420_DPTX_PHY_CONTROL,
79};
80
81static const struct of_device_id exynos_dp_video_phy_of_match[] = {
82 {
83 .compatible = "samsung,exynos5250-dp-video-phy",
84 .data = &exynos5250_dp_video_phy,
85 }, {
86 .compatible = "samsung,exynos5420-dp-video-phy",
87 .data = &exynos5420_dp_video_phy,
88 },
89 { },
90};
91MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match);
92
62static int exynos_dp_video_phy_probe(struct platform_device *pdev) 93static int exynos_dp_video_phy_probe(struct platform_device *pdev)
63{ 94{
64 struct exynos_dp_video_phy *state; 95 struct exynos_dp_video_phy *state;
65 struct device *dev = &pdev->dev; 96 struct device *dev = &pdev->dev;
66 struct resource *res; 97 const struct of_device_id *match;
67 struct phy_provider *phy_provider; 98 struct phy_provider *phy_provider;
68 struct phy *phy; 99 struct phy *phy;
69 100
@@ -71,11 +102,15 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
71 if (!state) 102 if (!state)
72 return -ENOMEM; 103 return -ENOMEM;
73 104
74 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 105 state->regs = syscon_regmap_lookup_by_phandle(dev->of_node,
75 106 "samsung,pmu-syscon");
76 state->regs = devm_ioremap_resource(dev, res); 107 if (IS_ERR(state->regs)) {
77 if (IS_ERR(state->regs)) 108 dev_err(dev, "Failed to lookup PMU regmap\n");
78 return PTR_ERR(state->regs); 109 return PTR_ERR(state->regs);
110 }
111
112 match = of_match_node(exynos_dp_video_phy_of_match, dev->of_node);
113 state->drvdata = match->data;
79 114
80 phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops, NULL); 115 phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops, NULL);
81 if (IS_ERR(phy)) { 116 if (IS_ERR(phy)) {
@@ -89,17 +124,10 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
89 return PTR_ERR_OR_ZERO(phy_provider); 124 return PTR_ERR_OR_ZERO(phy_provider);
90} 125}
91 126
92static const struct of_device_id exynos_dp_video_phy_of_match[] = {
93 { .compatible = "samsung,exynos5250-dp-video-phy" },
94 { },
95};
96MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match);
97
98static struct platform_driver exynos_dp_video_phy_driver = { 127static struct platform_driver exynos_dp_video_phy_driver = {
99 .probe = exynos_dp_video_phy_probe, 128 .probe = exynos_dp_video_phy_probe,
100 .driver = { 129 .driver = {
101 .name = "exynos-dp-video-phy", 130 .name = "exynos-dp-video-phy",
102 .owner = THIS_MODULE,
103 .of_match_table = exynos_dp_video_phy_of_match, 131 .of_match_table = exynos_dp_video_phy_of_match,
104 } 132 }
105}; 133};