From patchwork Mon Apr 17 09:10:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhruva Gole X-Patchwork-Id: 13213485 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 50C2AC77B72 for ; Mon, 17 Apr 2023 09:11:36 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PR4SvcoT/pNaYrIdC9/c2U5+eLDWhKr8Z5rc3wYxmkQ=; b=WV9LmIzF75wNxl hlYhz4d3jT3wZXNgeUbcDaUXJN6dYWebF2JWbDhLXpaGty8q4bVmpAOS5Nw1pyfw2UZfynI13sPk1 YtpoccWoPAJy7Sp4/xBhcpPtIhugZT1cWMXawRgrU6qr5+kTKw+UeJObrMeNDyLcJUdKbvHwDaFve yqTP1llDsEl1nSziYkBJN7TcfmqvoymFBf++LqSViAnnPtQ5lc+eq2Pur6RLNqiWOwziaB7D4tNoP yFYrhc0ieZquO+1XW033R1p0UJ8tZBoLubhbSo5nnWnw0aIhy5JI1d7PH07H4DAwdfk4mjE7kbYtt UxeDFZ0q3SrnG6RRKS6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poKsr-00FTi3-34; Mon, 17 Apr 2023 09:10:49 +0000 Received: from fllv0016.ext.ti.com ([198.47.19.142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poKso-00FTh2-0t for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 09:10:47 +0000 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 33H9Aeeo074935; Mon, 17 Apr 2023 04:10:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1681722640; bh=djsfRLtJu+oPMbnsgsWcD0rMfU9D4nVXsTjgpcSvFLk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ArqxgP/dStID3aR0LcMffpiac4Vdo+UkWv5MJndxIYM4zTiW+KOtwm4awpRgLj+gm GE76uSAyI5KgryZ7H36ukQWkT9YJvPe9miwj1PY/50mU/eAS66uBlAiHulLVg22+eD cUzvkdYqvOuUxFxbBHL+sBLDgZ22B3fgvw9msnYU= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 33H9AeLI005866 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Apr 2023 04:10:40 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Mon, 17 Apr 2023 04:10:40 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Mon, 17 Apr 2023 04:10:40 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 33H9Adj2102013; Mon, 17 Apr 2023 04:10:39 -0500 From: Dhruva Gole To: Mark Brown CC: Dhruva Gole , Vaishnav Achath , Vignesh , Apurva Nandan , , Subject: [PATCH 1/2] spi: cadence-quadspi: use macro SIMPLE_DEV_PM_OPS Date: Mon, 17 Apr 2023 14:40:26 +0530 Message-ID: <20230417091027.966146-2-d-gole@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417091027.966146-1-d-gole@ti.com> References: <20230417091027.966146-1-d-gole@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_021046_385586_CC1FEE5B X-CRM114-Status: UNSURE ( 9.77 ) 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 Using this macro makes the code more readable. It also inits the members of dev_pm_ops in the following manner without us explicitly needing to: .suspend = cqspi_suspend, \ .resume = cqspi_resume, \ .freeze = suspend_fn, \ .thaw = resume_fn, \ .poweroff = suspend_fn, \ .restore = resume_fn, Fixes: 140623410536 ("mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller") Signed-off-by: Dhruva Gole --- drivers/spi/spi-cadence-quadspi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c index 79ab7e309644..d47e954fe809 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1829,10 +1829,7 @@ static int cqspi_resume(struct device *dev) return 0; } -static const struct dev_pm_ops cqspi__dev_pm_ops = { - .suspend = cqspi_suspend, - .resume = cqspi_resume, -}; +static SIMPLE_DEV_PM_OPS(cqspi__dev_pm_ops, cqspi_suspend, cqspi_resume); #define CQSPI_DEV_PM_OPS (&cqspi__dev_pm_ops) #else From patchwork Mon Apr 17 09:10:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhruva Gole X-Patchwork-Id: 13213486 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 1670EC77B76 for ; Mon, 17 Apr 2023 09:11:38 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BJDCi2GgZf5BfT2JPokN9WqP638DAksjD2e2p0uEoBs=; b=oOd4LAEhoIyrL+ i18s2NQ63R8Kssyvu70ptls/moEm3PXZZAojRdDKYT30D2akw4zhwQuOqCAt3Qu9tOewk8i3LKmDf 76iAE4OqJMM1CiTWp5KPt9pnallVFAO3jIRwXDdP2799qFMtX1M5adNGyk0suDLdgoM2CCcsCVNSd 658KbA5HXH4401Hdbsf2U9UPSP7t8F5LtwXEwy4II2WTL7huY2piGdU9Ryc4yAZztRwewDw0XEUEb vmb1zL2SGcQpJgrx+nB9b3Xs21M0jUEBbVrhAt5COgd/u0fyfRPxJ4JgUicOJboVrWO7tzJxjFXMs 7+0sySo9VxKF4FzPmlCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poKsx-00FTj9-0F; Mon, 17 Apr 2023 09:10:55 +0000 Received: from fllv0015.ext.ti.com ([198.47.19.141]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poKsu-00FTiQ-2y for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 09:10:54 +0000 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 33H9Ahdx054374; Mon, 17 Apr 2023 04:10:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1681722643; bh=UXcdFetYc0x4zAHUqoGiOI+equY21mfPsG8/IYPhF4g=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=on/KdjPWVSrKcz5q562rAXd+QSsL4fcheY3gRNF3ZG+jnrb03OE10MWBE8zk8PbG0 07jhpfTN58cROBvTHdpSt9kszW5uNRJ0KsB3Fmm4nMSrN4Ti0d7rgqnVrRpQV75Igt PlbP18YV2EPPIf0OzqoorddfBgQq2KBjJxY7EjqQ= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 33H9AhPH107594 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 Apr 2023 04:10:43 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Mon, 17 Apr 2023 04:10:43 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Mon, 17 Apr 2023 04:10:43 -0500 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 33H9Aglp102040; Mon, 17 Apr 2023 04:10:42 -0500 From: Dhruva Gole To: Mark Brown CC: Dhruva Gole , Vaishnav Achath , Vignesh , Apurva Nandan , , Subject: [PATCH 2/2] spi: cadence-quadspi: fix suspend-resume implementations Date: Mon, 17 Apr 2023 14:40:27 +0530 Message-ID: <20230417091027.966146-3-d-gole@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417091027.966146-1-d-gole@ti.com> References: <20230417091027.966146-1-d-gole@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_021053_036405_B6312549 X-CRM114-Status: GOOD ( 11.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 The cadence QSPI driver misbehaves after performing a full system suspend resume: ... spi-nor spi0.0: resume() failed ... This results in a flash connected via OSPI interface after system suspend- resume to be unusable. fix these suspend and resume functions. Fixes: 140623410536 ("mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller") Signed-off-by: Dhruva Gole --- drivers/spi/spi-cadence-quadspi.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c index d47e954fe809..91908e8cf92e 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1816,17 +1816,30 @@ static void cqspi_remove(struct platform_device *pdev) static int cqspi_suspend(struct device *dev) { struct cqspi_st *cqspi = dev_get_drvdata(dev); + struct spi_master *master = dev_get_drvdata(dev); + int ret; + ret = spi_master_suspend(master); cqspi_controller_enable(cqspi, 0); - return 0; + + clk_disable_unprepare(cqspi->clk); + + return ret; } static int cqspi_resume(struct device *dev) { struct cqspi_st *cqspi = dev_get_drvdata(dev); + struct spi_master *master = dev_get_drvdata(dev); - cqspi_controller_enable(cqspi, 1); - return 0; + clk_prepare_enable(cqspi->clk); + cqspi_wait_idle(cqspi); + cqspi_controller_init(cqspi); + + cqspi->current_cs = -1; + cqspi->sclk = 0; + + return spi_master_resume(master); } static SIMPLE_DEV_PM_OPS(cqspi__dev_pm_ops, cqspi_suspend, cqspi_resume);