From patchwork Fri Jun 28 05:22:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingoo Han X-Patchwork-Id: 2797031 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C828B9F3A0 for ; Fri, 28 Jun 2013 05:22:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C7A5F2010C for ; Fri, 28 Jun 2013 05:22:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0CAA20109 for ; Fri, 28 Jun 2013 05:22:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751997Ab3F1FWx (ORCPT ); Fri, 28 Jun 2013 01:22:53 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:16662 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751200Ab3F1FWv (ORCPT ); Fri, 28 Jun 2013 01:22:51 -0400 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MP300BNE8A0D4P0@mailout3.samsung.com>; Fri, 28 Jun 2013 14:22:49 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.50]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id AB.53.29708.9AD1DC15; Fri, 28 Jun 2013 14:22:49 +0900 (KST) X-AuditID: cbfee690-b7f6f6d00000740c-e7-51cd1da9ead5 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 52.F4.28381.9AD1DC15; Fri, 28 Jun 2013 14:22:49 +0900 (KST) Received: from DOJG1HAN03 ([12.23.120.99]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MP300DFF8A1UFS0@mmp2.samsung.com>; Fri, 28 Jun 2013 14:22:49 +0900 (KST) From: Jingoo Han To: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: 'Kishon Vijay Abraham I' , linux-media@vger.kernel.org, 'Kukjin Kim' , 'Sylwester Nawrocki' , 'Felipe Balbi' , 'Tomasz Figa' , devicetree-discuss@lists.ozlabs.org, 'Inki Dae' , 'Donghwa Lee' , 'Kyungmin Park' , 'Jean-Christophe PLAGNIOL-VILLARD' , linux-fbdev@vger.kernel.org, Jingoo Han Subject: [PATCH 1/3] phy: Add driver for Exynos DP PHY Date: Fri, 28 Jun 2013 14:22:49 +0900 Message-id: <001501ce73bf$87c49c00$974dd400$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac5zv3lc6SWCsWOOSKqsgf7UOs0SGA== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRmVeSWpSXmKPExsVy+t8zI92VsmcDDR71qlscvF9v8fKQpsWB 2Q9ZLa6ft7OYdH8Ci8XlhZdYLXoXXGWzuPC0h83ibNMbdotNj6+xWpzo+8Bq0bNhK6vFjPP7 mCzWPXzBZHH4TTurxfoZr1kcBDxeXbjD4rF5Sb3H+RkLGT36tqxi9Dh+YzuTx+dNcgFsUVw2 Kak5mWWpRfp2CVwZ/VfNCk7qVuydeoClgfGVahcjJ4eEgInEykuvmSFsMYkL99azgdhCAssY JXr6RGBqFqx/ztLFyAUUn84osarpMBuE84tR4ndnB1g3m4CaxJcvh9m7GDk4RAS8JZZfUwSp YRZoZZGY9/o/C0iNsICZxKEnexhBalgEVCW+39YB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wC8moWUhG zUIyahaSlgWMLKsYRVMLkguKk9JzDfWKE3OLS/PS9ZLzczcxgtPIM6kdjCsbLA4xCnAwKvHw NiaeCRRiTSwrrsw9xCjBwawkwntnAVCINyWxsiq1KD++qDQntfgQYzLQoxOZpUST84EpLq8k 3tDYxMzI0sjMwsjE3Jw0YSVx3gOt1oFCAumJJanZqakFqUUwW5g4OKUaGGfbiRoxWwVbq/3m ZxdNbarQ3aaQ9i2GpUb7yIpQ7tbEjmXpM59sdPZTSbrWxVSqqsSyZ1mNcsTTU9WlplEV8xu3 +6rXhWXr6knUZZhZ7Cw8/aRe25/L5EC4xzM761g7z5tbd1/6EjB/pupsBgHXxYHL/Zxj5cWF A+es+/w3Z2GW/W6bqVOVWIozEg21mIuKEwEGq54OZwMAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a PHY provider driver for the Samsung Exynos SoC DP PHY. Signed-off-by: Jingoo Han --- .../phy/samsung,exynos5250-dp-video-phy.txt | 7 ++ drivers/phy/Kconfig | 8 ++ drivers/phy/Makefile | 3 +- drivers/phy/phy-exynos-dp-video.c | 130 ++++++++++++++++++++ 4 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt create mode 100644 drivers/phy/phy-exynos-dp-video.c diff --git a/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt b/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt new file mode 100644 index 0000000..8b6fa79 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt @@ -0,0 +1,7 @@ +Samsung EXYNOS SoC series DP PHY +------------------------------------------------- + +Required properties: +- compatible : should be "samsung,exynos5250-dp-video-phy"; +- reg : offset and length of the DP PHY register set; +- #phy-cells : from the generic phy bindings, must be 1; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 5f85909..6d10e3b 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -11,3 +11,11 @@ menuconfig GENERIC_PHY devices present in the kernel. This layer will have the generic API by which phy drivers can create PHY using the phy framework and phy users can obtain reference to the PHY. + +if GENERIC_PHY + +config PHY_EXYNOS_DP_VIDEO + tristate "EXYNOS SoC series DP PHY driver" + help + Support for DP PHY found on Samsung EXYNOS SoCs. +endif diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9e9560f..d8d861c 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -2,4 +2,5 @@ # Makefile for the phy drivers. # -obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c new file mode 100644 index 0000000..376b3bc2 --- /dev/null +++ b/drivers/phy/phy-exynos-dp-video.c @@ -0,0 +1,130 @@ +/* + * Samsung EXYNOS SoC series DP PHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Jingoo Han + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* DPTX_PHY_CONTROL register */ +#define EXYNOS_DPTX_PHY_ENABLE (1 << 0) + +struct exynos_dp_video_phy { + spinlock_t slock; + struct phy *phys; + void __iomem *regs; +}; + +static int __set_phy_state(struct exynos_dp_video_phy *state, unsigned int on) +{ + void __iomem *addr; + unsigned long flags; + u32 reg; + + addr = state->regs; + + spin_lock_irqsave(&state->slock, flags); + reg = readl(addr); + if (on) + reg |= EXYNOS_DPTX_PHY_ENABLE; + else + reg &= ~EXYNOS_DPTX_PHY_ENABLE; + writel(reg, addr); + spin_unlock_irqrestore(&state->slock, flags); + return 0; +} + +static int exynos_dp_video_phy_power_on(struct phy *phy) +{ + struct exynos_dp_video_phy *state = phy_get_drvdata(phy); + + return __set_phy_state(state, 1); +} + +static int exynos_dp_video_phy_power_off(struct phy *phy) +{ + struct exynos_dp_video_phy *state = phy_get_drvdata(phy); + + return __set_phy_state(state, 0); +} + +static struct phy *exynos_dp_video_phy_xlate(struct device *dev, + struct of_phandle_args *args) +{ + struct exynos_dp_video_phy *state = dev_get_drvdata(dev); + + return state->phys; +} + +static struct phy_ops exynos_dp_video_phy_ops = { + .power_on = exynos_dp_video_phy_power_on, + .power_off = exynos_dp_video_phy_power_off, + .owner = THIS_MODULE, +}; + +static int exynos_dp_video_phy_probe(struct platform_device *pdev) +{ + struct exynos_dp_video_phy *state; + struct device *dev = &pdev->dev; + struct resource *res; + struct phy_provider *phy_provider; + + state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + state->regs = devm_ioremap_resource(dev, res); + if (IS_ERR(state->regs)) + return PTR_ERR(state->regs); + + dev_set_drvdata(dev, state); + + phy_provider = devm_of_phy_provider_register(dev, + exynos_dp_video_phy_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + + state->phys = devm_phy_create(dev, 0, &exynos_dp_video_phy_ops, "dp"); + if (IS_ERR(state->phys)) { + dev_err(dev, "failed to create DP PHY\n"); + return PTR_ERR(state->phys); + } + phy_set_drvdata(state->phys, state); + + return 0; +} + +static const struct of_device_id exynos_dp_video_phy_of_match[] = { + { .compatible = "samsung,exynos5250-dp-video-phy" }, + { }, +}; +MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match); + +static struct platform_driver exynos_dp_video_phy_driver = { + .probe = exynos_dp_video_phy_probe, + .driver = { + .of_match_table = exynos_dp_video_phy_of_match, + .name = "exynos-dp-video-phy", + .owner = THIS_MODULE, + } +}; +module_platform_driver(exynos_dp_video_phy_driver); + +MODULE_DESCRIPTION("Samsung EXYNOS SoC DP PHY driver"); +MODULE_AUTHOR("Jingoo Han "); +MODULE_LICENSE("GPL v2");