From patchwork Thu Jun 5 15:48:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antoine Tenart X-Patchwork-Id: 4306961 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 16BD09F26E for ; Thu, 5 Jun 2014 15:52:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35A8D201EF for ; Thu, 5 Jun 2014 15:52:49 +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 47BB4200C6 for ; Thu, 5 Jun 2014 15:52:48 +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 1WsZwA-0001WM-EL; Thu, 05 Jun 2014 15:50:42 +0000 Received: from top.free-electrons.com ([176.31.233.9] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WsZv4-0008Bv-M3 for linux-arm-kernel@lists.infradead.org; Thu, 05 Jun 2014 15:49:36 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id C56FE98C; Thu, 5 Jun 2014 17:48:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost.localdomain (col31-4-88-188-83-94.fbx.proxad.net [88.188.83.94]) by mail.free-electrons.com (Postfix) with ESMTPSA id F120085A; Thu, 5 Jun 2014 17:48:51 +0200 (CEST) From: =?UTF-8?q?Antoine=20T=C3=A9nart?= To: sebastian.hesselbarth@gmail.com, Peter.Chen@freescale.com Subject: [PATCH 6/9] usb: chipidea: add Berlin USB support Date: Thu, 5 Jun 2014 17:48:43 +0200 Message-Id: <1401983326-19205-7-git-send-email-antoine.tenart@free-electrons.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1401983326-19205-1-git-send-email-antoine.tenart@free-electrons.com> References: <1401983326-19205-1-git-send-email-antoine.tenart@free-electrons.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140605_084935_206997_6B439FEF X-CRM114-Status: GOOD ( 16.45 ) X-Spam-Score: 0.3 (/) Cc: thomas.petazzoni@free-electrons.com, zmxu@marvell.com, =?UTF-8?q?Antoine=20T=C3=A9nart?= , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, alexandre.belloni@free-electrons.com, jszhang@marvell.com, linux-arm-kernel@lists.infradead.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-Virus-Scanned: ClamAV using ClamSMTP The Marvell Berlin USB controllers are compatible with ChipIdea. Add a driver using the ChipIdea common functions to support them. Signed-off-by: Antoine Ténart --- drivers/usb/chipidea/Makefile | 1 + drivers/usb/chipidea/ci_hdrc_berlin.c | 108 ++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 drivers/usb/chipidea/ci_hdrc_berlin.c diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile index 480bd4d5710a..b3a1b0b3b7a9 100644 --- a/drivers/usb/chipidea/Makefile +++ b/drivers/usb/chipidea/Makefile @@ -19,4 +19,5 @@ endif ifneq ($(CONFIG_OF),) obj-$(CONFIG_USB_CHIPIDEA) += usbmisc_imx.o ci_hdrc_imx.o + obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_berlin.o endif diff --git a/drivers/usb/chipidea/ci_hdrc_berlin.c b/drivers/usb/chipidea/ci_hdrc_berlin.c new file mode 100644 index 000000000000..567d83039e3e --- /dev/null +++ b/drivers/usb/chipidea/ci_hdrc_berlin.c @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2014 Marvell Technology Group Ltd. + * + * Antoine Ténart + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include + +#include "ci.h" + +struct ci_hdrc_berlin_priv { + struct platform_device *ci_pdev; + struct clk *clk; +}; + +static int ci_hdrc_berlin_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct ci_hdrc_berlin_priv *priv; + struct ci_hdrc_platform_data ci_pdata = { + .name = "ci_hdrc_berlin", + .capoffset = DEF_CAPOFFSET, + .flags = CI_HDRC_REQUIRE_TRANSCEIVER | + CI_HDRC_DISABLE_STREAMING, + }; + int ret; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->clk = devm_clk_get(dev, NULL); + if (IS_ERR(priv->clk)) { + dev_err(dev, "failed to get clock: %ld\n", PTR_ERR(priv->clk)); + return PTR_ERR(priv->clk); + } + + ret = clk_prepare_enable(priv->clk); + if (ret) + return ret; + + ci_pdata.phy = devm_usb_get_phy_by_phandle(dev, "marvell,usbphy", 0); + if (IS_ERR(ci_pdata.phy)) { + ret = PTR_ERR(ci_pdata.phy); + goto clk_err; + } + + priv->ci_pdev = ci_hdrc_add_device(dev, pdev->resource, + pdev->num_resources, &ci_pdata); + if (IS_ERR(priv->ci_pdev)) { + ret = PTR_ERR(priv->ci_pdev); + dev_err(dev, + "failed to register ci_hdrc platform device: %d\n", + ret); + goto clk_err; + } + + platform_set_drvdata(pdev, priv); + + pm_runtime_no_callbacks(dev); + pm_runtime_enable(dev); + + return 0; + +clk_err: + clk_disable_unprepare(priv->clk); + return ret; +} + +static int ci_hdrc_berlin_remove(struct platform_device *pdev) +{ + struct ci_hdrc_berlin_priv *priv = platform_get_drvdata(pdev); + + pm_runtime_disable(&pdev->dev); + ci_hdrc_remove_device(priv->ci_pdev); + clk_disable_unprepare(priv->clk); + + return 0; +} + +static const struct of_device_id ci_hdrc_berlin_of_match[] = { + { .compatible = "marvell,berlin-usb" }, + { } +}; + +static struct platform_driver ci_hdrc_berlin_driver = { + .probe = ci_hdrc_berlin_probe, + .remove = ci_hdrc_berlin_remove, + .driver = { + .name = "berlin-usb", + .owner = THIS_MODULE, + .of_match_table = ci_hdrc_berlin_of_match, + }, +}; +module_platform_driver(ci_hdrc_berlin_driver); + +MODULE_DESCRIPTION("ChipIdea HDRC Berlin USB binding"); +MODULE_AUTHOR("Antoine Ténart "); +MODULE_LICENSE("GPL");