From patchwork Fri Jun 28 07:15:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingoo Han X-Patchwork-Id: 2797331 Return-Path: X-Original-To: patchwork-linux-arm@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 DE85A9F3A0 for ; Fri, 28 Jun 2013 07:16:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A306E20109 for ; Fri, 28 Jun 2013 07:16:08 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F46A20108 for ; Fri, 28 Jun 2013 07:16:07 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UsSua-0003ZX-65; Fri, 28 Jun 2013 07:16:04 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UsSuX-0005Yc-BA; Fri, 28 Jun 2013 07:16:01 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UsSuT-0005Xz-MW for linux-arm-kernel@lists.infradead.org; Fri, 28 Jun 2013 07:15:59 +0000 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MP300F0KDGPCT00@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 28 Jun 2013 16:15:32 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.51]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 6C.4D.03969.4183DC15; Fri, 28 Jun 2013 16:15:32 +0900 (KST) X-AuditID: cbfee68f-b7f436d000000f81-2d-51cd3814a4a8 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 16.9C.21068.4183DC15; Fri, 28 Jun 2013 16:15:32 +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 <0MP300MDCDHWJDD0@mmp2.samsung.com>; Fri, 28 Jun 2013 16:15:32 +0900 (KST) From: Jingoo Han To: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH V2 1/3] phy: Add driver for Exynos DP PHY Date: Fri, 28 Jun 2013 16:15:32 +0900 Message-id: <001f01ce73cf$46d8c940$d48a5bc0$@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac5zz0FIrmq4FYsgQBmucu7pi4r+Kg== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRmVeSWpSXmKPExsVy+t8zY10Ri7OBBi8O6VocvF9v8fKQpsWB 2Q9ZLa6ft7OYdH8Ci8XlhZdYLXoXXGWzuPC0h83ibNMbdotNj6+xWpzo+8Bq0bNhK6vFjPP7 mCzWPXzBZHH4TTurxfoZr1kcBDxeXbjD4rF5Sb3H+RkLGT36tqxi9Dh+YzuTx+dNcgFsUVw2 Kak5mWWpRfp2CVwZDd9WsRR81K7Y97uHsYFxl0oXIyeHhICJROOE2SwQtpjEhXvr2boYuTiE BJYxSpyYfpAdpmj+rwlMEInpjBJ7Lz1ihXB+AVUtvMkMUsUmoCbx5cthoA4ODhEBb4nl1xRB wswC7SwSa44VgtjCApYS83u3g5WwCKhKrOxTBwnzAoU7pi5igrAF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FlFaNoakFyQXFSeq6RXnFibnFpXrpecn7uJkZwEnkmvYNxVYPFIUYBDkYlHt6GxDOB QqyJZcWVuYcYJTiYlUR47ywACvGmJFZWpRblxxeV5qQWH2JMBvpzIrOUaHI+MMHllcQbGpuY GVkamVkYmZibkyasJM57sNU6UEggPbEkNTs1tSC1CGYLEwenVANj3tFaVffrPv1n3WyDPk+t Ynz+R645v/lswgzG3Es7Z1564vrISu3v3iOax+2j/61/tSBMTdr8yqHWK3MMz/qeySmfc/d6 8IvMHSqhz6e85k462Kh86rP2Hukurqcd5XrPdra+uHhPip3bdZbXy7jaXRanNJQu6DVdZhFU Kw26O7OjYemJ+J7vSizFGYmGWsxFxYkAGkt1YGYDAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130628_031558_277826_3968751F X-CRM114-Status: GOOD ( 18.57 ) X-Spam-Score: -8.2 (--------) Cc: linux-fbdev@vger.kernel.org, 'Kukjin Kim' , 'Tomasz Figa' , 'Jingoo Han' , 'Donghwa Lee' , 'Felipe Balbi' , 'Kishon Vijay Abraham I' , 'Inki Dae' , 'Kyungmin Park' , 'Sylwester Nawrocki' , 'Jean-Christophe PLAGNIOL-VILLARD' , devicetree-discuss@lists.ozlabs.org, linux-media@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Acked-by: Felipe Balbi --- .../phy/samsung,exynos5250-dp-video-phy.txt | 7 ++ drivers/phy/Kconfig | 8 ++ drivers/phy/Makefile | 3 +- drivers/phy/phy-exynos-dp-video.c | 122 ++++++++++++++++++++ 4 files changed, 139 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..d1771ef --- /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 0; 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..9a3d6f1 --- /dev/null +++ b/drivers/phy/phy-exynos-dp-video.c @@ -0,0 +1,122 @@ +/* + * 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 + +/* 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_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, of_phy_simple_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; +} + +#ifdef CONFIG_OF +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); +#endif + +static struct platform_driver exynos_dp_video_phy_driver = { + .probe = exynos_dp_video_phy_probe, + .driver = { + .name = "exynos-dp-video-phy", + .owner = THIS_MODULE, + .of_match_table = exynos_dp_video_phy_of_match, + } +}; +module_platform_driver(exynos_dp_video_phy_driver); + +MODULE_DESCRIPTION("Samsung EXYNOS SoC DP PHY driver"); +MODULE_AUTHOR("Jingoo Han "); +MODULE_LICENSE("GPL v2");