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: 2797321 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6662EBF4A1 for ; Fri, 28 Jun 2013 07:15:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 470B820108 for ; Fri, 28 Jun 2013 07:15:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 09E6E20119 for ; Fri, 28 Jun 2013 07:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754611Ab3F1HPl (ORCPT ); Fri, 28 Jun 2013 03:15:41 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:13502 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752072Ab3F1HPj (ORCPT ); Fri, 28 Jun 2013 03:15:39 -0400 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>; 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 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 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 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit 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 wswC7SwSa44VgtjCApYS83u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34t3jBMYBWYhmTQLyaRZSCbN QtKygJFlFaNoakFyQXFSeq6RXnFibnFpXrpecn7uJkZwEnkmvYNxVYPFIUYBDkYlHt6GxDOB 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 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@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 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");