1 // SPDX-License-Identifier: GPL-2.0-only
3 * Samsung Exynos SoC series Display Port PHY driver
5 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
6 * Author: Jingoo Han <jg1.han@samsung.com>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/mfd/syscon.h>
15 #include <linux/phy/phy.h>
16 #include <linux/platform_device.h>
17 #include <linux/regmap.h>
18 #include <linux/soc/samsung/exynos-regs-pmu.h>
20 struct exynos_dp_video_phy_drvdata
{
24 struct exynos_dp_video_phy
{
26 const struct exynos_dp_video_phy_drvdata
*drvdata
;
29 static int exynos_dp_video_phy_power_on(struct phy
*phy
)
31 struct exynos_dp_video_phy
*state
= phy_get_drvdata(phy
);
33 /* Disable power isolation on DP-PHY */
34 return regmap_update_bits(state
->regs
, state
->drvdata
->phy_ctrl_offset
,
35 EXYNOS4_PHY_ENABLE
, EXYNOS4_PHY_ENABLE
);
38 static int exynos_dp_video_phy_power_off(struct phy
*phy
)
40 struct exynos_dp_video_phy
*state
= phy_get_drvdata(phy
);
42 /* Enable power isolation on DP-PHY */
43 return regmap_update_bits(state
->regs
, state
->drvdata
->phy_ctrl_offset
,
44 EXYNOS4_PHY_ENABLE
, 0);
47 static const struct phy_ops exynos_dp_video_phy_ops
= {
48 .power_on
= exynos_dp_video_phy_power_on
,
49 .power_off
= exynos_dp_video_phy_power_off
,
53 static const struct exynos_dp_video_phy_drvdata exynos5250_dp_video_phy
= {
54 .phy_ctrl_offset
= EXYNOS5_DPTX_PHY_CONTROL
,
57 static const struct exynos_dp_video_phy_drvdata exynos5420_dp_video_phy
= {
58 .phy_ctrl_offset
= EXYNOS5420_DPTX_PHY_CONTROL
,
61 static const struct of_device_id exynos_dp_video_phy_of_match
[] = {
63 .compatible
= "samsung,exynos5250-dp-video-phy",
64 .data
= &exynos5250_dp_video_phy
,
66 .compatible
= "samsung,exynos5420-dp-video-phy",
67 .data
= &exynos5420_dp_video_phy
,
71 MODULE_DEVICE_TABLE(of
, exynos_dp_video_phy_of_match
);
73 static int exynos_dp_video_phy_probe(struct platform_device
*pdev
)
75 struct exynos_dp_video_phy
*state
;
76 struct device
*dev
= &pdev
->dev
;
77 struct phy_provider
*phy_provider
;
80 state
= devm_kzalloc(dev
, sizeof(*state
), GFP_KERNEL
);
84 state
->regs
= syscon_node_to_regmap(dev
->parent
->of_node
);
85 if (IS_ERR(state
->regs
))
86 /* Backwards compatible way */
87 state
->regs
= syscon_regmap_lookup_by_phandle(dev
->of_node
,
88 "samsung,pmu-syscon");
89 if (IS_ERR(state
->regs
)) {
90 dev_err(dev
, "Failed to lookup PMU regmap\n");
91 return PTR_ERR(state
->regs
);
94 state
->drvdata
= of_device_get_match_data(dev
);
96 phy
= devm_phy_create(dev
, NULL
, &exynos_dp_video_phy_ops
);
98 dev_err(dev
, "failed to create Display Port PHY\n");
101 phy_set_drvdata(phy
, state
);
103 phy_provider
= devm_of_phy_provider_register(dev
, of_phy_simple_xlate
);
105 return PTR_ERR_OR_ZERO(phy_provider
);
108 static struct platform_driver exynos_dp_video_phy_driver
= {
109 .probe
= exynos_dp_video_phy_probe
,
111 .name
= "exynos-dp-video-phy",
112 .of_match_table
= exynos_dp_video_phy_of_match
,
113 .suppress_bind_attrs
= true,
116 module_platform_driver(exynos_dp_video_phy_driver
);
118 MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");
119 MODULE_DESCRIPTION("Samsung Exynos SoC DP PHY driver");
120 MODULE_LICENSE("GPL v2");