From patchwork Fri Sep 14 03:21:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 1455251 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (unknown [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 82D93DF24C for ; Fri, 14 Sep 2012 03:33:50 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TCMTn-0003d6-Ca; Fri, 14 Sep 2012 03:22:07 +0000 Received: from co1ehsobe004.messaging.microsoft.com ([216.32.180.187] helo=co1outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TCMTj-0003cI-Kf for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2012 03:22:04 +0000 Received: from mail94-co1-R.bigfish.com (10.243.78.247) by CO1EHSOBE004.bigfish.com (10.243.66.67) with Microsoft SMTP Server id 14.1.225.23; Fri, 14 Sep 2012 03:22:01 +0000 Received: from mail94-co1 (localhost [127.0.0.1]) by mail94-co1-R.bigfish.com (Postfix) with ESMTP id 83A85B4006A; Fri, 14 Sep 2012 03:22:01 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: -3 X-BigFish: VS-3(zzzz1202h1d1ah1d2ahzz17326ah8275bh5eeeKz2dh2a8h668h839hd24he5bhf0ah107ah1288h12a5h12bdh12e5h1315h1155h) Received: from mail94-co1 (localhost.localdomain [127.0.0.1]) by mail94-co1 (MessageSwitch) id 1347592919962487_27693; Fri, 14 Sep 2012 03:21:59 +0000 (UTC) Received: from CO1EHSMHS008.bigfish.com (unknown [10.243.78.249]) by mail94-co1.bigfish.com (Postfix) with ESMTP id E8943D00045; Fri, 14 Sep 2012 03:21:59 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS008.bigfish.com (10.243.66.18) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 14 Sep 2012 03:21:57 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.2.309.3; Thu, 13 Sep 2012 22:21:56 -0500 Received: from localhost.localdomain (nchen-desktop.ap.freescale.net [10.192.242.40]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id q8E3Lr85028915; Thu, 13 Sep 2012 20:21:54 -0700 From: Peter Chen To: , Subject: [PATCH 2/4] usb: mxs-phy: implement notify_suspend/notify_resume callback Date: Fri, 14 Sep 2012 11:21:57 +0800 Message-ID: <1347592917-13082-1-git-send-email-peter.chen@freescale.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [216.32.180.187 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: fabio.estevam@freescale.com, marex@denx.de, snijsure@grid-net.com, linux-usb@vger.kernel.org, mpthompson@gmail.com, linux-arm-kernel@lists.infradead.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 These notify will be called during the bus suspend/resume procedure. The mxs-phy needs to set/clear HW_USBPHY_CTRL.ENHOSTDISCONDETECT during the connect, disconnect,suspend and resume procedure. The phy notification should be added according to below rules: 1. Only set HW_USBPHY_CTRL.ENHOSTDISCONDETECT during high speed host mode. 2. Do not set HW_USBPHY_CTRL.ENHOSTDISCONDETECT during the reset and speed negotiation period. 3. Do not set HW_USBPHY_CTRL.ENHOSTDISCONDETECT during host suspend/resume sequence. Please refer: i.mx23RM, page: 413. http://www.freescale.com/files/dsp/doc/ref_manual/IMX23RM.pdf Freescale i.MX SoC, i.mx23, i.mx28 and i.mx6(i.mx6SL does not need to follow the 3rd rule) need to follow above rules. Signed-off-by: Peter Chen --- drivers/usb/otg/mxs-phy.c | 56 +++++++++++++++++++++++++++++++++++--------- 1 files changed, 44 insertions(+), 12 deletions(-) diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c index 88db976..41e0543 100644 --- a/drivers/usb/otg/mxs-phy.c +++ b/drivers/usb/otg/mxs-phy.c @@ -96,39 +96,69 @@ static void mxs_phy_enhostdiscondetect_delay(struct work_struct *ws) mxs_phy->phy.io_priv + HW_USBPHY_CTRL_SET); } -static int mxs_phy_on_connect(struct usb_phy *phy, int port) +static int mxs_phy_on_connect(struct usb_phy *phy, + enum usb_device_speed speed) { struct mxs_phy *mxs_phy = to_mxs_phy(phy); - dev_dbg(phy->dev, "Connect on port %d\n", port); - - mxs_phy_hw_init(mxs_phy); + dev_dbg(phy->dev, "%s speed device has connected\n", + (speed == USB_SPEED_HIGH) ? "high" : "non-high"); /* * Delay enabling ENHOSTDISCONDETECT so that connection and * reset processing can be completed for the root hub. */ - dev_dbg(phy->dev, "Delaying setting ENHOSTDISCONDETECT\n"); - PREPARE_DELAYED_WORK(&mxs_phy->enhostdiscondetect_work, + if (speed == USB_SPEED_HIGH) { + PREPARE_DELAYED_WORK(&mxs_phy->enhostdiscondetect_work, mxs_phy_enhostdiscondetect_delay); - schedule_delayed_work(&mxs_phy->enhostdiscondetect_work, + schedule_delayed_work(&mxs_phy->enhostdiscondetect_work, msecs_to_jiffies(MXY_PHY_ENHOSTDISCONDETECT_DELAY)); + } return 0; } -static int mxs_phy_on_disconnect(struct usb_phy *phy, int port) +static int mxs_phy_on_disconnect(struct usb_phy *phy, + enum usb_device_speed speed) { - dev_dbg(phy->dev, "Disconnect on port %d\n", port); + dev_dbg(phy->dev, "%s speed device has disconnected\n", + (speed == USB_SPEED_HIGH) ? "high" : "non-high"); - /* No need to delay before clearing ENHOSTDISCONDETECT. */ - dev_dbg(phy->dev, "Clearing ENHOSTDISCONDETECT\n"); - writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, + if (speed == USB_SPEED_HIGH) { + /* No need to delay before clearing ENHOSTDISCONDETECT. */ + writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, + phy->io_priv + HW_USBPHY_CTRL_CLR); + } + + return 0; +} + +static int mxs_phy_on_suspend(struct usb_phy *phy, + enum usb_device_speed speed) +{ + dev_dbg(phy->dev, "At suspend, %s speed device on the port\n", + (speed == USB_SPEED_HIGH) ? "high" : "non-high"); + + if (speed == USB_SPEED_HIGH) + writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, phy->io_priv + HW_USBPHY_CTRL_CLR); return 0; } +static int mxs_phy_on_resume(struct usb_phy *phy, + enum usb_device_speed speed) +{ + dev_dbg(phy->dev, "after resume, %s speed device on the port\n", + (speed == USB_SPEED_HIGH) ? "high" : "non-high"); + + if (speed == USB_SPEED_HIGH) + writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, + phy->io_priv + HW_USBPHY_CTRL_SET); + + return 0; +} + static int mxs_phy_probe(struct platform_device *pdev) { struct resource *res; @@ -166,6 +196,8 @@ static int mxs_phy_probe(struct platform_device *pdev) mxs_phy->phy.shutdown = mxs_phy_shutdown; mxs_phy->phy.notify_connect = mxs_phy_on_connect; mxs_phy->phy.notify_disconnect = mxs_phy_on_disconnect; + mxs_phy->phy.notify_suspend = mxs_phy_on_suspend; + mxs_phy->phy.notify_resume = mxs_phy_on_resume; ATOMIC_INIT_NOTIFIER_HEAD(&mxs_phy->phy.notifier);