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.
13 #include <linux/kernel.h>
14 #include <linux/module.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
{
27 static int __set_phy_state(struct exynos_dp_video_phy
*state
, unsigned int on
)
31 reg
= readl(state
->regs
);
33 reg
|= EXYNOS_DPTX_PHY_ENABLE
;
35 reg
&= ~EXYNOS_DPTX_PHY_ENABLE
;
36 writel(reg
, state
->regs
);
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
,
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
;
66 struct phy_provider
*phy_provider
;
69 state
= devm_kzalloc(dev
, sizeof(*state
), GFP_KERNEL
);
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
= devm_phy_create(dev
, &exynos_dp_video_phy_ops
, NULL
);
81 dev_err(dev
, "failed to create Display Port PHY\n");
84 phy_set_drvdata(phy
, state
);
86 phy_provider
= devm_of_phy_provider_register(dev
, of_phy_simple_xlate
);
87 if (IS_ERR(phy_provider
))
88 return PTR_ERR(phy_provider
);
93 static const struct of_device_id exynos_dp_video_phy_of_match
[] = {
94 { .compatible
= "samsung,exynos5250-dp-video-phy" },
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
,
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");