From patchwork Tue May 28 10:20:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 13676436 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 C90A016ABFA; Tue, 28 May 2024 10:20:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716891637; cv=none; b=tB9UKVDxsiec7zqxAu0r396+XZsZvaRqaGdEnKlWSg5RndJDoFoNnhm/rI58Ls4v2MPOJKuJjjISJE3ZB1DiTr5HcjVv6e2+W+HonnGz0tyzEDZkC5EDbE9kKmLf6xxczecTyRHnawvBv2wm8NcsIGj2od1fVe/SeEpX4Mmzp6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716891637; c=relaxed/simple; bh=mNFOcqVPeiW0TBAqSKiAPvLe2JSjS3/1NaL2Fa9ZSGE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=abCOAyYFDq1J579HR0qCRdAQvWXBOePBsBrlTVI5Mx39Br7QkFNsfmiGmP/SEUjfILsd6QBT8a7vkbkqshhpRfO58IN8oQpmVXb+Dg17WA7BJ1cpZHBM38NbZYzMIg+QAgwNPGsvANIh/1YbhK/HPPw2CI1jOVykcfxKZwWO7/Y= 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=SVfbZnEt; arc=none smtp.client-ip=217.70.183.193 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="SVfbZnEt" Received: by mail.gandi.net (Postfix) with ESMTPA id 225EE24000E; Tue, 28 May 2024 10:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716891630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pt4vcaHEqIK7tEg5aEV04mxd2ZnC0k99FgLlkPj/PX8=; b=SVfbZnEtNR0BhLFE21BoJQ30/zXBsCr4v3wujLSLANi/Z2fjIJc88cBrYT2byO2SqyAA8R DTBP9fLHFBAz8W21/rcQOdumlCGeKpML5PfNftca7BRdwWJdfHMOzwGXlPMoBPk/nqiXme rWPReML+hVUs3P2zCqpIUe8reR/hc073JZoI0mTxmt06nS+w1FXEKV8lq3I/OhdnHldGE5 bg1jhwUJ+DCl/0JEzl52Yql7zf5hjKsVBSo7qk4jnrkgHiGFkTXN9lYbGa+yluWXZHpUlK YnZvFO4iUoHG+qe7MUOjhGOD9JkRqaFfNBYFYUyNtILYyNwelzjdG7+3+g6ttQ== From: Bastien Curutchet To: Vinod Koul , Kishon Vijay Abraham I , Bin Liu , Greg Kroah-Hartman Cc: linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca, Bastien Curutchet Subject: [PATCH 1/4] phy: ti: phy-da8xx-usb: Add runtime PM support Date: Tue, 28 May 2024 12:20:23 +0200 Message-ID: <20240528102026.40136-2-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240528102026.40136-1-bastien.curutchet@bootlin.com> References: <20240528102026.40136-1-bastien.curutchet@bootlin.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com Runtime PM is not supported while USB PHY can be turned off from register accesses. Add runtime PM for the USB2.0 PHY. The PHY is entirely shut down to save as much power as possible. This means that gadgets will not be discovered once suspend state is entered, and suspend state can not be left without an explicit user intervention (through sysfs). That's why runtime PM is disabled by default. Signed-off-by: Bastien Curutchet Acked-by: Vinod Koul --- drivers/phy/ti/phy-da8xx-usb.c | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/phy/ti/phy-da8xx-usb.c b/drivers/phy/ti/phy-da8xx-usb.c index dc614aa09a5f..80bfe37cf846 100644 --- a/drivers/phy/ti/phy-da8xx-usb.c +++ b/drivers/phy/ti/phy-da8xx-usb.c @@ -15,11 +15,13 @@ #include #include #include +#include #include #define PHY_INIT_BITS (CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN) struct da8xx_usb_phy { + struct device *dev; struct phy_provider *phy_provider; struct phy *usb11_phy; struct phy *usb20_phy; @@ -40,6 +42,12 @@ static int da8xx_usb11_phy_power_on(struct phy *phy) regmap_write_bits(d_phy->regmap, CFGCHIP(2), CFGCHIP2_USB1SUSPENDM, CFGCHIP2_USB1SUSPENDM); + /* + * USB1.1 can used USB2.0 output clock as reference clock so this is here to prevent USB2.0 + * from shutting PHY's power when USB1.1 might use it + */ + pm_runtime_get_sync(d_phy->dev); + return 0; } @@ -50,6 +58,7 @@ static int da8xx_usb11_phy_power_off(struct phy *phy) regmap_write_bits(d_phy->regmap, CFGCHIP(2), CFGCHIP2_USB1SUSPENDM, 0); clk_disable_unprepare(d_phy->usb11_clk); + pm_runtime_put_sync(d_phy->dev); return 0; } @@ -119,6 +128,35 @@ static const struct phy_ops da8xx_usb20_phy_ops = { .owner = THIS_MODULE, }; +static int __maybe_unused da8xx_runtime_suspend(struct device *dev) +{ + struct da8xx_usb_phy *d_phy = dev_get_drvdata(dev); + + dev_dbg(dev, "Suspending ...\n"); + + regmap_set_bits(d_phy->regmap, CFGCHIP(2), CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN); + + return 0; +} + +static int __maybe_unused da8xx_runtime_resume(struct device *dev) +{ + u32 mask = CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN | CFGCHIP2_PHY_PLLON; + struct da8xx_usb_phy *d_phy = dev_get_drvdata(dev); + u32 pll_status; + + regmap_update_bits(d_phy->regmap, CFGCHIP(2), mask, CFGCHIP2_PHY_PLLON); + + dev_dbg(dev, "Resuming ...\n"); + + return regmap_read_poll_timeout(d_phy->regmap, CFGCHIP(2), pll_status, + pll_status & CFGCHIP2_PHYCLKGD, 1000, 500000); +} + +static const struct dev_pm_ops da8xx_usb_phy_pm_ops = { + SET_RUNTIME_PM_OPS(da8xx_runtime_suspend, da8xx_runtime_resume, NULL) +}; + static struct phy *da8xx_usb_phy_of_xlate(struct device *dev, const struct of_phandle_args *args) { @@ -148,6 +186,8 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev) if (!d_phy) return -ENOMEM; + d_phy->dev = dev; + if (pdata) d_phy->regmap = pdata->cfgchip; else @@ -209,6 +249,14 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev) regmap_write_bits(d_phy->regmap, CFGCHIP(2), PHY_INIT_BITS, PHY_INIT_BITS); + pm_runtime_set_active(dev); + devm_pm_runtime_enable(dev); + /* + * Prevent runtime pm from being ON by default. Users can enable + * it using power/control in sysfs. + */ + pm_runtime_forbid(dev); + return 0; } @@ -233,6 +281,7 @@ static struct platform_driver da8xx_usb_phy_driver = { .remove_new = da8xx_usb_phy_remove, .driver = { .name = "da8xx-usb-phy", + .pm = &da8xx_usb_phy_pm_ops, .of_match_table = da8xx_usb_phy_ids, }, }; From patchwork Tue May 28 10:20:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 13676439 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 AE84215E96; Tue, 28 May 2024 10:20:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716891637; cv=none; b=NfKTf+VxNnOhGLe6XidrT3QveavZOo8z2/YjEVq8QhXyhF9DaasgKY5oQSz9ReHd22/kKLmsA86Vnj3RaTXd/YWVmlD4kUyYyDmbfAQNm2k2s6vkq2Tgk8R6XdWOoSa2ql/Z2K0H47A+HY6AdewtinhwpFKI0lrqOJHPwD3cMlA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716891637; c=relaxed/simple; bh=3dxmjc0gq9Z1RscHVzOk2xvMOJ97HgvGI8PshdBRcow=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hTAkGV4v3P0ZlIPic26bYlLTBxy30auCd0tGaBMMP72L1CKpIQlaA/V2dy2d09pfgVVpvIQ2oSb6WSAlil6EF5RIubWiokCjv6m8lltdU0W+T68maDRyMXdpEsJT3/0nCO/K65XskCSSCRtym4vM/H41NZ++oNfBIdhvUJII5io= 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=evJjvDLs; arc=none smtp.client-ip=217.70.183.193 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="evJjvDLs" Received: by mail.gandi.net (Postfix) with ESMTPA id 7156F24000D; Tue, 28 May 2024 10:20:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716891632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GTwcLrJlkxUwGcPOIejW240WhGdaw9D79sS7IYE/LmE=; b=evJjvDLsjaOsXLEPIROckcqKHLfMvST0zu/ozGJRnQ200CWCKNLpgPEt6wTC18UUEV30Mg Ot0zq+pucWx4rB4J/ejdlfGgU+0pH90LXn4CgL6NmTzKnE00aK28RxPmikOMLG66GvVGWB yfMfAXI/nVD/TVhXTPXpk9ONwNSvyRIef0T6FgHwr2VHcf2GfjvkIijtstXL0Thq3jNiQ/ ydCAZHkL2GN2Ur55tpFEmPCHMqV27jt8nXsG7tbeAzju4fAOx3IijPxlV+YcCiMACu+bLA jydYKNs7qkSs/QPbrrz15AXz6INa9AnVKFUpUTaWqwoJpKeZx7ArZVB2xjJ11w== From: Bastien Curutchet To: Vinod Koul , Kishon Vijay Abraham I , Bin Liu , Greg Kroah-Hartman Cc: linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca, Bastien Curutchet Subject: [PATCH 2/4] Revert "usb: musb: da8xx: Set phy in OTG mode by default" Date: Tue, 28 May 2024 12:20:24 +0200 Message-ID: <20240528102026.40136-3-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240528102026.40136-1-bastien.curutchet@bootlin.com> References: <20240528102026.40136-1-bastien.curutchet@bootlin.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com This reverts commit 7ccf62941a38701ec9a42b4a0fa2868af456e96a. da8xx_musb_set_mode() forces OTG mode regardless the selected mode even if the property 'dr_mode = "host"' is present in device-tree. This causes an unrecoverable error when VBUS supply is shut down : plugged gadgets are no longer detected once VBUS supply is back. Reverting it allows to have a selected mode coherent with device-tree's description. IMO, this shouldn't cause regression because OTG mode is the default selection when 'dr_mode' property is not set. Signed-off-by: Bastien Curutchet --- drivers/usb/musb/da8xx.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 8abf3a567e30..1681f9fba3da 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -328,13 +328,6 @@ static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode) struct da8xx_glue *glue = dev_get_drvdata(musb->controller->parent); enum phy_mode phy_mode; - /* - * The PHY has some issues when it is forced in device or host mode. - * Unless the user request another mode, configure the PHY in OTG mode. - */ - if (!musb->is_initialized) - return phy_set_mode(glue->phy, PHY_MODE_USB_OTG); - switch (musb_mode) { case MUSB_HOST: /* Force VBUS valid, ID = 0 */ phy_mode = PHY_MODE_USB_HOST; From patchwork Tue May 28 10:20:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 13676438 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 AE8DE16B72B; Tue, 28 May 2024 10:20:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716891637; cv=none; b=BE5shheb9/pAV0dQ8Puv2Lqboetj4LpBhxTdNlm4zF2KkDQY9JpttgjiXwJmTO3R0NZRYkst5ccEVh9pmO5Mbtw2Ro6nlnHzgKZRcJsk1Maf8oZsEvOb/PjlD4fNHvY1Nnbt7wkMShBHdas7/T2OcfSfaAwliwdeyy3wt157hSw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716891637; c=relaxed/simple; bh=tPOaqNwFB7dfq+H7qsVa/mabtlwOrj5IgAb7rv2aADo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DUIQubf3WDPGmwhuSH4XBY04RUsltzTSipA57pmELGi5HuTm6bdNAAVu3zQJ+2jlWRx6qEaheYp9KAnyllQTBL/02oNLRaPv1gDhOc42ZFi1ljW5OIRcu6Hxht7/4nNBAIjR6GuDarxNnEUy6e8Nq2uUVEPz5WiRMNPbHhiFW7Y= 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=Tvxnf/1s; arc=none smtp.client-ip=217.70.183.193 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="Tvxnf/1s" Received: by mail.gandi.net (Postfix) with ESMTPA id 9D4C624000F; Tue, 28 May 2024 10:20:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716891633; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zGUowIjjvnUnYJCOfP5hA4A3GSUyMwVNLn232niSHqg=; b=Tvxnf/1sOxG7YTTlw/W1NXEz9FHTMOZtCPTbp39/HNLu3Qmmh41gSNHJUYTqYktQguxUns 950m2EEkYFKsnYsS8vxMnYUd4BJSgIixtf8ZxxM6lV06qmctdPAuv2EoAs/u1SICFvndKr HaGWBvV9pJaLlXAG8uLkOS6qVTnIPZsiM7CfpvXx2AXuSSIhVNT8XIzQzZFe5Hsy9f4Xqs KkhbWl8xr9yjuhEaQFRiBQS6fXmm74mV6pg5s/Om6s4OUAy3czrEfgOap7TLPxTn4Hdne+ hrIV8gBBH4HUgMOMGn+zB3UUV+CzJA8Sy3rVmjDkdcwQAiBZthQJeGW0rl950w== From: Bastien Curutchet To: Vinod Koul , Kishon Vijay Abraham I , Bin Liu , Greg Kroah-Hartman Cc: linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca, Bastien Curutchet Subject: [PATCH 3/4] usb: musb: da8xx: Remove try_idle implementation from host-only mode Date: Tue, 28 May 2024 12:20:25 +0200 Message-ID: <20240528102026.40136-4-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240528102026.40136-1-bastien.curutchet@bootlin.com> References: <20240528102026.40136-1-bastien.curutchet@bootlin.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com The idle_state is not meant for host-only mode. When the device acts as a host, it fails to exit the idle state once entered. This prevents new USB gadgets from being detected once plugged in. Commit 032ec49f5351 ("usb: musb: drop useless board_mode usage") removed a is_otg_enabled() check in the try_idle() that prevented from entering idle_state. This was removed because at that time it was not possible to select host-only mode with CONFIG_USB_MUSB_HOST so dual role was always set. Add #ifndef CONFIG_USB_MUSB_HOST around try_idle() callback to prevent from entering idle_state when host-only mode has been selected. Signed-off-by: Bastien Curutchet --- drivers/usb/musb/da8xx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 1681f9fba3da..c5cf733673a2 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -191,7 +191,7 @@ static void otg_timer(struct timer_list *t) spin_unlock_irqrestore(&musb->lock, flags); } -static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout) +static void __maybe_unused da8xx_musb_try_idle(struct musb *musb, unsigned long timeout) { static unsigned long last_timer; @@ -476,7 +476,10 @@ static const struct musb_platform_ops da8xx_ops = { .disable = da8xx_musb_disable, .set_mode = da8xx_musb_set_mode, + +#ifndef CONFIG_USB_MUSB_HOST .try_idle = da8xx_musb_try_idle, +#endif .set_vbus = da8xx_musb_set_vbus, }; From patchwork Tue May 28 10:20:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 13676437 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (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 DA58916B72D; Tue, 28 May 2024 10:20:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716891637; cv=none; b=If2ACMpu5ziaeTqZHjWelRMf3GxMz8ibP9/kWvrgnE9GWvX6lDyY7YrpmvDIS12yeXUR2cnpdgztDKH07KRvYw6xuqb2BCvByT09yn6sQrXVn2l6+V0MghCPNH37tFVMAKCDW1J+C5/ey1W86aW9ZprHfqzp6yDm/JyzKEA2SNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716891637; c=relaxed/simple; bh=lMCM/A3Z7snAmnLzSGIr7jM7SrSUs1WYwlorRMK6qr8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cRCmAOXLQ1j4TJb3ruORDeWyrKxlmRqoiGeRjyadpI3QvqefQXdZjpJioi/V+7IP0Qo1eSiEK06gD009qzD/2LMCP63RR/WsOfSYCojADev76tB+Qgr2stU5d/F5pXamGV5jLuUJTqOv2C4hzrpn8Q44BTXHl0+CA/S+XgrUgP8= 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=eTYE/3jd; arc=none smtp.client-ip=217.70.183.193 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="eTYE/3jd" Received: by mail.gandi.net (Postfix) with ESMTPA id B72CF240006; Tue, 28 May 2024 10:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716891634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qsG4a+QexdrWaD9z2b31NrWRE7fUVEl7ydWLvlxj0hU=; b=eTYE/3jdhGs5GEmTPLjC0zOErFPdwpIx6cL82ctXvsH22SFUCPeUB17Hsoo6/SHf3kkiGV xdIxWufJv5otteYpxjkhpbOtucCY8cv0tNs9Sh8y7dYGQ3dbK8ZNbqcGdieCedb9ahbkvd aDpqUPn5El7xZnIcCjS9tP7Eu+ggm2v68DEssTyT8Qd9DkmQOnSzfixwG8faZ8q9Lo6ttz BH+PPK/KQu5/mI1pXUnZSdZaiMfhPJRXQlJZndR1ekCy8Gsbvl9KRbq5J6kxE9oXCIhouS 5AeZZ1ekOh28JdrPbzkQdZwA253A0j3QMDjQkZsmHwSRkRNyga/HxfCMAJOMeQ== From: Bastien Curutchet To: Vinod Koul , Kishon Vijay Abraham I , Bin Liu , Greg Kroah-Hartman Cc: linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca, Bastien Curutchet Subject: [PATCH 4/4] usb: musb: da8xx: Implement BABBLE recovery Date: Tue, 28 May 2024 12:20:26 +0200 Message-ID: <20240528102026.40136-5-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240528102026.40136-1-bastien.curutchet@bootlin.com> References: <20240528102026.40136-1-bastien.curutchet@bootlin.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com There is no specific behaviour implemented to recover from a babble error. When a BABBLE error happens, recovery fails as connected sticks are no longer detected by the USB controller. Implement the recover callback of the MUSB operation to reset the USB controller when a BABBLE happens. Signed-off-by: Bastien Curutchet --- drivers/usb/musb/da8xx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index c5cf733673a2..fcf06dcf2d61 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -220,6 +220,13 @@ static void __maybe_unused da8xx_musb_try_idle(struct musb *musb, unsigned long mod_timer(&musb->dev_timer, timeout); } +static int da8xx_babble_recover(struct musb *musb) +{ + dev_dbg(musb->controller, "resetting controller to recover from babble\n"); + musb_writel(musb->ctrl_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK); + return 0; +} + static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) { struct musb *musb = hci; @@ -480,6 +487,7 @@ static const struct musb_platform_ops da8xx_ops = { #ifndef CONFIG_USB_MUSB_HOST .try_idle = da8xx_musb_try_idle, #endif + .recover = da8xx_babble_recover, .set_vbus = da8xx_musb_set_vbus, };