* [PATCH v2 0/2] mtd: spi-nor: Add flash device reset support
@ 2022-09-01 7:29 Sai Krishna Potthuri
2022-09-01 7:29 ` [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property Sai Krishna Potthuri
2022-09-01 7:29 ` [PATCH v2 2/2] mtd: spi-nor: Add support for flash reset Sai Krishna Potthuri
0 siblings, 2 replies; 9+ messages in thread
From: Sai Krishna Potthuri @ 2022-09-01 7:29 UTC (permalink / raw)
To: Tudor Ambarus, Pratyush Yadav, Michael Walle, Miquel Raynal,
Richard Weinberger, Vignesh Raghavendra, Rob Herring,
Krzysztof Kozlowski
Cc: devicetree, linux-mtd, linux-kernel, saikrishna12468, git,
Sai Krishna Potthuri
Update spi-nor dt-binding and spi-nor core to support flash device
reset using reset-gpios property.
changes in v2:
-> 1/2 - Updated the description of the 'reset-gpios' property.
-> 2/2 - Updated the reset sequence to match with "active low" flag in
device-tree, also removed unwanted comments.
-> 2/2 - Updated the logic to perform the flash reset unconditionally.
-> 2/2 - Updated the delay values to support more number of flash devices.
Sai Krishna Potthuri (2):
dt-bindings: mtd: spi-nor: Add reset-gpios property
mtd: spi-nor: Add support for flash reset
.../bindings/mtd/jedec,spi-nor.yaml | 6 +++++
drivers/mtd/spi-nor/core.c | 25 +++++++++++++++++++
2 files changed, 31 insertions(+)
--
2.17.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property
2022-09-01 7:29 [PATCH v2 0/2] mtd: spi-nor: Add flash device reset support Sai Krishna Potthuri
@ 2022-09-01 7:29 ` Sai Krishna Potthuri
2022-09-01 7:56 ` Krzysztof Kozlowski
2022-09-01 7:29 ` [PATCH v2 2/2] mtd: spi-nor: Add support for flash reset Sai Krishna Potthuri
1 sibling, 1 reply; 9+ messages in thread
From: Sai Krishna Potthuri @ 2022-09-01 7:29 UTC (permalink / raw)
To: Tudor Ambarus, Pratyush Yadav, Michael Walle, Miquel Raynal,
Richard Weinberger, Vignesh Raghavendra, Rob Herring,
Krzysztof Kozlowski
Cc: devicetree, linux-mtd, linux-kernel, saikrishna12468, git,
Sai Krishna Potthuri
SPI-NOR flashes have RESET pin which can be toggled using GPIO
controller, for those platforms reset-gpios property can be used to
reset the flash device.
Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
---
Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml b/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
index 7149784a36ac..4e98f78be750 100644
--- a/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
+++ b/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
@@ -70,6 +70,12 @@ properties:
be used on such systems, to denote the absence of a reliable reset
mechanism.
+ reset-gpios:
+ description:
+ A GPIO line connected to the RESET (active low) signal of the device.
+ If "broken-flash-reset" is present then having this property does not
+ make any difference.
+
partitions:
type: object
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/2] mtd: spi-nor: Add support for flash reset
2022-09-01 7:29 [PATCH v2 0/2] mtd: spi-nor: Add flash device reset support Sai Krishna Potthuri
2022-09-01 7:29 ` [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property Sai Krishna Potthuri
@ 2022-09-01 7:29 ` Sai Krishna Potthuri
2022-09-01 7:39 ` Michael Walle
1 sibling, 1 reply; 9+ messages in thread
From: Sai Krishna Potthuri @ 2022-09-01 7:29 UTC (permalink / raw)
To: Tudor Ambarus, Pratyush Yadav, Michael Walle, Miquel Raynal,
Richard Weinberger, Vignesh Raghavendra, Rob Herring,
Krzysztof Kozlowski
Cc: devicetree, linux-mtd, linux-kernel, saikrishna12468, git,
Sai Krishna Potthuri
Add support for spi-nor flash reset via GPIO controller by reading the
reset-gpio property. If there is a valid GPIO specifier then reset will
be performed by asserting and deasserting the GPIO using gpiod APIs
otherwise it will not perform any operation.
Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
---
drivers/mtd/spi-nor/core.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index f2c64006f8d7..a78ab9bae2be 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2933,6 +2933,27 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor)
mtd->_put_device = spi_nor_put_device;
}
+static int spi_nor_hw_reset(struct spi_nor *nor)
+{
+ struct gpio_desc *reset;
+
+ reset = devm_gpiod_get_optional(nor->dev, "reset", GPIOD_OUT_LOW);
+ if (IS_ERR_OR_NULL(reset))
+ return PTR_ERR_OR_ZERO(reset);
+
+ /*
+ * Experimental delay values by looking at different flash device
+ * vendors datasheets.
+ */
+ usleep_range(1, 5);
+ gpiod_set_value_cansleep(reset, 1);
+ 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,
const struct spi_nor_hwcaps *hwcaps)
{
@@ -2965,6 +2986,10 @@ 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;
+
info = spi_nor_get_flash_info(nor, name);
if (IS_ERR(info))
return PTR_ERR(info);
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] mtd: spi-nor: Add support for flash reset
2022-09-01 7:29 ` [PATCH v2 2/2] mtd: spi-nor: Add support for flash reset Sai Krishna Potthuri
@ 2022-09-01 7:39 ` Michael Walle
0 siblings, 0 replies; 9+ messages in thread
From: Michael Walle @ 2022-09-01 7:39 UTC (permalink / raw)
To: Sai Krishna Potthuri
Cc: Tudor Ambarus, Pratyush Yadav, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski,
devicetree, linux-mtd, linux-kernel, saikrishna12468, git
Am 2022-09-01 09:29, schrieb Sai Krishna Potthuri:
> Add support for spi-nor flash reset via GPIO controller by reading the
> reset-gpio property. If there is a valid GPIO specifier then reset will
> be performed by asserting and deasserting the GPIO using gpiod APIs
> otherwise it will not perform any operation.
>
> Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Just one comment, see below
> ---
> drivers/mtd/spi-nor/core.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index f2c64006f8d7..a78ab9bae2be 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -2933,6 +2933,27 @@ static void spi_nor_set_mtd_info(struct spi_nor
> *nor)
> mtd->_put_device = spi_nor_put_device;
> }
>
> +static int spi_nor_hw_reset(struct spi_nor *nor)
> +{
> + struct gpio_desc *reset;
> +
> + reset = devm_gpiod_get_optional(nor->dev, "reset", GPIOD_OUT_LOW);
> + if (IS_ERR_OR_NULL(reset))
> + return PTR_ERR_OR_ZERO(reset);
> +
> + /*
> + * Experimental delay values by looking at different flash device
> + * vendors datasheets.
> + */
> + usleep_range(1, 5);
I think this is superfluous, because parts of the kernel
will boot which should take longer than 1us. But I'm
fine with leaving it here.
-michael
> + gpiod_set_value_cansleep(reset, 1);
> + 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,
> const struct spi_nor_hwcaps *hwcaps)
> {
> @@ -2965,6 +2986,10 @@ 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;
> +
> info = spi_nor_get_flash_info(nor, name);
> if (IS_ERR(info))
> return PTR_ERR(info);
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property
2022-09-01 7:29 ` [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property Sai Krishna Potthuri
@ 2022-09-01 7:56 ` Krzysztof Kozlowski
2022-09-01 10:18 ` Potthuri, Sai Krishna
0 siblings, 1 reply; 9+ messages in thread
From: Krzysztof Kozlowski @ 2022-09-01 7:56 UTC (permalink / raw)
To: Sai Krishna Potthuri, Tudor Ambarus, Pratyush Yadav,
Michael Walle, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski
Cc: devicetree, linux-mtd, linux-kernel, saikrishna12468, git
On 01/09/2022 10:29, Sai Krishna Potthuri wrote:
> SPI-NOR flashes have RESET pin which can be toggled using GPIO
> controller, for those platforms reset-gpios property can be used to
> reset the flash device.
>
> Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
> ---
You still miss the user (DTS) of this change... The JEDEC spec did not
mention a reset pin. Can you provide the user?
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property
2022-09-01 7:56 ` Krzysztof Kozlowski
@ 2022-09-01 10:18 ` Potthuri, Sai Krishna
2022-09-01 10:28 ` Krzysztof Kozlowski
0 siblings, 1 reply; 9+ messages in thread
From: Potthuri, Sai Krishna @ 2022-09-01 10:18 UTC (permalink / raw)
To: Krzysztof Kozlowski, Tudor Ambarus, Pratyush Yadav,
Michael Walle, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski
Cc: devicetree, linux-mtd, linux-kernel, saikrishna12468, git (AMD-Xilinx)
Hi Krzysztof,
> -----Original Message-----
> From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Sent: Thursday, September 1, 2022 1:26 PM
> To: Potthuri, Sai Krishna <sai.krishna.potthuri@amd.com>; Tudor Ambarus
> <tudor.ambarus@microchip.com>; Pratyush Yadav <pratyush@kernel.org>;
> Michael Walle <michael@walle.cc>; Miquel Raynal
> <miquel.raynal@bootlin.com>; Richard Weinberger <richard@nod.at>;
> Vignesh Raghavendra <vigneshr@ti.com>; Rob Herring
> <robh+dt@kernel.org>; Krzysztof Kozlowski
> <krzysztof.kozlowski+dt@linaro.org>
> Cc: devicetree@vger.kernel.org; linux-mtd@lists.infradead.org; linux-
> kernel@vger.kernel.org; saikrishna12468@gmail.com; git (AMD-Xilinx)
> <git@amd.com>
> Subject: Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios
> property
>
> On 01/09/2022 10:29, Sai Krishna Potthuri wrote:
> > SPI-NOR flashes have RESET pin which can be toggled using GPIO
> > controller, for those platforms reset-gpios property can be used to
> > reset the flash device.
> >
> > Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
> > ---
>
> You still miss the user (DTS) of this change...
Do you mean to have this property in example DTS in this yaml?
> The JEDEC spec did not mention
> a reset pin. Can you provide the user?
Xilinx Octal SPI (cdns,qspi-nor.yaml) is using this reset pin to reset the
flash device on Versal platform.
Do you want me to update the example dts in cdns,qspi-nor.yaml file
to reflect this property in this patch?
Regards
Sai Krishna
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property
2022-09-01 10:18 ` Potthuri, Sai Krishna
@ 2022-09-01 10:28 ` Krzysztof Kozlowski
2022-09-07 9:49 ` Potthuri, Sai Krishna
0 siblings, 1 reply; 9+ messages in thread
From: Krzysztof Kozlowski @ 2022-09-01 10:28 UTC (permalink / raw)
To: Potthuri, Sai Krishna, Tudor Ambarus, Pratyush Yadav,
Michael Walle, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski
Cc: devicetree, linux-mtd, linux-kernel, saikrishna12468, git (AMD-Xilinx)
On 01/09/2022 13:18, Potthuri, Sai Krishna wrote:
> Hi Krzysztof,
>
>> -----Original Message-----
>> From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>> Sent: Thursday, September 1, 2022 1:26 PM
>> To: Potthuri, Sai Krishna <sai.krishna.potthuri@amd.com>; Tudor Ambarus
>> <tudor.ambarus@microchip.com>; Pratyush Yadav <pratyush@kernel.org>;
>> Michael Walle <michael@walle.cc>; Miquel Raynal
>> <miquel.raynal@bootlin.com>; Richard Weinberger <richard@nod.at>;
>> Vignesh Raghavendra <vigneshr@ti.com>; Rob Herring
>> <robh+dt@kernel.org>; Krzysztof Kozlowski
>> <krzysztof.kozlowski+dt@linaro.org>
>> Cc: devicetree@vger.kernel.org; linux-mtd@lists.infradead.org; linux-
>> kernel@vger.kernel.org; saikrishna12468@gmail.com; git (AMD-Xilinx)
>> <git@amd.com>
>> Subject: Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios
>> property
>>
>> On 01/09/2022 10:29, Sai Krishna Potthuri wrote:
>>> SPI-NOR flashes have RESET pin which can be toggled using GPIO
>>> controller, for those platforms reset-gpios property can be used to
>>> reset the flash device.
>>>
>>> Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
>>> ---
>>
>> You still miss the user (DTS) of this change...
> Do you mean to have this property in example DTS in this yaml?
No, I want to see in-tree DTS using it.
>
>> The JEDEC spec did not mention
>> a reset pin. Can you provide the user?
> Xilinx Octal SPI (cdns,qspi-nor.yaml) is using this reset pin to reset the
> flash device on Versal platform.> Do you want me to update the example dts in cdns,qspi-nor.yaml file
> to reflect this property in this patch?
>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property
2022-09-01 10:28 ` Krzysztof Kozlowski
@ 2022-09-07 9:49 ` Potthuri, Sai Krishna
2022-09-07 10:24 ` Krzysztof Kozlowski
0 siblings, 1 reply; 9+ messages in thread
From: Potthuri, Sai Krishna @ 2022-09-07 9:49 UTC (permalink / raw)
To: Krzysztof Kozlowski, Tudor Ambarus, Pratyush Yadav,
Michael Walle, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski
Cc: devicetree, linux-mtd, linux-kernel, saikrishna12468, git (AMD-Xilinx)
Hi Krzysztof,
> -----Original Message-----
> From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Sent: Thursday, September 1, 2022 3:58 PM
> To: Potthuri, Sai Krishna <sai.krishna.potthuri@amd.com>; Tudor Ambarus
> <tudor.ambarus@microchip.com>; Pratyush Yadav <pratyush@kernel.org>;
> Michael Walle <michael@walle.cc>; Miquel Raynal
> <miquel.raynal@bootlin.com>; Richard Weinberger <richard@nod.at>;
> Vignesh Raghavendra <vigneshr@ti.com>; Rob Herring
> <robh+dt@kernel.org>; Krzysztof Kozlowski
> <krzysztof.kozlowski+dt@linaro.org>
> Cc: devicetree@vger.kernel.org; linux-mtd@lists.infradead.org; linux-
> kernel@vger.kernel.org; saikrishna12468@gmail.com; git (AMD-Xilinx)
> <git@amd.com>
> Subject: Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios
> property
>
> On 01/09/2022 13:18, Potthuri, Sai Krishna wrote:
> > Hi Krzysztof,
> >
> >> -----Original Message-----
> >> From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> >> Sent: Thursday, September 1, 2022 1:26 PM
> >> To: Potthuri, Sai Krishna <sai.krishna.potthuri@amd.com>; Tudor
> >> Ambarus <tudor.ambarus@microchip.com>; Pratyush Yadav
> >> <pratyush@kernel.org>; Michael Walle <michael@walle.cc>; Miquel
> >> Raynal <miquel.raynal@bootlin.com>; Richard Weinberger
> >> <richard@nod.at>; Vignesh Raghavendra <vigneshr@ti.com>; Rob Herring
> >> <robh+dt@kernel.org>; Krzysztof Kozlowski
> >> <krzysztof.kozlowski+dt@linaro.org>
> >> Cc: devicetree@vger.kernel.org; linux-mtd@lists.infradead.org; linux-
> >> kernel@vger.kernel.org; saikrishna12468@gmail.com; git (AMD-Xilinx)
> >> <git@amd.com>
> >> Subject: Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add
> >> reset-gpios property
> >>
> >> On 01/09/2022 10:29, Sai Krishna Potthuri wrote:
> >>> SPI-NOR flashes have RESET pin which can be toggled using GPIO
> >>> controller, for those platforms reset-gpios property can be used to
> >>> reset the flash device.
> >>>
> >>> Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
> >>> ---
> >>
> >> You still miss the user (DTS) of this change...
> > Do you mean to have this property in example DTS in this yaml?
>
> No, I want to see in-tree DTS using it.
As Michal Simek talked to you about this over IRC, as of now we don’t have
a DTS in the mainline tree for Xilinx Versal platform but we have a plan to do it.
For time being i will add this property in the example dts in this yaml file.
Regards
Sai Krishna
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property
2022-09-07 9:49 ` Potthuri, Sai Krishna
@ 2022-09-07 10:24 ` Krzysztof Kozlowski
0 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2022-09-07 10:24 UTC (permalink / raw)
To: Potthuri, Sai Krishna, Tudor Ambarus, Pratyush Yadav,
Michael Walle, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Rob Herring, Krzysztof Kozlowski
Cc: devicetree, linux-mtd, linux-kernel, saikrishna12468, git (AMD-Xilinx)
On 07/09/2022 11:49, Potthuri, Sai Krishna wrote:
>>>>>
>>>>> Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
>>>>> ---
>>>>
>>>> You still miss the user (DTS) of this change...
>>> Do you mean to have this property in example DTS in this yaml?
>>
>> No, I want to see in-tree DTS using it.
> As Michal Simek talked to you about this over IRC, as of now we don’t have
> a DTS in the mainline tree for Xilinx Versal platform but we have a plan to do it.
> For time being i will add this property in the example dts in this yaml file.
Sure, sounds good.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-09-07 10:25 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-01 7:29 [PATCH v2 0/2] mtd: spi-nor: Add flash device reset support Sai Krishna Potthuri
2022-09-01 7:29 ` [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property Sai Krishna Potthuri
2022-09-01 7:56 ` Krzysztof Kozlowski
2022-09-01 10:18 ` Potthuri, Sai Krishna
2022-09-01 10:28 ` Krzysztof Kozlowski
2022-09-07 9:49 ` Potthuri, Sai Krishna
2022-09-07 10:24 ` Krzysztof Kozlowski
2022-09-01 7:29 ` [PATCH v2 2/2] mtd: spi-nor: Add support for flash reset Sai Krishna Potthuri
2022-09-01 7:39 ` Michael Walle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).