From: Srikanth Boyapally <srikanth.boyapally@amd.com>
To: Pratyush Yadav <pratyush@kernel.org>,
Michael Walle <mwalle@kernel.org>,
Takahiro Kuwano <takahiro.kuwano@infineon.com>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
<michal.simek@amd.com>, <git@amd.com>,
Srikanth Boyapally <srikanth.boyapally@amd.com>,
Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
Subject: [PATCH v2 1/2] mtd: spi-nor: Store GPIO info for resetting device during resume
Date: Tue, 1 Dec 2026 18:08:24 +0530 [thread overview]
Message-ID: <20261201-ospi_reset_v2-v2-1-ceb06548d531@amd.com> (raw)
In-Reply-To: <20261201-ospi_reset_v2-v2-0-ceb06548d531@amd.com>
From: Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
Upon resume, SPI-NOR triggers the hardware reset API to reset the flash
device by toggling the GPIO. This step is necessary because after resume,
the flash needs to be put in SDR mode. To facilitate this, SPI-NOR needs
GPIO information to reset the flash device.
Acquire the optional reset GPIO once in spi_nor_scan() and retain it in a
new gpio_desc member of struct spi_nor, so that spi_nor_hw_reset() can
use it later without looking it up again.
Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
Signed-off-by: Srikanth Boyapally <srikanth.boyapally@amd.com>
---
drivers/mtd/spi-nor/core.c | 19 +++++++++----------
include/linux/mtd/spi-nor.h | 2 ++
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index bc9c413df8df..0e0960bc6f63 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -3383,13 +3383,12 @@ static int spi_nor_set_mtd_info(struct spi_nor *nor)
return 0;
}
-static int spi_nor_hw_reset(struct spi_nor *nor)
+static void spi_nor_hw_reset(struct spi_nor *nor)
{
- struct gpio_desc *reset;
+ struct gpio_desc *reset = nor->reset;
- reset = devm_gpiod_get_optional(nor->dev, "reset", GPIOD_OUT_LOW);
- if (IS_ERR_OR_NULL(reset))
- return PTR_ERR_OR_ZERO(reset);
+ if (!reset)
+ return;
/*
* Experimental delay values by looking at different flash device
@@ -3400,8 +3399,6 @@ static int spi_nor_hw_reset(struct spi_nor *nor)
usleep_range(100, 150);
gpiod_set_value_cansleep(reset, 0);
usleep_range(1000, 1200);
-
- return 0;
}
int spi_nor_scan(struct spi_nor *nor, const char *name,
@@ -3434,9 +3431,11 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
if (!nor->bouncebuf)
return -ENOMEM;
- ret = spi_nor_hw_reset(nor);
- if (ret)
- return ret;
+ nor->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
+ if (IS_ERR(nor->reset))
+ return PTR_ERR(nor->reset);
+
+ spi_nor_hw_reset(nor);
info = spi_nor_get_flash_info(nor, name);
if (IS_ERR(info))
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index b3e3c6b10186..79775d5d8d0a 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -374,6 +374,7 @@ struct spi_nor_flash_parameter;
* settings that can be overwritten by the spi_nor_fixups
* hooks, or dynamically when parsing the SFDP tables.
* @dirmap: pointers to struct spi_mem_dirmap_desc for reads/writes.
+ * @reset: optional GPIO descriptor used to reset the flash device.
* @priv: pointer to the private data
*/
struct spi_nor {
@@ -415,6 +416,7 @@ struct spi_nor {
struct spi_mem_dirmap_desc *rdesc;
struct spi_mem_dirmap_desc *wdesc;
} dirmap;
+ struct gpio_desc *reset;
void *priv;
};
--
2.43.0
next prev parent reply other threads:[~2026-12-01 12:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 12:38 [PATCH v2 0/2] mtd: spi-nor: Add flash reset support " Srikanth Boyapally
2026-12-01 12:38 ` Srikanth Boyapally [this message]
2026-12-01 12:38 ` [PATCH v2 2/2] mtd: spi-nor: Reset flash device on resume Srikanth Boyapally
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201-ospi_reset_v2-v2-1-ceb06548d531@amd.com \
--to=srikanth.boyapally@amd.com \
--cc=amit.kumar-mahapatra@amd.com \
--cc=git@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=michal.simek@amd.com \
--cc=miquel.raynal@bootlin.com \
--cc=mwalle@kernel.org \
--cc=pratyush@kernel.org \
--cc=richard@nod.at \
--cc=takahiro.kuwano@infineon.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®