From patchwork Wed Jul 18 23:31:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 1213451 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 4D884DFFFD for ; Wed, 18 Jul 2012 23:35:02 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SrdiE-0005A4-TZ; Wed, 18 Jul 2012 23:31:22 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Srdi9-00059U-Gj for linux-arm-kernel@lists.infradead.org; Wed, 18 Jul 2012 23:31:18 +0000 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Srdi1-0006Zk-Hf; Thu, 19 Jul 2012 01:31:09 +0200 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1Srdhz-0000B1-QX; Thu, 19 Jul 2012 01:31:07 +0200 Date: Thu, 19 Jul 2012 01:31:07 +0200 From: Michael Grzeschik To: linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] usb: chipidea: ci13xxx-imx: remove global struct Message-ID: <20120718233107.GA32622@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline X-Uptime: 01:28:09 up 25 days, 14:39, 25 users, load average: 0, 09, 0, 49, 0, 57 User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: marex@denx.de, alexander.shishkin@linux.intel.com, shawn.guo@linaro.org, kernel@pengutronix.de, gregkh@linuxfoundation.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch removes the limitation of having only one instance of the ci13xxx-imx. Each instance of the ci13xxx-imx could have different flags to be configured with, so we also move this settings to the devicetree properties. Signed-off-by: Michael Grzeschik --- .../devicetree/bindings/usb/ci13xxx-imx.txt | 6 +++++ drivers/usb/chipidea/ci13xxx_imx.c | 25 +++++++++++--------- drivers/usb/chipidea/core.c | 11 +++++++++ include/linux/usb/chipidea.h | 3 +++ 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt index 2c29041..5485eb9 100644 --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt @@ -8,6 +8,9 @@ Required properties: Optional properties: - fsl,usbphy: phandler of usb phy that connects to the only one port - vbus-supply: regulator for vbus +- require-transceiver: enable the flag in the driver +- pullup-on-vbus: enable the flag in the driver +- disable-streaming: enable the flag in the driver Examples: usb@02184000 { /* USB OTG */ @@ -15,4 +18,7 @@ usb@02184000 { /* USB OTG */ reg = <0x02184000 0x200>; interrupts = <0 43 0x04>; fsl,usbphy = <&usbphy1>; + require-transceiver; + pullup-on-vbus; + disable-streaming; }; diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c index f741a02..7116b0c 100644 --- a/drivers/usb/chipidea/ci13xxx_imx.c +++ b/drivers/usb/chipidea/ci13xxx_imx.c @@ -58,18 +58,10 @@ static int ci13xxx_imx_vbus(struct ci13xxx *ci, int enable) return ret; } -static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata = { - .name = "ci13xxx_imx", - .flags = CI13XXX_REQUIRE_TRANSCEIVER | - CI13XXX_PULLUP_ON_VBUS | - CI13XXX_DISABLE_STREAMING, - .capoffset = DEF_CAPOFFSET, - .set_vbus_power = ci13xxx_imx_vbus, -}; - static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) { struct ci13xxx_imx_data *data; + struct ci13xxx_platform_data *pdata; struct platform_device *plat_ci; struct resource *res; struct regulator *reg_vbus; @@ -77,6 +69,17 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) struct usb_phy *phy; int ret; + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX pdata!\n"); + return -ENOMEM; + } + + pdata->name = "ci13xxx_imx"; + pdata->capoffset = DEF_CAPOFFSET; + pdata->set_vbus_power = ci13xxx_imx_vbus; + ci13xxx_get_dr_flags(pdev->dev.of_node, pdata); + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) { dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n"); @@ -112,7 +115,7 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) if (!IS_ERR_OR_NULL(phy)) { usb_phy_init(phy); data->phy = phy; - ci13xxx_imx_platdata.phy = phy; + pdata->phy = phy; } /* we only support host now, so enable vbus here */ @@ -140,7 +143,7 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) plat_ci = ci13xxx_add_device(&pdev->dev, pdev->resource, pdev->num_resources, - &ci13xxx_imx_platdata); + pdata); if (IS_ERR(plat_ci)) { ret = PTR_ERR(plat_ci); dev_err(&pdev->dev, diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 0942b9b..556ac76 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -390,6 +390,17 @@ void ci13xxx_remove_device(struct platform_device *pdev) } EXPORT_SYMBOL_GPL(ci13xxx_remove_device); +void ci13xxx_get_dr_flags(struct device_node *of_node, struct ci13xxx_platform_data *pdata) +{ + if (of_find_property(of_node, "require-transceiver", NULL)) + pdata->flags |= CI13XXX_REQUIRE_TRANSCEIVER; + if (of_find_property(of_node, "pullup-on-vbus", NULL)) + pdata->flags |= CI13XXX_PULLUP_ON_VBUS; + if (of_find_property(of_node, "disable-streaming", NULL)) + pdata->flags |= CI13XXX_DISABLE_STREAMING; +} +EXPORT_SYMBOL_GPL(ci13xxx_get_dr_flags); + static int __devinit ci_hdrc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index 080f479..0f8cdbb 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h @@ -37,4 +37,7 @@ struct platform_device *ci13xxx_add_device(struct device *dev, /* Remove ci13xxx device */ void ci13xxx_remove_device(struct platform_device *pdev); +/* Parse of-tree "flags" */ +void ci13xxx_get_dr_flags(struct device_node *of_node, struct ci13xxx_platform_data *pdata); + #endif