blob: 179cbf9451aacf1aca440e46eb05493f41037e48 [file] [log] [blame]
Jingoo Han74988e82013-10-16 21:58:14 +05301/*
2 * Samsung EXYNOS SoC series Display Port PHY driver
3 *
4 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
5 * Author: Jingoo Han <jg1.han@samsung.com>
6 *
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.
10 */
11
Sachin Kamatbbe21b22014-05-29 12:00:47 +053012#include <linux/err.h>
Jingoo Han74988e82013-10-16 21:58:14 +053013#include <linux/io.h>
14#include <linux/kernel.h>
15#include <linux/module.h>
Vivek Gautama5ec5982014-09-16 10:32:06 +053016#include <linux/mfd/syscon.h>
17#include <linux/mfd/syscon/exynos5-pmu.h>
Jingoo Han74988e82013-10-16 21:58:14 +053018#include <linux/of.h>
19#include <linux/of_address.h>
20#include <linux/phy/phy.h>
21#include <linux/platform_device.h>
Vivek Gautama5ec5982014-09-16 10:32:06 +053022#include <linux/regmap.h>
Jingoo Han74988e82013-10-16 21:58:14 +053023
Vivek Gautama5ec5982014-09-16 10:32:06 +053024struct exynos_dp_video_phy_drvdata {
25 u32 phy_ctrl_offset;
Jingoo Han74988e82013-10-16 21:58:14 +053026};
27
Vivek Gautama5ec5982014-09-16 10:32:06 +053028struct exynos_dp_video_phy {
29 struct regmap *regs;
30 const struct exynos_dp_video_phy_drvdata *drvdata;
31};
32
Jingoo Han74988e82013-10-16 21:58:14 +053033static int exynos_dp_video_phy_power_on(struct phy *phy)
34{
35 struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
36
Vivek Gautama5ec5982014-09-16 10:32:06 +053037 /* Disable power isolation on DP-PHY */
Axel Lin0f9722e2015-02-27 12:34:10 +080038 return regmap_update_bits(state->regs, state->drvdata->phy_ctrl_offset,
39 EXYNOS5_PHY_ENABLE, EXYNOS5_PHY_ENABLE);
Jingoo Han74988e82013-10-16 21:58:14 +053040}
41
42static int exynos_dp_video_phy_power_off(struct phy *phy)
43{
44 struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
45
Vivek Gautama5ec5982014-09-16 10:32:06 +053046 /* Enable power isolation on DP-PHY */
Axel Lin0f9722e2015-02-27 12:34:10 +080047 return regmap_update_bits(state->regs, state->drvdata->phy_ctrl_offset,
48 EXYNOS5_PHY_ENABLE, 0);
Jingoo Han74988e82013-10-16 21:58:14 +053049}
50
51static struct phy_ops exynos_dp_video_phy_ops = {
52 .power_on = exynos_dp_video_phy_power_on,
53 .power_off = exynos_dp_video_phy_power_off,
54 .owner = THIS_MODULE,
55};
56
Vivek Gautama5ec5982014-09-16 10:32:06 +053057static const struct exynos_dp_video_phy_drvdata exynos5250_dp_video_phy = {
58 .phy_ctrl_offset = EXYNOS5_DPTX_PHY_CONTROL,
59};
60
61static const struct exynos_dp_video_phy_drvdata exynos5420_dp_video_phy = {
62 .phy_ctrl_offset = EXYNOS5420_DPTX_PHY_CONTROL,
63};
64
65static const struct of_device_id exynos_dp_video_phy_of_match[] = {
66 {
67 .compatible = "samsung,exynos5250-dp-video-phy",
68 .data = &exynos5250_dp_video_phy,
69 }, {
70 .compatible = "samsung,exynos5420-dp-video-phy",
71 .data = &exynos5420_dp_video_phy,
72 },
73 { },
74};
75MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match);
76
Jingoo Han74988e82013-10-16 21:58:14 +053077static int exynos_dp_video_phy_probe(struct platform_device *pdev)
78{
79 struct exynos_dp_video_phy *state;
80 struct device *dev = &pdev->dev;
Vivek Gautama5ec5982014-09-16 10:32:06 +053081 const struct of_device_id *match;
Jingoo Han74988e82013-10-16 21:58:14 +053082 struct phy_provider *phy_provider;
83 struct phy *phy;
84
85 state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL);
86 if (!state)
87 return -ENOMEM;
88
Vivek Gautama5ec5982014-09-16 10:32:06 +053089 state->regs = syscon_regmap_lookup_by_phandle(dev->of_node,
90 "samsung,pmu-syscon");
91 if (IS_ERR(state->regs)) {
92 dev_err(dev, "Failed to lookup PMU regmap\n");
Jingoo Han74988e82013-10-16 21:58:14 +053093 return PTR_ERR(state->regs);
Vivek Gautama5ec5982014-09-16 10:32:06 +053094 }
95
96 match = of_match_node(exynos_dp_video_phy_of_match, dev->of_node);
97 state->drvdata = match->data;
Jingoo Han74988e82013-10-16 21:58:14 +053098
Heikki Krogerusdbc98632014-11-19 17:28:21 +020099 phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops);
Jingoo Han74988e82013-10-16 21:58:14 +0530100 if (IS_ERR(phy)) {
101 dev_err(dev, "failed to create Display Port PHY\n");
102 return PTR_ERR(phy);
103 }
104 phy_set_drvdata(phy, state);
105
Kishon Vijay Abraham I64fe1892014-02-17 14:29:25 +0530106 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
Kishon Vijay Abraham I64fe1892014-02-17 14:29:25 +0530107
Sachin Kamatbbe21b22014-05-29 12:00:47 +0530108 return PTR_ERR_OR_ZERO(phy_provider);
Jingoo Han74988e82013-10-16 21:58:14 +0530109}
110
Jingoo Han74988e82013-10-16 21:58:14 +0530111static struct platform_driver exynos_dp_video_phy_driver = {
112 .probe = exynos_dp_video_phy_probe,
113 .driver = {
114 .name = "exynos-dp-video-phy",
Jingoo Han74988e82013-10-16 21:58:14 +0530115 .of_match_table = exynos_dp_video_phy_of_match,
116 }
117};
118module_platform_driver(exynos_dp_video_phy_driver);
119
120MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");
121MODULE_DESCRIPTION("Samsung EXYNOS SoC DP PHY driver");
122MODULE_LICENSE("GPL v2");