From patchwork Wed Sep 25 14:27:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Guo X-Patchwork-Id: 277878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 729662C0141 for ; Thu, 26 Sep 2013 00:28:08 +1000 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1VOq4Q-0004oe-4w; Wed, 25 Sep 2013 14:28:02 +0000 Received: from mail-pb0-f53.google.com ([209.85.160.53]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1VOq4D-0004m1-Sl for kernel-team@lists.ubuntu.com; Wed, 25 Sep 2013 14:27:50 +0000 Received: by mail-pb0-f53.google.com with SMTP id up15so6058114pbc.40 for ; Wed, 25 Sep 2013 07:27:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=43JnRoM1r6x6TZOsqpgci4K5KJeOr0FkugVSDZ6JY+A=; b=m+Bv4exPxUR0ODxjA9g3saUI3yGfof86tCzsa766ZampIJXMf5VTEbW3YoivNa+YKD KvWu9RL0XmYxjY9jNV58JU+qJAb/fqJpdKo8dxyrbywH+AsGa8VrQEZgJEcCh6ArJ/wh lcvtVKFgLVby/cWurmb+CvHFUxlmNHylOGYbMFLNAnqtAJg0aHpWMHtOwD+OwSgjxNmb U9vMOdU5E2o/M5AENTOPbK3U6B+U7zS07sXgYA1dS8PE0KgwdtrtzCZgT64DmhWVMP3K 7yljgSwEoEHc9YMpLL6HM6SkxRre96Lu6sGJUJ/nu0YuZNJBpoc2XpNOIuSMD6od2H2k U1rg== X-Gm-Message-State: ALoCoQmZii6G+R4Ta6xR1cp2TSoc3nMcqg0u33DNrE66e4qrRBXpGJkiKllTcnv8yYDBJ3mdxRAU X-Received: by 10.68.242.1 with SMTP id wm1mr33846729pbc.57.1380119268922; Wed, 25 Sep 2013 07:27:48 -0700 (PDT) Received: from localhost.localdomain (114-42-203-198.dynamic.hinet.net. [114.42.203.198]) by mx.google.com with ESMTPSA id xs1sm53818235pac.7.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 25 Sep 2013 07:27:48 -0700 (PDT) From: Gavin Guo To: kernel-team@lists.ubuntu.com Subject: [Quantal][SRU][PATCH 1/2] usb: xhci: define port register names and use them instead of magic numbers Date: Wed, 25 Sep 2013 22:27:39 +0800 Message-Id: <1380119260-29231-2-git-send-email-gavin.guo@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1380119260-29231-1-git-send-email-gavin.guo@canonical.com> References: <1380119260-29231-1-git-send-email-gavin.guo@canonical.com> Cc: anthony.wong@canonical.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Mathias Nyman BugLink: https://bugs.launchpad.net/bugs/1229576 Signed-off-by: Mathias Nyman Signed-off-by: Sarah Sharp (cherry picked from commit b6e76371c888f5cb677f190a28444ac8875359ad) Signed-off-by: Shawn Wang Signed-off-by: Gavin Guo --- drivers/usb/host/xhci-hub.c | 16 +++++++--------- drivers/usb/host/xhci.c | 4 ++-- drivers/usb/host/xhci.h | 5 +++++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index abb9772..b3e3b0b 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -860,18 +860,18 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, case USB_PORT_FEAT_U1_TIMEOUT: if (hcd->speed != HCD_USB3) goto error; - temp = xhci_readl(xhci, port_array[wIndex] + 1); + temp = xhci_readl(xhci, port_array[wIndex] + PORTPMSC); temp &= ~PORT_U1_TIMEOUT_MASK; temp |= PORT_U1_TIMEOUT(timeout); - xhci_writel(xhci, temp, port_array[wIndex] + 1); + xhci_writel(xhci, temp, port_array[wIndex] + PORTPMSC); break; case USB_PORT_FEAT_U2_TIMEOUT: if (hcd->speed != HCD_USB3) goto error; - temp = xhci_readl(xhci, port_array[wIndex] + 1); + temp = xhci_readl(xhci, port_array[wIndex] + PORTPMSC); temp &= ~PORT_U2_TIMEOUT_MASK; temp |= PORT_U2_TIMEOUT(timeout); - xhci_writel(xhci, temp, port_array[wIndex] + 1); + xhci_writel(xhci, temp, port_array[wIndex] + PORTPMSC); break; default: goto error; @@ -1079,10 +1079,8 @@ int xhci_bus_suspend(struct usb_hcd *hcd) __le32 __iomem *addr; u32 tmp; - /* Add one to the port status register address to get - * the port power control register address. - */ - addr = port_array[port_index] + 1; + /* Get the port power control register address. */ + addr = port_array[port_index] + PORTPMSC; tmp = xhci_readl(xhci, addr); tmp |= PORT_RWE; xhci_writel(xhci, tmp, addr); @@ -1174,7 +1172,7 @@ int xhci_bus_resume(struct usb_hcd *hcd) /* Add one to the port status register address to get * the port power control register address. */ - addr = port_array[port_index] + 1; + addr = port_array[port_index] + PORTPMSC; tmp = xhci_readl(xhci, addr); tmp &= ~PORT_RWE; xhci_writel(xhci, tmp, addr); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 585bd6c..c3b0f2d 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3879,7 +3879,7 @@ static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd, * Check device's USB 2.0 extension descriptor to determine whether * HIRD or BESL shoule be used. See USB2.0 LPM errata. */ - pm_addr = port_array[port_num] + 1; + pm_addr = port_array[port_num] + PORTPMSC; hird = xhci_calculate_hird_besl(xhci, udev); temp = PORT_L1DS(udev->slot_id) | PORT_HIRD(hird); xhci_writel(xhci, temp, pm_addr); @@ -3976,7 +3976,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, port_array = xhci->usb2_ports; port_num = udev->portnum - 1; - pm_addr = port_array[port_num] + 1; + pm_addr = port_array[port_num] + PORTPMSC; temp = xhci_readl(xhci, pm_addr); xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n", diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 212d408..79c324a 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -132,6 +132,11 @@ struct xhci_cap_regs { /* Number of registers per port */ #define NUM_PORT_REGS 4 +#define PORTSC 0 +#define PORTPMSC 1 +#define PORTLI 2 +#define PORTHLPMC 3 + /** * struct xhci_op_regs - xHCI Host Controller Operational Registers. * @command: USBCMD - xHC command register