From patchwork Fri Sep 14 03:22:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 1455261 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 05292DF24C for ; Fri, 14 Sep 2012 03:34:06 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TCMUc-0004BG-Ut; Fri, 14 Sep 2012 03:22:59 +0000 Received: from ch1ehsobe003.messaging.microsoft.com ([216.32.181.183] helo=ch1outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TCMUY-00045u-9V for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2012 03:22:55 +0000 Received: from mail176-ch1-R.bigfish.com (10.43.68.229) by CH1EHSOBE004.bigfish.com (10.43.70.54) with Microsoft SMTP Server id 14.1.225.23; Fri, 14 Sep 2012 03:22:46 +0000 Received: from mail176-ch1 (localhost [127.0.0.1]) by mail176-ch1-R.bigfish.com (Postfix) with ESMTP id D3DC5380196; Fri, 14 Sep 2012 03:22:46 +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: 0 X-BigFish: VS0(zzzz1202h1d1ah1d2ahzz8275bhz2dh2a8h668h839hd24he5bhf0ah107ah1288h12a5h12bdh12e5h1315h1155h) Received: from mail176-ch1 (localhost.localdomain [127.0.0.1]) by mail176-ch1 (MessageSwitch) id 1347592965238968_1970; Fri, 14 Sep 2012 03:22:45 +0000 (UTC) Received: from CH1EHSMHS033.bigfish.com (snatpool2.int.messaging.microsoft.com [10.43.68.236]) by mail176-ch1.bigfish.com (Postfix) with ESMTP id 2D5BAC005C; Fri, 14 Sep 2012 03:22:45 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS033.bigfish.com (10.43.70.33) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 14 Sep 2012 03:22:45 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.2.309.3; Thu, 13 Sep 2012 22:22:44 -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 q8E3MeI3029353; Thu, 13 Sep 2012 20:22:41 -0700 From: Peter Chen To: , Subject: [PATCH 3/4] usb: chipidea: add phy notify at suspend/resume procedure Date: Fri, 14 Sep 2012 11:22:45 +0800 Message-ID: <1347592965-13116-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.181.183 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, gregkh@linuxfoundation.org, 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 When there is a device at the port, it needs to notify PHY driver bus's status during bus suspend/resume procedure for some freescale i.mx SoC (i.mx23, i.mx28, i.mx6). Signed-off-by: Peter Chen --- drivers/usb/chipidea/host.c | 75 +++++++++++++++++++++++++++++++++++++++++- 1 files changed, 73 insertions(+), 2 deletions(-) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index ebff9f4..74a6d57 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -23,6 +23,7 @@ #include #include #include +#include #define CHIPIDEA_EHCI #include "../host/ehci-hcd.c" @@ -46,6 +47,76 @@ static int ci_ehci_setup(struct usb_hcd *hcd) return ret; } +static enum usb_device_speed ci_get_device_speed(struct ehci_hcd *ehci, + u32 portsc) +{ + if (ehci_is_TDI(ehci)) { + switch ((portsc >> (ehci->has_hostpc ? 25 : 26)) & 3) { + case 0: + return USB_SPEED_FULL; + case 1: + return USB_SPEED_LOW; + case 2: + return USB_SPEED_HIGH; + default: + return USB_SPEED_UNKNOWN; + } + } else { + return USB_SPEED_HIGH; + } +} + +static int ci_bus_suspend(struct usb_hcd *hcd) +{ + int ret; + struct ehci_hcd *ehci = hcd_to_ehci(hcd); + int port; + + ret = ehci_bus_suspend(hcd); + if (ret) + return ret; + + port = HCS_N_PORTS(ehci->hcs_params); + while (port--) { + u32 __iomem *reg = &ehci->regs->port_status[port]; + u32 portsc = ehci_readl(ehci, reg); + + if (portsc & PORT_CONNECT) { + enum usb_device_speed speed; + speed = ci_get_device_speed(ehci, portsc); + /* notify the USB PHY */ + if (hcd->phy) + usb_phy_notify_suspend(hcd->phy, speed); + } + } + + return ret; +} + +static int ci_bus_resume(struct usb_hcd *hcd) +{ + int ret; + struct ehci_hcd *ehci = hcd_to_ehci(hcd); + int port; + + ret = ehci_bus_resume(hcd); + + port = HCS_N_PORTS(ehci->hcs_params); + while (port--) { + u32 __iomem *reg = &ehci->regs->port_status[port]; + u32 portsc = ehci_readl(ehci, reg); + + if (portsc & PORT_CONNECT) { + enum usb_device_speed speed; + speed = ci_get_device_speed(ehci, portsc); + /* notify the USB PHY */ + if (hcd->phy) + usb_phy_notify_resume(hcd->phy, speed); + } + } + + return ret; +} static const struct hc_driver ci_ehci_hc_driver = { .description = "ehci_hcd", @@ -84,8 +155,8 @@ static const struct hc_driver ci_ehci_hc_driver = { */ .hub_status_data = ehci_hub_status_data, .hub_control = ehci_hub_control, - .bus_suspend = ehci_bus_suspend, - .bus_resume = ehci_bus_resume, + .bus_suspend = ci_bus_suspend, + .bus_resume = ci_bus_resume, .relinquish_port = ehci_relinquish_port, .port_handed_over = ehci_port_handed_over,