Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755663AbbKRNXq (ORCPT ); Wed, 18 Nov 2015 08:23:46 -0500 Received: from mail-bl2nam02on0055.outbound.protection.outlook.com ([104.47.38.55]:50832 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751206AbbKRNXn (ORCPT ); Wed, 18 Nov 2015 08:23:43 -0500 X-Greylist: delayed 1938 seconds by postgrey-1.27 at vger.kernel.org; Wed, 18 Nov 2015 08:23:43 EST Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; From: Subbaraya Sundeep Bhatta To: , CC: , , , Subbaraya Sundeep Bhatta Subject: [PATCH 2/2] usb: dwc3: Add Xilinx ZynqMP platform specific glue layer Date: Wed, 18 Nov 2015 18:21:11 +0530 Message-ID: <1447851071-16330-1-git-send-email-sbhatta@xilinx.com> X-Mailer: git-send-email 2.1.2 X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-21948.006 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.83;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(5001920100001)(106466001)(5003940100001)(5001960100002)(5001770100001)(42186005)(107886002)(586003)(189998001)(5008740100001)(19580405001)(81156007)(19580395003)(6806005)(36386004)(103686003)(63266004)(36756003)(90966002)(46386002)(50466002)(50986999)(48376002)(11100500001)(50226001)(4001430100002)(5007970100001)(52956003)(229853001)(33646002)(575784001)(86362001)(47776003)(92566002)(45336002)(87936001)(2004002)(107986001);DIR:OUT;SFP:1101;SCL:1;SRVR:BL2NAM02HT041;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;PTR:unknown-60-83.xilinx.com;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(8251501001);SRVR:BL2NAM02HT041; X-Microsoft-Antispam-PRVS: <2899cc1c4a3e4d498f690a2b9aab76aa@BL2NAM02HT041.eop-nam02.prod.protection.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046);SRVR:BL2NAM02HT041;BCL:0;PCL:0;RULEID:;SRVR:BL2NAM02HT041; X-Forefront-PRVS: 0764C4A8CD X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2015 12:51:21.7522 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2NAM02HT041 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5481 Lines: 184 This patch adds glue driver for DWC3 core in Xilinx ZynqMP SOC. DWC3 glue layer is hardware layer around Synopsys DesignWare USB3 core. Its purpose is to supply Synopsys IP with required clocks and interface it with the rest of the SoC. Signed-off-by: Subbaraya Sundeep Bhatta --- drivers/usb/dwc3/Kconfig | 8 +++ drivers/usb/dwc3/Makefile | 1 + drivers/usb/dwc3/dwc3-xilinx.c | 131 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 drivers/usb/dwc3/dwc3-xilinx.c diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 5a42c45..a447879 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -104,4 +104,12 @@ config USB_DWC3_QCOM Recent Qualcomm SoCs ship with one DesignWare Core USB3 IP inside, say 'Y' or 'M' if you have one such device. +config USB_DWC3_XILINX + tristate "Xilinx ZynqMP Platform" + depends on ARCH_ZYNQMP || COMPILE_TEST + default USB_DWC3 + help + Xilinx ZynqMP SOC ship with two DesignWare Core USB3 IPs inside, + say 'Y' or 'M' if you have one such device. + endif diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index acc951d..50cb626 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile @@ -39,3 +39,4 @@ obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o obj-$(CONFIG_USB_DWC3_KEYSTONE) += dwc3-keystone.o obj-$(CONFIG_USB_DWC3_QCOM) += dwc3-qcom.o obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o +obj-$(CONFIG_USB_DWC3_XILINX) += dwc3-xilinx.o diff --git a/drivers/usb/dwc3/dwc3-xilinx.c b/drivers/usb/dwc3/dwc3-xilinx.c new file mode 100644 index 0000000..a0dce3e --- /dev/null +++ b/drivers/usb/dwc3/dwc3-xilinx.c @@ -0,0 +1,131 @@ +/** + * dwc3-xilinx.c - Xilinx ZynqMP specific Glue layer + * + * Copyright (C) 2015 Xilinx Inc. + * + * Author: Subbaraya Sundeep + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 of + * the License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include + +/** + * struct xilinx_dwc3 - dwc3 xilinx glue structure + * @dev: device pointer + * @ref_clk: clock input to core during PHY power down + * @bus_clk: bus clock input to core + */ +struct xilinx_dwc3 { + struct device *dev; + struct clk *ref_clk; + struct clk *bus_clk; +}; + +/** + * xilinx_dwc3_probe - The device probe function for driver initialization. + * @pdev: pointer to the platform device structure. + * + * Return: 0 for success and error value on failure + */ +static int xilinx_dwc3_probe(struct platform_device *pdev) +{ + struct device_node *node = pdev->dev.of_node; + struct xilinx_dwc3 *xdwc3; + int ret; + + xdwc3 = devm_kzalloc(&pdev->dev, sizeof(*xdwc3), GFP_KERNEL); + if (!xdwc3) + return -ENOMEM; + + xdwc3->dev = &pdev->dev; + + xdwc3->bus_clk = devm_clk_get(xdwc3->dev, "bus_clk"); + if (IS_ERR(xdwc3->bus_clk)) { + dev_err(xdwc3->dev, "unable to get usb bus clock"); + return PTR_ERR(xdwc3->bus_clk); + } + + xdwc3->ref_clk = devm_clk_get(xdwc3->dev, "ref_clk"); + if (IS_ERR(xdwc3->ref_clk)) { + dev_err(xdwc3->dev, "unable to get usb ref clock"); + return PTR_ERR(xdwc3->ref_clk); + } + + ret = clk_prepare_enable(xdwc3->bus_clk); + if (ret) + goto err_bus_clk; + ret = clk_prepare_enable(xdwc3->ref_clk); + if (ret) + goto err_ref_clk; + + platform_set_drvdata(pdev, xdwc3); + + ret = of_platform_populate(node, NULL, NULL, xdwc3->dev); + if (ret) { + dev_err(xdwc3->dev, "failed to create dwc3 core\n"); + goto err_dwc3_core; + } + + return 0; + +err_dwc3_core: + clk_disable_unprepare(xdwc3->ref_clk); +err_ref_clk: + clk_disable_unprepare(xdwc3->bus_clk); +err_bus_clk: + return ret; +} + +/** + * xilinx_dwc3_remove - Releases the resources allocated during initialization. + * @pdev: pointer to the platform device structure. + * + * Return: 0 always + */ +static int xilinx_dwc3_remove(struct platform_device *pdev) +{ + struct xilinx_dwc3 *xdwc3 = platform_get_drvdata(pdev); + + of_platform_depopulate(xdwc3->dev); + + clk_disable_unprepare(xdwc3->bus_clk); + clk_disable_unprepare(xdwc3->ref_clk); + platform_set_drvdata(pdev, NULL); + + return 0; +} + +/* Match table for of_platform binding */ +static const struct of_device_id xilinx_dwc3_of_match[] = { + { .compatible = "xlnx,zynqmp-dwc3", }, + { /* end of list */ }, +}; +MODULE_DEVICE_TABLE(of, xilinx_dwc3_of_match); + +static struct platform_driver xilinx_dwc3_driver = { + .probe = xilinx_dwc3_probe, + .remove = xilinx_dwc3_remove, + .driver = { + .name = "xilinx-dwc3", + .of_match_table = xilinx_dwc3_of_match, + }, +}; + +module_platform_driver(xilinx_dwc3_driver); + +MODULE_AUTHOR("Xilinx Inc."); +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("DesignWare USB3 Xilinx Glue Layer"); -- 2.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/