PM / sleep: Asynchronous threads for suspend_noirq
[linux/fpc-iii.git] / drivers / phy / phy-exynos-dp-video.c
blob1dbe6ce7b2ce795e0a81ec3a632a8b6d6927f2bc
1 /*
2 * Samsung EXYNOS SoC series Display Port PHY driver
4 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
5 * Author: Jingoo Han <jg1.han@samsung.com>
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.
12 #include <linux/io.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/of.h>
16 #include <linux/of_address.h>
17 #include <linux/phy/phy.h>
18 #include <linux/platform_device.h>
20 /* DPTX_PHY_CONTROL register */
21 #define EXYNOS_DPTX_PHY_ENABLE (1 << 0)
23 struct exynos_dp_video_phy {
24 void __iomem *regs;
27 static int __set_phy_state(struct exynos_dp_video_phy *state, unsigned int on)
29 u32 reg;
31 reg = readl(state->regs);
32 if (on)
33 reg |= EXYNOS_DPTX_PHY_ENABLE;
34 else
35 reg &= ~EXYNOS_DPTX_PHY_ENABLE;
36 writel(reg, state->regs);
38 return 0;
41 static int exynos_dp_video_phy_power_on(struct phy *phy)
43 struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
45 return __set_phy_state(state, 1);
48 static int exynos_dp_video_phy_power_off(struct phy *phy)
50 struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
52 return __set_phy_state(state, 0);
55 static struct phy_ops exynos_dp_video_phy_ops = {
56 .power_on = exynos_dp_video_phy_power_on,
57 .power_off = exynos_dp_video_phy_power_off,
58 .owner = THIS_MODULE,
61 static int exynos_dp_video_phy_probe(struct platform_device *pdev)
63 struct exynos_dp_video_phy *state;
64 struct device *dev = &pdev->dev;
65 struct resource *res;
66 struct phy_provider *phy_provider;
67 struct phy *phy;
69 state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL);
70 if (!state)
71 return -ENOMEM;
73 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
75 state->regs = devm_ioremap_resource(dev, res);
76 if (IS_ERR(state->regs))
77 return PTR_ERR(state->regs);
79 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
80 if (IS_ERR(phy_provider))
81 return PTR_ERR(phy_provider);
83 phy = devm_phy_create(dev, &exynos_dp_video_phy_ops, NULL);
84 if (IS_ERR(phy)) {
85 dev_err(dev, "failed to create Display Port PHY\n");
86 return PTR_ERR(phy);
88 phy_set_drvdata(phy, state);
90 return 0;
93 static const struct of_device_id exynos_dp_video_phy_of_match[] = {
94 { .compatible = "samsung,exynos5250-dp-video-phy" },
95 { },
97 MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match);
99 static struct platform_driver exynos_dp_video_phy_driver = {
100 .probe = exynos_dp_video_phy_probe,
101 .driver = {
102 .name = "exynos-dp-video-phy",
103 .owner = THIS_MODULE,
104 .of_match_table = exynos_dp_video_phy_of_match,
107 module_platform_driver(exynos_dp_video_phy_driver);
109 MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");
110 MODULE_DESCRIPTION("Samsung EXYNOS SoC DP PHY driver");
111 MODULE_LICENSE("GPL v2");