Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp535900rdf; Tue, 21 Nov 2023 09:06:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVGQwDEk8FmWhBvFeLqJMIzBb83BeXT1WSl4mIvrHjkbBVVUUms1W5jsax3vb9c8JuROAe X-Received: by 2002:a05:6a00:8c04:b0:68a:5cf8:dac5 with SMTP id ih4-20020a056a008c0400b0068a5cf8dac5mr12006111pfb.22.1700586415995; Tue, 21 Nov 2023 09:06:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700586415; cv=none; d=google.com; s=arc-20160816; b=QRWlpptedRxeSXDQsuy3lyPmZjf6z675Cwx8ZFmyIGMXwfdyiBzSk7AH/I4TbqCNIk F3izP8AxuVNhiZDNe1IZfz+MoCF/szrEpjEvHlS4/3cgMfGBqMzHlHFAAVl5WnAwkZ1W 6cGFnx+YFz/Xx9RTI8p3LnKcEWhG3KON/j/cXr1EvLJXR2HSqzvKBTvdjhhn/G4shlLE sqBRhqlhP17HCDTwSTIcGXek586qbc8sFkZzxlJ2NOHOMCqWQdQNQIAWcJP+RSRMiVp/ frvwRJ9AlFeeIF2LMgeQ60fFNmfADwKjhD3C7MDBkHZ0Ed7pur4mG3JFruwgEGtYc9ae 4MFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:message-id:from:to:cc :subject:date:content-transfer-encoding:mime-version:dkim-signature; bh=9OlDSO/6KbnGCD41BC35yjBL1rC+a7EqniQWve6Dfd8=; fh=9DSXFC5Eb834EsGDFfXyr+3+8NGxpPPcVNeAGmdnqzc=; b=D5FT+XVW30j6rYWqvQwHbJwKTtA8WP0I1Jh3A1DCXVXTq3Rl3Rakx1ncwVr/H/JaHT CQIgwabpOl9+ouYeiE2kS+O5WmXTbBpIIjL553Vl4Ka/g4DqP+zNWoJu6hkyCXTUAxzt KKB1EkgCL6oPYOUEM18jqHU2AndV0GMohFOAYom1bfW+YbKfRGcnEeXBtYzQyRtW9KoB K60FsyvnRWCV57XMpWGNiAXEC0qsyTEQyi/quC2+yIE4a1FRIprfNJbAEmmWyPZPzIJN 2ZpgpDXJk/Ph7EIUg0Zmi98oK9PopdJCNz88BEkmHRDsuZvHM/GcIpgD5p4JvgafE6od QGfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=W+ZDKXrS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id 30-20020a63175e000000b005bd85b32495si10413026pgx.685.2023.11.21.09.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 09:06:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=W+ZDKXrS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3FC9580C6E98; Tue, 21 Nov 2023 09:06:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230348AbjKURGO (ORCPT + 99 others); Tue, 21 Nov 2023 12:06:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbjKURGM (ORCPT ); Tue, 21 Nov 2023 12:06:12 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD64510E; Tue, 21 Nov 2023 09:06:04 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id C440BFF81A; Tue, 21 Nov 2023 17:06:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700586363; 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=9OlDSO/6KbnGCD41BC35yjBL1rC+a7EqniQWve6Dfd8=; b=W+ZDKXrSmia4ht5KtC8bLOg0gZ67cnEIeiRrysNdOHASGu3yrD1W8ZcbeiBa30t9Yfm3yW Uu3sCwQAQuGwffWLP2aG1tDAu7cyZZ0UkuqDG+JTsiI7/8gg5hA7zAoMOF1pJzXDqQId7Z zkVUi/N0NVzhZyJcay7o2Wta5QF0dAnxWz1iTk4oanU67TZwX2TzMI7yJnFSzhrVaJlDfa 6xFBH3ddxTQ8uiA+p5pgK83B1SwiwOHkmLjC2H9XoKk3BRNJ/D1ezvTnbJ56hkNg5bNXvM aPjFXxwPaX3ZN3ZhdSOQpsEVnmwoE8fSXy/a0KTbWR2IhWojaJ6Etdok1X0yMA== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 21 Nov 2023 18:06:01 +0100 Subject: Re: [PATCH v2 6/7] usb: cdns3-ti: signal reset-on-resume to xHCI for J7200 platform Cc: , , , , =?utf-8?q?Gr=C3=A9gory_Clement?= To: "Roger Quadros" , "Greg Kroah-Hartman" , "Rob Herring" , "Krzysztof Kozlowski" , "Conor Dooley" , "Peter Chen" , "Pawel Laszczak" , "Nishanth Menon" , "Vignesh Raghavendra" , "Tero Kristo" From: =?utf-8?q?Th=C3=A9o_Lebrun?= Message-Id: X-Mailer: aerc 0.15.2 References: <20231120-j7200-usb-suspend-v2-0-038c7e4a3df4@bootlin.com> <20231120-j7200-usb-suspend-v2-6-038c7e4a3df4@bootlin.com> In-Reply-To: X-GND-Sasl: theo.lebrun@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 09:06:40 -0800 (PST) Hello, On Tue Nov 21, 2023 at 5:53 PM CET, Roger Quadros wrote: > On 20/11/2023 19:06, Th=C3=A9o Lebrun wrote: > > Pass CDNS3_RESET_ON_RESUME as platform data to cdns3 host role. It will > > in turn pass it down to xHCI platform data as XHCI_RESET_ON_RESUME. > >=20 > > Avoid this warning on resume: > >=20 > > [ 16.017462] xhci-hcd xhci-hcd.1.auto: xHC error in resume, USBSTS = 0x401, Reinit > >=20 > > When used, remote wakeup is not expected to work. > >=20 > > Only focus J7200 as other SoC are untested. > >=20 > > Signed-off-by: Th=C3=A9o Lebrun > > --- > > drivers/usb/cdns3/cdns3-ti.c | 19 +++++++++++++++++-- > > 1 file changed, 17 insertions(+), 2 deletions(-) > >=20 > > diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.= c > > index 84f93c2fcd5c..7d56a1acbc54 100644 > > --- a/drivers/usb/cdns3/cdns3-ti.c > > +++ b/drivers/usb/cdns3/cdns3-ti.c > > @@ -16,6 +16,7 @@ > > #include > > #include > > #include > > +#include "core.h" > > =20 > > /* USB Wrapper register offsets */ > > #define USBSS_PID 0x0 > > @@ -128,6 +129,7 @@ static int cdns_ti_probe(struct platform_device *pd= ev) > > { > > struct device *dev =3D &pdev->dev; > > struct device_node *node =3D pdev->dev.of_node; > > + const struct of_dev_auxdata *auxdata; > > struct cdns_ti *data; > > unsigned long rate; > > int error, i; > > @@ -177,7 +179,8 @@ static int cdns_ti_probe(struct platform_device *pd= ev) > > =20 > > cdns_ti_init_hw(data); > > =20 > > - error =3D of_platform_populate(node, NULL, NULL, dev); > > + auxdata =3D of_device_get_match_data(dev); > > + error =3D of_platform_populate(node, NULL, auxdata, dev); > > if (error) { > > dev_err(dev, "failed to create children: %d\n", error); > > return error; > > @@ -222,8 +225,20 @@ static const struct dev_pm_ops cdns_ti_pm_ops =3D = { > > =20 > > #endif /* CONFIG_PM */ > > =20 > > +static struct cdns3_platform_data cdns_ti_j7200_pdata =3D { > > + .quirks =3D CDNS3_RESET_ON_RESUME, > > +}; > > We will need to introduce a new data structure "struct cdns_ti_platform_d= ata" > and add platform specific details like "reset_on_resume" to it. > This is to address what Krzysztof pointed to in patch 4. Yes I've got it locally following Krzysztof's review. Below my signature is a sneak peak as I'll wait a bit more before a V3. First we implement resume behavior in the wrapper driver using match data then we add auxdata passed to the subdevices. Regards, -- Th=C3=A9o Lebrun, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ------------------------------------------------------------------------ From 69a59e3408668dfa06d3790cb20948961708791d Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Th=3DC3=3DA9o=3D20Lebrun?=3D Date: Mon, 20 Nov 2023 16:47:29 +0100 Subject: [PATCH 05/13] usb: cdns3-ti: add suspend/resume procedures for J72= 00 MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Hardware initialisation is only done at probe. The J7200 USB controller is reset at resume because of power-domains toggling off & on. We therefore reconfigure the hardware at resume. Reuse the newly extracted cdns_ti_init_hw() function that contains the register write sequence. Only focus J7200 as other SoC are untested. If the controller does not reset we do not want to redo reg writes. Signed-off-by: Th=C3=A9o Lebrun --- drivers/usb/cdns3/cdns3-ti.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.c index d4232b440e4e..7530b6b5159d 100644 --- a/drivers/usb/cdns3/cdns3-ti.c +++ b/drivers/usb/cdns3/cdns3-ti.c @@ -58,6 +58,11 @@ struct cdns_ti { struct clk *usb2_refclk; struct clk *lpm_clk; int usb2_refclk_rate_code; + const struct cdns_ti_match_data *match_data; +}; + +struct cdns_ti_match_data { + bool reset_on_resume; }; static const int cdns_ti_rate_table[] =3D { /* in KHZ */ @@ -138,6 +143,7 @@ static int cdns_ti_probe(struct platform_device *pdev) platform_set_drvdata(pdev, data); data->dev =3D dev; + data->match_data =3D of_device_get_match_data(dev); data->usbss =3D devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(data->usbss)) { @@ -202,7 +208,30 @@ static void cdns_ti_remove(struct platform_device *pde= v) platform_set_drvdata(pdev, NULL); } +#ifdef CONFIG_PM + +static int cdns_ti_resume(struct device *dev) +{ + struct cdns_ti *data =3D dev_get_drvdata(dev); + + if (data->match_data && data->match_data->reset_on_resume) + cdns_ti_init_hw(data); + + return 0; +} + +static const struct dev_pm_ops cdns_ti_pm_ops =3D { + SET_SYSTEM_SLEEP_PM_OPS(NULL, cdns_ti_resume) +}; + +#endif /* CONFIG_PM */ + +static const struct cdns_ti_match_data cdns_ti_j7200_match_data =3D { + .reset_on_resume =3D true, +}; + static const struct of_device_id cdns_ti_of_match[] =3D { + { .compatible =3D "ti,j7200-usb", .data =3D &cdns_ti_j7200_match_data, }= , { .compatible =3D "ti,j721e-usb", }, { .compatible =3D "ti,am64-usb", }, {}, @@ -213,8 +242,9 @@ static struct platform_driver cdns_ti_driver =3D { .probe =3D cdns_ti_probe, .remove_new =3D cdns_ti_remove, .driver =3D { - .name =3D "cdns3-ti", + .name =3D "cdns3-ti", .of_match_table =3D cdns_ti_of_match, + .pm =3D pm_ptr(&cdns_ti_pm_ops), }, }; -- 2.42.0 ------------------------------------------------------------------------ From 4ff91a036da297e9e8585980c6133bee9c45d9a6 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Th=3DC3=3DA9o=3D20Lebrun?=3D Date: Mon, 20 Nov 2023 17:02:44 +0100 Subject: [PATCH 07/13] usb: cdns3-ti: signal reset-on-resume to xHCI for J7= 200 platform MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Pass CDNS3_RESET_ON_RESUME as platform data to cdns3 host role. It will in turn pass it down to xHCI platform data as XHCI_RESET_ON_RESUME. Avoid this warning on resume: [ 16.017462] xhci-hcd xhci-hcd.1.auto: xHC error in resume, USBSTS 0x40= 1, Reinit When used, remote wakeup is not expected to work. Only focus J7200 as other SoC are untested. Signed-off-by: Th=C3=A9o Lebrun --- drivers/usb/cdns3/cdns3-ti.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.c index 7530b6b5159d..da2648ebc179 100644 --- a/drivers/usb/cdns3/cdns3-ti.c +++ b/drivers/usb/cdns3/cdns3-ti.c @@ -16,6 +16,7 @@ #include #include #include +#include "core.h" /* USB Wrapper register offsets */ #define USBSS_PID 0x0 @@ -62,7 +63,8 @@ struct cdns_ti { }; struct cdns_ti_match_data { - bool reset_on_resume; + bool reset_on_resume; + const struct of_dev_auxdata *auxdata; }; static const int cdns_ti_rate_table[] =3D { /* in KHZ */ @@ -132,6 +134,7 @@ static int cdns_ti_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; struct device_node *node =3D pdev->dev.of_node; + const struct of_dev_auxdata *auxdata =3D NULL; struct cdns_ti *data; unsigned long rate; int error, i; @@ -181,7 +184,9 @@ static int cdns_ti_probe(struct platform_device *pdev) cdns_ti_init_hw(data); - error =3D of_platform_populate(node, NULL, NULL, dev); + if (data->match_data) + auxdata =3D data->match_data->auxdata; + error =3D of_platform_populate(node, NULL, auxdata, dev); if (error) { dev_err(dev, "failed to create children: %d\n", error); return error; @@ -226,8 +231,21 @@ static const struct dev_pm_ops cdns_ti_pm_ops =3D { #endif /* CONFIG_PM */ +static struct cdns3_platform_data cdns_ti_j7200_pdata =3D { + .quirks =3D CDNS3_RESET_ON_RESUME, +}; + +static const struct of_dev_auxdata cdns_ti_j7200_auxdata[] =3D { + { + .compatible =3D "cdns,usb3", + .platform_data =3D &cdns_ti_j7200_pdata, + }, + {}, +}; + static const struct cdns_ti_match_data cdns_ti_j7200_match_data =3D { .reset_on_resume =3D true, + .auxdata =3D cdns_ti_j7200_auxdata, }; static const struct of_device_id cdns_ti_of_match[] =3D { -- 2.42.0