From patchwork Tue Apr 8 14:37:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Stanislawski X-Patchwork-Id: 3949091 Return-Path: X-Original-To: patchwork-dri-devel@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 1F34E9F3E2 for ; Tue, 8 Apr 2014 14:38:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C29320266 for ; Tue, 8 Apr 2014 14:38:31 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id CD0F5203DF for ; Tue, 8 Apr 2014 14:38:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1ED846E240; Tue, 8 Apr 2014 07:38:29 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by gabe.freedesktop.org (Postfix) with ESMTP id C130D6E240 for ; Tue, 8 Apr 2014 07:38:27 -0700 (PDT) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N3P00GVXVC2GY50@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Tue, 08 Apr 2014 23:38:26 +0900 (KST) X-AuditID: cbfee61b-b7f456d000006dfd-a4-534409e21e65 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 87.0D.28157.2E904435; Tue, 08 Apr 2014 23:38:26 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N3P001YRVAS9H00@mmp1.samsung.com>; Tue, 08 Apr 2014 23:38:26 +0900 (KST) From: Tomasz Stanislawski To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCHv2 1/3] phy: Add exynos-simple-phy driver Date: Tue, 08 Apr 2014 16:37:34 +0200 Message-id: <1396967856-27470-2-git-send-email-t.stanislaws@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1396967856-27470-1-git-send-email-t.stanislaws@samsung.com> References: <1396967856-27470-1-git-send-email-t.stanislaws@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCLMWRmVeSWpSXmKPExsVy+t9jAd1HnC7BBk/aVS3mHznHanHl63s2 iwN/djBaTLo/gcWid8FVNosLT3vYLM42vWG3uLxrDptFz4atrBYzzu9jspiy6DCrReveI+wW 8z7vZLJYP+M1i8W89pesDvweO2fdZffYtKqTzePOtT1sHve7jzN59G1Zxehx/MZ2Jo/Pm+QC 2KO4bFJSczLLUov07RK4Mk73b2Mp2GZS8Wt7egPjca0uRk4OCQETiZuNnawQtpjEhXvr2UBs IYFFjBJPHoR3MXIB2V1MElOOvmcBSbABNRxb8pkRJCEisJBRYuvJKWAOs0AHk8T5J7uYQaqE BSwkmpZOAOrg4GARUJW4sKwcJMwr4CFxa0EDO8Q2RYnuZxPAtnEKeEr8efOQFaRcCKhm3saE CYy8CxgZVjGKphYkFxQnpeca6RUn5haX5qXrJefnbmIEh+0z6R2MqxosDjEKcDAq8fAqHHIK FmJNLCuuzD3EKMHBrCTCW3HMOViINyWxsiq1KD++qDQntfgQozQHi5I478FW60AhgfTEktTs 1NSC1CKYLBMHp1QDY0QNh7WWcIlL0jwdAxbpl8clzj+623aN42en8Ub7XSWZ4YwVkb5t64/3 7rTWKF8gOD1ALSyFYRZPjaC5xnvlbes2iygdPJv/nusEz+PJupFmi+9xGT79evP6jxgWNnO1 T7Msy4JFj+4OTxaMiD7uKO16THlxYiBfnUMNi1BbgNoOXu2fvB1KLMUZiYZazEXFiQAzwCBZ VwIAAA== Cc: Tomasz Stanislawski , kgene.kim@samsung.com, kishon@ti.com, kyungmin.park@samsung.com, robh+dt@kernel.org, grant.likely@linaro.org, sylvester.nawrocki@gmail.com, rahul.sharma@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.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 exynos-simple-phy driver to support a single register PHY interfaces present on Exynos4 SoC. Signed-off-by: Tomasz Stanislawski --- .../devicetree/bindings/phy/samsung-phy.txt | 24 +++ drivers/phy/Kconfig | 5 + drivers/phy/Makefile | 1 + drivers/phy/exynos-simple-phy.c | 154 ++++++++++++++++++++ 4 files changed, 184 insertions(+) create mode 100644 drivers/phy/exynos-simple-phy.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index b422e38..f97c4c3 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -114,3 +114,27 @@ Example: compatible = "samsung,exynos-sataphy-i2c"; reg = <0x38>; }; + +Samsung S5P/EXYNOS SoC series SIMPLE PHY +------------------------------------------------- + +Required properties: +- compatible : should be one of the listed compatibles: + - "samsung,exynos4210-simple-phy" + - "samsung,exynos4412-simple-phy" +- reg : offset and length of the register set; +- #phy-cells : from the generic phy bindings, must be 1; + +For "samsung,exynos4210-simple-phy" compatible PHYs the second cell in +the PHY specifier identifies the PHY and its meaning is as follows: + 0 - HDMI PHY, + 1 - DAC PHY, + 2 - ADC PHY, + 3 - PCIE PHY. + 4 - SATA PHY. + +For "samsung,exynos4412-simple-phy" compatible PHYs the second cell in +the PHY specifier identifies the PHY and its meaning is as follows: + 0 - HDMI PHY, + 1 - ADC PHY, + diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 3bb05f1..65ab783 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -166,4 +166,9 @@ config PHY_XGENE help This option enables support for APM X-Gene SoC multi-purpose PHY. +config EXYNOS_SIMPLE_PHY + tristate "Exynos Simple PHY driver" + help + Support for 1-bit PHY controllers on SoCs from Exynos family. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 2faf78e..88c5b60 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -18,3 +18,4 @@ obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o obj-$(CONFIG_PHY_XGENE) += phy-xgene.o +obj-$(CONFIG_EXYNOS_SIMPLE_PHY) += exynos-simple-phy.o diff --git a/drivers/phy/exynos-simple-phy.c b/drivers/phy/exynos-simple-phy.c new file mode 100644 index 0000000..57ad338 --- /dev/null +++ b/drivers/phy/exynos-simple-phy.c @@ -0,0 +1,154 @@ +/* + * Exynos Simple PHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Tomasz Stanislawski + * + * 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 + +#define EXYNOS_PHY_ENABLE (1 << 0) + +static int exynos_phy_power_on(struct phy *phy) +{ + void __iomem *reg = phy_get_drvdata(phy); + u32 val; + + val = readl(reg); + val |= EXYNOS_PHY_ENABLE; + writel(val, reg); + + return 0; +} + +static int exynos_phy_power_off(struct phy *phy) +{ + void __iomem *reg = phy_get_drvdata(phy); + u32 val; + + val = readl(reg); + val &= ~EXYNOS_PHY_ENABLE; + writel(val, reg); + + return 0; +} + +static struct phy_ops exynos_phy_ops = { + .power_on = exynos_phy_power_on, + .power_off = exynos_phy_power_off, + .owner = THIS_MODULE, +}; + +static const u32 exynos4210_offsets[] = { + 0x0700, /* HDMI_PHY */ + 0x070C, /* DAC_PHY */ + 0x0718, /* ADC_PHY */ + 0x071C, /* PCIE_PHY */ + 0x0720, /* SATA_PHY */ + ~0, /* end mark */ +}; + +static const u32 exynos4412_offsets[] = { + 0x0700, /* HDMI_PHY */ + 0x0718, /* ADC_PHY */ + ~0, /* end mark */ +}; + +static const struct of_device_id exynos_phy_of_match[] = { + { .compatible = "samsung,exynos4210-simple-phy", + .data = exynos4210_offsets}, + { .compatible = "samsung,exynos4412-simple-phy", + .data = exynos4412_offsets}, + { }, +}; +MODULE_DEVICE_TABLE(of, exynos_phy_of_match); + +static struct phy *exynos_phy_xlate(struct device *dev, + struct of_phandle_args *args) +{ + struct phy **phys = dev_get_drvdata(dev); + int index = args->args[0]; + int i; + + /* verify if index is valid */ + for (i = 0; i <= index; ++i) + if (!phys[i]) + return ERR_PTR(-ENODEV); + + return phys[index]; +} + +static int exynos_phy_probe(struct platform_device *pdev) +{ + const struct of_device_id *of_id = of_match_device( + of_match_ptr(exynos_phy_of_match), &pdev->dev); + const u32 *offsets = of_id->data; + int count; + struct device *dev = &pdev->dev; + struct phy **phys; + struct resource *res; + void __iomem *regs; + int i; + struct phy_provider *phy_provider; + + /* count number of phys to create */ + for (count = 0; offsets[count] != ~0; ++count) + ; + + phys = devm_kzalloc(dev, (count + 1) * sizeof(phys[0]), GFP_KERNEL); + if (!phys) + return -ENOMEM; + + dev_set_drvdata(dev, phys); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + regs = devm_ioremap(dev, res->start, res->end - res->start); + if (!regs) { + dev_err(dev, "failed to ioremap registers\n"); + return -EFAULT; + } + + /* NOTE: last entry in phys[] is NULL */ + for (i = 0; i < count; ++i) { + phys[i] = devm_phy_create(dev, &exynos_phy_ops, NULL); + if (IS_ERR(phys[i])) { + dev_err(dev, "failed to create PHY %d\n", i); + return PTR_ERR(phys[i]); + } + phy_set_drvdata(phys[i], regs + offsets[i]); + } + + phy_provider = devm_of_phy_provider_register(dev, exynos_phy_xlate); + if (IS_ERR(phy_provider)) { + dev_err(dev, "failed to register PHY provider\n"); + return PTR_ERR(phy_provider); + } + + dev_info(dev, "added %d phys\n", count); + + return 0; +} + +static struct platform_driver exynos_phy_driver = { + .probe = exynos_phy_probe, + .driver = { + .of_match_table = exynos_phy_of_match, + .name = "exynos-simple-phy", + .owner = THIS_MODULE, + } +}; +module_platform_driver(exynos_phy_driver); + +MODULE_DESCRIPTION("Exynos Simple PHY driver"); +MODULE_AUTHOR("Tomasz Stanislawski "); +MODULE_LICENSE("GPL v2");