From patchwork Thu Jun 15 20:06:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Chen X-Patchwork-Id: 13281693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2D6C9EB64D9 for ; Thu, 15 Jun 2023 20:06:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe :List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=a+8JgyT6PkzpnqKjDgjw7DRwD7bt7X8/DsilnxyACjw=; b=sVXRjvKvU5anb4fTuUGEwBinqB 3DnkRxTsrpZ7p9n02BSLDErdBtXbkmVAADN7ViPZ+uWAaeEJnPPIitfLjBjRP5azRLGnxoECqSl2c 1Q8ptB2LnfvrzyQBQvVV/SOVFUMrMBfTEBiR6TA8ZAB/xA8e63OBHX1gfAyhBVXsXddnS45beS4q4 piECRAf5plyfzUVgJjXM4S4RghyAfHeOFUgltGGzJsqxRfglm//L6kPABfzCOc6q2vq9vyTPoYp8y gkd4qtrLdxx1pwYKrnjqbATg4HLbWiUncCAhuUP8pp/KF1XU6X+wTwbKj5LnEAgHm5SZIHJb114Z7 5c6Q2RnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9tEl-00Fz0L-27; Thu, 15 Jun 2023 20:06:31 +0000 Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q9tEh-00FyyV-22 for linux-phy@lists.infradead.org; Thu, 15 Jun 2023 20:06:29 +0000 Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-75d4f12d4a3so1484685a.0 for ; Thu, 15 Jun 2023 13:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1686859584; x=1689451584; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=9bWmXJX5XEWUbF60J+VXK2ykeeH1d/FXn2EHqiwots8=; b=E3dbS8+31/ZAzxx0HkRY5M9nrzM1/rfGu9wAKQU+FG4oFc3arpmQWik9ZQ//rLvtXB 4mgtVBPtvrUuhHtA4z4iWAET+SsZd8DNQtnp0mw25uvGxqYGXR3vEwCspV9LpVOJsEqh BGX+gTjcKTRqwJb5PHkhB8IgaiRNJ4LWKvny8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686859584; x=1689451584; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9bWmXJX5XEWUbF60J+VXK2ykeeH1d/FXn2EHqiwots8=; b=Dk67XIsbiQr7KivCtVt3DSpQoFI7oeiKwV/uK6+LYt0k3XepPaZ2J85DmaH1ExsRgA V1WTl1Td6nwOtsOT8W2Y88zD8UAdsjxp/fofF7DcZQNMOH3ZdtSEYz2stlkT+N4C193y FM0FQhRKqSU8s56hEwf1x4HYkT4eldAqfqMtXxboFfejQIOwSAbnRc8cxntrMUQ5PvT/ OyjOKUpkDWPQwG+4vkQirp39ExCqRgKgF4+NBnjTwbKhv27KOCekMu4HIz2LBUd32wJ8 F43jGOWVF4dY7ZaOYAr8OXL72tN/9xCw7ChgTvTW0zrXIGnYOcK7hW57ZTS3lyQkb273 Wlfg== X-Gm-Message-State: AC+VfDxwHlpHASOGkNWk4uByN6BmAT3R7dJIabNYt3lxeEMX0FfLmDy2 mWP4tV4EIMNEN5EteR0LQDVat3tCIxlFZKAHTGGOFoaekqz+L/IfDqFVibw95EAlSN/JEA+2Jgh 4IuyOAV51xC4UiJJOo/CODvzOCqfaz2R8AC7WjjrPlYslp0FlaRJuP752R8xMQgUPJPa914rOjP qSVbZrDEFvnIY76Ks= X-Google-Smtp-Source: ACHHUZ4I8QqRqxVTJ00VzyT9TWYR5uen+/Rc2bZUMBzr1gHqwNZ161+yG9cqJ5FNF2WEFkeOMAPi8Q== X-Received: by 2002:a37:688f:0:b0:75d:44af:19f2 with SMTP id d137-20020a37688f000000b0075d44af19f2mr19579005qkc.11.1686859584470; Thu, 15 Jun 2023 13:06:24 -0700 (PDT) Received: from stbirv-lnx-2.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id k4-20020a05620a142400b0075ceca53e84sm5721407qkj.15.2023.06.15.13.06.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jun 2023 13:06:24 -0700 (PDT) From: Justin Chen To: linux-phy@lists.infradead.org Cc: bcm-kernel-feedback-list@broadcom.com, florian.fainelli@broadcom.com, Justin Chen , Justin Chen , Al Cooper , Vinod Koul , Kishon Vijay Abraham I , linux-kernel@vger.kernel.org (open list:BROADCOM BRCMSTB USB2 and USB3 PHY DRIVER) Subject: [PATCH 1/2] phy: usb: Turn off phy when port is in suspend Date: Thu, 15 Jun 2023 13:06:16 -0700 Message-Id: <1686859578-45242-2-git-send-email-justin.chen@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1686859578-45242-1-git-send-email-justin.chen@broadcom.com> References: <1686859578-45242-1-git-send-email-justin.chen@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230615_130627_760271_A8323444 X-CRM114-Status: GOOD ( 18.33 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org The COMMONONN bit turns off the PHY when the host controller puts it into suspend state. This can happen during the following... - Nothing is connected to the port - The host controller goes into low power mode whatever due to auto suspend or system suspend. With COMMONONN we also must unset U2_FREECLK_EXISTS since the UTMI clock is fed by the PHY. With these changes we see a power savings of ~12mW when port is in suspend. Reviewed-by: Florian Fainelli Signed-off-by: Justin Chen --- drivers/phy/broadcom/phy-brcm-usb-init-synopsys.c | 15 +++++++++++++-- drivers/phy/broadcom/phy-brcm-usb-init.h | 8 ++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/phy/broadcom/phy-brcm-usb-init-synopsys.c b/drivers/phy/broadcom/phy-brcm-usb-init-synopsys.c index 76cf4280d7ed..4c10cafded4e 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init-synopsys.c +++ b/drivers/phy/broadcom/phy-brcm-usb-init-synopsys.c @@ -59,6 +59,8 @@ #define USB_CTLR_TP_DIAG1_wake_MASK BIT(1) #define USB_CTRL_CTLR_CSHCR 0x50 #define USB_CTRL_CTLR_CSHCR_ctl_pme_en_MASK BIT(18) +#define USB_CTRL_P0_U2PHY_CFG1 0x68 +#define USB_CTRL_P0_U2PHY_CFG1_COMMONONN_MASK BIT(10) /* Register definitions for the USB_PHY block in 7211b0 */ #define USB_PHY_PLL_CTL 0x00 @@ -90,6 +92,8 @@ #define BDC_EC_AXIRDA_RTS_MASK GENMASK(31, 28) #define BDC_EC_AXIRDA_RTS_SHIFT 28 +#define USB_XHCI_GBL_GUSB2PHYCFG 0x100 +#define USB_XHCI_GBL_GUSB2PHYCFG_U2_FREECLK_EXISTS_MASK BIT(30) static void usb_mdio_write_7211b0(struct brcm_usb_init_params *params, uint8_t addr, uint16_t data) @@ -140,13 +144,17 @@ static void xhci_soft_reset(struct brcm_usb_init_params *params, int on_off) { void __iomem *ctrl = params->regs[BRCM_REGS_CTRL]; + void __iomem *xhci_gbl = params->regs[BRCM_REGS_XHCI_GBL]; /* Assert reset */ - if (on_off) + if (on_off) { USB_CTRL_UNSET(ctrl, USB_PM, XHC_SOFT_RESETB); /* De-assert reset */ - else + } else { USB_CTRL_SET(ctrl, USB_PM, XHC_SOFT_RESETB); + /* Required for COMMONONN to be set */ + USB_XHCI_GBL_UNSET(xhci_gbl, GUSB2PHYCFG, U2_FREECLK_EXISTS); + } } static void usb_init_ipp(struct brcm_usb_init_params *params) @@ -320,6 +328,9 @@ static void usb_init_common_7216(struct brcm_usb_init_params *params) /* 1 millisecond - for USB clocks to settle down */ usleep_range(1000, 2000); + /* Disable PHY when port is suspended */ + USB_CTRL_SET(ctrl, P0_U2PHY_CFG1, COMMONONN); + usb_wake_enable_7216(params, false); usb_init_common(params); } diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.h b/drivers/phy/broadcom/phy-brcm-usb-init.h index f9fbf8fb80e5..c1a88f5cd4cd 100644 --- a/drivers/phy/broadcom/phy-brcm-usb-init.h +++ b/drivers/phy/broadcom/phy-brcm-usb-init.h @@ -34,6 +34,14 @@ enum brcmusb_reg_sel { brcm_usb_ctrl_unset(USB_CTRL_REG(base, reg), \ USB_CTRL_##reg##_##field##_MASK) +#define USB_XHCI_GBL_REG(base, reg) ((void __iomem *)base + USB_XHCI_GBL_##reg) +#define USB_XHCI_GBL_SET(base, reg, field) \ + brcm_usb_ctrl_set(USB_XHCI_GBL_REG(base, reg), \ + USB_XHCI_GBL_##reg##_##field##_MASK) +#define USB_XHCI_GBL_UNSET(base, reg, field) \ + brcm_usb_ctrl_unset(USB_XHCI_GBL_REG(base, reg), \ + USB_XHCI_GBL_##reg##_##field##_MASK) + struct brcm_usb_init_params; struct brcm_usb_init_ops {