From patchwork Fri Feb 23 16:05:28 2024 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: 13569403 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 0B43CC54E4C for ; Fri, 23 Feb 2024 16:07:41 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ml4JfiN7asRVM4HYqftKuTL6P2PlE8zhYida8I5JgPc=; b=5ClvE1ldaSSkDZ jrNDefI9TjmApv6WKeoaJJ7JHJWVQeD5MjgfB6L3hEAr0OEfHYxc5eLBmEjVHJjLyKF9XwC3381Yv VVuJyKXnYRvHGtjiJr5O2ifa7Zn5NftGGhW8YaKjrI+MHbUsq6iYYGaeRoEXdDfYGBa2jsAYeKc0B Fqe/zWYBpDSphsUapi72iIPXuwhc0VOXq4xukOSNDl1cJr3M0hiUFusM3C+bC1IlXvP2kTwoER+Vw 6lKO7Kw7hZuLrniPTJbCPG5rZ0sZZO5/NYRXkEpb7vktW5MAPqij8h1Z6hUv1xWYzRoM0+I/yO09S w+0RefBOAyZCSSjPWGAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdY57-0000000A8nF-0dpa; Fri, 23 Feb 2024 16:07:25 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdY3M-0000000A7wb-237v for linux-arm-kernel@lists.infradead.org; Fri, 23 Feb 2024 16:05:39 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id B24741C0008; Fri, 23 Feb 2024 16:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708704334; 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=9FINWLp/w0HN6A+6t4rg5b6XzSr+dwLhUgwTrZyKrbg=; b=cOD7OspLvGU9jVADF5Hs8xu3HGeAENLLkI5Ccu/rnM7Nb6QAN993aq6F6blcocec/8zYOU kt1fGZgX3RevRgRzg0stoXbRmz/b7rTLu+uNiqGkX5jIrPy9HYWZFdm7TmqdGiwLqv527R C9SQ4kyCbS5k5Fk04BCbRQCa5S3lUF5sbzzT8sbVDP11szXnSuq6OKmHVybNDt3fa77CSj zYPTB8ZXxt2friE/EDQ+gAx7+JAwDLtxOO8YHo8RtqqFGy665GLQgcWqxQhnO+h19JoxX3 Ep6/7ylAX6DHDXwMBPHUlFp1EB3h+ETaxlQQ0SLC0lqFyLtplZ6A1RwLXBFlVA== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Fri, 23 Feb 2024 17:05:28 +0100 Subject: [PATCH v3 4/8] usb: cdns3-ti: support reset-on-resume behavior MIME-Version: 1.0 Message-Id: <20240223-j7200-usb-suspend-v3-4-b41c9893a130@bootlin.com> References: <20240223-j7200-usb-suspend-v3-0-b41c9893a130@bootlin.com> In-Reply-To: <20240223-j7200-usb-suspend-v3-0-b41c9893a130@bootlin.com> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Roger Quadros , Peter Chen , Pawel Laszczak , Nishanth Menon , Vignesh Raghavendra , Tero Kristo Cc: Thomas Petazzoni , =?utf-8?q?Gr=C3=A9gory_?= =?utf-8?q?Clement?= , Kevin Hilman , Alan Stern , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.13.0 X-GND-Sasl: theo.lebrun@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240223_080536_901328_36B6BB18 X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add match data support, with one boolean to indicate whether the hardware resets after a system-wide suspend. If hardware resets, we force execute ->runtime_resume() at system-wide resume to run the hardware init sequence. No compatible exploits this functionality, just yet. Signed-off-by: Théo Lebrun --- drivers/usb/cdns3/cdns3-ti.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.c index 4c8a557e6a6f..f76327566798 100644 --- a/drivers/usb/cdns3/cdns3-ti.c +++ b/drivers/usb/cdns3/cdns3-ti.c @@ -57,9 +57,14 @@ struct cdns_ti { unsigned vbus_divider:1; struct clk *usb2_refclk; struct clk *lpm_clk; + const struct cdns_ti_match_data *match_data; int usb2_refclk_rate_code; }; +struct cdns_ti_match_data { + bool reset_on_resume; +}; + static const int cdns_ti_rate_table[] = { /* in KHZ */ 9600, 10000, @@ -101,6 +106,7 @@ static int cdns_ti_probe(struct platform_device *pdev) platform_set_drvdata(pdev, data); data->dev = dev; + data->match_data = device_get_match_data(dev); data->usbss = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(data->usbss)) { @@ -220,8 +226,29 @@ static int cdns_ti_runtime_resume(struct device *dev) return 0; } +static int cdns_ti_suspend(struct device *dev) +{ + struct cdns_ti *data = dev_get_drvdata(dev); + + if (data->match_data && data->match_data->reset_on_resume) + return pm_runtime_force_suspend(dev); + else + return 0; +} + +static int cdns_ti_resume(struct device *dev) +{ + struct cdns_ti *data = dev_get_drvdata(dev); + + if (data->match_data && data->match_data->reset_on_resume) + return pm_runtime_force_resume(dev); + else + 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(cdns_ti_suspend, cdns_ti_resume) }; static const struct of_device_id cdns_ti_of_match[] = {