From patchwork Fri Jan 26 14:36:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532717 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 C8C7FC47422 for ; Fri, 26 Jan 2024 14:37:56 +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=1AUHcJmpwoZFTcUlXceu2Lf6oJTlTvlGiDTFGtN+wK0=; b=QWPYA5VXcnH4S+ sY0fJXhKLBLU/RWubfPQR1nN49f2A+nSea4W2mDaIXKFuLbpy5vuGHfFoKYnam8RWXbnWjuCCBHfG X8eDcOj/witp83QznI0asjJecgpJRzfICtJT7+AJ5ZgCCsx3kL1rCSehLObd5HNG27qzFbIAGnK2w HJaeDM3bzuyBIDh+CDGRMhDo7VuxxJ0Qfljt0Cn1+hZabbNDBAHV0ozEgCVza0CYr4iGlVrzcxncZ NnXBFdIUVwVcRI7O/Dg0R3fHA0coqqmz52WLNOTd4n7eOXUU8rerA6Ble4cuj65pklq9DXRGt8RLi obPVpAcMJHMWLhS2c3wg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNL0-00000004MzJ-18bZ; Fri, 26 Jan 2024 14:37:46 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNKp-00000004Msz-33dU; Fri, 26 Jan 2024 14:37:37 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id D48BD40010; Fri, 26 Jan 2024 14:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279854; 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=UeT42sEpDDYGcpf5YrXoKh3jtRRClLytLS9mk4kxR3s=; b=QeD+UINS/zyJVUS478SNFmS/cAWoK6t9gopcTzrs5nJYkpqEUtEvkahDp7Vc5PIPAQBQI+ Dnw0MvCHZlPJ4wDUiqAGUgN2QReYkr5W+fx9cYu7BuYJAYCJ8KPAdaFBRELUGFbYgIaGe7 rDS/Awtg1g8wuh/+xpjgb1yMR3WhaSLEeqqeXRQU8WgMdVzepnDLESUlgcTLrgrIkIAiuV 9BIj+isUeaxYUTYAB9O/sqtXDAyPI7O+VlXojO7xSLrHrg0B07UD6fxYI+GK3KX2BUHjix KgPxn9S7mfQOKMiDtTc0IiTESa5jDd+dWvrAzP2ftvTRvWTE2/0vMD19UByEcg== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:43 +0100 Subject: [PATCH v2 01/15] gpio: pca953x: move suspend()/resume() to suspend_noirq()/resume_noirq() MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-1-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_063735_935810_177BBF58 X-CRM114-Status: UNSURE ( 9.84 ) X-CRM114-Notice: Please train this message. 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 Some IOs can be needed during suspend_noirq()/resume_noirq(). So move suspend()/resume() to noirq. Signed-off-by: Thomas Richard Reviewed-by: Andy Shevchenko Acked-by: Bartosz Golaszewski Reviewed-by: Andi Shyti --- drivers/gpio/gpio-pca953x.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 00ffa168e405..6e495fc67a93 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -1234,7 +1234,7 @@ static void pca953x_save_context(struct pca953x_chip *chip) regcache_cache_only(chip->regmap, true); } -static int pca953x_suspend(struct device *dev) +static int pca953x_suspend_noirq(struct device *dev) { struct pca953x_chip *chip = dev_get_drvdata(dev); @@ -1248,7 +1248,7 @@ static int pca953x_suspend(struct device *dev) return 0; } -static int pca953x_resume(struct device *dev) +static int pca953x_resume_noirq(struct device *dev) { struct pca953x_chip *chip = dev_get_drvdata(dev); int ret; @@ -1268,7 +1268,8 @@ static int pca953x_resume(struct device *dev) return ret; } -static DEFINE_SIMPLE_DEV_PM_OPS(pca953x_pm_ops, pca953x_suspend, pca953x_resume); +static DEFINE_NOIRQ_DEV_PM_OPS(pca953x_pm_ops, + pca953x_suspend_noirq, pca953x_resume_noirq); /* convenience to stop overlong match-table lines */ #define OF_653X(__nrgpio, __int) ((void *)(__nrgpio | PCAL653X_TYPE | __int)) From patchwork Fri Jan 26 14:36:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532719 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 B7FECC48286 for ; Fri, 26 Jan 2024 14:38:07 +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=JXLaYn7iq6noU7or/W1fkP8KNEwRkmYXe0kpFv8He0I=; b=fBWCTdADmusGmU NU9DWBD7qDm7UE5FjVHweC7fSRqxanNml8tiRVMD0VEcwsMvwiMGW1obN0jaiogJe+s9PDmCiNyna heX75G5NKvBka9MyZV2l2vaV4DnWOKf8h+bVHDNcok3Sc5WQ3w0LiItI3IvsqpJGFNL3+8k/+PHy7 3CLwO0/iiSuGX49JkN3/KN+wraOjgV0wx8V963mgjl8QW/SiTHSkAnwn4o7MiepTJH2hqbkULau6u YJpML6QTG3S9ueMdU3QEbsdTHw8ZnRBZ0L14Mr+gOh+wSLP3bZpGjq2IJyN6EawI9X+2qX6oe03ov ZtI3YVKoweLpFfv7nAAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLA-00000004N5T-0lVm; Fri, 26 Jan 2024 14:37:56 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNKt-00000004Mv3-3JFR; Fri, 26 Jan 2024 14:37:41 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 6711C40004; Fri, 26 Jan 2024 14:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279858; 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=bBvfyrsgnxZkigb51H7bXjq0DEAjmH59sXjUpzTvFno=; b=Eduz/GPtIshO4mhHx0xqXY9W397R7/7eTiPnCpA1xinvHumYUW15LbC6hpiJ8vUVPJusIO 1/fi+ua9yXAwEL5p3+mXoMJ+HN+LjJKuAfLXINAN0FmNgv0Hqia+1z3w+j1YSD9ES1AMKl 45WY9fSHJZ6Za1bEzrYDRWc0g4sbE+p9Ls/4k+LbLuL/ZnsftWzBvr0dgpug8OgL/SK5mZ cX5bDEhyCrjk4GvrxP3WhZXqmv2StRGvA9KGTV3k0LRh2JrWJ0w21qnHZTNVRPPYOdU+Q9 IbDVUT5+UK6L1Jk6if5RmpuOa/tg9LnIalVXenvesLE4Mxi4WyO4pk//kzgSUg== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:44 +0100 Subject: [PATCH v2 02/15] pinctrl: pinctrl-single: move suspend()/resume() callbacks to noirq MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-2-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_063740_174315_0A398420 X-CRM114-Status: GOOD ( 13.46 ) 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 The goal is to extend the active period of pinctrl. Some devices may need active pinctrl after suspend() and/or before resume(). So move suspend()/resume() to suspend_noirq()/resume_noirq() in order to have active pinctrl until suspend_noirq() (included), and from resume_noirq() (included). The deprecated API has been removed to use the new one (dev_pm_ops struct). Signed-off-by: Thomas Richard Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/pinctrl/pinctrl-single.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index 19cc0db771a5..0dd4b0e11adf 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -1625,7 +1625,6 @@ static int pcs_irq_init_chained_handler(struct pcs_device *pcs, return 0; } -#ifdef CONFIG_PM static int pcs_save_context(struct pcs_device *pcs) { int i, mux_bytes; @@ -1690,14 +1689,9 @@ static void pcs_restore_context(struct pcs_device *pcs) } } -static int pinctrl_single_suspend(struct platform_device *pdev, - pm_message_t state) +static int pinctrl_single_suspend_noirq(struct device *dev) { - struct pcs_device *pcs; - - pcs = platform_get_drvdata(pdev); - if (!pcs) - return -EINVAL; + struct pcs_device *pcs = dev_get_drvdata(dev); if (pcs->flags & PCS_CONTEXT_LOSS_OFF) { int ret; @@ -1710,20 +1704,19 @@ static int pinctrl_single_suspend(struct platform_device *pdev, return pinctrl_force_sleep(pcs->pctl); } -static int pinctrl_single_resume(struct platform_device *pdev) +static int pinctrl_single_resume_noirq(struct device *dev) { - struct pcs_device *pcs; - - pcs = platform_get_drvdata(pdev); - if (!pcs) - return -EINVAL; + struct pcs_device *pcs = dev_get_drvdata(dev); if (pcs->flags & PCS_CONTEXT_LOSS_OFF) pcs_restore_context(pcs); return pinctrl_force_default(pcs->pctl); } -#endif + +static DEFINE_NOIRQ_DEV_PM_OPS(pinctrl_single_pm_ops, + pinctrl_single_suspend_noirq, + pinctrl_single_resume_noirq); /** * pcs_quirk_missing_pinctrl_cells - handle legacy binding @@ -1986,11 +1979,8 @@ static struct platform_driver pcs_driver = { .driver = { .name = DRIVER_NAME, .of_match_table = pcs_of_match, + .pm = pm_sleep_ptr(&pinctrl_single_pm_ops), }, -#ifdef CONFIG_PM - .suspend = pinctrl_single_suspend, - .resume = pinctrl_single_resume, -#endif }; module_platform_driver(pcs_driver); From patchwork Fri Jan 26 14:36:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532718 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 3C747C47422 for ; Fri, 26 Jan 2024 14:38:07 +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=jwWBzUMH0NADG2IeiOoS1ZnVJ9XmBZudGOnglPHWHxY=; b=OBqtIjwZxCRQsv 3KTJ7A294cZCnqYkgEdMkFcIOt0Bu3vd3qgB4lbzvQadU6eNhSOa/O2K5FRIOOPc4c+LwKggcu6OS 6q9aikwhg8YQ+BHvMjBOm9dAlt/UCGM7CBjZasU0YYaD6cjjalnpEpP3TH1ew9URGhaiVj2lyJ9f0 ijYJ3zF5wO3fh6WW7xz0rVHQL9eRNVk0rhpESuBuOtrIAkqn63f9Ppxrf9V+rETvKT6bHxzciIz7S fAc1h8AGGhcw7pnojaXThpk36gvqt94+BvIS9jgHdfuVACE2JG0mhSPl9VzsNz2e2OkEwPlGl5jKH Lecp2Ea1tvaZDmlB1b5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLB-00000004N7K-3tac; Fri, 26 Jan 2024 14:37:57 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNKw-00000004Mw5-2mIA; Fri, 26 Jan 2024 14:37:44 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 72DEE40015; Fri, 26 Jan 2024 14:37:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279861; 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=HkHotbSbtdMXKRaQO3NvmhStluWksZQ2iVlQ1BQwp/I=; b=Bj8R8Tf4PXMPWI2dTOvlQf19bh14EHrUwblXp9Ri21obZFiVBXZ2kqSLmeuNIq250JQwRr HW5d1caxgvZP5mRH2njiaedfOLVVK7fHFEdRro8cZlvONRmluu9rlEgxwflbRvVNWfiQKo e/1rkB9DNlNMWtqvLP9Y79xdQEvmEKUZGr3GXptYrwNjci9nWaTysP88xuwHxDlEGkPEFW u3O+QFhZmsY93Nip0wgPoUwOBYXIknqWXidqTyHeZjWBKPyXY1R+kdJuaqKBQGT47pIjQd jvgymVGrwCXIuzoblVHrjKqQx9i4pM6dh2aRyuvXb5dDkhH5aDwyP4w+/q/jwQ== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:45 +0100 Subject: [PATCH v2 03/15] i2c: omap: wakeup the controller during suspend() callback MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-3-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_063743_038190_5BC6BCED X-CRM114-Status: GOOD ( 11.44 ) 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 A device may need the controller up during suspend_noirq() or resume_noirq(). But if the controller is autosuspended, there is no way to wakeup it during suspend_noirq() or resume_noirq() because runtime pm is disabled at this time. The suspend() callback wakes up the controller, so it is available until its suspend_noirq() callback (pm_runtime_force_suspend()). During the resume, it's restored by resume_noirq() callback (pm_runtime_force_resume()). Then resume() callback enables autosuspend. So the controller is up during a little time slot in suspend and resume sequences even if it's not used. Signed-off-by: Thomas Richard --- drivers/i2c/busses/i2c-omap.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 42165ef57946..cc9841cb08f1 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -1575,9 +1575,23 @@ static int __maybe_unused omap_i2c_runtime_resume(struct device *dev) return 0; } +static int omap_i2c_suspend(struct device *dev) +{ + return pm_runtime_resume_and_get(dev); +} + +static int omap_i2c_resume(struct device *dev) +{ + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + + return 0; +} + static const struct dev_pm_ops omap_i2c_pm_ops = { SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) + SET_SYSTEM_SLEEP_PM_OPS(omap_i2c_suspend, omap_i2c_resume) SET_RUNTIME_PM_OPS(omap_i2c_runtime_suspend, omap_i2c_runtime_resume, NULL) }; From patchwork Fri Jan 26 14:36:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532721 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 748A1C47DDF for ; Fri, 26 Jan 2024 14:38:14 +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=GhgSx0+f1uwebP1fDJqFbcLqhg5V6v2mQoAKBxWwz+8=; b=bFYoNTadSzsnUG qPMQrOQRfBIh1OkmyRUA1tG0K6JcyLcYYiElQ+oiRl50Q7irn5U8ssb4DmpiTnxPgl5ztDyXDxD3M 0339Naekdu/B8j5oDbf5QYEa6NZYm//7ogAEsgEKFfsR2P8fVrT4Fe9w40SamsfwewTG08tV3cyzD 7zVDGLxozfclA4AcG7+JzJnvymo2Y/AIVSS4Kcv8LT5Y1/E2MbwJZVEMuWrzs6mfpGKN6w/KOZupq AtDzotx8UmHular6GiyaRXPnqDKMA26n/+mo2nsTFAwXev9ZbDczmHULSnvqZu0EJeH5bSalhUee4 mD6kldM/73uFbBFPS4Pw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLE-00000004N9V-2RJJ; Fri, 26 Jan 2024 14:38:00 +0000 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNKz-00000004MxN-3tIi; Fri, 26 Jan 2024 14:37:47 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 564F440014; Fri, 26 Jan 2024 14:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279863; 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=Cbw3dfSNoiflIv8mn1Y7eM6xBgXjeUJCd/7i0kUTDu4=; b=HIsJspISmq9+z03H8FRmqs/PxBEH2bY6w4YjXjpYjf84eeKJKyfRd8h7X97Ckfs/vM3MN8 ajG8doZk8ZKGo0M0j2VzYTFIybcYp+s+vCjyP/8oxsw2XTGpgO2xoXsDHyJFC72xsmtC4f AXZsPD7frToR88bXP3aSHZaNt/l/vagv9KnKtzOiWYuEwG3tAnhnHslb77YNE1AKgWGWWX qNQ9WKUME2rM1gjPiHlGBxFadl0hJzjDgSgSdsUbR93+dFkFXzMl7gwvUWiR/Qv1nMJAGk 37288DOuqlcr95ZCxnsxf3sZcdeb0yMzaNJhmrcILe74lVQjnNpKzbZiaQEOvw== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:46 +0100 Subject: [PATCH v2 04/15] mux: add mux_chip_resume() function MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-4-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_063746_355307_1B38D5A0 X-CRM114-Status: GOOD ( 13.33 ) 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 The mux_chip_resume() function restores a mux_chip using the cached state of each mux. Signed-off-by: Thomas Richard --- drivers/mux/core.c | 27 +++++++++++++++++++++++++++ include/linux/mux/driver.h | 1 + 2 files changed, 28 insertions(+) diff --git a/drivers/mux/core.c b/drivers/mux/core.c index 775816112932..896f74b34eb8 100644 --- a/drivers/mux/core.c +++ b/drivers/mux/core.c @@ -215,6 +215,33 @@ void mux_chip_free(struct mux_chip *mux_chip) } EXPORT_SYMBOL_GPL(mux_chip_free); +/** + * mux_chip_resume() - restores the mux-chip state + * @mux_chip: The mux-chip to resume. + * + * Restores the mux-chip state. + * + * Return: Zero on success or a negative errno on error. + */ +int mux_chip_resume(struct mux_chip *mux_chip) +{ + int ret, i; + + for (i = 0; i < mux_chip->controllers; ++i) { + struct mux_control *mux = &mux_chip->mux[i]; + + if (mux->cached_state != MUX_CACHE_UNKNOWN) { + ret = mux_control_set(mux, mux->cached_state); + if (ret < 0) { + dev_err(&mux_chip->dev, "unable to restore state\n"); + return ret; + } + } + } + return 0; +} +EXPORT_SYMBOL_GPL(mux_chip_resume); + static void devm_mux_chip_release(struct device *dev, void *res) { struct mux_chip *mux_chip = *(struct mux_chip **)res; diff --git a/include/linux/mux/driver.h b/include/linux/mux/driver.h index 18824064f8c0..2a7e5ec5d540 100644 --- a/include/linux/mux/driver.h +++ b/include/linux/mux/driver.h @@ -88,6 +88,7 @@ struct mux_chip *mux_chip_alloc(struct device *dev, int mux_chip_register(struct mux_chip *mux_chip); void mux_chip_unregister(struct mux_chip *mux_chip); void mux_chip_free(struct mux_chip *mux_chip); +int mux_chip_resume(struct mux_chip *mux_chip); struct mux_chip *devm_mux_chip_alloc(struct device *dev, unsigned int controllers, From patchwork Fri Jan 26 14:36:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532720 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 68243C47422 for ; Fri, 26 Jan 2024 14:38:14 +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=EBC4jbOYUtAWjwibluiL739/5u2f3VkgoXzlY+FAKY8=; b=d0zjpLOiYcHi1v GRQh3Hh7pa/2MdpvyLw4+6lKpmU5I/OVy39sOhdeGyYf0suYkS0Ue6DJsI6+dv3xckzP+U6krHKLu 9p9k+m+Kb7qpp7fsHoJlm44XJwZUYQyB39ro+oEAcVtQlgU1+9KAoYILmgEILWRZX9l/pVqGo7Aed LDK/Bu/cmVYka43r0xIP3dQmeYFnaB9JjN2ZbaDLwdcLiMe5noFNQIKNRIWN8DuY0jU9qrD3pg+JH ttVC4zJ2ItZsB4jVT1IjCcl1Z2A0nDNZQfejVaOUL11MwZGEfPm/l8svjkPGsQPC4msdJIudms1Mb mDC71q8mKKyXJa4nAf3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLH-00000004NCK-2Pim; Fri, 26 Jan 2024 14:38:03 +0000 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNL2-00000004Mzg-0UDv; Fri, 26 Jan 2024 14:37:49 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id F15CA4000C; Fri, 26 Jan 2024 14:37:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279866; 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=tZJ+2FIjmJ3bZ38rbdAVVTffmaC+WvVgUK7GwRKTE04=; b=UpAgNFun0NVNnY8k9eOqBgvyd6OtEWrfn5hfbdJb2qghuKCU3lVrcVGffgLMqHcaoxFviT pTB1e8YU8XTPwd+W2XZD+RUiodvkRevqbKPCk8pAvEBeHmF6HaEvTfhvub2s3Kbn4Bcdtf 2p5ppt4VTXli4/hl0EtBoYu7wcoP8i+4mZMeC1kawKLhTFwjx3Aco3xV6GwgSUKN9BPGD2 2KiZAq5m5s1Ng8xEyE2NhWoxf3oyc6Ns5GFn+gClI8BpgUTB5xhVZquAI1fVWPmIH5bOZJ oj0upQRBh/YBaMDou6cDcjCbj+IPpvU9i7NZ5GJ+i5XhNhGpiF4hhnePELNHbA== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:47 +0100 Subject: [PATCH v2 05/15] mux: mmio: add resume support MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-5-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_063748_355634_09A0A15E X-CRM114-Status: GOOD ( 11.44 ) 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 From: Théo Lebrun No need to save something during the suspend stage, as the mux core has an internal cache to store the state of muxes. This cache is used by mux_chip_resume to restore all muxes. Signed-off-by: Théo Lebrun Signed-off-by: Thomas Richard --- drivers/mux/mmio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/mux/mmio.c b/drivers/mux/mmio.c index fd1d121a584b..892ff4714b68 100644 --- a/drivers/mux/mmio.c +++ b/drivers/mux/mmio.c @@ -125,13 +125,25 @@ static int mux_mmio_probe(struct platform_device *pdev) mux_chip->ops = &mux_mmio_ops; + dev_set_drvdata(dev, mux_chip); + return devm_mux_chip_register(dev, mux_chip); } +static int mux_mmio_resume_noirq(struct device *dev) +{ + struct mux_chip *mux_chip = dev_get_drvdata(dev); + + return mux_chip_resume(mux_chip); +} + +static DEFINE_NOIRQ_DEV_PM_OPS(mux_mmio_pm_ops, NULL, mux_mmio_resume_noirq); + static struct platform_driver mux_mmio_driver = { .driver = { .name = "mmio-mux", .of_match_table = mux_mmio_dt_ids, + .pm = pm_sleep_ptr(&mux_mmio_pm_ops), }, .probe = mux_mmio_probe, }; From patchwork Fri Jan 26 14:36:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532722 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 BFA5AC47422 for ; Fri, 26 Jan 2024 14:38:22 +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=KiCAvJv8dd+3rbYxMN1MTlkIfrojN84sJ/9ViHFQv1c=; b=pTG48kLKl4j4U1 uAtGNbGiI1/xV1LnOujthyKUs+y57SKallSMfvT27qvu74etmdkZy1YvEkCONLcnO4Dkpxu0SJE5C z4qEjkMK1zjQY4+HoOJADDcIHE8iPooyiPztMhm9xXIUolQSQJ7k4O9ghLWhwjIRdbkE2g5/Jp8QN rarDPHFdFKdpxWUthVW2APtNJOjXuETCoDLowlSx6iRMj5qRA5yQUT6rVznaPGlWpG701/WW07hIn Hv+7Fi8kYubqS/ELtwy/w9m3m+bqSrf2IqbXgH/pb4Lw0E4X49LsB6JUkGTqGBj5hp0cnR7LvNet2 p8jR856qyz9DANS3BLDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLL-00000004NG3-3AOv; Fri, 26 Jan 2024 14:38:07 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNL4-00000004N2L-2llX; Fri, 26 Jan 2024 14:37:52 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 9414640004; Fri, 26 Jan 2024 14:37:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279869; 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=TYpIlz92+4LlPtdrbkhMPtlalEsL2Q+znIFM/DHRXRE=; b=bcElLzJhYd7HVh2QtZ37cGb9zfLd8NGMhYzI6tdfIj2bRrCEaWZC0TlgFD7PA/F/B19J13 eoajjwRK9UaqdOgOzvyFK2Dzw8P85nkcewX/dzdTRpyvBVmapJ9udLpXes2tu2tdy9lUDB WR68OjdMwqBE/MW7dxmFOym0T29E93eew1jr9EHLYWsLnFC8ZyV8uXSvynunFK1B5CKytl T6LQ5NHC5EyVRDGLV5cSgJbEMf2YETePIvGkx0QQvpRstsLorOqx5gIneDv286OxSHRJwc Qlc1cE/yg2K8v8z645P4US+hK9JgYPVHKuS1hiSPnrm6wjfnuyDdMyVRp106Uw== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:48 +0100 Subject: [PATCH v2 06/15] phy: ti: phy-j721e-wiz: make wiz_clock_init callable multiple times MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-6-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_063751_010555_460E7172 X-CRM114-Status: GOOD ( 14.05 ) 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 For suspend and resume support, wiz_clock_init needs to be called multiple times. Add a parameter to wiz_clock_init to be able to skip clocks registration. Based on the work of Théo Lebrun Signed-off-by: Thomas Richard --- drivers/phy/ti/phy-j721e-wiz.c | 60 +++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c index fc3cd98c60ff..09f7edf16562 100644 --- a/drivers/phy/ti/phy-j721e-wiz.c +++ b/drivers/phy/ti/phy-j721e-wiz.c @@ -1076,7 +1076,7 @@ static int wiz_clock_register(struct wiz *wiz) return ret; } -static int wiz_clock_init(struct wiz *wiz, struct device_node *node) +static int wiz_clock_init(struct wiz *wiz, struct device_node *node, bool probe) { const struct wiz_clk_mux_sel *clk_mux_sel = wiz->clk_mux_sel; struct device *dev = wiz->dev; @@ -1087,14 +1087,36 @@ static int wiz_clock_init(struct wiz *wiz, struct device_node *node) int ret; int i; - clk = devm_clk_get(dev, "core_ref_clk"); - if (IS_ERR(clk)) { - dev_err(dev, "core_ref_clk clock not found\n"); - ret = PTR_ERR(clk); - return ret; + if (probe) { + clk = devm_clk_get(dev, "core_ref_clk"); + if (IS_ERR(clk)) { + dev_err(dev, "core_ref_clk clock not found\n"); + ret = PTR_ERR(clk); + return ret; + } + wiz->input_clks[WIZ_CORE_REFCLK] = clk; + + if (wiz->data->pma_cmn_refclk1_int_mode) { + clk = devm_clk_get(dev, "core_ref1_clk"); + if (IS_ERR(clk)) { + dev_err(dev, "core_ref1_clk clock not found\n"); + ret = PTR_ERR(clk); + return ret; + } + wiz->input_clks[WIZ_CORE_REFCLK1] = clk; + } + + clk = devm_clk_get(dev, "ext_ref_clk"); + if (IS_ERR(clk)) { + dev_err(dev, "ext_ref_clk clock not found\n"); + ret = PTR_ERR(clk); + return ret; + } + wiz->input_clks[WIZ_EXT_REFCLK] = clk; } - wiz->input_clks[WIZ_CORE_REFCLK] = clk; + + clk = wiz->input_clks[WIZ_CORE_REFCLK]; rate = clk_get_rate(clk); if (rate >= 100000000) regmap_field_write(wiz->pma_cmn_refclk_int_mode, 0x1); @@ -1121,14 +1143,7 @@ static int wiz_clock_init(struct wiz *wiz, struct device_node *node) } if (wiz->data->pma_cmn_refclk1_int_mode) { - clk = devm_clk_get(dev, "core_ref1_clk"); - if (IS_ERR(clk)) { - dev_err(dev, "core_ref1_clk clock not found\n"); - ret = PTR_ERR(clk); - return ret; - } - wiz->input_clks[WIZ_CORE_REFCLK1] = clk; - + clk = wiz->input_clks[WIZ_CORE_REFCLK1]; rate = clk_get_rate(clk); if (rate >= 100000000) regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x1); @@ -1136,20 +1151,17 @@ static int wiz_clock_init(struct wiz *wiz, struct device_node *node) regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x3); } - clk = devm_clk_get(dev, "ext_ref_clk"); - if (IS_ERR(clk)) { - dev_err(dev, "ext_ref_clk clock not found\n"); - ret = PTR_ERR(clk); - return ret; - } - wiz->input_clks[WIZ_EXT_REFCLK] = clk; - + clk = wiz->input_clks[WIZ_EXT_REFCLK]; rate = clk_get_rate(clk); if (rate >= 100000000) regmap_field_write(wiz->pma_cmn_refclk_mode, 0x0); else regmap_field_write(wiz->pma_cmn_refclk_mode, 0x2); + /* What follows is about registering clocks. */ + if (!probe) + return 0; + switch (wiz->type) { case AM64_WIZ_10G: case J7200_WIZ_10G: @@ -1592,7 +1604,7 @@ static int wiz_probe(struct platform_device *pdev) goto err_get_sync; } - ret = wiz_clock_init(wiz, node); + ret = wiz_clock_init(wiz, node, true); if (ret < 0) { dev_warn(dev, "Failed to initialize clocks\n"); goto err_get_sync; From patchwork Fri Jan 26 14:36:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532723 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 801D8C47DDF for ; Fri, 26 Jan 2024 14:38:24 +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=NV5b3CHuWUVB4bAn9T1k6QSl4Sc+i6fC6yCw5usQP2A=; b=blh2Ew/QruCfEZ h6KTgmqys5jcszqmjnkyPxAEIIk7t+EFRlv/9vtLnAmIE3ABa1f7BHb+Asl8zLKl4Rp04dHIn/XMX rxmHysS8504ktZOgqQBrh3gqLOse4cWo8WNAc/1JmQ3mdQie/eJDkhr7zxcwrNlDNm/Jle71v6icp +E0mxCspWKA0YO47O9bAmRDiobZPr/uIHuVLLxiHc55aEZ7yiBk+WhOuTIOvTKdly2v2xzZv5SiDQ t21B890ghOwIackPpPjtQOXG62e4qO57dUP6SnJlAwfVRlr0cUYxkhv/D/EKldhVWP+M8Ey0jOFLY iDTd/bhhKKSQVERVF0NA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLQ-00000004NJu-0sQ5; Fri, 26 Jan 2024 14:38:12 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNL8-00000004N42-07cb; Fri, 26 Jan 2024 14:37:55 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 466B04000F; Fri, 26 Jan 2024 14:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279872; 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=I18NFvlzsoQfZSmja7rXdApCroRS70XYkOT3y7UrK2g=; b=fumspxXRNw5UiOEesNyasc94ujx9HeTv582Up4GE0IaxaMpACWSc19XX5ZdiGHjcP2H5Cy foG4E5lxEtWWThdX+GRtdP2ppslw2kiq5USgOYsDkwvI9D/yQVdURPKIBjKtBoRn8kRSzM qd+FZ0ZJfKxIGSn9ziVAPpNEp8aCgkND7XQ1tlUdLFz+kb7b+CI2szTvaf8bkshv1Gx0Js 5UMY6+3ARpLmSGbzwOlqLZfz6tkvjZkcq2FW6rycjJSzffzsw8vQd3xumCNWCzSpQ5cLQQ feZjVdsEItXk5zxcz5wk+R/ZcGQs7JLBDLCXqc4Oc9Vg8bDFrhe3XB3qMirEjQ== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:49 +0100 Subject: [PATCH v2 07/15] phy: ti: phy-j721e-wiz: add resume support MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-7-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_063754_363512_9FE0B5A9 X-CRM114-Status: GOOD ( 13.83 ) 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 resume support. It has been tested on J7200 SR1.0 and SR2.0. Based on the work of Théo Lebrun Signed-off-by: Thomas Richard --- drivers/phy/ti/phy-j721e-wiz.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c index 09f7edf16562..163ac3e95ddb 100644 --- a/drivers/phy/ti/phy-j721e-wiz.c +++ b/drivers/phy/ti/phy-j721e-wiz.c @@ -1666,12 +1666,47 @@ static void wiz_remove(struct platform_device *pdev) pm_runtime_disable(dev); } +static int wiz_resume_noirq(struct device *dev) +{ + struct device_node *node = dev->of_node; + struct wiz *wiz = dev_get_drvdata(dev); + int ret; + + /* Enable supplemental Control override if available */ + if (wiz->sup_legacy_clk_override) + regmap_field_write(wiz->sup_legacy_clk_override, 1); + + ret = wiz_clock_init(wiz, node, false); + if (ret < 0) { + dev_warn(dev, "Failed to initialize clocks\n"); + goto err_get_sync; + } + + ret = wiz_init(wiz); + if (ret) { + dev_err(dev, "WIZ initialization failed\n"); + goto err_wiz_init; + } + + return 0; + +err_wiz_init: + wiz_clock_cleanup(wiz, node); + +err_get_sync: + + return ret; +} + +static DEFINE_NOIRQ_DEV_PM_OPS(wiz_pm_ops, NULL, wiz_resume_noirq); + static struct platform_driver wiz_driver = { .probe = wiz_probe, .remove_new = wiz_remove, .driver = { .name = "wiz", .of_match_table = wiz_id_table, + .pm = pm_sleep_ptr(&wiz_pm_ops), }, }; module_platform_driver(wiz_driver); From patchwork Fri Jan 26 14:36:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532775 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 88E1FC47422 for ; Fri, 26 Jan 2024 14:40:15 +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=ua5J2Kip1MXeIlysgr6dD3Dg5Fr+wEYtKY3x8CIoPx4=; b=hXwZAmYo3hYzi6 PEdPnZUrvPig1NIU+aZDWkpyzVnz9lT1QfUybNOmJqzP38o2DKwtvTBpket0SiRMvYqGNCC2NHOjl 5xGIw4cKpRLh3T7XsQ43G0fA6SeOr1XnHWy3sM8eUPlqvAJDg82/NlWtC1aP28+9UMGJG7oc8YFoQ XaOLrWeADzMhrH0Lc1w0r74kyOkxEZdzqLaCTIHNS3bFT/LREmr7i69xHHuCl5BdGjZgOpsXstMZU VOaHW61d2Whhixq4Z2xFmZXZzXbrgKoUqX+x5BBzvFmPgVTbY+s6emtIav8T8xBJxx/JtZnvqgqS+ Aat6zGBKyI9DEAANa81g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNNE-00000004ORb-24da; Fri, 26 Jan 2024 14:40:04 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLA-00000004N5B-2ubu; Fri, 26 Jan 2024 14:37:59 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id AE57940013; Fri, 26 Jan 2024 14:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279875; 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=qwKGf7qwzlJSl38EGsWN6oKmN7+Z3kA3VFlKRRwxvC0=; b=o4O7mnoUq5A/6H+rHvxtjvciqbCFP15d6F6L6R5e1LnanZD8U3kKDuHisbUVzK3vKei3Ly rKMHdUOycj2B9TX483dMmKasyTHEnJJQs//vgQKRqio/mh30dDl0+mvZXXenU/CNf9a2FZ xBfbpIrePDnIVg80gEkcak9Wwnwkms0ZPb/NU7Ws5k2+qLXlUhh45kkBCHS7z0DmE0YJV7 seB2w+FTCbp5YN62lN5dpI+of6GnAGCDHzHqzMvWB8GTFnZ7iOB3nOTl1v8jxZi7NFLM7D +I9P7ECX2KpIx+YTmSvyF2NiJIpmCM6IHLs11oeM+AXDTqJUhBrY8YlJTfVeMQ== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:50 +0100 Subject: [PATCH v2 08/15] phy: cadence-torrent: extract calls to clk_get from cdns_torrent_clk MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-8-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_063757_052459_7F119B7F X-CRM114-Status: GOOD ( 11.91 ) 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 Extract calls to clk_get from cdns_torrent_clk into a separate function. It needs to call cdns_torrent_clk at resume without looking up the clock. Based on the work of Théo Lebrun Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c index a75c96385c57..94298ad9f875 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -2681,18 +2681,22 @@ static int cdns_torrent_reset(struct cdns_torrent_phy *cdns_phy) return 0; } -static int cdns_torrent_clk(struct cdns_torrent_phy *cdns_phy) +static int cdns_torrent_of_get_clk(struct cdns_torrent_phy *cdns_phy) { - struct device *dev = cdns_phy->dev; - unsigned long ref_clk_rate; - int ret; - - cdns_phy->clk = devm_clk_get(dev, "refclk"); + cdns_phy->clk = devm_clk_get(cdns_phy->dev, "refclk"); if (IS_ERR(cdns_phy->clk)) { - dev_err(dev, "phy ref clock not found\n"); + dev_err(cdns_phy->dev, "phy ref clock not found\n"); return PTR_ERR(cdns_phy->clk); } + return 0; +} + +static int cdns_torrent_clk(struct cdns_torrent_phy *cdns_phy) +{ + unsigned long ref_clk_rate; + int ret; + ret = clk_prepare_enable(cdns_phy->clk); if (ret) { dev_err(cdns_phy->dev, "Failed to prepare ref clock\n"); @@ -2776,6 +2780,10 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) if (ret) return ret; + ret = cdns_torrent_of_get_clk(cdns_phy); + if (ret) + goto clk_cleanup; + regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); if (!already_configured) { From patchwork Fri Jan 26 14:36:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532862 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 D3CBDC47DDF for ; Fri, 26 Jan 2024 15:50:14 +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=XFIfJb12BR1DYP0/A3Sm3rrC3ZNe1IDHwQme6ReS5po=; b=3lygYq1/HTJpJe glBI1z7wmLkhKx/6wOGs01JjRNnwDPUjcdgBd7G6NpJnPsuZFtISu6EP8jXXfgHTG5xwVnlfhQsBX dF/8kU8qJNauBL9EoTkWKALBySZTMtuFjq4zG/6XBd7r+pmzHm5iDEOFprd2kehdfJqN+Tm5owhij 9pBeuionwC8a8oSw8W5z0O1ED74xnqZmen5UiaWNBJcIHk2CbfibIMyDl/wSyaL5XRsWbDvIC1aHD TF4fXCJoodVzWQzCwQnNQkMbRolVjb5zsq8/gSDVgZI9Vkhy87e6iD+UER03DrZZRrG8EqssTW5O3 TVtephIbF0MNL4LQKIwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTOSq-00000004aEX-06G6; Fri, 26 Jan 2024 15:49:56 +0000 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLD-00000004N7S-2Nwo; Fri, 26 Jan 2024 14:38:04 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 53AE940010; Fri, 26 Jan 2024 14:37:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279877; 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=N4pB3p7l4Wmx1B5ikJiVEe+u1C2q0FduhxiC+T5adXA=; b=TeN/aDnJfTUIuoo9ivm9jVMsuO/VzY5HtvEAR7CtPNYbwre0S2xufDx1v4ZsqQWH/2dZeM fCIPcmyZFEJJ7ToNTW/PEKXq8Kbga6jQtXGrJjQ+JsmcXeNhJZQxP7+keT6Y7wGBAl6WuV HwgBbvlQ/ZKjDFPb24/n2VNyfXoZJnKjDZ5YueNMeiKKj3mLNiE/tP0tgdYaVrS/1+mxE/ 60asLrVla4YCkFaPdXr71TSE7713QC64S8tLbramUvYfxMCvxhCvFCcaFfPQbdCKcIyaIO g34ogRTUB7BTdUrSrrgtxy0PXFTAW4Lin9X6fI3X/ZCeD6k5QfILOeIZBKVjRA== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:51 +0100 Subject: [PATCH v2 09/15] phy: cadence-torrent: register resets even if the phy is already configured MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-9-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_063800_249394_8DA67837 X-CRM114-Status: GOOD ( 14.03 ) 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 Resets are needed during suspend and resume stages. So they shall be registered during the probe even the phy is already initialized. The function cdns_torrent_reset is renamed cdns_torrent_of_get_reset to make it clear. Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c index 94298ad9f875..100b58965558 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -2660,7 +2660,7 @@ static int cdns_torrent_clk_register(struct cdns_torrent_phy *cdns_phy) return 0; } -static int cdns_torrent_reset(struct cdns_torrent_phy *cdns_phy) +static int cdns_torrent_of_get_reset(struct cdns_torrent_phy *cdns_phy) { struct device *dev = cdns_phy->dev; @@ -2780,6 +2780,10 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) if (ret) return ret; + ret = cdns_torrent_of_get_reset(cdns_phy); + if (ret) + goto clk_cleanup; + ret = cdns_torrent_of_get_clk(cdns_phy); if (ret) goto clk_cleanup; @@ -2787,10 +2791,6 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); if (!already_configured) { - ret = cdns_torrent_reset(cdns_phy); - if (ret) - goto clk_cleanup; - ret = cdns_torrent_clk(cdns_phy); if (ret) goto clk_cleanup; From patchwork Fri Jan 26 14:36:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532861 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 1F945C47422 for ; Fri, 26 Jan 2024 15:50:06 +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=ImyAH/KcrSah+qfc5Tvukd8lNM7Sd+Bq+T77kymaYqM=; b=bvdj1QtIZf/Eqr ed6Q5xURV+6BghNJdD1ixOxKaSeIlJ5pgGBpJiZYo+3/hog0vsjWT9CCxcceuYfn01urhCBjiZiY3 EysZQ0W4yV4bhUIkOOF8DKGiz7meGnmAfkRgYnz75j9VHw35FbrpmPP7RFcjIUq2/KG6mdUmZaJ6Z iPJX63PD4NtweWkXxr5SzqPvryfG3b+suyjfVysC6uke0ySaKvwDTv/28eBAMklBMd917fAClWUZZ Kyizeoj5+aZ5l43peXhgv7yT0RRSCuO1aE9aOHyUHit4EWKmhCIIqzmGaMZT6yxgUoy8JnrKubbEn Dzmp7RA05FcYrqR0TRUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTOSq-00000004aEu-3lQC; Fri, 26 Jan 2024 15:49:56 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLF-00000004N9v-48nx; Fri, 26 Jan 2024 14:38:10 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id E7AEC40004; Fri, 26 Jan 2024 14:37:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279880; 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=gnJ23VCimbUGdQ0UqYdvjkkS5bTWXmYZASCtO+19bbI=; b=omPugX1EMe7mTs0frLWKo/wGBfGDaIEA1TfN/MRwstsklYAuD2hzuPBLSVCryf18B7O0PQ 9CTOOCCXUKgSqTAwtXU1lsu6N6ygaxt/rvbHk7degfPkvAhqnJ2hgxvS/NWZzqL7AMHwiC 8WBu6OC47A5RWIrHfPDW0p2NRhj+u2sq6uG1zXjMeTIGemppG31cP/2JWmO2J+w+jHqgIL FD/8Ks3A/lcndaGoZYZ4JRraL2PmemIHjiyOUHlY5OpY8SMYCqJsqxyYaubPA6lm2LMxrd fH59Ccb7zP2PGQVqu66GA0kLH99zn+lnM7Bd+Ok1XprhoVCtyVddRCKAFatGYg== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:52 +0100 Subject: [PATCH v2 10/15] phy: cadence-torrent: add already_configured to struct cdns_torrent_phy MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-10-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_063802_687732_CEA0DE5E X-CRM114-Status: GOOD ( 13.13 ) 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 already_configured to struct cdns_torrent_phy, so it can be used at differents stages. Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c index 100b58965558..a1e9d06453e6 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -358,6 +358,7 @@ struct cdns_torrent_phy { enum cdns_torrent_ref_clk ref_clk_rate; struct cdns_torrent_inst phys[MAX_NUM_LANES]; int nsubnodes; + int already_configured; const struct cdns_torrent_data *init_data; struct regmap *regmap_common_cdb; struct regmap *regmap_phy_pcs_common_cdb; @@ -2741,7 +2742,6 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) struct device_node *child; int ret, subnodes, node = 0, i; u32 total_num_lanes = 0; - int already_configured; u8 init_dp_regmap = 0; u32 phy_type; @@ -2788,9 +2788,9 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) if (ret) goto clk_cleanup; - regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); + regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &cdns_phy->already_configured); - if (!already_configured) { + if (!cdns_phy->already_configured) { ret = cdns_torrent_clk(cdns_phy); if (ret) goto clk_cleanup; @@ -2870,7 +2870,7 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) of_property_read_u32(child, "cdns,ssc-mode", &cdns_phy->phys[node].ssc_mode); - if (!already_configured) + if (!cdns_phy->already_configured) gphy = devm_phy_create(dev, child, &cdns_torrent_phy_ops); else gphy = devm_phy_create(dev, child, &noop_ops); @@ -2956,7 +2956,7 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) goto put_lnk_rst; } - if (cdns_phy->nsubnodes > 1 && !already_configured) { + if (cdns_phy->nsubnodes > 1 && !cdns_phy->already_configured) { ret = cdns_torrent_phy_configure_multilink(cdns_phy); if (ret) goto put_lnk_rst; From patchwork Fri Jan 26 14:36:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532777 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 2B0E7C47DDF for ; Fri, 26 Jan 2024 14:40:22 +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=PKLonVAyzp56Aucj/TjLek4ft9qRWQqXERv+S3OfaCI=; b=kXcGHg8Jr/NU3f I/0Y63yPEo+t29D8lxIQh3qUlp1ZQ2sh+ONAs3agbzDpUGlJZMUMsb2zNKJnGdDGJXG2wqGPaa70h +ry2vSo8HVSvbriYtEPAbQHBUYw0HP1TgIuIeAciLi++OoCHKNSFc5c1GK5AsGqED7QiWZn6JYzkZ +FsVQtK4smlp0K0AcB1LUujHxSgoRVFahpHLFAW/WAmDGy3HZbE71e30GL9g2eb/CH32xHZFJ0fVR JQKYUx957WxfarpxU8LKtF1K+AKa65Bx5HMGh3S3hGopzfAQPLSZHh5g4Bky4+ugwjM6OvanwMP0S h9p/e66N5P50IcHMdkHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNNG-00000004OSz-1BDI; Fri, 26 Jan 2024 14:40:06 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLI-00000004NCb-3UlV; Fri, 26 Jan 2024 14:38:14 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 7820340002; Fri, 26 Jan 2024 14:38:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279883; 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=CVpiN82f3zCgJBhjbVDcCVvrfuyt97XnSCcK895Im2c=; b=px9ryNFeMKXk7pLDO4zGLrbwm1wFyczUEnneQAqKIGrfrjUr0+iMPzdZD+DSV/HhXrvm4G Fj1B8tCtWRGRW9DuVLvzyERry+/UxdW35d2Tr/ggp3DZ1rxqWE1eMQUqk5NxQjFM8dBjC+ 8+amNhn/yVYUw7L5O08ZdgK2KphlobFp7MFg80hmoByGkwjZoZk/NtBcG8Gr5Bvcaean4e AXUbYFu+M0ut3S5yy10oXWkhUct5mfK+afGgbgLhwuOiLEVanQ0odHEqvHhyNmZnsuetnc wfpKolkCxyymi9vJJX3XORHm0S3nzL3YyKhImRqtzDRbj5yYn8E/9+mk2T1Rcw== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:53 +0100 Subject: [PATCH v2 11/15] phy: cadence-torrent: remove noop_ops phy operations MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-11-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_063805_483322_7A5D2CF7 X-CRM114-Status: GOOD ( 14.19 ) 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 Even if a PHY is already configured, the PHY operations are needed during resume stage, as the PHY is in reset state. The noop_ops PHY operations is removed to always have PHY operations. The already_configured flag is checked at the begening of init, configure and poweron operations to keep the already_configured behaviour. Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c index a1e9d06453e6..70413fca5776 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -1593,6 +1593,9 @@ static int cdns_torrent_dp_configure(struct phy *phy, struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); int ret; + if (cdns_phy->already_configured) + return 0; + ret = cdns_torrent_dp_verify_config(inst, &opts->dp); if (ret) { dev_err(&phy->dev, "invalid params for phy configure\n"); @@ -1628,6 +1631,12 @@ static int cdns_torrent_phy_on(struct phy *phy) u32 read_val; int ret; + if (cdns_phy->already_configured) { + /* Give 5ms to 10ms delay for the PIPE clock to be stable */ + usleep_range(5000, 10000); + return 0; + } + if (cdns_phy->nsubnodes == 1) { /* Take the PHY lane group out of reset */ reset_control_deassert(inst->lnk_rst); @@ -2306,6 +2315,9 @@ static int cdns_torrent_phy_init(struct phy *phy) u32 num_regs; int i, j; + if (cdns_phy->already_configured) + return 0; + if (cdns_phy->nsubnodes > 1) { if (phy_type == TYPE_DP) return cdns_torrent_dp_multilink_init(cdns_phy, inst, phy); @@ -2443,19 +2455,6 @@ static const struct phy_ops cdns_torrent_phy_ops = { .owner = THIS_MODULE, }; -static int cdns_torrent_noop_phy_on(struct phy *phy) -{ - /* Give 5ms to 10ms delay for the PIPE clock to be stable */ - usleep_range(5000, 10000); - - return 0; -} - -static const struct phy_ops noop_ops = { - .power_on = cdns_torrent_noop_phy_on, - .owner = THIS_MODULE, -}; - static int cdns_torrent_phy_configure_multilink(struct cdns_torrent_phy *cdns_phy) { @@ -2870,10 +2869,7 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) of_property_read_u32(child, "cdns,ssc-mode", &cdns_phy->phys[node].ssc_mode); - if (!cdns_phy->already_configured) - gphy = devm_phy_create(dev, child, &cdns_torrent_phy_ops); - else - gphy = devm_phy_create(dev, child, &noop_ops); + gphy = devm_phy_create(dev, child, &cdns_torrent_phy_ops); if (IS_ERR(gphy)) { ret = PTR_ERR(gphy); goto put_child; From patchwork Fri Jan 26 14:36:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532773 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 636FFC47DDF for ; Fri, 26 Jan 2024 14:39:37 +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=maPIyN0l2eWMdRNYfrezN6rAOFGnzhRljM0QU90I0K4=; b=TB8cdczAVZwDTo ku6ysMPJC0pNdeD2PribUUL4or0wNFPTw7CYlYpHNdgdqz5nJ2rujHJhWfZdRccJhXB2FUU8K9Yf6 yOAJOkfTRhsCe1gd6P1UrTdLEYa1wH8AF+CtyE63qbf+48VKl85UIkkEqHdwFnEBCD5wY3MoWmiLv DJisEYKcCsh45n3roJwIRFt1J6YWpYZdYmF5LXO71V6A9Y34U0W8OsY/PSzudHnD+Ns7meWhFVguH ToQ5YS6jfd/eXgbU2hckE/VVPYe4+AnWq3XB/y1PaNZrhDXGZyY+wkNNXxwfpkG/loegLid6ED3l/ X9o8x9gIl3294Ym+5SZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNMc-00000004O6b-0nME; Fri, 26 Jan 2024 14:39:26 +0000 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLL-00000004NEr-2vNZ; Fri, 26 Jan 2024 14:38:20 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 4A4CC40006; Fri, 26 Jan 2024 14:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279885; 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=L1Wa2mY0ZsxjqXg85U4q4TJn+2bPk0WDE8ok1dd694Q=; b=JrLwE1YhIpUGiROfu5Z8MPi46E2d+RrF/zQoKlXIwnH2k9kF57QC6Uex4mY2QvRtCzjED1 h8ga3G6Ua8bxI+VSx31SrVOL5Gb37K4odJvfa2R5S6UmyIBQJufg0s7rvzG7gqyKa1QLRO N8mOLdwusdyTbNFpSi2qjD1d1CK5Nmvyo1g6u7ygIBAWknlBtu4FZDIaXwc0pE7H9KUcBn Dnj2eyJNAAGWM6BanbHn9JmlVfO1XTMPgP2c+I4rKwCcjmRn+mXkA2yvsE0QvImileV9zB YEDcQlpKKu1W105qqUHJ59nYkHSZBsN2Xpqzg3BJCk1CPJukul03PadoC5w68w== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:54 +0100 Subject: [PATCH v2 12/15] phy: cadence-torrent: add suspend and resume support MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-12-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_063808_422534_FC5F4638 X-CRM114-Status: GOOD ( 14.55 ) 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 suspend and resume support. The already_configured flag is cleared during suspend stage to force the PHY initialization during the resume stage. Based on the work of Théo Lebrun Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c index 70413fca5776..5f4ecf371030 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -3006,6 +3006,59 @@ static void cdns_torrent_phy_remove(struct platform_device *pdev) cdns_torrent_clk_cleanup(cdns_phy); } +static int cdns_torrent_phy_suspend_noirq(struct device *dev) +{ + struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(dev); + int i; + + reset_control_assert(cdns_phy->phy_rst); + reset_control_assert(cdns_phy->apb_rst); + for (i = 0; i < cdns_phy->nsubnodes; i++) + reset_control_assert(cdns_phy->phys[i].lnk_rst); + + if (!cdns_phy->already_configured) + clk_disable_unprepare(cdns_phy->clk); + else + cdns_phy->already_configured = 0; + + return 0; +} + +static int cdns_torrent_phy_resume_noirq(struct device *dev) +{ + struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(dev); + int node = cdns_phy->nsubnodes; + int ret, i; + + ret = cdns_torrent_clk(cdns_phy); + if (ret) + goto clk_cleanup; + + /* Enable APB */ + reset_control_deassert(cdns_phy->apb_rst); + + if (cdns_phy->nsubnodes > 1) { + ret = cdns_torrent_phy_configure_multilink(cdns_phy); + if (ret) + goto put_lnk_rst; + } + + return 0; + +put_lnk_rst: + for (i = 0; i < node; i++) + reset_control_assert(cdns_phy->phys[i].lnk_rst); + reset_control_assert(cdns_phy->apb_rst); + clk_disable_unprepare(cdns_phy->clk); +clk_cleanup: + cdns_torrent_clk_cleanup(cdns_phy); + return ret; +} + +static DEFINE_NOIRQ_DEV_PM_OPS(cdns_torrent_phy_pm_ops, + cdns_torrent_phy_suspend_noirq, + cdns_torrent_phy_resume_noirq); + /* USB and DP link configuration */ static struct cdns_reg_pairs usb_dp_link_cmn_regs[] = { {0x0002, PHY_PLL_CFG}, @@ -4577,6 +4630,7 @@ static struct platform_driver cdns_torrent_phy_driver = { .driver = { .name = "cdns-torrent-phy", .of_match_table = cdns_torrent_phy_of_match, + .pm = pm_sleep_ptr(&cdns_torrent_phy_pm_ops), } }; module_platform_driver(cdns_torrent_phy_driver); From patchwork Fri Jan 26 14:36:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532776 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 682CBC47422 for ; Fri, 26 Jan 2024 14:40:20 +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=0lpFG8An9dtUlfC1CGrh3ANv56AOghu6IJFla9s1aAU=; b=d8UY2b4Ll06D13 51lVkauLn2vsRlS7+Ug3OXJsXzU8CbOIqYkc5muPo0GkENZlFmVTVcBOd8gwaINOmRfajGKUjYnFU LIX95kT3lxa5iwp3Vd/zKKYuZJmKNZ1EHssWE5YSbzfxzKFUSeqU8Hj2V6bcuat2fVkGZkwJMO7/w yQJ24MOBMu04QuBbbQNW4dPDEKesJwm10q+tQ524hBYT04dhe5AN1rbCSMHKE7RMk6vxSvIDP4yed P+EZp1Yls1dWFmVKHSaIX5iurmEbfLTBGMuu3kp0MRaICUtR3HJKU1X1lSFR2xcbfaUIOHIYY5ffF dkhiHpwPopsGWr/zOKlg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNNI-00000004OUI-0xdm; Fri, 26 Jan 2024 14:40:08 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLU-00000004NNd-2XGW; Fri, 26 Jan 2024 14:38:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=lcccQt60PbgXpfFYlxstnMtRY1ZKZ/mBq6e6WJEE79I=; b=m+nETqy7HmiqHB6hxbqW/zZaD1 m3A8zUpeGvs7oUspw5LMG1DjO5PGCVVyWFQuFo0yNMfWOKb+ywheDMnX6WRPRTxr/vjEQ+XllbdAm YtyeWi54qBxQPrmpaEd/RVQf8GbUragQVf9p7/S38V2vBSg5+4bAtOlwammkpynKg2IC8I3KsJPU/ gjtiJpA8SFtjVsSGgEaq7sVepCobCkHjEiOhnikc3EKRYeWwMa+b9ugnGG/u5Nj4oPSfldx3MGevz LvmtHdGzJ0m55HOWaExNyIDO2a0ZJ3TXWdzytO8d8KBWSWp3v+GwV8KGf4uYbR5siM7M/bzw5Fc+r WBoGXEQA==; Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLP-00000006554-44RQ; Fri, 26 Jan 2024 14:38:14 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id ECC734000C; Fri, 26 Jan 2024 14:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279888; 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=lcccQt60PbgXpfFYlxstnMtRY1ZKZ/mBq6e6WJEE79I=; b=NLM/H13Hw/PkB6gbvbxB84bToMata8sGd+8fNgBMPoCQyJBCFw7ww/kaf4etU5S8sBoSba qEXCwG03S1uvdeiaBigfX6iJ5K+LnYAemVXCIpZXWPF+Re9gI+xG5sjsYMPLHSNthiO8Mv Ox1r1V7G4eJL7pNLmSx7Ew6p21yyF9d12y0Fx+OJmSD8HUvazkJY8K6ZbI15tLVr4qtajv Rpim2RT9MllbJPXO9Bi9DugU+P79Qr0qvkKh1IjKFprTSYdMIbQoch6YWVhDADzwN3iNyM zdxtkji3XSDQCuK1XLF9te52H/2uQq2JGQAsYthPAoyMm5PVOTufu34ERyKZZg== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:55 +0100 Subject: [PATCH v2 13/15] PCI: cadence: add resume support to cdns_pcie_host_setup() MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-13-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_143812_576681_BA83E3FB X-CRM114-Status: GOOD ( 15.83 ) 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 From: Théo Lebrun That function mixes probe structure init and hardware config. The whole hardware config part must be done at resume after a suspend to ram. We therefore pass it a boolean flag determining if we are at probe or at resume. Signed-off-by: Théo Lebrun Signed-off-by: Thomas Richard --- drivers/pci/controller/cadence/pci-j721e.c | 2 +- drivers/pci/controller/cadence/pcie-cadence-host.c | 49 ++++++++++++---------- drivers/pci/controller/cadence/pcie-cadence-plat.c | 2 +- drivers/pci/controller/cadence/pcie-cadence.h | 4 +- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index 2c87e7728a65..9b343a46da11 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -509,7 +509,7 @@ static int j721e_pcie_probe(struct platform_device *pdev) gpiod_set_value_cansleep(gpiod, 1); } - ret = cdns_pcie_host_setup(rc); + ret = cdns_pcie_host_setup(rc, true); if (ret < 0) { clk_disable_unprepare(pcie->refclk); goto err_pcie_setup; diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/pci/controller/cadence/pcie-cadence-host.c index 5b14f7ee3c79..dd4d876a9138 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-host.c +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c @@ -497,14 +497,14 @@ static int cdns_pcie_host_init(struct device *dev, return cdns_pcie_host_init_address_translation(rc); } -int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) +int cdns_pcie_host_setup(struct cdns_pcie_rc *rc, bool probe) { struct device *dev = rc->pcie.dev; struct platform_device *pdev = to_platform_device(dev); struct device_node *np = dev->of_node; struct pci_host_bridge *bridge; enum cdns_pcie_rp_bar bar; - struct cdns_pcie *pcie; + struct cdns_pcie *pcie = &rc->pcie; struct resource *res; int ret; @@ -512,26 +512,27 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) if (!bridge) return -ENOMEM; - pcie = &rc->pcie; - pcie->is_rc = true; + if (probe) { + pcie->is_rc = true; - rc->vendor_id = 0xffff; - of_property_read_u32(np, "vendor-id", &rc->vendor_id); + rc->vendor_id = 0xffff; + of_property_read_u32(np, "vendor-id", &rc->vendor_id); - rc->device_id = 0xffff; - of_property_read_u32(np, "device-id", &rc->device_id); + rc->device_id = 0xffff; + of_property_read_u32(np, "device-id", &rc->device_id); - pcie->reg_base = devm_platform_ioremap_resource_byname(pdev, "reg"); - if (IS_ERR(pcie->reg_base)) { - dev_err(dev, "missing \"reg\"\n"); - return PTR_ERR(pcie->reg_base); - } + pcie->reg_base = devm_platform_ioremap_resource_byname(pdev, "reg"); + if (IS_ERR(pcie->reg_base)) { + dev_err(dev, "missing \"reg\"\n"); + return PTR_ERR(pcie->reg_base); + } - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); - rc->cfg_base = devm_pci_remap_cfg_resource(dev, res); - if (IS_ERR(rc->cfg_base)) - return PTR_ERR(rc->cfg_base); - rc->cfg_res = res; + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); + rc->cfg_base = devm_pci_remap_cfg_resource(dev, res); + if (IS_ERR(rc->cfg_base)) + return PTR_ERR(rc->cfg_base); + rc->cfg_res = res; + } if (rc->quirk_detect_quiet_flag) cdns_pcie_detect_quiet_min_delay_set(&rc->pcie); @@ -555,12 +556,14 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) if (ret) return ret; - if (!bridge->ops) - bridge->ops = &cdns_pcie_host_ops; + if (probe) { + if (!bridge->ops) + bridge->ops = &cdns_pcie_host_ops; - ret = pci_host_probe(bridge); - if (ret < 0) - goto err_init; + ret = pci_host_probe(bridge); + if (ret < 0) + goto err_init; + } return 0; diff --git a/drivers/pci/controller/cadence/pcie-cadence-plat.c b/drivers/pci/controller/cadence/pcie-cadence-plat.c index 0456845dabb9..071423091668 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-plat.c +++ b/drivers/pci/controller/cadence/pcie-cadence-plat.c @@ -86,7 +86,7 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) goto err_get_sync; } - ret = cdns_pcie_host_setup(rc); + ret = cdns_pcie_host_setup(rc, true); if (ret) goto err_init; } else { diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h index 373cb50fcd15..3b0da889ed64 100644 --- a/drivers/pci/controller/cadence/pcie-cadence.h +++ b/drivers/pci/controller/cadence/pcie-cadence.h @@ -515,11 +515,11 @@ static inline bool cdns_pcie_link_up(struct cdns_pcie *pcie) } #ifdef CONFIG_PCIE_CADENCE_HOST -int cdns_pcie_host_setup(struct cdns_pcie_rc *rc); +int cdns_pcie_host_setup(struct cdns_pcie_rc *rc, bool probe); void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn, int where); #else -static inline int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) +static inline int cdns_pcie_host_setup(struct cdns_pcie_rc *rc, bool probe) { return 0; } From patchwork Fri Jan 26 14:36:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532774 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 AD2CFC47DDF for ; Fri, 26 Jan 2024 14:39:50 +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=Ey0aVeQj9OE0XYkTe4naytvucePW3+zz15b+6ABKGDo=; b=sJszvnb0NLji8H JQc/t+fV6AHFBKakzLa7ORrUKnAolCQ4j8JBi+cth6cRKCfGtDF4oXL6TlOl65l4PKi2nPNhmtbC/ I5Bgh3M6XZ/kK8e6XuUZ81cwjTlkuCw1B7gW6PfT2SNVHwaWQx4JL6VcvgbDfRnT1qfQSfV2eD0iC 6H9jQiiymMgJjP+U5fkkouAl6VR+gksb/P03dMPmxlxbj4NjqhC4ToJgXAHTxzT2kvbUkHRFjoMzq Vbq00wpu8u62rQKJVbdwX0kjrwGtizH7lccuVOSlZ+U00aNz/Ki2hB2fMFUfGHS2jrH53l8j8a1a/ v6+gag14mgWZHSMAaTEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNMr-00000004OEg-35YG; Fri, 26 Jan 2024 14:39:41 +0000 Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLR-00000004NJy-124H; Fri, 26 Jan 2024 14:38:27 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id A193640010; Fri, 26 Jan 2024 14:38:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279891; 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=0in7eUMCy1CUgdfa3NkgNoUarIRy00PjQmN5k2XOfW8=; b=XDC7cnmSoyMATdXpU1tgJyrpCGrrYHdLBskthJV5CEbt+4EavYPPm6csGnBGXzgYekdVL8 E0BQ3R6CohJrEbsZ5/Jp78XV1Kf0+VloyBOdyiDXrEelIyOKn8DSXyzfCCF4ZoJy82Nsnc DLJQ726Avyas/qGdXAwuyxPzCSkeApHT20xNdPNcMKgnhn93AvbfW7dMDNouZTS3eG2ePZ 818Qvb7yNhR2wLyxK3JucldVg7POKnMmQGAx4CB6NhbIN5+Lq0Vq/Tw6YEM7MTx3tsXUUw DgvTId9KkB9BrkLAqWPBWdQarOBiBKqUq9Tie7n6H7+0gG4lqaM/sBOq1xWR7g== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:56 +0100 Subject: [PATCH v2 14/15] PCI: j721e: add reset GPIO to struct j721e_pcie MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-14-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_063814_062796_9DDE7228 X-CRM114-Status: GOOD ( 13.78 ) 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 From: Théo Lebrun Add reset GPIO to struct j721e_pcie, so it can be used at suspend and resume stages. Signed-off-by: Théo Lebrun Signed-off-by: Thomas Richard --- drivers/pci/controller/cadence/pci-j721e.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index 9b343a46da11..477275d72257 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -54,6 +54,7 @@ struct j721e_pcie { struct clk *refclk; u32 mode; u32 num_lanes; + struct gpio_desc *reset_gpio; void __iomem *user_cfg_base; void __iomem *intd_cfg_base; u32 linkdown_irq_regfield; @@ -359,7 +360,6 @@ static int j721e_pcie_probe(struct platform_device *pdev) struct j721e_pcie *pcie; struct cdns_pcie_rc *rc = NULL; struct cdns_pcie_ep *ep = NULL; - struct gpio_desc *gpiod; void __iomem *base; struct clk *clk; u32 num_lanes; @@ -468,9 +468,9 @@ static int j721e_pcie_probe(struct platform_device *pdev) switch (mode) { case PCI_MODE_RC: - gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); - if (IS_ERR(gpiod)) { - ret = PTR_ERR(gpiod); + pcie->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); + if (IS_ERR(pcie->reset_gpio)) { + ret = PTR_ERR(pcie->reset_gpio); if (ret != -EPROBE_DEFER) dev_err(dev, "Failed to get reset GPIO\n"); goto err_get_sync; @@ -504,9 +504,9 @@ static int j721e_pcie_probe(struct platform_device *pdev) * mode is selected while enabling the PHY. So deassert PERST# * after 100 us. */ - if (gpiod) { + if (pcie->reset_gpio) { usleep_range(100, 200); - gpiod_set_value_cansleep(gpiod, 1); + gpiod_set_value_cansleep(pcie->reset_gpio, 1); } ret = cdns_pcie_host_setup(rc, true); From patchwork Fri Jan 26 14:36:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 13532778 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 5FF6CC47422 for ; Fri, 26 Jan 2024 14:40:24 +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=N7loXEykSqT1shDEfL694QgrgM8W1nipPrRVY9qutVY=; b=4ois/k1e1da7E8 muA7DzxNhXkkFW1QON90k5SIs9hlpjNnIOe89oasRJEYtIeYw+lSlt/tH1m+mYQDEJ8Q5ZYyEps3v GH9gDj/2qmR8kcc5odCUdbxU+Y7DBSofOagOFRtJFJZSiMO6v+OKP7Phd33j2pnEmb+N87G3Famom ZvIUQKgP4uzk9ADEXTGK6Vn8Aeu1BzZ0hf+AFa1SqJ+TZrZ0TV83/BeR6ynJ7y54+nTho+P59FhE8 AGSdHSHhYV1NWoJI9GP2apBDp6wXDHHk6UHJT9G+c+hEQf6iT8IzH/itk4x33xd7r2xbpLVHrXR9e AnDa8QdDnNWDB/f3XclA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNNK-00000004OVc-0EY5; Fri, 26 Jan 2024 14:40:10 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLa-00000004NSd-1rcX; Fri, 26 Jan 2024 14:38:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=DV+PfVFG+B6uq9zkwyO5cQW010WYXqAyimrtCyB36hg=; b=hRbnnQA0w4Qmu1bMAmKYgR1v0J 7XC2Hi2AqBt8qiH+7GibLAh1UCbIkFz5MgwdhejKg+eMBtSPbeFc/KubVFy+t6ArZBu6BvhvlNaew a6uzPIcg0BRBoUeYpSU6ACiNJFp+LbdDCMrsZxq0mfeu7RXiDRq07JTq4hqmzh1atZ5Z0Zi+Fvg4W q5Ze3x4kCLqLwN2TSZBuDTp10pEWtlEILeQq+avkZSGaWGqI9lWSZb8AexSxw7Bc6bfTc4P7IhSkX G6K5YE2gGin+GugjDDwsVjqzppCejxfMAjVgoB30kIRhFIOCvPCT1QvAYBwnGrEX0XWpo/00E43jh A2A3qSXQ==; Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTNLT-0000000655r-1X7o; Fri, 26 Jan 2024 14:38:19 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 5B40B40004; Fri, 26 Jan 2024 14:38:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279894; 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=DV+PfVFG+B6uq9zkwyO5cQW010WYXqAyimrtCyB36hg=; b=PIftpjT+y/RyuehPANnuJOuPqUqHRnH5Lr5aRuer/H/+YHouEsFoSxIGW5TWrtVINGTxRH ChZoIqNqYtEejdsgdQDaQBhOsPDmi8m7+UmpihImWXSHTxs6GPuPV32pJUEc28Ji89R6Pw AF2EBRI5o4O0X3EJsmmgWpKjbrgCOMX4AuoNn/OCclmaTI/TQG1oHoss+CWbXQDpW/e6V2 j1y/BQ8thUsJHI/aTN0KtaboXeccHA3gnDhzBsY7ymkiXVUvJ111h3MTOKGtLjpMZ/mgve pLY3jvhniQLLuvFL3rGXn7K3DVX1QS0fUJgc5pNGiRG1Hv0yRpbfa6mc6pYefw== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:57 +0100 Subject: [PATCH v2 15/15] PCI: j721e: add suspend and resume support MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v2-15-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_143815_787740_9B440D78 X-CRM114-Status: GOOD ( 17.83 ) 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 From: Théo Lebrun Add suspend and resume support. Only the rc mode is supported. During the suspend stage PERST# is asserted, then deasserted during the resume stage. Signed-off-by: Théo Lebrun Signed-off-by: Thomas Richard --- drivers/pci/controller/cadence/pci-j721e.c | 79 ++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index 477275d72257..668d98422c4d 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -6,6 +6,7 @@ * Author: Kishon Vijay Abraham I */ +#include #include #include #include @@ -18,10 +19,13 @@ #include #include #include +#include #include "../../pci.h" #include "pcie-cadence.h" +#define cdns_pcie_to_rc(p) container_of(p, struct cdns_pcie_rc, pcie) + #define ENABLE_REG_SYS_2 0x108 #define STATUS_REG_SYS_2 0x508 #define STATUS_CLR_REG_SYS_2 0x708 @@ -554,6 +558,80 @@ static void j721e_pcie_remove(struct platform_device *pdev) pm_runtime_disable(dev); } +static int j721e_pcie_suspend_noirq(struct device *dev) +{ + struct j721e_pcie *pcie = dev_get_drvdata(dev); + + if (pcie->mode == PCI_MODE_RC) { + gpiod_set_value_cansleep(pcie->reset_gpio, 0); + clk_disable_unprepare(pcie->refclk); + } + + cdns_pcie_disable_phy(pcie->cdns_pcie); + + return 0; +} + +static int j721e_pcie_resume_noirq(struct device *dev) +{ + struct j721e_pcie *pcie = dev_get_drvdata(dev); + struct cdns_pcie *cdns_pcie = pcie->cdns_pcie; + int ret; + + ret = j721e_pcie_ctrl_init(pcie); + if (ret < 0) { + dev_err(dev, "j721e_pcie_ctrl_init failed\n"); + return ret; + } + + j721e_pcie_config_link_irq(pcie); + + /* + * This is not called explicitly in the probe, it is called by + * cdns_pcie_init_phy. + */ + ret = cdns_pcie_enable_phy(pcie->cdns_pcie); + if (ret < 0) { + dev_err(dev, "cdns_pcie_enable_phy failed\n"); + return -ENODEV; + } + + if (pcie->mode == PCI_MODE_RC) { + struct cdns_pcie_rc *rc = cdns_pcie_to_rc(cdns_pcie); + + ret = clk_prepare_enable(pcie->refclk); + if (ret < 0) { + dev_err(dev, "clk_prepare_enable failed\n"); + return -ENODEV; + } + + /* + * "Power Sequencing and Reset Signal Timings" table in + * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 3.0 + * indicates PERST# should be deasserted after minimum of 100us + * once REFCLK is stable. The REFCLK to the connector in RC + * mode is selected while enabling the PHY. So deassert PERST# + * after 100 us. + */ + if (pcie->reset_gpio) { + usleep_range(100, 200); + gpiod_set_value_cansleep(pcie->reset_gpio, 1); + } + + ret = cdns_pcie_host_setup(rc, false); + if (ret < 0) { + clk_disable_unprepare(pcie->refclk); + return ret; + } + } + + return 0; +} + +static DEFINE_NOIRQ_DEV_PM_OPS(j721e_pcie_pm_ops, + j721e_pcie_suspend_noirq, + j721e_pcie_resume_noirq); + static struct platform_driver j721e_pcie_driver = { .probe = j721e_pcie_probe, .remove_new = j721e_pcie_remove, @@ -561,6 +639,7 @@ static struct platform_driver j721e_pcie_driver = { .name = "j721e-pcie", .of_match_table = of_j721e_pcie_match, .suppress_bind_attrs = true, + .pm = pm_sleep_ptr(&j721e_pcie_pm_ops), }, }; builtin_platform_driver(j721e_pcie_driver);