From patchwork Fri Jan 15 13:42:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 8040851 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4C9759F6FA for ; Fri, 15 Jan 2016 13:42:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 32D5620444 for ; Fri, 15 Jan 2016 13:42:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0438C203A1 for ; Fri, 15 Jan 2016 13:42:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aK4eG-00011c-Ij; Fri, 15 Jan 2016 13:42:40 +0000 Received: from albert.telenet-ops.be ([195.130.137.90]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aK4e9-0000z3-NS for linux-mediatek@lists.infradead.org; Fri, 15 Jan 2016 13:42:36 +0000 Received: from ayla.of.borg ([84.195.106.123]) by albert.telenet-ops.be with bizsmtp id 6DiA1s00a2fm56U06DiAHX; Fri, 15 Jan 2016 14:42:10 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1aK4dm-0005wJ-BW; Fri, 15 Jan 2016 14:42:10 +0100 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1aK4dn-0008Qu-8s; Fri, 15 Jan 2016 14:42:11 +0100 From: Geert Uytterhoeven To: Mathias Nyman , Greg Kroah-Hartman , Matthias Brugger Subject: [PATCH] xhci: mediatek: Move PM functions inside #idef CONFIG_PM_SLEEP Date: Fri, 15 Jan 2016 14:42:10 +0100 Message-Id: <1452865330-32383-1-git-send-email-geert@linux-m68k.org> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160115_054234_146159_843F7D0C X-CRM114-Status: GOOD ( 14.08 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Geert Uytterhoeven , linux-usb@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If CONFIG_PM_SLEEP=n: drivers/usb/host/xhci-mtk.c:136: warning: ‘xhci_mtk_host_disable’ defined but not used drivers/usb/host/xhci-mtk.c:314: warning: ‘usb_wakeup_enable’ defined but not used drivers/usb/host/xhci-mtk.c:322: warning: ‘usb_wakeup_disable’ defined but not used Move all functions related to power management into the existing section protected by #ifdef CONFIG_PM_SLEEP section to fix this. Signed-off-by: Geert Uytterhoeven --- drivers/usb/host/xhci-mtk.c | 242 ++++++++++++++++++++++---------------------- 1 file changed, 121 insertions(+), 121 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index c9ab6a44c34aef05..43a1ae0fc0a9911e 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -132,42 +132,6 @@ static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk) return 0; } -static int xhci_mtk_host_disable(struct xhci_hcd_mtk *mtk) -{ - struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; - u32 value; - int ret; - int i; - - /* power down all u3 ports */ - for (i = 0; i < mtk->num_u3_ports; i++) { - value = readl(&ippc->u3_ctrl_p[i]); - value |= CTRL_U3_PORT_PDN; - writel(value, &ippc->u3_ctrl_p[i]); - } - - /* power down all u2 ports */ - for (i = 0; i < mtk->num_u2_ports; i++) { - value = readl(&ippc->u2_ctrl_p[i]); - value |= CTRL_U2_PORT_PDN; - writel(value, &ippc->u2_ctrl_p[i]); - } - - /* power down host ip */ - value = readl(&ippc->ip_pw_ctr1); - value |= CTRL1_IP_HOST_PDN; - writel(value, &ippc->ip_pw_ctr1); - - /* wait for host ip to sleep */ - ret = readl_poll_timeout(&ippc->ip_pw_sts1, value, - (value & STS1_IP_SLEEP_STS), 100, 100000); - if (ret) { - dev_err(mtk->dev, "ip sleep failed!!!\n"); - return ret; - } - return 0; -} - static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk) { struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; @@ -241,91 +205,6 @@ static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk) clk_disable_unprepare(mtk->sys_clk); } -/* only clocks can be turn off for ip-sleep wakeup mode */ -static void usb_wakeup_ip_sleep_en(struct xhci_hcd_mtk *mtk) -{ - u32 tmp; - struct regmap *pericfg = mtk->pericfg; - - regmap_read(pericfg, PERI_WK_CTRL1, &tmp); - tmp &= ~UWK_CTL1_IS_P; - tmp &= ~(UWK_CTL1_IS_C(0xf)); - tmp |= UWK_CTL1_IS_C(0x8); - regmap_write(pericfg, PERI_WK_CTRL1, tmp); - regmap_write(pericfg, PERI_WK_CTRL1, tmp | UWK_CTL1_IS_E); - - regmap_read(pericfg, PERI_WK_CTRL1, &tmp); - dev_dbg(mtk->dev, "%s(): WK_CTRL1[P6,E25,C26:29]=%#x\n", - __func__, tmp); -} - -static void usb_wakeup_ip_sleep_dis(struct xhci_hcd_mtk *mtk) -{ - u32 tmp; - - regmap_read(mtk->pericfg, PERI_WK_CTRL1, &tmp); - tmp &= ~UWK_CTL1_IS_E; - regmap_write(mtk->pericfg, PERI_WK_CTRL1, tmp); -} - -/* -* for line-state wakeup mode, phy's power should not power-down -* and only support cable plug in/out -*/ -static void usb_wakeup_line_state_en(struct xhci_hcd_mtk *mtk) -{ - u32 tmp; - struct regmap *pericfg = mtk->pericfg; - - /* line-state of u2-port0 */ - regmap_read(pericfg, PERI_WK_CTRL1, &tmp); - tmp &= ~UWK_CTL1_0P_LS_P; - tmp &= ~(UWK_CTL1_0P_LS_C(0xf)); - tmp |= UWK_CTL1_0P_LS_C(0x8); - regmap_write(pericfg, PERI_WK_CTRL1, tmp); - regmap_read(pericfg, PERI_WK_CTRL1, &tmp); - regmap_write(pericfg, PERI_WK_CTRL1, tmp | UWK_CTL1_0P_LS_E); - - /* line-state of u2-port1 */ - regmap_read(pericfg, PERI_WK_CTRL0, &tmp); - tmp &= ~(UWK_CTL1_1P_LS_C(0xf)); - tmp |= UWK_CTL1_1P_LS_C(0x8); - regmap_write(pericfg, PERI_WK_CTRL0, tmp); - regmap_write(pericfg, PERI_WK_CTRL0, tmp | UWK_CTL1_1P_LS_E); -} - -static void usb_wakeup_line_state_dis(struct xhci_hcd_mtk *mtk) -{ - u32 tmp; - struct regmap *pericfg = mtk->pericfg; - - /* line-state of u2-port0 */ - regmap_read(pericfg, PERI_WK_CTRL1, &tmp); - tmp &= ~UWK_CTL1_0P_LS_E; - regmap_write(pericfg, PERI_WK_CTRL1, tmp); - - /* line-state of u2-port1 */ - regmap_read(pericfg, PERI_WK_CTRL0, &tmp); - tmp &= ~UWK_CTL1_1P_LS_E; - regmap_write(pericfg, PERI_WK_CTRL0, tmp); -} - -static void usb_wakeup_enable(struct xhci_hcd_mtk *mtk) -{ - if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP) - usb_wakeup_ip_sleep_en(mtk); - else if (mtk->wakeup_src == SSUSB_WK_LINE_STATE) - usb_wakeup_line_state_en(mtk); -} - -static void usb_wakeup_disable(struct xhci_hcd_mtk *mtk) -{ - if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP) - usb_wakeup_ip_sleep_dis(mtk); - else if (mtk->wakeup_src == SSUSB_WK_LINE_STATE) - usb_wakeup_line_state_dis(mtk); -} - static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk *mtk, struct device_node *dn) { @@ -696,6 +575,127 @@ static int xhci_mtk_remove(struct platform_device *dev) } #ifdef CONFIG_PM_SLEEP +static int xhci_mtk_host_disable(struct xhci_hcd_mtk *mtk) +{ + struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; + u32 value; + int ret; + int i; + + /* power down all u3 ports */ + for (i = 0; i < mtk->num_u3_ports; i++) { + value = readl(&ippc->u3_ctrl_p[i]); + value |= CTRL_U3_PORT_PDN; + writel(value, &ippc->u3_ctrl_p[i]); + } + + /* power down all u2 ports */ + for (i = 0; i < mtk->num_u2_ports; i++) { + value = readl(&ippc->u2_ctrl_p[i]); + value |= CTRL_U2_PORT_PDN; + writel(value, &ippc->u2_ctrl_p[i]); + } + + /* power down host ip */ + value = readl(&ippc->ip_pw_ctr1); + value |= CTRL1_IP_HOST_PDN; + writel(value, &ippc->ip_pw_ctr1); + + /* wait for host ip to sleep */ + ret = readl_poll_timeout(&ippc->ip_pw_sts1, value, + (value & STS1_IP_SLEEP_STS), 100, 100000); + if (ret) { + dev_err(mtk->dev, "ip sleep failed!!!\n"); + return ret; + } + return 0; +} + +/* only clocks can be turn off for ip-sleep wakeup mode */ +static void usb_wakeup_ip_sleep_en(struct xhci_hcd_mtk *mtk) +{ + u32 tmp; + struct regmap *pericfg = mtk->pericfg; + + regmap_read(pericfg, PERI_WK_CTRL1, &tmp); + tmp &= ~UWK_CTL1_IS_P; + tmp &= ~(UWK_CTL1_IS_C(0xf)); + tmp |= UWK_CTL1_IS_C(0x8); + regmap_write(pericfg, PERI_WK_CTRL1, tmp); + regmap_write(pericfg, PERI_WK_CTRL1, tmp | UWK_CTL1_IS_E); + + regmap_read(pericfg, PERI_WK_CTRL1, &tmp); + dev_dbg(mtk->dev, "%s(): WK_CTRL1[P6,E25,C26:29]=%#x\n", + __func__, tmp); +} + +static void usb_wakeup_ip_sleep_dis(struct xhci_hcd_mtk *mtk) +{ + u32 tmp; + + regmap_read(mtk->pericfg, PERI_WK_CTRL1, &tmp); + tmp &= ~UWK_CTL1_IS_E; + regmap_write(mtk->pericfg, PERI_WK_CTRL1, tmp); +} + +/* +* for line-state wakeup mode, phy's power should not power-down +* and only support cable plug in/out +*/ +static void usb_wakeup_line_state_en(struct xhci_hcd_mtk *mtk) +{ + u32 tmp; + struct regmap *pericfg = mtk->pericfg; + + /* line-state of u2-port0 */ + regmap_read(pericfg, PERI_WK_CTRL1, &tmp); + tmp &= ~UWK_CTL1_0P_LS_P; + tmp &= ~(UWK_CTL1_0P_LS_C(0xf)); + tmp |= UWK_CTL1_0P_LS_C(0x8); + regmap_write(pericfg, PERI_WK_CTRL1, tmp); + regmap_read(pericfg, PERI_WK_CTRL1, &tmp); + regmap_write(pericfg, PERI_WK_CTRL1, tmp | UWK_CTL1_0P_LS_E); + + /* line-state of u2-port1 */ + regmap_read(pericfg, PERI_WK_CTRL0, &tmp); + tmp &= ~(UWK_CTL1_1P_LS_C(0xf)); + tmp |= UWK_CTL1_1P_LS_C(0x8); + regmap_write(pericfg, PERI_WK_CTRL0, tmp); + regmap_write(pericfg, PERI_WK_CTRL0, tmp | UWK_CTL1_1P_LS_E); +} + +static void usb_wakeup_line_state_dis(struct xhci_hcd_mtk *mtk) +{ + u32 tmp; + struct regmap *pericfg = mtk->pericfg; + + /* line-state of u2-port0 */ + regmap_read(pericfg, PERI_WK_CTRL1, &tmp); + tmp &= ~UWK_CTL1_0P_LS_E; + regmap_write(pericfg, PERI_WK_CTRL1, tmp); + + /* line-state of u2-port1 */ + regmap_read(pericfg, PERI_WK_CTRL0, &tmp); + tmp &= ~UWK_CTL1_1P_LS_E; + regmap_write(pericfg, PERI_WK_CTRL0, tmp); +} + +static void usb_wakeup_enable(struct xhci_hcd_mtk *mtk) +{ + if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP) + usb_wakeup_ip_sleep_en(mtk); + else if (mtk->wakeup_src == SSUSB_WK_LINE_STATE) + usb_wakeup_line_state_en(mtk); +} + +static void usb_wakeup_disable(struct xhci_hcd_mtk *mtk) +{ + if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP) + usb_wakeup_ip_sleep_dis(mtk); + else if (mtk->wakeup_src == SSUSB_WK_LINE_STATE) + usb_wakeup_line_state_dis(mtk); +} + static int xhci_mtk_suspend(struct device *dev) { struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);