Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp447963lqi; Thu, 7 Mar 2024 01:57:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLMx6M9QxY2pPctMDHdIo3vSlxyVfCK42bIjPFE1zHCcJx4T9/ewNe2OzNWBm/HYLnUG4ehOdUpnEEiLljHmg86PJ0zPYUWo5vKFs+5A== X-Google-Smtp-Source: AGHT+IEn4GIH2jvgaz+R2x4CcsIsqTvy8IkoAf3C0R4eoJokUtuvQBKbJr8EHBCjQsVouPwbU4PM X-Received: by 2002:a67:e3ba:0:b0:472:fe6f:676a with SMTP id j26-20020a67e3ba000000b00472fe6f676amr1652411vsm.0.1709805431395; Thu, 07 Mar 2024 01:57:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709805431; cv=pass; d=google.com; s=arc-20160816; b=wU574UG4IbxJOrchH8H4gfhz+ngLHbI4hPCvReJXTZLzk3U/4RBVUrY0tYVEwJTf6o /+avXWVkPXtIhwFF9NLToFhrLJXGJqs/JUXnwC+DyUH1E8Mu7FhAVsgSy/lmD6tbcuXW AVkeQq8gHblk9srsFZF5wwx0pQkG7bIgaAGaDsUsIepw1HHvplrOnX0n2wzANIvkbqY4 eOCu+qMNWoKIA0HcRUrBOYsJPp0s/AIIpZ3iLUy01EVxSlX5ucqf6UfFMrphfAlitMtu 0nYgUi5QowrRtluQCizTnSuXGBZbWzmJNhaO61OtYh4b+YWaqqrq0CGo0e/VCBnJEKXn Tgjw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=ORK3ooFzTv7MrS/tadWslkKnebORiux/zlJ4WhF6LKM=; fh=ETrV/TJQ0D54aecHJ7+ZWHft2hV1Bw4fCfbLWnN7i4U=; b=MbQlIBAQi4j4h/X8yGxEQPJPlaHqFhQHO5awDBXbV3oOvczQKMQl1KmfCgUgECkaIX MN+zVBdRIJQfSeGsYBa3gib4pli+rLUk9kPuX2VRpsXMC6nJoyQyvZmLePc84EFzoUQU 8O5veV2xwv6z40VWKeMX3lh+qBdohqRuKH7G54UCc6Pme1/hMgJJ3VGlvJD5rMPVWXa5 OYQD9BtlRJjh2loh/bv41yfxrtNvxmAbQ63jkCAaVpPN/iU7aOm5AaK7GqlXi/mNQz4W fdQKZzrCpEyQYEyto14n8Tm3b7AAnFYgGJffXoWxvplMBb44nIuUnpYkqMA/sLDzgixW l/zg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=eDt6wKeW; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-95266-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95266-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f8-20020ac87f08000000b0042ed9b51f95si12091039qtk.501.2024.03.07.01.57.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 01:57:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95266-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=eDt6wKeW; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-95266-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95266-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1AB721C20E59 for ; Thu, 7 Mar 2024 09:57:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F71612A155; Thu, 7 Mar 2024 09:55:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="eDt6wKeW" Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 8A42384FC8; Thu, 7 Mar 2024 09:55:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709805321; cv=none; b=GIV7M0B6V4vIPDo+MlbKPWnEwLrZ6XxEO6KaG+AzxUVqo8cIHFQkSM+vRhj56vQuDtQPYrlGhR5Fmp7SpX++rkzf3kvIAEakAqHQITIBdezCANKG0XzPLqFZNH+WBYogdoDrNOLeiXtaPC2xhZ6wLnBpI9cTMiL9Rm54T1VoKrg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709805321; c=relaxed/simple; bh=ywTxIisOOTpj+HDN2NsOLT9qLjcBWovcybVHSKaAnsk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lVpa4cShoaSOQPILw+z8iWi/1PnFhRuW1Vpyh4snxwp9rkOysW8jtHYKlBWFnxzo5dVSIg4C3UZJyHiTtRQb71hvKVzeOhzOOY329g/Z/FwGebWIQ+mgKN4JLigGLjxqbe9peKzEptkjtiFU4EFmKJRGOve3faHSKmmGucNWLUs= 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=eDt6wKeW; arc=none smtp.client-ip=217.70.183.197 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 Received: by mail.gandi.net (Postfix) with ESMTPSA id A77021C000C; Thu, 7 Mar 2024 09:55:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709805312; 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=ORK3ooFzTv7MrS/tadWslkKnebORiux/zlJ4WhF6LKM=; b=eDt6wKeW0kg+C/fqGb1QlxB5PIOaEmhPkzdXT1ncVRdX9OLvPmnke2BQSNI4Ll+kWP3Tt0 RDQvSJO6++eZVDNwgVvncNk2Wt7HjxvOx3FiANhP95MYHAjx17LNeNtVUFdlGnhWziCrfw IpET2iwG6JPfM6F/i51B+xlKMOZWIGoDB7aZGWZDcGxkDf3d4uzkn1sADVACcvuIvUB7S5 pwl9f6lwlwMCP+CKOPA04stLPE6t82LkB5QLIJsnqKjZ/tV6byty9Pc+r7K0c6K8Ji+Uun +Rpz3sz/4Zi6LtXUogCEAO5iA+nRtefKXrLMDzTt6iUwnmVO4CXuDUujRT02ag== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Thu, 07 Mar 2024 10:55:05 +0100 Subject: [PATCH v4 4/9] usb: cdns3-ti: support reset-on-resume behavior Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240307-j7200-usb-suspend-v4-4-5ec7615431f3@bootlin.com> References: <20240307-j7200-usb-suspend-v4-0-5ec7615431f3@bootlin.com> In-Reply-To: <20240307-j7200-usb-suspend-v4-0-5ec7615431f3@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_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 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[] = { -- 2.44.0