From patchwork Fri Jun 27 11:23:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punnaiah Choudary Kalluri X-Patchwork-Id: 4434721 Return-Path: X-Original-To: patchwork-linux-arm@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 30711BEEAA for ; Fri, 27 Jun 2014 11:26:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 500102020F for ; Fri, 27 Jun 2014 11:26:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5DF6D201DD for ; Fri, 27 Jun 2014 11:26:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X0UHI-0000yu-TH; Fri, 27 Jun 2014 11:25:12 +0000 Received: from mail-bl2lp0203.outbound.protection.outlook.com ([207.46.163.203] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X0UGi-0007VY-7r for linux-arm-kernel@lists.infradead.org; Fri, 27 Jun 2014 11:24:37 +0000 Received: from BL2FFO11FD034.protection.gbl (10.173.160.33) by BL2FFO11HUB010.protection.gbl (10.173.161.112) with Microsoft SMTP Server (TLS) id 15.0.969.12; Fri, 27 Jun 2014 11:24:07 +0000 Received: from xsj-pvapsmtpgw01 (149.199.60.83) by BL2FFO11FD034.mail.protection.outlook.com (10.173.161.130) with Microsoft SMTP Server (TLS) id 15.0.969.12 via Frontend Transport; Fri, 27 Jun 2014 11:24:07 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-smtp1) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1X0UGC-0000aK-BD; Fri, 27 Jun 2014 04:24:04 -0700 From: Punnaiah Choudary Kalluri To: , , , , , Subject: [PATCH v2 2/2] usb: chipidea: Add support for zynq usb host and device controller Date: Fri, 27 Jun 2014 16:53:53 +0530 X-Mailer: git-send-email 1.7.4 In-Reply-To: <1403868233-5123-1-git-send-email-punnaia@xilinx.com> References: <1403868233-5123-1-git-send-email-punnaia@xilinx.com> X-RCIS-Action: ALLOW Message-ID: X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.83; CTRY:US; IPV:NLI; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6009001)(438002)(199002)(189002)(20776003)(74502001)(88136002)(83322001)(50466002)(62966002)(44976005)(19580395003)(77156001)(19580405001)(53416004)(50986999)(87286001)(31696002)(76176999)(47776003)(4396001)(46102001)(86362001)(107046002)(1496007)(81342001)(76482001)(74316001)(575784001)(81542001)(77096002)(6806004)(87936001)(21056001)(79102001)(33646001)(92726001)(2201001)(85306003)(99396002)(89996001)(48376002)(95666004)(104166001)(50226001)(77982001)(70736001)(85852003)(83072002)(104016002)(80022001)(106466001)(74662001)(102836001)(64706001)(107986001)(2004002)(2101003)(23106004); DIR:OUT; SFP:; SCL:1; SRVR:BL2FFO11HUB010; H:xsj-pvapsmtpgw01; FPR:; MLV:sfv; PTR:unknown-60-83.xilinx.com; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-OriginatorOrg: xilinx.onmicrosoft.com X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 0255DF69B9 Received-SPF: Pass (: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=punnaiah.choudary.kalluri@xilinx.com; X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140627_042436_459269_34430B25 X-CRM114-Status: GOOD ( 14.30 ) X-Spam-Score: -0.7 (/) Cc: devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kalluripunnaiahchoudary@gmail.com, kpc528@gmail.com, Punnaiah Choudary Kalluri , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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=-1.9 required=5.0 tests=BAYES_00, T_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 Zynq soc uses Chipidea/Synopsys usb IP core(CI13612). This patch adds necessary glue to allow the chipidea driver to work on zynq soc. Signed-off-by: Punnaiah Choudary Kalluri --- Changes in v2: - modified the commit message for better readability - fixed the dev_err message --- drivers/usb/chipidea/Makefile | 1 + drivers/usb/chipidea/ci_hdrc_zynq.c | 115 +++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 0 deletions(-) create mode 100644 drivers/usb/chipidea/ci_hdrc_zynq.c diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile index 2f099c7..b0d6b6f 100644 --- a/drivers/usb/chipidea/Makefile +++ b/drivers/usb/chipidea/Makefile @@ -12,6 +12,7 @@ ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_msm.o obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_zevio.o +obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_zynq.o # PCI doesn't provide stubs, need to check ifneq ($(CONFIG_PCI),) diff --git a/drivers/usb/chipidea/ci_hdrc_zynq.c b/drivers/usb/chipidea/ci_hdrc_zynq.c new file mode 100644 index 0000000..5ef2717 --- /dev/null +++ b/drivers/usb/chipidea/ci_hdrc_zynq.c @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2014 Xilinx, Inc. + * + * 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; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "ci.h" + +#define ZYNQ_USB_DMA_MASK 0xFFFFFFF0 + +struct ci_hdrc_zynq_data { + struct platform_device *ci_pdev; + struct clk *clk; +}; + +static struct ci_hdrc_platform_data pdata = { + .name = "ci_hdrc_zynq", + .capoffset = DEF_CAPOFFSET, + .flags = CI_HDRC_REQUIRE_TRANSCEIVER +}; + +static int ci_hdrc_zynq_probe(struct platform_device *pdev) +{ + struct ci_hdrc_zynq_data *data; + int ret; + + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) { + dev_err(&pdev->dev, "Failed to allocate ci_hdrc_zynq data!\n"); + return -ENOMEM; + } + + data->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(data->clk)) { + dev_err(&pdev->dev, + "Failed to get clock, err=%ld\n", PTR_ERR(data->clk)); + return PTR_ERR(data->clk); + } + + ret = clk_prepare_enable(data->clk); + if (ret) { + dev_err(&pdev->dev, + "Failed to prepare or enable clock, err=%d\n", ret); + return ret; + } + + ret = dma_coerce_mask_and_coherent(&pdev->dev, ZYNQ_USB_DMA_MASK); + if (ret) + goto err_clk; + + data->ci_pdev = ci_hdrc_add_device(&pdev->dev, + pdev->resource, pdev->num_resources, + &pdata); + if (IS_ERR(data->ci_pdev)) { + ret = PTR_ERR(data->ci_pdev); + dev_err(&pdev->dev, + "Can't register ci_hdrc platform device, err=%d\n", + ret); + goto err_clk; + } + + platform_set_drvdata(pdev, data); + + pm_runtime_no_callbacks(&pdev->dev); + pm_runtime_enable(&pdev->dev); + return 0; + +err_clk: + clk_disable_unprepare(data->clk); + return ret; +} + +static int ci_hdrc_zynq_remove(struct platform_device *pdev) +{ + struct ci_hdrc_zynq_data *data = platform_get_drvdata(pdev); + + pm_runtime_disable(&pdev->dev); + ci_hdrc_remove_device(data->ci_pdev); + clk_disable_unprepare(data->clk); + + return 0; +} + +static const struct of_device_id ci_hdrc_zynq_dt_ids[] = { + { .compatible = "xlnx,zynq-usb-2.20a" }, + {}, +}; + +static struct platform_driver ci_hdrc_zynq_driver = { + .probe = ci_hdrc_zynq_probe, + .remove = ci_hdrc_zynq_remove, + .driver = { + .name = "zynq_usb", + .owner = THIS_MODULE, + .of_match_table = ci_hdrc_zynq_dt_ids, + }, +}; + +module_platform_driver(ci_hdrc_zynq_driver); + +MODULE_ALIAS("platform:zynq_usb"); +MODULE_DESCRIPTION("CI HDRC ZYNQ USB binding"); +MODULE_AUTHOR("Xilinx Inc"); +MODULE_LICENSE("GPL v2");