From patchwork Wed Mar 20 09:12:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 2305991 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 8B08B3FC54 for ; Wed, 20 Mar 2013 09:16:06 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UIF4o-00084y-Fa; Wed, 20 Mar 2013 09:12:54 +0000 Received: from bear.ext.ti.com ([192.94.94.41]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UIF4k-00083e-2j for linux-arm-kernel@lists.infradead.org; Wed, 20 Mar 2013 09:12:50 +0000 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r2K9CZLU000481; Wed, 20 Mar 2013 04:12:36 -0500 Received: from DBDE70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id r2K9CNPu015564; Wed, 20 Mar 2013 14:42:35 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by dbde70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 14.1.323.3; Wed, 20 Mar 2013 14:42:23 +0530 Received: from a0393678lt.apr.dhcp.ti.com (smtpvbd.itg.ti.com [172.24.170.250]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with ESMTP id r2K9CAS9012295; Wed, 20 Mar 2013 14:42:22 +0530 From: Kishon Vijay Abraham I To: , , , , Subject: [PATCH v3 2/6] usb: phy: omap-usb2: use the new generic PHY framework Date: Wed, 20 Mar 2013 14:42:01 +0530 Message-ID: <1363770725-13717-3-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1363770725-13717-1-git-send-email-kishon@ti.com> References: <1363770725-13717-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130320_051250_217121_9880BB32 X-CRM114-Status: GOOD ( 15.15 ) X-Spam-Score: -9.4 (---------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-9.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [192.94.94.41 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -2.5 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: broonie@opensource.wolfsonmicro.com, linux@arm.linux.org.uk, b-cousson@ti.com, linux-doc@vger.kernel.org, tony@atomide.com, devicetree-discuss@lists.ozlabs.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, rob.herring@calxeda.com, kishon@ti.com, grant.likely@secretlab.ca, eballetbo@gmail.com, santosh.shilimkar@ti.com, linux-arm-kernel@lists.infradead.org, swarren@nvidia.com, javier@dowhile0.org, linux-omap@vger.kernel.org, davem@davemloft.net, cesarb@cesarb.net, mchehab@redhat.com 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 Used the generic PHY framework API to create the PHY. omap_usb2_suspend is split into omap_usb_suspend and omap_usb_resume in order to align with the new framework. However using the old USB PHY library cannot be completely removed because OTG is intertwined with PHY and moving to the new framework will break OTG. Once we have a separate OTG state machine, we can get rid of the USB PHY library. Signed-off-by: Kishon Vijay Abraham I --- drivers/usb/phy/omap-usb2.c | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/usb/phy/omap-usb2.c b/drivers/usb/phy/omap-usb2.c index 844ab68..819ba71 100644 --- a/drivers/usb/phy/omap-usb2.c +++ b/drivers/usb/phy/omap-usb2.c @@ -28,6 +28,7 @@ #include #include #include +#include /** * omap_usb2_set_comparator - links the comparator present in the sytem with @@ -119,9 +120,48 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend) return 0; } +static int omap_usb_suspend(struct phy *x) +{ + struct omap_usb *phy = dev_get_drvdata(&x->dev); + + if (!phy->is_suspended) { + omap_control_usb_phy_power(phy->control_dev, 0); + pm_runtime_put_sync(phy->dev); + phy->is_suspended = 1; + } + + return 0; +} + +static int omap_usb_resume(struct phy *x) +{ + u32 ret; + struct omap_usb *phy = dev_get_drvdata(&x->dev); + + if (phy->is_suspended) { + ret = pm_runtime_get_sync(phy->dev); + if (ret < 0) { + dev_err(phy->dev, "get_sync failed with err %d\n", + ret); + return ret; + } + omap_control_usb_phy_power(phy->control_dev, 1); + phy->is_suspended = 0; + } + + return 0; +} + +static struct phy_ops ops = { + .suspend = omap_usb_suspend, + .resume = omap_usb_resume, + .owner = THIS_MODULE, +}; + static int omap_usb2_probe(struct platform_device *pdev) { struct omap_usb *phy; + struct phy *generic_phy; struct usb_otg *otg; phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL); @@ -144,6 +184,13 @@ static int omap_usb2_probe(struct platform_device *pdev) phy->phy.otg = otg; phy->phy.type = USB_PHY_TYPE_USB2; + generic_phy = devm_phy_create(phy->dev, "omap-usb2", pdev->dev.of_node, + USB_PHY_TYPE_USB2, &ops, phy); + if (IS_ERR(generic_phy)) { + dev_dbg(&pdev->dev, "Failed to create PHY\n"); + return PTR_ERR(generic_phy); + } + phy->control_dev = omap_get_control_dev(); if (IS_ERR(phy->control_dev)) { dev_dbg(&pdev->dev, "Failed to get control device\n");