From patchwork Wed Jan 29 10:56:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 860824 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87E00192D63; Wed, 29 Jan 2025 10:56:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148184; cv=none; b=bfQ+X2/fhblCgZVfNzrobSKy9MmJk6vMKKeUDwn8NJm8/e0p4Z7HTb9m6BuTTDGwcpseNyOCnvt2CQ/ZesD2iuqejIKz0Y/KGg51c/3UWuZGj6+Eb9s731BiaxJlN9hoyZeRGxDRC8Got+VvBWBlT92Gr7fCR5VUNJaj1k5KExE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148184; c=relaxed/simple; bh=s8khawUl//s7nitdOojlYPrff3QD3m7G+TulAv0eWjA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OpTu9FYUTdpI3pfdE/5Dlv4Z50CbOPIX7TRVIx1pKiNOTqIZuUZd7cqTBxbQfpOf/2JTriP7jamjgSZev1dOor1OcynHluMWcNjnoc422IZzAx9mcr4VyMWSNtZ6QocfqR+gmELGSPWbY0M8eYCLCyZ3JsTJ+wJPDkyAJAnHNgg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=BzJLEzAh; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="BzJLEzAh" Received: by mail.gandi.net (Postfix) with ESMTPSA id F089EFF807; Wed, 29 Jan 2025 10:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1738148175; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lGFmjlkg7TkERZPvhXDKEKXVV3yb3Ab9WFgTB5BJEeY=; b=BzJLEzAh6DLo7uO+UCIDB+rgJhrMgdvWk5ZGSCjvRTEYfangmKc3yYCW7I7MY1YyBPkUSa DP8lW/C7FsI5dPox9VyLq0gyO42W4r3z1Syp+HtJ/ZftvLqileajVU6w5/iWjx190AhlDh DGFAPPT6wmhulrv0ps8j/Cl4GyfHAa0tFqchYY1iRJiWHVxbSxvk8tG3sG+4D53GVLkJoW e/7sOIfzitp3de6P5KMaoZsoXeMCzBMlEjyktTm+YJgODzUT0qMh6hj16lJ7TsSswk13LD ZznPO4PbhkKxCTAN+1Vy+AiGMWdI91p7uot0ibPCqDRIvU86lXW1ysCKEb3eQw== From: =?utf-8?q?Th=C3=A9o_Lebrun?= To: theo.lebrun@bootlin.com, mathias.nyman@linux.intel.com Cc: rogerq@kernel.org, peter.chen@kernel.org, pawell@cadence.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com, gregory.clement@bootlin.com, thomas.petazzoni@bootlin.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/9] usb: host: xhci-plat: mvebu: use ->quirks instead of ->init_quirk() func Date: Wed, 29 Jan 2025 11:56:05 +0100 Message-ID: <20250129105613.403923-1-theo.lebrun@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: theo.lebrun@bootlin.com Compatible "marvell,armada3700-xhci" match data uses the struct xhci_plat_priv::init_quirk() function pointer to add XHCI_RESET_ON_RESUME as quirk on XHCI. Instead, use the struct xhci_plat_priv::quirks field. Signed-off-by: Théo Lebrun --- drivers/usb/host/xhci-mvebu.c | 10 ---------- drivers/usb/host/xhci-mvebu.h | 6 ------ drivers/usb/host/xhci-plat.c | 2 +- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c index 87f1597a0e5a..257e4d79971f 100644 --- a/drivers/usb/host/xhci-mvebu.c +++ b/drivers/usb/host/xhci-mvebu.c @@ -73,13 +73,3 @@ int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd) return 0; } - -int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd) -{ - struct xhci_hcd *xhci = hcd_to_xhci(hcd); - - /* Without reset on resume, the HC won't work at all */ - xhci->quirks |= XHCI_RESET_ON_RESUME; - - return 0; -} diff --git a/drivers/usb/host/xhci-mvebu.h b/drivers/usb/host/xhci-mvebu.h index 3be021793cc8..9d26e22c4842 100644 --- a/drivers/usb/host/xhci-mvebu.h +++ b/drivers/usb/host/xhci-mvebu.h @@ -12,16 +12,10 @@ struct usb_hcd; #if IS_ENABLED(CONFIG_USB_XHCI_MVEBU) int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd); -int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd); #else static inline int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd) { return 0; } - -static inline int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd) -{ - return 0; -} #endif #endif /* __LINUX_XHCI_MVEBU_H */ diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index ecaa75718e59..49cc24e3ce23 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -106,7 +106,7 @@ static const struct xhci_plat_priv xhci_plat_marvell_armada = { }; static const struct xhci_plat_priv xhci_plat_marvell_armada3700 = { - .init_quirk = xhci_mvebu_a3700_init_quirk, + .quirks = XHCI_RESET_ON_RESUME, }; static const struct xhci_plat_priv xhci_plat_brcm = { From patchwork Wed Jan 29 10:56:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 861437 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3CFB1B042F; Wed, 29 Jan 2025 10:56:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148185; cv=none; b=QIfEmPMk9iWWr3wkr/W9I9sW8LTEh3YX78xTYr0NJMlCuToZ9sNcn8m1VtKrP7OvCt6W62gRzjkj4CaX0fgpWtaIt7czIaD/AA2nc0ayRhXf9UE7DQu4qLzbQw59Z5sYEEOZ6Mhg4M3UwaqX34A1kPRgTdd9tS8cfiTcWGbyesQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148185; c=relaxed/simple; bh=V0XfBjxVLe8TjT1SzH9ee/rLTeJX0xs4FJiLO3XaGYw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Tt54vx7kkExwPDWCm9RVgAMCvgCr+Sv5E6bkxBJavH870s+ScXJo56zjvIQRJl9d7gB0R3JsaLj4U3WtmJw0DGPonW9DvXhaO8OTFyVwVp+ruOzB8a1k0Vla00FK1X0aBIT0x3g+JUfeBankxQMjeC7DXnFBAUJEwQkUHDsci6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=df3QvIf7; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="df3QvIf7" Received: by mail.gandi.net (Postfix) with ESMTPSA id B85B1FF80C; Wed, 29 Jan 2025 10:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1738148176; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cqyXcYPn6o4khrIuGIfr97uJFzLfRYA+LGIhlGC/Grk=; b=df3QvIf7jdpEWAGdB8sqlbc2Q7FZMNm+aZjO3DXQa0NyKiQoQlz1pE6jI1EMNTDLYJiLYL gU9FPh27XEkvV/cvqsGQ1oAFS6/YcR98ZdCs6xmaM39aTpdvGVNEt0bIoZV1hNAQTJ3l4W hyiBckgH+5ZTz+MaCmSxQIbaqWBlV8f4uRsw4RpKvRro/14bSGGKRh0nvQs0Wn9177JRZ1 JO9ikEyYCIp2FW/KZtAWYcogFdih/gX2Bd28zCB4MFXer2Rtd4Eu8fAqQR7kW71ZDODLk8 /CikeWRw95LE67N6KIiqkBFopfCwRy+HqfoA0aXv4A09hODwtPi5X+5LbWEHRQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= To: theo.lebrun@bootlin.com, mathias.nyman@linux.intel.com Cc: rogerq@kernel.org, peter.chen@kernel.org, pawell@cadence.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com, gregory.clement@bootlin.com, thomas.petazzoni@bootlin.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/9] usb: xhci: tegra: rename `runtime` boolean to `is_auto_runtime` Date: Wed, 29 Jan 2025 11:56:06 +0100 Message-ID: <20250129105613.403923-2-theo.lebrun@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: theo.lebrun@bootlin.com Unify naming convention: use `is_auto_runtime` in xhci-tegra, to be in phase with (future) drivers/usb/host/xhci.c. Signed-off-by: Théo Lebrun --- drivers/usb/host/xhci-tegra.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index 76f228e7443c..94dd32f1a0da 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -2161,11 +2161,11 @@ static void tegra_xhci_program_utmi_power_lp0_exit(struct tegra_xusb *tegra) } } -static int tegra_xusb_enter_elpg(struct tegra_xusb *tegra, bool runtime) +static int tegra_xusb_enter_elpg(struct tegra_xusb *tegra, bool is_auto_resume) { struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); struct device *dev = tegra->dev; - bool wakeup = runtime ? true : device_may_wakeup(dev); + bool wakeup = is_auto_resume ? true : device_may_wakeup(dev); unsigned int i; int err; u32 usbcmd; @@ -2231,11 +2231,11 @@ static int tegra_xusb_enter_elpg(struct tegra_xusb *tegra, bool runtime) return err; } -static int tegra_xusb_exit_elpg(struct tegra_xusb *tegra, bool runtime) +static int tegra_xusb_exit_elpg(struct tegra_xusb *tegra, bool is_auto_resume) { struct xhci_hcd *xhci = hcd_to_xhci(tegra->hcd); struct device *dev = tegra->dev; - bool wakeup = runtime ? true : device_may_wakeup(dev); + bool wakeup = is_auto_resume ? true : device_may_wakeup(dev); unsigned int i; u32 usbcmd; int err; @@ -2286,7 +2286,7 @@ static int tegra_xusb_exit_elpg(struct tegra_xusb *tegra, bool runtime) if (wakeup) tegra_xhci_disable_phy_sleepwalk(tegra); - err = xhci_resume(xhci, runtime ? PMSG_AUTO_RESUME : PMSG_RESUME); + err = xhci_resume(xhci, is_auto_resume ? PMSG_AUTO_RESUME : PMSG_RESUME); if (err < 0) { dev_err(tegra->dev, "failed to resume XHCI: %d\n", err); goto disable_phy; From patchwork Wed Jan 29 10:56:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 861436 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 795531B4121; Wed, 29 Jan 2025 10:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148186; cv=none; b=VTV9kS9Twe9F5kUqeIlNT4eoumsaDkAqj1OaOz+lwYrVMe6PKicKrz6kreogM53HACsLgqAKjB3ijxUTzfZO+fJTzRbVRrFznHwgSWTteIv9VAyi1I+yeUMHLTsOtR2eMdXpQqyWKivNrnsgIQ+jtaWhH8F6SJSuRb3lBPu75HM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148186; c=relaxed/simple; bh=IJC00DE3GlC7zrdzpMRavEarNfz7IgwVOrM3evg2Wn0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mMZtbn6zakPrb9rTxRe+cbMNI3eTiUi5kxhiBw+aTwcPGtOgK4Zuez9rWua5n0VQNB0JFhTj8m8eBYmDFKqd6q4+rfxrp90MDVt1QO8c6rO8S0Ek2NpCkTODlxuibPGrgDJyZo0O2tbR87SROl0L914wK/WH0h/1p7hPfi6JHlo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Ol6HuDVN; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Ol6HuDVN" Received: by mail.gandi.net (Postfix) with ESMTPSA id 3CB7BFF806; Wed, 29 Jan 2025 10:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1738148176; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EvcUjcQINxY47aE8hz81LLvxBarwsjc+2RUVSQ3JIbo=; b=Ol6HuDVNm7xKhwOhLbLm9xoqiRqxviEg2N3sqWZHE6YHmQntmPPbn4unqvK3ZjMyP/3U/1 VJm61IU7oDhexysZTUdtnr6pL3jN810D2dZY7/PeCBiMcayG3KPJ6H03P26W1ooCtboDkD KB4Jf8iSPYFUEKWmWnRzgZZne+4i0+/RY9fW2ZISZAi0T2JaIQL3xtQ30VqTiGEy2onUAp mLbzMNgz/itdzn3lm6gPsKVcHnEEf1zQVGn0jVM8MF8KuQqs+5tgjLY9vribo5e1onqdJM 3zxY6oIN+lVDglI6ahVLhJwx3fETSV4/c9Lo7gAyNSMKenqlqnv4V4MeDhJzDg== From: =?utf-8?q?Th=C3=A9o_Lebrun?= To: theo.lebrun@bootlin.com, mathias.nyman@linux.intel.com Cc: rogerq@kernel.org, peter.chen@kernel.org, pawell@cadence.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com, gregory.clement@bootlin.com, thomas.petazzoni@bootlin.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/9] usb: cdns3-ti: move reg writes to separate function Date: Wed, 29 Jan 2025 11:56:07 +0100 Message-ID: <20250129105613.403923-3-theo.lebrun@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: theo.lebrun@bootlin.com The device probe function mixes management code and hardware initialisation code. Extract the latter into an explicitly named cdns_ti_reset_and_init_hw() function to clarify intent. It also will allow easier transition to using runtime PM for triggering HW init. Reviewed-by: Roger Quadros Signed-off-by: Théo Lebrun --- drivers/usb/cdns3/cdns3-ti.c | 82 +++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.c index cfabc12ee0e3..2863249665c2 100644 --- a/drivers/usb/cdns3/cdns3-ti.c +++ b/drivers/usb/cdns3/cdns3-ti.c @@ -58,6 +58,7 @@ struct cdns_ti { unsigned vbus_divider:1; struct clk *usb2_refclk; struct clk *lpm_clk; + int usb2_refclk_rate_code; }; static const int cdns_ti_rate_table[] = { /* in KHZ */ @@ -98,15 +99,50 @@ static const struct of_dev_auxdata cdns_ti_auxdata[] = { {}, }; +static void cdns_ti_reset_and_init_hw(struct cdns_ti *data) +{ + u32 reg; + + /* assert RESET */ + reg = cdns_ti_readl(data, USBSS_W1); + reg &= ~USBSS_W1_PWRUP_RST; + cdns_ti_writel(data, USBSS_W1, reg); + + /* set static config */ + reg = cdns_ti_readl(data, USBSS_STATIC_CONFIG); + reg &= ~USBSS1_STATIC_PLL_REF_SEL_MASK; + reg |= data->usb2_refclk_rate_code << USBSS1_STATIC_PLL_REF_SEL_SHIFT; + + reg &= ~USBSS1_STATIC_VBUS_SEL_MASK; + if (data->vbus_divider) + reg |= 1 << USBSS1_STATIC_VBUS_SEL_SHIFT; + + cdns_ti_writel(data, USBSS_STATIC_CONFIG, reg); + reg = cdns_ti_readl(data, USBSS_STATIC_CONFIG); + + /* set USB2_ONLY mode if requested */ + reg = cdns_ti_readl(data, USBSS_W1); + if (data->usb2_only) + reg |= USBSS_W1_USB2_ONLY; + + /* set default modestrap */ + reg |= USBSS_W1_MODESTRAP_SEL; + reg &= ~USBSS_W1_MODESTRAP_MASK; + reg |= USBSS_MODESTRAP_MODE_NONE << USBSS_W1_MODESTRAP_SHIFT; + cdns_ti_writel(data, USBSS_W1, reg); + + /* de-assert RESET */ + reg |= USBSS_W1_PWRUP_RST; + cdns_ti_writel(data, USBSS_W1, reg); +} + static int cdns_ti_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *node = pdev->dev.of_node; struct cdns_ti *data; - int error; - u32 reg; - int rate_code, i; unsigned long rate; + int error, i; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) @@ -146,7 +182,11 @@ static int cdns_ti_probe(struct platform_device *pdev) return -EINVAL; } - rate_code = i; + data->usb2_refclk_rate_code = i; + data->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider"); + data->usb2_only = device_property_read_bool(dev, "ti,usb2-only"); + + cdns_ti_reset_and_init_hw(data); pm_runtime_enable(dev); error = pm_runtime_get_sync(dev); @@ -155,40 +195,6 @@ static int cdns_ti_probe(struct platform_device *pdev) goto err; } - /* assert RESET */ - reg = cdns_ti_readl(data, USBSS_W1); - reg &= ~USBSS_W1_PWRUP_RST; - cdns_ti_writel(data, USBSS_W1, reg); - - /* set static config */ - reg = cdns_ti_readl(data, USBSS_STATIC_CONFIG); - reg &= ~USBSS1_STATIC_PLL_REF_SEL_MASK; - reg |= rate_code << USBSS1_STATIC_PLL_REF_SEL_SHIFT; - - reg &= ~USBSS1_STATIC_VBUS_SEL_MASK; - data->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider"); - if (data->vbus_divider) - reg |= 1 << USBSS1_STATIC_VBUS_SEL_SHIFT; - - cdns_ti_writel(data, USBSS_STATIC_CONFIG, reg); - reg = cdns_ti_readl(data, USBSS_STATIC_CONFIG); - - /* set USB2_ONLY mode if requested */ - reg = cdns_ti_readl(data, USBSS_W1); - data->usb2_only = device_property_read_bool(dev, "ti,usb2-only"); - if (data->usb2_only) - reg |= USBSS_W1_USB2_ONLY; - - /* set default modestrap */ - reg |= USBSS_W1_MODESTRAP_SEL; - reg &= ~USBSS_W1_MODESTRAP_MASK; - reg |= USBSS_MODESTRAP_MODE_NONE << USBSS_W1_MODESTRAP_SHIFT; - cdns_ti_writel(data, USBSS_W1, reg); - - /* de-assert RESET */ - reg |= USBSS_W1_PWRUP_RST; - cdns_ti_writel(data, USBSS_W1, reg); - error = of_platform_populate(node, NULL, cdns_ti_auxdata, dev); if (error) { dev_err(dev, "failed to create children: %d\n", error); From patchwork Wed Jan 29 10:56:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 860823 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 795001B395F; Wed, 29 Jan 2025 10:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148186; cv=none; b=GNxGTwnklxDoy7BfRqtvV9y+DQ1dIjYHB5155U1EXksaNUkemQfu5a2CW+PJ7lJOrMRdkE2uh4oRe+x9y1rm11IEFynFtK9L2tUh8GP+Q4hdcsVfCAp9jdQpGln55nrI/fcQ2TMbAY2RUoHsXKrTaKB6M7xHxB9SsDZxTuBQOek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148186; c=relaxed/simple; bh=E3sZpO2ZDDdSerDkEqctEBCeBfsGAZxxuJQiFQglbxA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M/+LZsjOkkA+BbzAI6b4J+G2pyYo57L5aENCUYNOFyaCXvxsCYDobMd7xCPU04m8J+nyvJAHYDHMlZF3QzAm/Shp4T4xDk4B2T2u6pNb8yEmFwR/hnIln0ivapttT0MhnZLKPddmxwlasUqpSgFekHlsJAEMmIozWl1nRC4lNQY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Xuur70nj; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Xuur70nj" Received: by mail.gandi.net (Postfix) with ESMTPSA id BE173FF80B; Wed, 29 Jan 2025 10:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1738148177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KBpZYyQZvSnDBWS4b3Zllq0kdljgm85ce8KMv3JTfrI=; b=Xuur70njlrt0mR6eVn3AVQuetPQmAl/MM4NnsMTBifG/Dyjwf8MiVSPMTw3WflFBI73aVw GPxVhZxCxOPDfwD8esnOvRR1cOeH9eo22CB4BVptjDhfM/8A2w/RZxqbuUZe8qv4KQqZ1G dwKklEo3hRLOaHcJ3GcveSWB0/Rc3sNwzeX8pV5WwhePRb7o7nk+tXp571FcBssVrj2bAt noIqsPeAWiAl5kCcs8krBkv7AyU/g9YLH3PP/0/IB9Hk1PJIU5z7ayDRMK85Iz28ufv6Rg ALAVL1ydm0zVjL3X82YshtqYle37KbwPZzahsZn7F3wFchhu6IExMyaMPfqQ/Q== From: =?utf-8?q?Th=C3=A9o_Lebrun?= To: theo.lebrun@bootlin.com, mathias.nyman@linux.intel.com Cc: rogerq@kernel.org, peter.chen@kernel.org, pawell@cadence.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com, gregory.clement@bootlin.com, thomas.petazzoni@bootlin.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/9] usb: cdns3-ti: run HW init at resume() if HW was reset Date: Wed, 29 Jan 2025 11:56:08 +0100 Message-ID: <20250129105613.403923-4-theo.lebrun@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: theo.lebrun@bootlin.com At runtime_resume(), read the W1 (Wrapper Register 1) register to detect if an hardware reset occurred. If it did, run the hardware init sequence. This callback will be called at system-wide resume. Previously, if a reset occurred during suspend, we would crash. The wrapper config had not been written, leading to invalid register accesses inside cdns3. Signed-off-by: Théo Lebrun --- drivers/usb/cdns3/cdns3-ti.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.c index 2863249665c2..225993f7bdb6 100644 --- a/drivers/usb/cdns3/cdns3-ti.c +++ b/drivers/usb/cdns3/cdns3-ti.c @@ -186,6 +186,12 @@ static int cdns_ti_probe(struct platform_device *pdev) data->vbus_divider = device_property_read_bool(dev, "ti,vbus-divider"); data->usb2_only = device_property_read_bool(dev, "ti,usb2-only"); + /* + * The call below to pm_runtime_get_sync() MIGHT reset hardware, if it + * detects it as uninitialised. We want to enforce a reset at probe, + * and so do it manually here. This means the first runtime_resume() + * will be a no-op. + */ cdns_ti_reset_and_init_hw(data); pm_runtime_enable(dev); @@ -230,6 +236,24 @@ static void cdns_ti_remove(struct platform_device *pdev) platform_set_drvdata(pdev, NULL); } +static int cdns_ti_runtime_resume(struct device *dev) +{ + const u32 mask = USBSS_W1_PWRUP_RST | USBSS_W1_MODESTRAP_SEL; + struct cdns_ti *data = dev_get_drvdata(dev); + u32 w1; + + w1 = cdns_ti_readl(data, USBSS_W1); + if ((w1 & mask) != mask) + cdns_ti_reset_and_init_hw(data); + + return 0; +} + +static const struct dev_pm_ops cdns_ti_pm_ops = { + RUNTIME_PM_OPS(NULL, cdns_ti_runtime_resume, NULL) + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) +}; + static const struct of_device_id cdns_ti_of_match[] = { { .compatible = "ti,j721e-usb", }, { .compatible = "ti,am64-usb", }, @@ -243,6 +267,7 @@ static struct platform_driver cdns_ti_driver = { .driver = { .name = "cdns3-ti", .of_match_table = cdns_ti_of_match, + .pm = pm_ptr(&cdns_ti_pm_ops), }, }; From patchwork Wed Jan 29 10:56:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 861435 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 955831B6547; Wed, 29 Jan 2025 10:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148187; cv=none; b=MCywaHeCooNnLcfzYJBWuwDozCjl/UWUnV6NTCigDIG3ADXBt+ntUoxQ9J2PkU9gcOc4uccLVfQVcGnCDYr3p3hCEPdzD5cUf+0h1vxICtdTZQhkpIMViQS6b1RlTHGljoVkxPlncN2z0+jw7vqyV/GGrFb5z6KEoY+gNJyz9ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148187; c=relaxed/simple; bh=CWdjP4aUsHF+7P6+eloiUKH9950Yvc0l5PM/y2Qolco=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eKEeR0OpQ61Yc9oq0JkFu3nkHqduGYFsQn6COK3Zdr+sTuQ07TjcQQstvA8ILS3kaomX4OUEzZ7d4TVWV5IVz1Y4CU0eBFQn0AUL6N2lRXNmtZGQ3jcncUpUGj98mFZchpMUq1sm5XozHBo1n8O9uUY3JhCxMJcSB1a0rwmeN4U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=G2HF2J1x; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="G2HF2J1x" Received: by mail.gandi.net (Postfix) with ESMTPSA id 4A0C4FF809; Wed, 29 Jan 2025 10:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1738148177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v1e6nofxVdA9RtAytuEMyu+ZjGQH8z/fAVMV8muk7RU=; b=G2HF2J1xfEOHD9801iHUNZRM/al04CV+2IOD57s6OLmJOm3IE7YMXEIb8GJkvyLNjDdnYu ET4/Eao5FSycyS9dNfFat4zVC843SueRUGSWsXbWwk83KRM3pvey8vCxpXyMdJaYyYkn15 c6dkpXhfNlLlLtUcO45Ct17GhcOLlLjeTBg4EXKy0o3j1XpvfbihU54uJacJTrKg1ML/5q 3L1Z3+ZSLW8sUs7DpJ60/4zJGm5PvYgi9ekPw3Vb0QM2BIZGpMTKLgPB29FR4YD2ilTuPg 4Hv1P5SyAxj1+BLJ2bxnrZJ+UeGptvaBRI/h2whLCAMDAbK3Of4Uo1QS/ugkhA== From: =?utf-8?q?Th=C3=A9o_Lebrun?= To: theo.lebrun@bootlin.com, mathias.nyman@linux.intel.com Cc: rogerq@kernel.org, peter.chen@kernel.org, pawell@cadence.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com, gregory.clement@bootlin.com, thomas.petazzoni@bootlin.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] usb: cdns3: rename hibernated argument of role->resume() to lost_power Date: Wed, 29 Jan 2025 11:56:09 +0100 Message-ID: <20250129105613.403923-5-theo.lebrun@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: theo.lebrun@bootlin.com The cdns_role_driver->resume() callback takes a second boolean argument named `hibernated` in its implementations. This is mistaken; the only potential caller is: int cdns_resume(struct cdns *cdns) { /* ... */ if (cdns->roles[cdns->role]->resume) cdns->roles[cdns->role]->resume(cdns, cdns_power_is_lost(cdns)); return 0; } The argument can be true in cases outside of return from hibernation. Reflect the true meaning by renaming both arguments to `lost_power`. Signed-off-by: Théo Lebrun --- drivers/usb/cdns3/cdns3-gadget.c | 4 ++-- drivers/usb/cdns3/cdnsp-gadget.c | 2 +- drivers/usb/cdns3/core.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c index fd1beb10bba7..694aa1457739 100644 --- a/drivers/usb/cdns3/cdns3-gadget.c +++ b/drivers/usb/cdns3/cdns3-gadget.c @@ -3468,7 +3468,7 @@ __must_hold(&cdns->lock) return 0; } -static int cdns3_gadget_resume(struct cdns *cdns, bool hibernated) +static int cdns3_gadget_resume(struct cdns *cdns, bool lost_power) { struct cdns3_device *priv_dev = cdns->gadget_dev; @@ -3476,7 +3476,7 @@ static int cdns3_gadget_resume(struct cdns *cdns, bool hibernated) return 0; cdns3_gadget_config(priv_dev); - if (hibernated) + if (lost_power) writel(USB_CONF_DEVEN, &priv_dev->regs->usb_conf); return 0; diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c index 4a3f0f958256..7d05180442fb 100644 --- a/drivers/usb/cdns3/cdnsp-gadget.c +++ b/drivers/usb/cdns3/cdnsp-gadget.c @@ -1973,7 +1973,7 @@ static int cdnsp_gadget_suspend(struct cdns *cdns, bool do_wakeup) return 0; } -static int cdnsp_gadget_resume(struct cdns *cdns, bool hibernated) +static int cdnsp_gadget_resume(struct cdns *cdns, bool lost_power) { struct cdnsp_device *pdev = cdns->gadget_dev; enum usb_device_speed max_speed; diff --git a/drivers/usb/cdns3/core.h b/drivers/usb/cdns3/core.h index 57d47348dc19..921cccf1ca9d 100644 --- a/drivers/usb/cdns3/core.h +++ b/drivers/usb/cdns3/core.h @@ -30,7 +30,7 @@ struct cdns_role_driver { int (*start)(struct cdns *cdns); void (*stop)(struct cdns *cdns); int (*suspend)(struct cdns *cdns, bool do_wakeup); - int (*resume)(struct cdns *cdns, bool hibernated); + int (*resume)(struct cdns *cdns, bool lost_power); const char *name; #define CDNS_ROLE_STATE_INACTIVE 0 #define CDNS_ROLE_STATE_ACTIVE 1 From patchwork Wed Jan 29 10:56:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 860822 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 842B41B6525; Wed, 29 Jan 2025 10:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148187; cv=none; b=SRuoA7qXKTpULiTUZkhxznFviewV2/POWMk7uw41H2/OTVOoFUG5PSDcWYq+JnzSzSxws3IYABNzYQ3c9JnqJRHJjlvGtm1uDjMzsg56iwiJRsp0AjEYzfFVjxjParGiwzd8R4UDBKzBdEOb8ub5uUjkrEUm2+1lrq3c6y9A8wY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148187; c=relaxed/simple; bh=ZbfDEAGGRcoowrUfu5EDqO266YEpTTycz1vMlF9U2TA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DsrsiS+1TA5Pxicu5zgIiWf/BnPWevL1gAZA+fNKMOq79PrB5MjcQ5ovxUBqiMXdU39R7kpNStQKpu7zjkDx8gbYwsk71C9XbTJ8cF1ZwryuvCMi9cOOyd1nVoUxLXEhkqKzf97xU4ysnxKQ5w6/2QCe97DfjdvdTbZ1rtJNXLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=agYTMqE1; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="agYTMqE1" Received: by mail.gandi.net (Postfix) with ESMTPSA id D1FF7FF80A; Wed, 29 Jan 2025 10:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1738148178; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eG2+4hA9d7BGbB5uoMrFvtObkrA1624sPDDaskGyR5A=; b=agYTMqE1Rufvd0KeF9wN1a+JQqjozJXoQ9z3tFfN+gnkpASeB4jxUeDGOla9GGqqxKMk5T 1e+foz1U5PKKQPf24MjQa9oH0eGsfQLGqZXkg7fPOqQNhb3ZbqUlKf8lXu5rB3BosnT1sC AdV5jUdhCaxd2TzMXGvivbZMZQFvS0b/JO3xfrXpwUHnnfT/d8umA6trHXKBO2lfnspbGi 3TXiAwWa/ZXAxN68utX6toA5k3WjhesO4WbGWyqNBl5/wttJmZ0xAfzqRZg1HZgWmXsA1K /XYU97ptbytSGVNV0rPLwL2RgPDqcHt+ndSH3yTqWGHG6QNJ8HVmRHt1bVNSDw== From: =?utf-8?q?Th=C3=A9o_Lebrun?= To: theo.lebrun@bootlin.com, mathias.nyman@linux.intel.com Cc: rogerq@kernel.org, peter.chen@kernel.org, pawell@cadence.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com, gregory.clement@bootlin.com, thomas.petazzoni@bootlin.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/9] usb: cdns3: call cdns_power_is_lost() only once in cdns_resume() Date: Wed, 29 Jan 2025 11:56:10 +0100 Message-ID: <20250129105613.403923-6-theo.lebrun@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: theo.lebrun@bootlin.com cdns_power_is_lost() does a register read. Call it only once rather than twice. Signed-off-by: Théo Lebrun --- drivers/usb/cdns3/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 465e9267b49c..799987c88960 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -524,11 +524,12 @@ EXPORT_SYMBOL_GPL(cdns_suspend); int cdns_resume(struct cdns *cdns) { + bool power_lost = cdns_power_is_lost(cdns); enum usb_role real_role; bool role_changed = false; int ret = 0; - if (cdns_power_is_lost(cdns)) { + if (power_lost) { if (cdns->role_sw) { cdns->role = cdns_role_get(cdns->role_sw); } else { @@ -553,7 +554,7 @@ int cdns_resume(struct cdns *cdns) } if (cdns->roles[cdns->role]->resume) - cdns->roles[cdns->role]->resume(cdns, cdns_power_is_lost(cdns)); + cdns->roles[cdns->role]->resume(cdns, power_lost); return 0; } From patchwork Wed Jan 29 10:56:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 861434 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B6B61B85DF; Wed, 29 Jan 2025 10:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148188; cv=none; b=RJgWiMOQSAy48RWPanU7iZuXtT26stpftMcJpFLx44Hc4HkztSiZd66mq+cccArXZMUcm24oNqYBcCgzQ7s6maBaNDWM6rlnBglyhb34P9Igo9IZNtUlVko5GX8jCD3fJTDvOlm7QDwWfb7B1Xjj6Y9rI+/CPFGlIBcH20eJd2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148188; c=relaxed/simple; bh=9XGUKvg1fAU/b/KY137j5fnFRhZjWZ6U99qPmAdtb/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MbYUNtRGZtjhgtedO30k4rCebwgbZFWMOt7vpntn5ta7pthS00eTPvMiUi/lc7n6/5d/joQ7KIF0ZKQP+OSh69W+GoTD8z+ZbXaYOF6xET5IxO07VetLbyLanNlf22YcX8nW8LjjUXELhiyM1K5wobNJVTm2oC4mXgQk3jI1XIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=i0M5As/R; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="i0M5As/R" Received: by mail.gandi.net (Postfix) with ESMTPSA id 5DD45FF80D; Wed, 29 Jan 2025 10:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1738148178; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YLjMpIBrYYqfaDFpRRkZcmwmehpVp7jUah3fTA/7BeQ=; b=i0M5As/RQwXZtv+NIf3AtV8xJCS+Z7qguwS1hXr0Cviqo/7hf5y0s9Fku0O2RbMiQwX9e3 83j52FSfD0/3iIqEzzoRX2544mOgmOQzY9F5a3FmXCotApJPHwRcxk/IbfuZzBxvpTUuVO vsEyKy2Amp1vh5qi98FS6LEHm06jtoibTWuJDFpvR3h6u0xLO2pNgyoiHWpjyO8qBINJ+l WXNslKi3FG4vmvNiVbRhi1rptJVfZ2/4GHgK3T5Je6CskuZR+l21+CLavIVgqW8lanym1D CLWdCq+h8lUMV1DnUVSPGt0VGVEhQeQBqh5LhvOfUrlyEu9n+xtPc+OZZvhLwA== From: =?utf-8?q?Th=C3=A9o_Lebrun?= To: theo.lebrun@bootlin.com, mathias.nyman@linux.intel.com Cc: rogerq@kernel.org, peter.chen@kernel.org, pawell@cadence.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com, gregory.clement@bootlin.com, thomas.petazzoni@bootlin.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/9] usb: xhci: change xhci_resume() parameters to explicit the desired info Date: Wed, 29 Jan 2025 11:56:11 +0100 Message-ID: <20250129105613.403923-7-theo.lebrun@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: theo.lebrun@bootlin.com Previous signature was: int xhci_resume(struct xhci_hcd *xhci, pm_message_t msg); Internally, it extracted two information out of the message: - whether we are after hibernation: msg.event == PM_EVENT_RESTORE, - whether this is an auto resume: msg.event == PM_EVENT_AUTO_RESUME. First bulletpoint is somewhat wrong: driver wants to know if the device did lose power, it doesn't care about hibernation per se. Knowing that, refactor to ask upper layers the right questions: (1) "did we lose power?" and, (2) "is this an auto resume?". Change the signature to: int xhci_resume(struct xhci_hcd *xhci, bool power_lost, bool is_auto_resume); The goal is to allow some upper layers (cdns3-plat) to tell us when power was lost after system-wise suspend. Note that lost_power is ORed at the start of xhci_resume() to xhci->quirks & XHCI_RESET_ON_RESUME || xhci->broken_suspend. It is simpler to keep those checks inside of xhci_resume() instead of doing them at each caller of xhci_resume(). Signed-off-by: Théo Lebrun --- drivers/usb/host/xhci-histb.c | 2 +- drivers/usb/host/xhci-pci.c | 8 +++++--- drivers/usb/host/xhci-plat.c | 10 +++++----- drivers/usb/host/xhci-tegra.c | 2 +- drivers/usb/host/xhci.c | 19 ++++++++----------- drivers/usb/host/xhci.h | 2 +- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/usb/host/xhci-histb.c b/drivers/usb/host/xhci-histb.c index f9a4a4b0eb57..dde2ae0e9a0f 100644 --- a/drivers/usb/host/xhci-histb.c +++ b/drivers/usb/host/xhci-histb.c @@ -355,7 +355,7 @@ static int __maybe_unused xhci_histb_resume(struct device *dev) if (!device_may_wakeup(dev)) xhci_histb_host_enable(histb); - return xhci_resume(xhci, PMSG_RESUME); + return xhci_resume(xhci, false, false); } static const struct dev_pm_ops xhci_histb_pm_ops = { diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index cb07cee9ed0c..6362a8d9a74d 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -807,8 +807,10 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) static int xhci_pci_resume(struct usb_hcd *hcd, pm_message_t msg) { - struct xhci_hcd *xhci = hcd_to_xhci(hcd); - struct pci_dev *pdev = to_pci_dev(hcd->self.controller); + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + struct pci_dev *pdev = to_pci_dev(hcd->self.controller); + bool power_lost = msg.event == PM_EVENT_RESTORE; + bool is_auto_resume = msg.event == PM_EVENT_AUTO_RESUME; reset_control_reset(xhci->reset); @@ -839,7 +841,7 @@ static int xhci_pci_resume(struct usb_hcd *hcd, pm_message_t msg) if (xhci->quirks & XHCI_PME_STUCK_QUIRK) xhci_pme_quirk(hcd); - return xhci_resume(xhci, msg); + return xhci_resume(xhci, power_lost, is_auto_resume); } static int xhci_pci_poweroff_late(struct usb_hcd *hcd, bool do_wakeup) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 49cc24e3ce23..831af518a6ec 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -476,7 +476,7 @@ static int xhci_plat_suspend(struct device *dev) return 0; } -static int xhci_plat_resume_common(struct device *dev, struct pm_message pmsg) +static int xhci_plat_resume_common(struct device *dev, bool power_lost) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); @@ -498,7 +498,7 @@ static int xhci_plat_resume_common(struct device *dev, struct pm_message pmsg) if (ret) goto disable_clks; - ret = xhci_resume(xhci, pmsg); + ret = xhci_resume(xhci, power_lost, false); if (ret) goto disable_clks; @@ -519,12 +519,12 @@ static int xhci_plat_resume_common(struct device *dev, struct pm_message pmsg) static int xhci_plat_resume(struct device *dev) { - return xhci_plat_resume_common(dev, PMSG_RESUME); + return xhci_plat_resume_common(dev, false); } static int xhci_plat_restore(struct device *dev) { - return xhci_plat_resume_common(dev, PMSG_RESTORE); + return xhci_plat_resume_common(dev, true); } static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev) @@ -545,7 +545,7 @@ static int __maybe_unused xhci_plat_runtime_resume(struct device *dev) struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); - return xhci_resume(xhci, PMSG_AUTO_RESUME); + return xhci_resume(xhci, false, true); } const struct dev_pm_ops xhci_plat_pm_ops = { diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index 94dd32f1a0da..74a4a2719e4f 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -2286,7 +2286,7 @@ static int tegra_xusb_exit_elpg(struct tegra_xusb *tegra, bool is_auto_resume) if (wakeup) tegra_xhci_disable_phy_sleepwalk(tegra); - err = xhci_resume(xhci, is_auto_resume ? PMSG_AUTO_RESUME : PMSG_RESUME); + err = xhci_resume(xhci, false, is_auto_resume); if (err < 0) { dev_err(tegra->dev, "failed to resume XHCI: %d\n", err); goto disable_phy; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 899c0effb5d3..ccdc74b24d3f 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1001,16 +1001,14 @@ EXPORT_SYMBOL_GPL(xhci_suspend); * This is called when the machine transition from S3/S4 mode. * */ -int xhci_resume(struct xhci_hcd *xhci, pm_message_t msg) +int xhci_resume(struct xhci_hcd *xhci, bool power_lost, bool is_auto_resume) { - bool hibernated = (msg.event == PM_EVENT_RESTORE); u32 command, temp = 0; struct usb_hcd *hcd = xhci_to_hcd(xhci); int retval = 0; bool comp_timer_running = false; bool pending_portevent = false; bool suspended_usb3_devs = false; - bool reinit_xhc = false; if (!hcd->state) return 0; @@ -1029,10 +1027,10 @@ int xhci_resume(struct xhci_hcd *xhci, pm_message_t msg) spin_lock_irq(&xhci->lock); - if (hibernated || xhci->quirks & XHCI_RESET_ON_RESUME || xhci->broken_suspend) - reinit_xhc = true; + if (xhci->quirks & XHCI_RESET_ON_RESUME || xhci->broken_suspend) + power_lost = true; - if (!reinit_xhc) { + if (!power_lost) { /* * Some controllers might lose power during suspend, so wait * for controller not ready bit to clear, just as in xHC init. @@ -1072,12 +1070,12 @@ int xhci_resume(struct xhci_hcd *xhci, pm_message_t msg) /* re-initialize the HC on Restore Error, or Host Controller Error */ if ((temp & (STS_SRE | STS_HCE)) && !(xhci->xhc_state & XHCI_STATE_REMOVING)) { - reinit_xhc = true; - if (!xhci->broken_suspend) + if (!power_lost) xhci_warn(xhci, "xHC error in resume, USBSTS 0x%x, Reinit\n", temp); + power_lost = true; } - if (reinit_xhc) { + if (power_lost) { if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && !(xhci_all_ports_seen_u0(xhci))) { del_timer_sync(&xhci->comp_mode_recovery_timer); @@ -1175,8 +1173,7 @@ int xhci_resume(struct xhci_hcd *xhci, pm_message_t msg) pending_portevent = xhci_pending_portevent(xhci); - if (suspended_usb3_devs && !pending_portevent && - msg.event == PM_EVENT_AUTO_RESUME) { + if (suspended_usb3_devs && !pending_portevent && is_auto_resume) { msleep(120); pending_portevent = xhci_pending_portevent(xhci); } diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index f0fb696d5619..4f045a864ac1 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1859,7 +1859,7 @@ int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id); int xhci_ext_cap_init(struct xhci_hcd *xhci); int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup); -int xhci_resume(struct xhci_hcd *xhci, pm_message_t msg); +int xhci_resume(struct xhci_hcd *xhci, bool power_lost, bool is_auto_resume); irqreturn_t xhci_irq(struct usb_hcd *hcd); irqreturn_t xhci_msi_irq(int irq, void *hcd); From patchwork Wed Jan 29 10:56:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 860821 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B7121B85E2; Wed, 29 Jan 2025 10:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148188; cv=none; b=PG7r00bvXUjMXv/BE7RNUycn1brp8bN6xS+uguEI7SmgaaQ3DD7OFeDR0uuiW61LO2dZCxPm1UcLw6mvZZnaqNHezXwWUHzEGhmrz3VflHxLItVFFooc371Z6kc6Glu/LACLqs/SlU+PByxza9mFbFAfDpv5LhRua55le3n0No8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148188; c=relaxed/simple; bh=akp8FO9P2Jx990YIUJHM+r/jn8TJqVsUZUalIBq9TF4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TeqIW4YLqqWNm//ETQDGNwGspTYD3obQvriEm2uoAKvPdZcREgtuJ9FSGJCfm2WtnSZsnCmflwHxaIleTzofA+7SUsS9gnd3rAlrOzyIGzo1NO1wfDWSSrjnL9/bBZQYGl2fRiYvNg8RBpJRlp5ixMfLtFrr390PyH39jH5HbSY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=BT2VXL2O; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="BT2VXL2O" Received: by mail.gandi.net (Postfix) with ESMTPSA id D72F0FF802; Wed, 29 Jan 2025 10:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1738148179; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uaejGi7/Nw1yFvMy04uA40ZGAAurzlofQcopOK8Hb10=; b=BT2VXL2OPDg3DQZ+StP6OF6NzYE/iQIJy1PjhaaKpS4pVtzvwyZPXj30Gbzf3cyFXdQ1kN wOMfhJa7NBcr5EhNn0kLaX/ygzaGCWtlCg+tqZDYBFTf4GvMs+lUR+C8sngLK/y0MRmRg/ 1aYo2AA4PnhFTZ7xo3xxJ3FdumzN3sFIylnn68CDGhcOdezuJg0068CcsDvxa8gDPZ3ioH IoAl/p8483dUNRmfDrwXRzDyIcuhVsweQ8ou2mwZitN6PzKMCQAccNy0O3RDOZI8oJeOVD ubmo+R9ZwJnnWxyBs58q8gcuKtsHz2zFk/AoZ6Hu3Z4Wbth7XxAAbV94szT2sQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= To: theo.lebrun@bootlin.com, mathias.nyman@linux.intel.com Cc: rogerq@kernel.org, peter.chen@kernel.org, pawell@cadence.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com, gregory.clement@bootlin.com, thomas.petazzoni@bootlin.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/9] usb: host: xhci-plat: allow upper layers to signal power loss Date: Wed, 29 Jan 2025 11:56:12 +0100 Message-ID: <20250129105613.403923-8-theo.lebrun@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: theo.lebrun@bootlin.com Now that xhci_resume() exposes a power_lost boolean argument, expose that to all xhci-plat implementations. They are free to set it from wherever they want: - Their own resume() callback. - The xhci_plat_priv::resume_quirk() callback. Signed-off-by: Théo Lebrun --- drivers/usb/host/xhci-plat.c | 3 ++- drivers/usb/host/xhci-plat.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 831af518a6ec..8b18494ccc41 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -479,6 +479,7 @@ static int xhci_plat_suspend(struct device *dev) static int xhci_plat_resume_common(struct device *dev, bool power_lost) { struct usb_hcd *hcd = dev_get_drvdata(dev); + struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); struct xhci_hcd *xhci = hcd_to_xhci(hcd); int ret; @@ -498,7 +499,7 @@ static int xhci_plat_resume_common(struct device *dev, bool power_lost) if (ret) goto disable_clks; - ret = xhci_resume(xhci, power_lost, false); + ret = xhci_resume(xhci, power_lost || priv->power_lost, false); if (ret) goto disable_clks; diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h index 6475130eac4b..fe4f95e690fa 100644 --- a/drivers/usb/host/xhci-plat.h +++ b/drivers/usb/host/xhci-plat.h @@ -15,6 +15,7 @@ struct usb_hcd; struct xhci_plat_priv { const char *firmware_name; unsigned long long quirks; + bool power_lost; void (*plat_start)(struct usb_hcd *); int (*init_quirk)(struct usb_hcd *); int (*suspend_quirk)(struct usb_hcd *); From patchwork Wed Jan 29 10:56:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 860820 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 693221D0F5A; Wed, 29 Jan 2025 10:56:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148189; cv=none; b=ibpFEiPeqFbUBXNkPqGDZIoZy+BzyYO2MqGJfg5B2Oq30juxD1BlxpayG8jbW36iH+p/ZXtnnsbBkq+XiGVPskHserXbk3yM0AcODsWuwX2OvXB5E+5OtnWpT6gQCIzzRi0uwOENOKnZHXs1slkHgxR51Il83e9C+s4qCyCrL+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738148189; c=relaxed/simple; bh=eBy2wZc03fg5WLGtOI3rz810FtgqWGk5IdPSV5cMmfM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SBTyGkD4cJSwUvz3qul+qm/6dt9/wNFqFRJvfNEgRiEuigBnNiFI+i4ZSqwaFSNvaOvO90MiSrH8KdlTuBJBEzihvrZQ9gCXI2Nt1OrM1eAXbWkIomFjmmVvqLry9P1CvpElNA7yq/Ql9xarQ0vf/445RLx/nYO9BAlrYwbs5JQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=kYj2yifV; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="kYj2yifV" Received: by mail.gandi.net (Postfix) with ESMTPSA id 56DC3FF80F; Wed, 29 Jan 2025 10:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1738148179; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gtY/ue4tP/7qgGhS7KR0RiR9xU44j3m0SPzMgH7vv6k=; b=kYj2yifVjxgkvFuBDsmLSo1bstPtMfxsnN8kr+CMQ/xVeJ73ND9BqQBMKtckJ7XjBlRY5U j9QrtZNLSIopVkadra7tYkTXfVMD39pinyUNLPOgo/EdkiHqUkCdw4jSk9oJIWouiD3H9E 8YLSnk7Lc8Y5OHqFEV509+upBri+dwcYB7ohxD0qcIfO2vYWWP2K5f0w1gN6+VBssRRAHU EyuNhTBgnLWsr0NHKqogzbI+q4FdytI9a7+0nDQ5ZKqDkOsfA78EjLl3WOB9rVW0h16G4b 7teJlBwVNqeMD0Z7FZ2iFeGq68wlaTm/mMNL+Cb43wJgnqJu4xSHdDVcp8/r2Q== From: =?utf-8?q?Th=C3=A9o_Lebrun?= To: theo.lebrun@bootlin.com, mathias.nyman@linux.intel.com Cc: rogerq@kernel.org, peter.chen@kernel.org, pawell@cadence.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com, gregory.clement@bootlin.com, thomas.petazzoni@bootlin.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 9/9] usb: host: cdns3: forward lost power information to xhci Date: Wed, 29 Jan 2025 11:56:13 +0100 Message-ID: <20250129105613.403923-9-theo.lebrun@bootlin.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: theo.lebrun@bootlin.com cdns3-plat can know if power was lost across system-wide suspend. Forward that information: - Grab the lost_power bool from cdns_role_driver::resume(). Store it into the power_lost field in struct xhci_plat_priv. - xhci-plat will call xhci_resume() with that value (ORed to whether we are in a hibernation restore). Signed-off-by: Théo Lebrun --- drivers/usb/cdns3/host.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c index 7ba760ee62e3..f0df114c2b53 100644 --- a/drivers/usb/cdns3/host.c +++ b/drivers/usb/cdns3/host.c @@ -138,6 +138,16 @@ static void cdns_host_exit(struct cdns *cdns) cdns_drd_host_off(cdns); } +static int cdns_host_resume(struct cdns *cdns, bool power_lost) +{ + struct usb_hcd *hcd = platform_get_drvdata(cdns->host_dev); + struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); + + priv->power_lost = power_lost; + + return 0; +} + int cdns_host_init(struct cdns *cdns) { struct cdns_role_driver *rdrv; @@ -148,6 +158,7 @@ int cdns_host_init(struct cdns *cdns) rdrv->start = __cdns_host_init; rdrv->stop = cdns_host_exit; + rdrv->resume = cdns_host_resume; rdrv->state = CDNS_ROLE_STATE_INACTIVE; rdrv->name = "host";