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/of_address.h>
16 #include <linux/of_device.h>
17 #include <linux/phy/phy.h>
18 #include <linux/platform_device.h>
19 #include <linux/regmap.h>
20 #include <linux/soc/samsung/exynos-regs-pmu.h>
22 struct exynos_dp_video_phy_drvdata
{
26 struct exynos_dp_video_phy
{
28 const struct exynos_dp_video_phy_drvdata
*drvdata
;
31 static int exynos_dp_video_phy_power_on(struct phy
*phy
)
33 struct exynos_dp_video_phy
*state
= phy_get_drvdata(phy
);
35 /* Disable power isolation on DP-PHY */
36 return regmap_update_bits(state
->regs
, state
->drvdata
->phy_ctrl_offset
,
37 EXYNOS4_PHY_ENABLE
, EXYNOS4_PHY_ENABLE
);
40 static int exynos_dp_video_phy_power_off(struct phy
*phy
)
42 struct exynos_dp_video_phy
*state
= phy_get_drvdata(phy
);
44 /* Enable power isolation on DP-PHY */
45 return regmap_update_bits(state
->regs
, state
->drvdata
->phy_ctrl_offset
,
46 EXYNOS4_PHY_ENABLE
, 0);
49 static const struct phy_ops exynos_dp_video_phy_ops
= {
50 .power_on
= exynos_dp_video_phy_power_on
,
51 .power_off
= exynos_dp_video_phy_power_off
,
55 static const struct exynos_dp_video_phy_drvdata exynos5250_dp_video_phy
= {
56 .phy_ctrl_offset
= EXYNOS5_DPTX_PHY_CONTROL
,
59 static const struct exynos_dp_video_phy_drvdata exynos5420_dp_video_phy
= {
60 .phy_ctrl_offset
= EXYNOS5420_DPTX_PHY_CONTROL
,
63 static const struct of_device_id exynos_dp_video_phy_of_match
[] = {
65 .compatible
= "samsung,exynos5250-dp-video-phy",
66 .data
= &exynos5250_dp_video_phy
,
68 .compatible
= "samsung,exynos5420-dp-video-phy",
69 .data
= &exynos5420_dp_video_phy
,
73 MODULE_DEVICE_TABLE(of
, exynos_dp_video_phy_of_match
);
75 static int exynos_dp_video_phy_probe(struct platform_device
*pdev
)
77 struct exynos_dp_video_phy
*state
;
78 struct device
*dev
= &pdev
->dev
;
79 struct phy_provider
*phy_provider
;
82 state
= devm_kzalloc(dev
, sizeof(*state
), GFP_KERNEL
);
86 state
->regs
= syscon_regmap_lookup_by_phandle(dev
->of_node
,
87 "samsung,pmu-syscon");
88 if (IS_ERR(state
->regs
)) {
89 dev_err(dev
, "Failed to lookup PMU regmap\n");
90 return PTR_ERR(state
->regs
);
93 state
->drvdata
= of_device_get_match_data(dev
);
95 phy
= devm_phy_create(dev
, NULL
, &exynos_dp_video_phy_ops
);
97 dev_err(dev
, "failed to create Display Port PHY\n");
100 phy_set_drvdata(phy
, state
);
102 phy_provider
= devm_of_phy_provider_register(dev
, of_phy_simple_xlate
);
104 return PTR_ERR_OR_ZERO(phy_provider
);
107 static struct platform_driver exynos_dp_video_phy_driver
= {
108 .probe
= exynos_dp_video_phy_probe
,
110 .name
= "exynos-dp-video-phy",
111 .of_match_table
= exynos_dp_video_phy_of_match
,
112 .suppress_bind_attrs
= true,
115 module_platform_driver(exynos_dp_video_phy_driver
);
117 MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");
118 MODULE_DESCRIPTION("Samsung EXYNOS SoC DP PHY driver");
119 MODULE_LICENSE("GPL v2");