diff options
| author | Vivek Gautam <gautam.vivek@samsung.com> | 2014-09-16 01:02:06 -0400 |
|---|---|---|
| committer | Kishon Vijay Abraham I <kishon@ti.com> | 2014-09-24 05:48:34 -0400 |
| commit | a5ec598650257d9a7abefa6616840c872e194fdb (patch) | |
| tree | 3e027828bd1c845721e14e98289a7e2f6811fa18 | |
| parent | 26389c78269ada2927a4ec114bbf4df45776445d (diff) | |
phy: exynos-dp-video: Use syscon support to control pmu register
Currently the DP_PHY_ENABLE register is mapped in the driver,
and accessed to control power to the PHY.
With mfd-syscon and regmap interface available at our disposal,
it's wise to use that instead of using a 'reg' property for the
controller and allocating a memory resource for that.
To facilitate this, we have added another compatible string
for Exynso5420 SoC to acquire driver data which contains
different DP-PHY-CONTROL register offset.
Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
| -rw-r--r-- | Documentation/devicetree/bindings/phy/samsung-phy.txt | 7 | ||||
| -rw-r--r-- | drivers/phy/phy-exynos-dp-video.c | 79 |
2 files changed, 59 insertions, 27 deletions
diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index 7a6feea2a48b..15e0f2c7130f 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt | |||
| @@ -17,8 +17,11 @@ Samsung EXYNOS SoC series Display Port PHY | |||
| 17 | ------------------------------------------------- | 17 | ------------------------------------------------- |
| 18 | 18 | ||
| 19 | Required properties: | 19 | Required properties: |
| 20 | - compatible : should be "samsung,exynos5250-dp-video-phy"; | 20 | - compatible : should be one of the following supported values: |
| 21 | - reg : offset and length of the Display Port PHY register set; | 21 | - "samsung,exynos5250-dp-video-phy" |
| 22 | - "samsung,exynos5420-dp-video-phy" | ||
| 23 | - samsung,pmu-syscon: phandle for PMU system controller interface, used to | ||
| 24 | control pmu registers for power isolation. | ||
| 22 | - #phy-cells : from the generic PHY bindings, must be 0; | 25 | - #phy-cells : from the generic PHY bindings, must be 0; |
| 23 | 26 | ||
| 24 | Samsung S5P/EXYNOS SoC series USB PHY | 27 | Samsung S5P/EXYNOS SoC series USB PHY |
diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c index 8b3026e2af7f..53f44a0fe0aa 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 */ | 24 | struct exynos_dp_video_phy_drvdata { |
| 22 | #define EXYNOS_DPTX_PHY_ENABLE (1 << 0) | 25 | u32 phy_ctrl_offset; |
| 26 | }; | ||
| 23 | 27 | ||
| 24 | struct exynos_dp_video_phy { | 28 | struct 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 | ||
| 28 | static int __set_phy_state(struct exynos_dp_video_phy *state, unsigned int on) | 33 | static 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 | ||
| 42 | static int exynos_dp_video_phy_power_on(struct phy *phy) | 47 | static 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 | ||
| 49 | static int exynos_dp_video_phy_power_off(struct phy *phy) | 57 | static 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 | ||
| 56 | static struct phy_ops exynos_dp_video_phy_ops = { | 67 | static 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 | ||
| 73 | static const struct exynos_dp_video_phy_drvdata exynos5250_dp_video_phy = { | ||
| 74 | .phy_ctrl_offset = EXYNOS5_DPTX_PHY_CONTROL, | ||
| 75 | }; | ||
| 76 | |||
| 77 | static const struct exynos_dp_video_phy_drvdata exynos5420_dp_video_phy = { | ||
| 78 | .phy_ctrl_offset = EXYNOS5420_DPTX_PHY_CONTROL, | ||
| 79 | }; | ||
| 80 | |||
| 81 | static 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 | }; | ||
| 91 | MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match); | ||
| 92 | |||
| 62 | static int exynos_dp_video_phy_probe(struct platform_device *pdev) | 93 | static 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,12 +124,6 @@ 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 | ||
| 92 | static const struct of_device_id exynos_dp_video_phy_of_match[] = { | ||
| 93 | { .compatible = "samsung,exynos5250-dp-video-phy" }, | ||
| 94 | { }, | ||
| 95 | }; | ||
| 96 | MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match); | ||
| 97 | |||
| 98 | static struct platform_driver exynos_dp_video_phy_driver = { | 127 | static 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 = { |
