mtd: spi-nor: Add flash device reset support
Subsystems (3)
v3 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 v3:
-> 1/2 - Add reset-gpios property in the example dts.
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 | 8 ++++++ drivers/mtd/spi-nor/core.c | 25 +++++++++++++++++++ 2 files changed, 33 insertions(+)
Signature · 1 line
2.17.1
PATCH v3 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 | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml +8 -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
@@ -88,6 +94,7 @@ unevaluatedProperties: false examples: - | + #include <dt-bindings/gpio/gpio.h> spi { #address-cells = <1>; #size-cells = <0>;
@@ -97,6 +104,7 @@ examples: reg = <0>; spi-max-frequency = <40000000>; m25p,fast-read; + reset-gpios = <&gpio 12 GPIO_ACTIVE_LOW>; }; }; ...
Signature · 1 line
2.17.1
Re: [PATCH v3 1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property
Quoted 5 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]>
Best regards,
Krzysztof
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 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 · 1 line
2.17.1
Re: [PATCH v3 2/2] mtd: spi-nor: Add support for flash reset
Quoted 46 lines · Sai Krishna Potthuri
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
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]>Reviewed-by Michael Walle <[email protected]>--- drivers/mtd/spi-nor/core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/mtd/spi-nor/core.c +21
-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) {
drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 2989
Quoted 4 lines
drivers/mtd/spi-nor/core.c +1
-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);
Should we condition the calling of this method by the absence of the "broken-flash-reset" dt prop?
Quoted 9 lines
drivers/mtd/spi-nor/core.c +3
-1+if (ret) +return ret; + info =spi_nor_get_flash_info (nor, name);if (IS_ERR (info))return PTR_ERR (info); --2.17.1
Signature · 5 lines
Cheers, ta ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
RE: [PATCH v3 2/2] mtd: spi-nor: Add support for flash reset
Hi Tudor Ambarus,
Quoted 62 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: Monday, October 3, 2022 3:13 PM
To: Potthuri, Sai Krishna <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; git (AMD-Xilinx) <[email protected]>
Subject: Re: [PATCH v3 2/2] mtd: spi-nor: Add support for flash resetdrivers/mtd/spi-nor/core.c static void spi_nor_set_mtd_info(struct spi_nor
Quoted 19 lines · Sai Krishna Potthuri
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
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]>Reviewed-by Michael Walle <[email protected]>--- drivers/mtd/spi-nor/core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/mtd/spi-nor/core.c +0
-0@@ -2933,6 +2933,27 @@ static void spi_nor_set_mtd_info(struct spi_nor*nor)
drivers/mtd/spi-nor/core.c static void spi_nor_set_mtd_info(struct spi_nor *nor)
Quoted 6 lines
drivers/mtd/spi-nor/core.c +4
-0mtd->_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);Quoted 22 lines
drivers/mtd/spi-nor/core.c +17
-0+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 ;
Quoted 5 lines
Quoted 1 line
+ ret =
spi_nor_hw_reset(nor);Should we condition the calling of this method by the absence of the "broken-flash-reset"
dt prop?
This is the suggestion from Michael on top of my initial series for which i also agreed to have this call unconditionally. If device tree is having this reset property then we can do the reset in any case.
Regards
Sai Krishna
Re: [PATCH v3 2/2] mtd: spi-nor: Add support for flash reset
Quoted 66 lines · Sai Krishna
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Hi Tudor Ambarus,
Quoted 62 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: Monday, October 3, 2022 3:13 PM
To: Potthuri, Sai Krishna <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; git (AMD-Xilinx) <[email protected]>
Subject: Re: [PATCH v3 2/2] mtd: spi-nor: Add support for flash resetdrivers/mtd/spi-nor/core.c static void spi_nor_set_mtd_info(struct spi_nor
Quoted 19 lines · Sai Krishna Potthuri
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
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]>Reviewed-by Michael Walle <[email protected]>--- drivers/mtd/spi-nor/core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/mtd/spi-nor/core.c +0
-0@@ -2933,6 +2933,27 @@ static void spi_nor_set_mtd_info(struct spi_nor*nor)
drivers/mtd/spi-nor/core.c static void spi_nor_set_mtd_info(struct spi_nor *nor)
Quoted 6 lines
drivers/mtd/spi-nor/core.c +4
-0mtd->_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);Quoted 22 lines
drivers/mtd/spi-nor/core.c +17
-0+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 ;
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
+ ret =
spi_nor_hw_reset(nor);Should we condition the calling of this method by the absence of the "broken-flash-reset"
dt prop?This is the suggestion from Michael on top of my initial series for which i also agreed to have this call unconditionally. If device tree is having this reset property then we can do the reset in any case.
Okay.
Signature · 2 lines
Cheers, ta
Tudor Ambarus
AppliedQuoted 6 lines · Sai Krishna Potthuri
Update spi-nor dt-binding and spi-nor core to support flash device reset using reset-gpios property.
changes in v3:
-> 1/2 - Add reset-gpios property in the example dts.
Quoted 8 lines
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.[...]
Applied to spi-nor/next, thanks!
[1/2] dt-bindings: mtd: spi-nor: Add reset-gpios property
https://git.kernel.org/mtd/c/7f2937efe186 [2/2] mtd: spi-nor: Add support for flash reset https://git.kernel.org/mtd/c/8f1ee9ef71d0
Best regards,
Signature · 1 line
Tudor Ambarus <[email protected]>