From patchwork Tue Jun 24 10:35:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antoine Tenart X-Patchwork-Id: 363383 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1664A1400CF for ; Tue, 24 Jun 2014 20:41:51 +1000 (EST) 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 1WzO7V-00068S-Ki; Tue, 24 Jun 2014 10:38:33 +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 1WzO58-0004Nu-EI for linux-arm-kernel@lists.infradead.org; Tue, 24 Jun 2014 10:36:10 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id E11518BD; Tue, 24 Jun 2014 12:35:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.3.2 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 44F3D7A0; Tue, 24 Jun 2014 12:35:37 +0200 (CEST) From: =?UTF-8?q?Antoine=20T=C3=A9nart?= To: sebastian.hesselbarth@gmail.com, Peter.Chen@freescale.com Subject: [PATCH v2 07/12] usb: chipidea: add a generic driver Date: Tue, 24 Jun 2014 12:35:16 +0200 Message-Id: <1403606121-6368-8-git-send-email-antoine.tenart@free-electrons.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1403606121-6368-1-git-send-email-antoine.tenart@free-electrons.com> References: <1403606121-6368-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-20140624_033606_893059_C150A201 X-CRM114-Status: GOOD ( 16.69 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 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.18-1 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Add a generic ChipIdea driver, with optional PHY and clock, to support ChipIdea controllers that doesn't need specific functions. Needed for the Marvell Berlin SoCs SUB controllers. Signed-off-by: Antoine Ténart --- drivers/usb/chipidea/Makefile | 1 + drivers/usb/chipidea/ci_hdrc_generic.c | 108 +++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 drivers/usb/chipidea/ci_hdrc_generic.c diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile index 2f099c7df7b5..c705f0fe7a00 100644 --- a/drivers/usb/chipidea/Makefile +++ b/drivers/usb/chipidea/Makefile @@ -20,4 +20,5 @@ endif ifneq ($(CONFIG_OF),) obj-$(CONFIG_USB_CHIPIDEA) += usbmisc_imx.o ci_hdrc_imx.o + obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_generic.o endif diff --git a/drivers/usb/chipidea/ci_hdrc_generic.c b/drivers/usb/chipidea/ci_hdrc_generic.c new file mode 100644 index 000000000000..27520710a1f7 --- /dev/null +++ b/drivers/usb/chipidea/ci_hdrc_generic.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_generic_priv { + struct platform_device *ci_pdev; + struct clk *clk; +}; + +static int ci_hdrc_generic_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct ci_hdrc_generic_priv *priv; + struct ci_hdrc_platform_data ci_pdata = { + .name = "ci_hdrc", + .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)) { + ret = clk_prepare_enable(priv->clk); + if (ret) { + dev_err(dev, "failed to enable the clock: %d\n", ret); + return ret; + } + } + + ci_pdata.phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); + if (IS_ERR(ci_pdata.phy)) + /* PHY is optional */ + ci_pdata.phy = NULL; + + 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); + if (ret != -EPROBE_DEFER) + 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_generic_remove(struct platform_device *pdev) +{ + struct ci_hdrc_generic_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_generic_of_match[] = { + { .compatible = "chipidea-usb" }, + { } +}; +MODULE_DEVICE_TABLE(of, ci_hdrc_generic_of_match); + +static struct platform_driver ci_hdrc_generic_driver = { + .probe = ci_hdrc_generic_probe, + .remove = ci_hdrc_generic_remove, + .driver = { + .name = "chipidea-usb", + .owner = THIS_MODULE, + .of_match_table = ci_hdrc_generic_of_match, + }, +}; +module_platform_driver(ci_hdrc_generic_driver); + +MODULE_DESCRIPTION("Generic ChipIdea HDRC USB binding"); +MODULE_AUTHOR("Antoine Ténart "); +MODULE_LICENSE("GPL");