phy-exynos-dp-video.c (3277B)
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Samsung Exynos SoC series Display Port PHY driver 4 * 5 * Copyright (C) 2013 Samsung Electronics Co., Ltd. 6 * Author: Jingoo Han <jg1.han@samsung.com> 7 */ 8 9#include <linux/err.h> 10#include <linux/io.h> 11#include <linux/kernel.h> 12#include <linux/module.h> 13#include <linux/mfd/syscon.h> 14#include <linux/of.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> 21 22struct exynos_dp_video_phy_drvdata { 23 u32 phy_ctrl_offset; 24}; 25 26struct exynos_dp_video_phy { 27 struct regmap *regs; 28 const struct exynos_dp_video_phy_drvdata *drvdata; 29}; 30 31static int exynos_dp_video_phy_power_on(struct phy *phy) 32{ 33 struct exynos_dp_video_phy *state = phy_get_drvdata(phy); 34 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); 38} 39 40static int exynos_dp_video_phy_power_off(struct phy *phy) 41{ 42 struct exynos_dp_video_phy *state = phy_get_drvdata(phy); 43 44 /* Enable power isolation on DP-PHY */ 45 return regmap_update_bits(state->regs, state->drvdata->phy_ctrl_offset, 46 EXYNOS4_PHY_ENABLE, 0); 47} 48 49static 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, 52 .owner = THIS_MODULE, 53}; 54 55static const struct exynos_dp_video_phy_drvdata exynos5250_dp_video_phy = { 56 .phy_ctrl_offset = EXYNOS5_DPTX_PHY_CONTROL, 57}; 58 59static const struct exynos_dp_video_phy_drvdata exynos5420_dp_video_phy = { 60 .phy_ctrl_offset = EXYNOS5420_DPTX_PHY_CONTROL, 61}; 62 63static const struct of_device_id exynos_dp_video_phy_of_match[] = { 64 { 65 .compatible = "samsung,exynos5250-dp-video-phy", 66 .data = &exynos5250_dp_video_phy, 67 }, { 68 .compatible = "samsung,exynos5420-dp-video-phy", 69 .data = &exynos5420_dp_video_phy, 70 }, 71 { }, 72}; 73MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match); 74 75static int exynos_dp_video_phy_probe(struct platform_device *pdev) 76{ 77 struct exynos_dp_video_phy *state; 78 struct device *dev = &pdev->dev; 79 struct phy_provider *phy_provider; 80 struct phy *phy; 81 82 state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL); 83 if (!state) 84 return -ENOMEM; 85 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); 91 } 92 93 state->drvdata = of_device_get_match_data(dev); 94 95 phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops); 96 if (IS_ERR(phy)) { 97 dev_err(dev, "failed to create Display Port PHY\n"); 98 return PTR_ERR(phy); 99 } 100 phy_set_drvdata(phy, state); 101 102 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 103 104 return PTR_ERR_OR_ZERO(phy_provider); 105} 106 107static struct platform_driver exynos_dp_video_phy_driver = { 108 .probe = exynos_dp_video_phy_probe, 109 .driver = { 110 .name = "exynos-dp-video-phy", 111 .of_match_table = exynos_dp_video_phy_of_match, 112 .suppress_bind_attrs = true, 113 } 114}; 115module_platform_driver(exynos_dp_video_phy_driver); 116 117MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>"); 118MODULE_DESCRIPTION("Samsung Exynos SoC DP PHY driver"); 119MODULE_LICENSE("GPL v2");