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/err.h>
14 #include <linux/kernel.h>
15 #include <linux/module.h>
17 #include <linux/of_address.h>
18 #include <linux/phy/phy.h>
19 #include <linux/platform_device.h>
21 /* DPTX_PHY_CONTROL register */
22 #define EXYNOS_DPTX_PHY_ENABLE (1 << 0)
24 struct exynos_dp_video_phy {
28 static int __set_phy_state(struct exynos_dp_video_phy *state, unsigned int on)
32 reg = readl(state->regs);
34 reg |= EXYNOS_DPTX_PHY_ENABLE;
36 reg &= ~EXYNOS_DPTX_PHY_ENABLE;
37 writel(reg, state->regs);
42 static int exynos_dp_video_phy_power_on(struct phy *phy)
44 struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
46 return __set_phy_state(state, 1);
49 static int exynos_dp_video_phy_power_off(struct phy *phy)
51 struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
53 return __set_phy_state(state, 0);
56 static 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,
62 static int exynos_dp_video_phy_probe(struct platform_device *pdev)
64 struct exynos_dp_video_phy *state;
65 struct device *dev = &pdev->dev;
67 struct phy_provider *phy_provider;
70 state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL);
74 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
76 state->regs = devm_ioremap_resource(dev, res);
77 if (IS_ERR(state->regs))
78 return PTR_ERR(state->regs);
80 phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops, NULL);
82 dev_err(dev, "failed to create Display Port PHY\n");
85 phy_set_drvdata(phy, state);
87 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
89 return PTR_ERR_OR_ZERO(phy_provider);
92 static const struct of_device_id exynos_dp_video_phy_of_match[] = {
93 { .compatible = "samsung,exynos5250-dp-video-phy" },
96 MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match);
98 static struct platform_driver exynos_dp_video_phy_driver = {
99 .probe = exynos_dp_video_phy_probe,
101 .name = "exynos-dp-video-phy",
102 .owner = THIS_MODULE,
103 .of_match_table = exynos_dp_video_phy_of_match,
106 module_platform_driver(exynos_dp_video_phy_driver);
108 MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");
109 MODULE_DESCRIPTION("Samsung EXYNOS SoC DP PHY driver");
110 MODULE_LICENSE("GPL v2");