mtd: spi-nor: Add flash device reset support
Subsystems (3)
v2 cover mtd: spi-nor: Add flash device reset support
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(+)
Signature · 6 lines
2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v2 1/2 dt-bindings: mtd: spi-nor: Add reset-gpios property
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.
--- Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml +6 -0
@@ -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
Signature · 6 lines
2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property
Quoted 6 lines · 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 <[email protected]>---
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
RE: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property
Hi Krzysztof,
Quoted 17 lines
-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Thursday, September 1, 2022 1:26 PM
To: Potthuri, Sai Krishna <[email protected]>; Tudor Ambarus <[email protected]>; Pratyush Yadav <[email protected]>; Michael Walle <[email protected]>; Miquel Raynal <[email protected]>; Richard Weinberger <[email protected]>; Vignesh Raghavendra <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; git (AMD-Xilinx) <[email protected]>
Subject: Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios propertyOn 01/09/2022 10:29, Sai Krishna Potthuri wrote:
Quoted 8 lines
Quoted 6 lines
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 <[email protected]>---
You still miss the user (DTS) of this change...
Do you mean to have this property in example DTS in this yaml?
Quoted 2 lines
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
Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property
Quoted 23 lines · Sai Krishna
Hi Krzysztof,
Quoted 21 lines
-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Thursday, September 1, 2022 1:26 PM
To: Potthuri, Sai Krishna <[email protected]>; Tudor Ambarus <[email protected]>; Pratyush Yadav <[email protected]>; Michael Walle <[email protected]>; Miquel Raynal <[email protected]>; Richard Weinberger <[email protected]>; Vignesh Raghavendra <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; git (AMD-Xilinx) <[email protected]>
Subject: Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios propertyQuoted 4 lines · 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.
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Sai Krishna Potthuri <[email protected]>---
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.
Quoted 7 lines
Quoted 3 lines
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
RE: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property
Hi Krzysztof,
Quoted 40 lines
-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Thursday, September 1, 2022 3:58 PM
To: Potthuri, Sai Krishna <[email protected]>; Tudor Ambarus <[email protected]>; Pratyush Yadav <[email protected]>; Michael Walle <[email protected]>; Miquel Raynal <[email protected]>; Richard Weinberger <[email protected]>; Vignesh Raghavendra <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; git (AMD-Xilinx) <[email protected]>
Subject: Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios propertyQuoted 23 lines · Sai Krishna
Hi Krzysztof,
Quoted 21 lines
-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Thursday, September 1, 2022 1:26 PM
To: Potthuri, Sai Krishna <[email protected]>; Tudor Ambarus <[email protected]>; Pratyush Yadav <[email protected]>; Michael Walle <[email protected]>; Miquel Raynal <[email protected]>; Richard Weinberger <[email protected]>; Vignesh Raghavendra <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; git (AMD-Xilinx) <[email protected]>
Subject: Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios propertyQuoted 4 lines · 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.
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Sai Krishna Potthuri <[email protected]>---
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
Re: [PATCH v2 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property
Quoted 11 lines · Sai Krishna
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Signed-off-by Sai Krishna Potthuri <[email protected]>---
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
PATCH v2 2/2 mtd: spi-nor: Add support for flash reset
In reply to Sai Krishna PotthuriAdd 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.
--- drivers/mtd/spi-nor/core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/mtd/spi-nor/core.c +25 -0
@@ -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);
Signature · 6 lines
2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v2 2/2] mtd: spi-nor: Add support for flash reset
Am 2022-09-01 09:29, schrieb Sai Krishna Potthuri:
Quoted 6 lines
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 <[email protected]>
Just one comment, see below
Quoted 16 lines
--- drivers/mtd/spi-nor/core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/mtd/spi-nor/core.c +3
-0@@ -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;
drivers/mtd/spi-nor/core.c static void spi_nor_set_mtd_info(struct spi_nor · line 2949
Quoted 10 lines
drivers/mtd/spi-nor/core.c +10
-0+ + 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
Quoted 23 lines
drivers/mtd/spi-nor/core.c +8
-0+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){
drivers/mtd/spi-nor/core.c +4
-0@@ -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);