Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[deliverable/linux.git] / drivers / phy / phy-exynos-dp-video.c
CommitLineData
74988e8b
JH
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
bbe21b2a 12#include <linux/err.h>
74988e8b
JH
13#include <linux/io.h>
14#include <linux/kernel.h>
15#include <linux/module.h>
16#include <linux/of.h>
17#include <linux/of_address.h>
18#include <linux/phy/phy.h>
19#include <linux/platform_device.h>
20
21/* DPTX_PHY_CONTROL register */
22#define EXYNOS_DPTX_PHY_ENABLE (1 << 0)
23
24struct exynos_dp_video_phy {
25 void __iomem *regs;
26};
27
28static int __set_phy_state(struct exynos_dp_video_phy *state, unsigned int on)
29{
30 u32 reg;
31
32 reg = readl(state->regs);
33 if (on)
34 reg |= EXYNOS_DPTX_PHY_ENABLE;
35 else
36 reg &= ~EXYNOS_DPTX_PHY_ENABLE;
37 writel(reg, state->regs);
38
39 return 0;
40}
41
42static int exynos_dp_video_phy_power_on(struct phy *phy)
43{
44 struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
45
46 return __set_phy_state(state, 1);
47}
48
49static int exynos_dp_video_phy_power_off(struct phy *phy)
50{
51 struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
52
53 return __set_phy_state(state, 0);
54}
55
56static struct phy_ops exynos_dp_video_phy_ops = {
57 .power_on = exynos_dp_video_phy_power_on,
58 .power_off = exynos_dp_video_phy_power_off,
59 .owner = THIS_MODULE,
60};
61
62static int exynos_dp_video_phy_probe(struct platform_device *pdev)
63{
64 struct exynos_dp_video_phy *state;
65 struct device *dev = &pdev->dev;
66 struct resource *res;
67 struct phy_provider *phy_provider;
68 struct phy *phy;
69
70 state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL);
71 if (!state)
72 return -ENOMEM;
73
74 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
75
76 state->regs = devm_ioremap_resource(dev, res);
77 if (IS_ERR(state->regs))
78 return PTR_ERR(state->regs);
79
f0ed8176 80 phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops, NULL);
74988e8b
JH
81 if (IS_ERR(phy)) {
82 dev_err(dev, "failed to create Display Port PHY\n");
83 return PTR_ERR(phy);
84 }
85 phy_set_drvdata(phy, state);
86
64fe1891 87 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
64fe1891 88
bbe21b2a 89 return PTR_ERR_OR_ZERO(phy_provider);
74988e8b
JH
90}
91
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 = {
99 .probe = exynos_dp_video_phy_probe,
100 .driver = {
101 .name = "exynos-dp-video-phy",
102 .owner = THIS_MODULE,
103 .of_match_table = exynos_dp_video_phy_of_match,
104 }
105};
106module_platform_driver(exynos_dp_video_phy_driver);
107
108MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");
109MODULE_DESCRIPTION("Samsung EXYNOS SoC DP PHY driver");
110MODULE_LICENSE("GPL v2");
This page took 0.077166 seconds and 5 git commands to generate.