mtd: spi-nor: move vendor specific code into vendor modules
Subsystems (4)
v4 cover mtd: spi-nor: move vendor specific code into vendor modules
It turns out that most of the special status register handling is specific for a particular vendor. I.e. Xilinx has some different opcodes for the status register read, Micron has an additional FSR register and Spansion has these flags integrated into the SR.
Create a callback to ready() where a flash chip can register its own function. This will let us move all the vendor specific stuff out of the core into the vendor modules.
As a preparation step, unify all function and object names in the vendor modules. For the sake of consistency and better readability of the code flow, I also converted the setup() callback to be optional.
Please note that this is only compile-time tested.
Changes since v3:
- fix spansion.c compilation, messed up the patch export. Sorry for the noise
Changes since v2:
- use family_nor_ instead of just family_ prefix
- fix function doc
Changes since v1:
- rename/unify function names inside the vendor modules.
- make local functions static
- fix function doc typo
- use late_init hook to set fsr_ready op
- Use uppercase and period in comments
- Add comments for the vendor flags
- move coding style change in spi_nor_sr_ready() into own patch
- new patch to add missing parenthesis in S3AN_INFO()
- add missing function prefix rename patch for the spansion module
Michael Walle (32):
mtd: spi-nor: atmel: unify function names
mtd: spi-nor: catalyst: unify function names
mtd: spi-nor: eon: unify function names
mtd: spi-nor: esmt: unify function names
mtd: spi-nor: everspin: unify function names
mtd: spi-nor: fujitsu: unify function names
mtd: spi-nor: gigadevice: unify function names
mtd: spi-nor: intel: unify function names
mtd: spi-nor: issi: unify function names
mtd: spi-nor: macronix: unify function names
mtd: spi-nor: micron-st: unify function names
mtd: spi-nor: spansion: unify function names
mtd: spi-nor: sst: unify function names
mtd: spi-nor: winbond: unify function names
mtd: spi-nor: xilinx: unify function names
mtd: spi-nor: xmc: unify function names
mtd: spi-nor: slightly refactor the spi_nor_setup()
mtd: spi-nor: allow a flash to define its own ready() function
mtd: spi-nor: export more function to be used in vendor modules
mtd: spi-nor: guard _page_size parameter in S3AN_INFO()
mtd: spi-nor: move all xilinx specifics into xilinx.c
mtd: spi-nor: xilinx: rename vendor specific functions and defines
mtd: spi-nor: xilinx: correct the debug message
mtd: spi-nor: move all micron-st specifics into micron-st.c
mtd: spi-nor: micron-st: convert USE_FSR to a manufacturer flag
mtd: spi-nor: micron-st: rename vendor specific functions and defines
mtd: spi-nor: spansion: slightly rework control flow in late_init()
mtd: spi-nor: move all spansion specifics into spansion.c
mtd: spi-nor: spansion: convert USE_CLSR to a manufacturer flag
mtd: spi-nor: spansion: rename vendor specific functions and defines
mtd: spi-nor: slightly change code style in spi_nor_sr_ready()
mtd: spi-nor: renumber flags
drivers/mtd/spi-nor/atmel.c | 81 +++++----- drivers/mtd/spi-nor/catalyst.c | 6 +- drivers/mtd/spi-nor/core.c | 265 ++----------------------------- drivers/mtd/spi-nor/core.h | 70 ++++---- drivers/mtd/spi-nor/eon.c | 6 +- drivers/mtd/spi-nor/esmt.c | 6 +- drivers/mtd/spi-nor/everspin.c | 6 +- drivers/mtd/spi-nor/fujitsu.c | 6 +- drivers/mtd/spi-nor/gigadevice.c | 6 +- drivers/mtd/spi-nor/intel.c | 6 +- drivers/mtd/spi-nor/issi.c | 10 +- drivers/mtd/spi-nor/macronix.c | 14 +- drivers/mtd/spi-nor/micron-st.c | 258 ++++++++++++++++++++++++------ drivers/mtd/spi-nor/spansion.c | 168 +++++++++++++++----- drivers/mtd/spi-nor/sst.c | 44 ++--- drivers/mtd/spi-nor/winbond.c | 29 ++-- drivers/mtd/spi-nor/xilinx.c | 97 +++++++++-- drivers/mtd/spi-nor/xmc.c | 6 +- include/linux/mtd/spi-nor.h | 18 --- 19 files changed, 578 insertions(+), 524 deletions(-)
Signature · 1 line
2.30.2
PATCH v4 1/32 mtd: spi-nor: atmel: unify function names
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/atmel.c | 81 +++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 39 deletions(-)
drivers/mtd/spi-nor/atmel.c +42 -39
@@ -16,12 +16,12 @@* is to unlock the whole flash array on startup. Therefore, we have to support * exactly this operation. */ -static int atmel_at25fs_lock (struct spi_nor *nor,loff_t ofs,uint64_t len) +static int at25fs_nor_lock (struct spi_nor *nor,loff_t ofs,uint64_t len) {return -EOPNOTSUPP ; } -static int atmel_at25fs_unlock (struct spi_nor *nor,loff_t ofs,uint64_t len) +static int at25fs_nor_unlock (struct spi_nor *nor,loff_t ofs,uint64_t len) {int ret;
@@ -37,28 +37,28 @@ static int atmel_at25fs_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)return ret; } -static int atmel_at25fs_is_locked (struct spi_nor *nor,loff_t ofs,uint64_t len) +static int at25fs_nor_is_locked (struct spi_nor *nor,loff_t ofs,uint64_t len) {return -EOPNOTSUPP ; } -static const struct spi_nor_locking_ops atmel_at25fs_locking_ops = { - .lock = atmel_at25fs_lock, - .unlock = atmel_at25fs_unlock, - .is_locked = atmel_at25fs_is_locked, +static const struct spi_nor_locking_ops at25fs_nor_locking_ops = { + .lock = at25fs_nor_lock, + .unlock = at25fs_nor_unlock, + .is_locked = at25fs_nor_is_locked, }; -static void atmel_at25fs_late_init (struct spi_nor *nor) +static void at25fs_nor_late_init (struct spi_nor *nor) { - nor->params->locking_ops = &atmel_at25fs_locking_ops; + nor->params->locking_ops = &at25fs_nor_locking_ops; } -static const struct spi_nor_fixups atmel_at25fs_fixups = { - .late_init = atmel_at25fs_late_init, +static const struct spi_nor_fixups at25fs_nor_fixups = { + .late_init = at25fs_nor_late_init, };/** -* atmel_set_global_protection - Do a Global Protect or Unprotect command +* atmel_nor_set_global_protection - Do a Global Protect or Unprotect command * @nor: pointer to 'struct spi_nor' * @ofs: offset in bytes * @len: len in bytes
@@ -66,8 +66,8 @@ static const struct spi_nor_fixups atmel_at25fs_fixups = {* * Return: 0 on success, -error otherwise. */ -static int atmel_set_global_protection (struct spi_nor *nor,loff_t ofs, -uint64_t len,bool is_protect) +static int atmel_nor_set_global_protection (struct spi_nor *nor,loff_t ofs, +uint64_t len,bool is_protect) {int ret;u8 sr;
@@ -116,17 +116,20 @@ static int atmel_set_global_protection(struct spi_nor *nor, loff_t ofs,return spi_nor_write_sr (nor, nor->bouncebuf,1 ); } -static int atmel_global_protect (struct spi_nor *nor,loff_t ofs,uint64_t len) +static int atmel_nor_global_protect (struct spi_nor *nor,loff_t ofs, +uint64_t len) { -return atmel_set_global_protection (nor, ofs, len, true); +return atmel_nor_set_global_protection (nor, ofs, len, true); } -static int atmel_global_unprotect (struct spi_nor *nor,loff_t ofs,uint64_t len) +static int atmel_nor_global_unprotect (struct spi_nor *nor,loff_t ofs, +uint64_t len) { -return atmel_set_global_protection (nor, ofs, len, false); +return atmel_nor_set_global_protection (nor, ofs, len, false); } -static int atmel_is_global_protected (struct spi_nor *nor,loff_t ofs,uint64_t len) +static int atmel_nor_is_global_protected (struct spi_nor *nor,loff_t ofs, +uint64_t len) {int ret;
@@ -140,47 +143,47 @@ static int atmel_is_global_protected(struct spi_nor *nor, loff_t ofs, uint64_t lreturn ((nor->bouncebuf[0 ] &ATMEL_SR_GLOBAL_PROTECT_MASK ) ==ATMEL_SR_GLOBAL_PROTECT_MASK ); } -static const struct spi_nor_locking_ops atmel_global_protection_ops = { - .lock = atmel_global_protect, - .unlock = atmel_global_unprotect, - .is_locked = atmel_is_global_protected, +static const struct spi_nor_locking_ops atmel_nor_global_protection_ops = { + .lock = atmel_nor_global_protect, + .unlock = atmel_nor_global_unprotect, + .is_locked = atmel_nor_is_global_protected, }; -static void atmel_global_protection_late_init (struct spi_nor *nor) +static void atmel_nor_global_protection_late_init (struct spi_nor *nor) { - nor->params->locking_ops = &atmel_global_protection_ops; + nor->params->locking_ops = &atmel_nor_global_protection_ops; } -static const struct spi_nor_fixups atmel_global_protection_fixups = { - .late_init = atmel_global_protection_late_init, +static const struct spi_nor_fixups atmel_nor_global_protection_fixups = { + .late_init = atmel_nor_global_protection_late_init, }; -static const struct flash_info atmel_parts[] = { +static const struct flash_info atmel_nor_parts[] = {/* Atmel -- some are (confusingly) marketed as "DataFlash" */ { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4) FLAGS(SPI_NOR_HAS_LOCK)NO_SFDP_FLAGS (SECT_4K ) - .fixups = &atmel_at25fs_fixups }, + .fixups = &at25fs_nor_fixups }, { "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8) FLAGS(SPI_NOR_HAS_LOCK)NO_SFDP_FLAGS (SECT_4K ) - .fixups = &atmel_at25fs_fixups }, + .fixups = &at25fs_nor_fixups }, { "at25df041a", INFO(0x1f4401, 0, 64 * 1024, 8) FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)NO_SFDP_FLAGS (SECT_4K ) - .fixups = &atmel_global_protection_fixups }, + .fixups = &atmel_nor_global_protection_fixups }, { "at25df321", INFO(0x1f4700, 0, 64 * 1024, 64) FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)NO_SFDP_FLAGS (SECT_4K ) - .fixups = &atmel_global_protection_fixups }, + .fixups = &atmel_nor_global_protection_fixups }, { "at25df321a", INFO(0x1f4701, 0, 64 * 1024, 64) FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)NO_SFDP_FLAGS (SECT_4K ) - .fixups = &atmel_global_protection_fixups }, + .fixups = &atmel_nor_global_protection_fixups }, { "at25df641", INFO(0x1f4800, 0, 64 * 1024, 128) FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)NO_SFDP_FLAGS (SECT_4K ) - .fixups = &atmel_global_protection_fixups }, + .fixups = &atmel_nor_global_protection_fixups }, { "at25sl321", INFO(0x1f4216, 0, 64 * 1024, 64)NO_SFDP_FLAGS (SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ ) }, {"at26f004" ,INFO (0x1f0400 ,0 ,64 *1024 ,8 )
@@ -188,21 +191,21 @@ static const struct flash_info atmel_parts[] = { { "at26df081a", INFO(0x1f4501, 0, 64 * 1024, 16) FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)NO_SFDP_FLAGS (SECT_4K ) - .fixups = &atmel_global_protection_fixups }, + .fixups = &atmel_nor_global_protection_fixups }, { "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32) FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)NO_SFDP_FLAGS (SECT_4K ) - .fixups = &atmel_global_protection_fixups }, + .fixups = &atmel_nor_global_protection_fixups }, { "at26df321", INFO(0x1f4700, 0, 64 * 1024, 64) FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)NO_SFDP_FLAGS (SECT_4K ) - .fixups = &atmel_global_protection_fixups }, + .fixups = &atmel_nor_global_protection_fixups }, { "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16) NO_SFDP_FLAGS(SECT_4K) }, };const struct spi_nor_manufacturer spi_nor_atmel = { .name ="atmel" , - .parts = atmel_parts, - .nparts =ARRAY_SIZE (atmel_parts), + .parts = atmel_nor_parts, + .nparts =ARRAY_SIZE (atmel_nor_parts), };
Signature · 1 line
2.30.2
Re: [PATCH v4 01/32] mtd: spi-nor: atmel: unify function names
Quoted 5 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
Shouldn't this be "<flash_part>_nor_"?
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
Re: [PATCH v4 01/32] mtd: spi-nor: atmel: unify function names
Am 2022-02-22 08:23, schrieb Pratyush Yadav:
Quoted 8 lines · Michael Walle
Quoted 5 lines
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_Shouldn't this be "<flash_part>_nor_"?
No, a part name is already unique and its the same "style" as spi nand is doing it.
-michael
Pratyush Yadav
Acked-byRe: [PATCH v4 01/32] mtd: spi-nor: atmel: unify function names
Quoted 9 lines · Michael Walle
Am 2022-02-22 08:23, schrieb Pratyush Yadav:
Quoted 8 lines · Michael Walle
Quoted 6 lines
To avoid name clashes unify all the function and static object names and
use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
Quoted 4 lines
Quoted 1 line
Shouldn't this be "<flash_part>_nor_"?
No, a part name is already unique and its the same "style" as spi nand is doing it.
Okay. Fine by me.
I have not went and checked every single function changed. I trust you to get them right.
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 2/32 mtd: spi-nor: catalyst: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/catalyst.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/spi-nor/catalyst.c +3 -3
@@ -8,7 +8,7 @@#include "core.h" -static const struct flash_info catalyst_parts[] = { +static const struct flash_info catalyst_nor_parts[] = {/* Catalyst / On Semiconductor -- non-JEDEC */ {"cat25c11" ,CAT25_INFO (16 ,8 ,16 ,1 ) }, {"cat25c03" ,CAT25_INFO (32 ,8 ,16 ,2 ) },
@@ -19,6 +19,6 @@ static const struct flash_info catalyst_parts[] = {const struct spi_nor_manufacturer spi_nor_catalyst = { .name ="catalyst" , - .parts = catalyst_parts, - .nparts =ARRAY_SIZE (catalyst_parts), + .parts = catalyst_nor_parts, + .nparts =ARRAY_SIZE (catalyst_nor_parts), };
Signature · 1 line
2.30.2
Re: [PATCH v4 02/32] mtd: spi-nor: catalyst: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 3/32 mtd: spi-nor: eon: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/eon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/spi-nor/eon.c +3 -3
@@ -8,7 +8,7 @@#include "core.h" -static const struct flash_info eon_parts[] = { +static const struct flash_info eon_nor_parts[] = {/* EON -- en25xxx */ { "en25f32", INFO(0x1c3116, 0, 64 * 1024, 64)NO_SFDP_FLAGS (SECT_4K ) },
@@ -32,6 +32,6 @@ static const struct flash_info eon_parts[] = {const struct spi_nor_manufacturer spi_nor_eon = { .name ="eon" , - .parts = eon_parts, - .nparts =ARRAY_SIZE (eon_parts), + .parts = eon_nor_parts, + .nparts =ARRAY_SIZE (eon_nor_parts), };
Signature · 1 line
2.30.2
Re: [PATCH v4 03/32] mtd: spi-nor: eon: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v4 4/32 mtd: spi-nor: esmt: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/esmt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/spi-nor/esmt.c +3 -3
@@ -8,7 +8,7 @@#include "core.h" -static const struct flash_info esmt_parts[] = { +static const struct flash_info esmt_nor_parts[] = {/* ESMT */ { "f25l32pa", INFO(0x8c2016, 0, 64 * 1024, 64)FLAGS (SPI_NOR_HAS_LOCK |SPI_NOR_SWP_IS_VOLATILE )
@@ -23,6 +23,6 @@ static const struct flash_info esmt_parts[] = {const struct spi_nor_manufacturer spi_nor_esmt = { .name ="esmt" , - .parts = esmt_parts, - .nparts =ARRAY_SIZE (esmt_parts), + .parts = esmt_nor_parts, + .nparts =ARRAY_SIZE (esmt_nor_parts), };
Signature · 1 line
2.30.2
Re: [PATCH v4 04/32] mtd: spi-nor: esmt: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 5/32 mtd: spi-nor: everspin: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/everspin.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/spi-nor/everspin.c +3 -3
@@ -8,7 +8,7 @@#include "core.h" -static const struct flash_info everspin_parts[] = { +static const struct flash_info everspin_nor_parts[] = {/* Everspin */ {"mr25h128" ,CAT25_INFO (16 *1024 ,1 ,256 ,2 ) }, {"mr25h256" ,CAT25_INFO (32 *1024 ,1 ,256 ,2 ) },
@@ -18,6 +18,6 @@ static const struct flash_info everspin_parts[] = {const struct spi_nor_manufacturer spi_nor_everspin = { .name ="everspin" , - .parts = everspin_parts, - .nparts =ARRAY_SIZE (everspin_parts), + .parts = everspin_nor_parts, + .nparts =ARRAY_SIZE (everspin_nor_parts), };
Signature · 1 line
2.30.2
Re: [PATCH v4 05/32] mtd: spi-nor: everspin: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 6/32 mtd: spi-nor: fujitsu: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/fujitsu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/spi-nor/fujitsu.c +3 -3
@@ -8,7 +8,7 @@#include "core.h" -static const struct flash_info fujitsu_parts[] = { +static const struct flash_info fujitsu_nor_parts[] = {/* Fujitsu */ { "mb85rs1mt", INFO(0x047f27, 0, 128 * 1024, 1)FLAGS (SPI_NOR_NO_ERASE ) },
@@ -16,6 +16,6 @@ static const struct flash_info fujitsu_parts[] = {const struct spi_nor_manufacturer spi_nor_fujitsu = { .name ="fujitsu" , - .parts = fujitsu_parts, - .nparts =ARRAY_SIZE (fujitsu_parts), + .parts = fujitsu_nor_parts, + .nparts =ARRAY_SIZE (fujitsu_nor_parts), };
Signature · 1 line
2.30.2
Re: [PATCH v4 06/32] mtd: spi-nor: fujitsu: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 7/32 mtd: spi-nor: gigadevice: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/gigadevice.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/spi-nor/gigadevice.c +3 -3
@@ -23,7 +23,7 @@ static const struct spi_nor_fixups gd25q256_fixups = { .default_init = gd25q256_default_init, }; -static const struct flash_info gigadevice_parts[] = { +static const struct flash_info gigadevice_nor_parts[] = { { "gd25q16", INFO(0xc84015, 0, 64 * 1024, 32) FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
@@ -61,6 +61,6 @@ static const struct flash_info gigadevice_parts[] = {const struct spi_nor_manufacturer spi_nor_gigadevice = { .name ="gigadevice" , - .parts = gigadevice_parts, - .nparts =ARRAY_SIZE (gigadevice_parts), + .parts = gigadevice_nor_parts, + .nparts =ARRAY_SIZE (gigadevice_nor_parts), };
Signature · 1 line
2.30.2
Re: [PATCH v4 07/32] mtd: spi-nor: gigadevice: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 8/32 mtd: spi-nor: intel: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/intel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/spi-nor/intel.c +3 -3
@@ -8,7 +8,7 @@#include "core.h" -static const struct flash_info intel_parts[] = { +static const struct flash_info intel_nor_parts[] = {/* Intel/Numonyx -- xxxs33b */ { "160s33b", INFO(0x898911, 0, 64 * 1024, 32)FLAGS (SPI_NOR_HAS_LOCK |SPI_NOR_SWP_IS_VOLATILE ) },
@@ -20,6 +20,6 @@ static const struct flash_info intel_parts[] = {const struct spi_nor_manufacturer spi_nor_intel = { .name ="intel" , - .parts = intel_parts, - .nparts =ARRAY_SIZE (intel_parts), + .parts = intel_nor_parts, + .nparts =ARRAY_SIZE (intel_nor_parts), };
Signature · 1 line
2.30.2
Re: [PATCH v4 08/32] mtd: spi-nor: intel: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 9/32 mtd: spi-nor: issi: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/issi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mtd/spi-nor/issi.c +5 -5
@@ -29,7 +29,7 @@ static const struct spi_nor_fixups is25lp256_fixups = { .post_bfpt = is25lp256_post_bfpt_fixups, }; -static const struct flash_info issi_parts[] = { +static const struct flash_info issi_nor_parts[] = {/* ISSI */ { "is25cd512", INFO(0x7f9d20, 0, 32 * 1024, 2)NO_SFDP_FLAGS (SECT_4K ) },
@@ -69,18 +69,18 @@ static const struct flash_info issi_parts[] = { NO_SFDP_FLAGS(SECT_4K) }, }; -static void issi_default_init (struct spi_nor *nor) +static void issi_nor_default_init (struct spi_nor *nor) { nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable; }static const struct spi_nor_fixups issi_fixups = { - .default_init = issi_default_init, + .default_init = issi_nor_default_init, };const struct spi_nor_manufacturer spi_nor_issi = { .name ="issi" , - .parts = issi_parts, - .nparts =ARRAY_SIZE (issi_parts), + .parts = issi_nor_parts, + .nparts =ARRAY_SIZE (issi_nor_parts), .fixups = &issi_fixups, };
Signature · 1 line
2.30.2
Re: [PATCH v4 09/32] mtd: spi-nor: issi: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 10/32 mtd: spi-nor: macronix: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/macronix.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/mtd/spi-nor/macronix.c +7 -7
@@ -32,7 +32,7 @@ static const struct spi_nor_fixups mx25l25635_fixups = { .post_bfpt = mx25l25635_post_bfpt_fixups, }; -static const struct flash_info macronix_parts[] = { +static const struct flash_info macronix_nor_parts[] = {/* Macronix */ { "mx25l512e", INFO(0xc22010, 0, 64 * 1024, 1)NO_SFDP_FLAGS (SECT_4K ) },
@@ -102,19 +102,19 @@ static const struct flash_info macronix_parts[] = { FIXUP_FLAGS(SPI_NOR_4B_OPCODES) }, }; -static void macronix_default_init (struct spi_nor *nor) +static void macronix_nor_default_init (struct spi_nor *nor) { nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable; nor->params->set_4byte_addr_mode = spi_nor_set_4byte_addr_mode; } -static const struct spi_nor_fixups macronix_fixups = { - .default_init = macronix_default_init, +static const struct spi_nor_fixups macronix_nor_fixups = { + .default_init = macronix_nor_default_init, };const struct spi_nor_manufacturer spi_nor_macronix = { .name ="macronix" , - .parts = macronix_parts, - .nparts =ARRAY_SIZE (macronix_parts), - .fixups = ¯onix_fixups, + .parts = macronix_nor_parts, + .nparts =ARRAY_SIZE (macronix_nor_parts), + .fixups = ¯onix_nor_fixups, };
Signature · 1 line
2.30.2
Re: [PATCH v4 10/32] mtd: spi-nor: macronix: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 11/32 mtd: spi-nor: micron-st: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/micron-st.c | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/mtd/spi-nor/micron-st.c +17 -17
@@ -17,7 +17,7 @@#define SPINOR_MT_OCT_DTR 0xe7/* Enable Octal DTR. */ #define SPINOR_MT_EXSPI 0xff/* Enable Extended SPI (default) */ -static int spi_nor_micron_octal_dtr_enable (struct spi_nor *nor,bool enable) +static int micron_st_nor_octal_dtr_enable (struct spi_nor *nor,bool enable) {struct spi_mem_op op;u8 *buf = nor->bouncebuf;
@@ -102,7 +102,7 @@ static int spi_nor_micron_octal_dtr_enable(struct spi_nor *nor, bool enable)static void mt35xu512aba_default_init (struct spi_nor *nor) { - nor->params->octal_dtr_enable = spi_nor_micron_octal_dtr_enable; + nor->params->octal_dtr_enable = micron_st_nor_octal_dtr_enable; }static void mt35xu512aba_post_sfdp_fixup (struct spi_nor *nor)
@@ -130,7 +130,7 @@ static const struct spi_nor_fixups mt35xu512aba_fixups = { .post_sfdp = mt35xu512aba_post_sfdp_fixup, }; -static const struct flash_info micron_parts[] = { +static const struct flash_info micron_nor_parts[] = { { "mt35xu512aba", INFO(0x2c5b1a, 0, 128 * 1024, 512) FLAGS(USE_FSR) NO_SFDP_FLAGS(SECT_4K | SPI_NOR_OCTAL_READ |
@@ -143,7 +143,7 @@ static const struct flash_info micron_parts[] = { FIXUP_FLAGS(SPI_NOR_4B_OPCODES) }, }; -static const struct flash_info st_parts[] = { +static const struct flash_info st_nor_parts[] = { { "n25q016a", INFO(0x20bb15, 0, 64 * 1024, 32)NO_SFDP_FLAGS (SECT_4K |SPI_NOR_QUAD_READ ) }, {"n25q032" ,INFO (0x20ba16 ,0 ,64 *1024 ,64 )
@@ -250,15 +250,15 @@ static const struct flash_info st_parts[] = { };/** -* st_micron_set_4byte_addr_mode() - Set 4-byte address mode for ST and Micron -* flashes. +* micron_st_nor_set_4byte_addr_mode() - Set 4-byte address mode for ST and +* Micron flashes. * @nor: pointer to 'struct spi_nor'. * @enable: true to enter the 4-byte address mode, false to exit the 4-byte * address mode. * * Return: 0 on success, -errno otherwise. */ -static int st_micron_set_4byte_addr_mode (struct spi_nor *nor,bool enable) +static int micron_st_nor_set_4byte_addr_mode (struct spi_nor *nor,bool enable) {int ret;
@@ -273,28 +273,28 @@ static int st_micron_set_4byte_addr_mode(struct spi_nor *nor, bool enable)return spi_nor_write_disable (nor); } -static void micron_st_default_init (struct spi_nor *nor) +static void micron_st_nor_default_init (struct spi_nor *nor) { nor->flags |=SNOR_F_HAS_LOCK ; nor->flags &= ~SNOR_F_HAS_16BIT_SR ; nor->params->quad_enable =NULL ; - nor->params->set_4byte_addr_mode = st_micron_set_4byte_addr_mode; + nor->params->set_4byte_addr_mode = micron_st_nor_set_4byte_addr_mode; } -static const struct spi_nor_fixups micron_st_fixups = { - .default_init = micron_st_default_init, +static const struct spi_nor_fixups micron_st_nor_fixups = { + .default_init = micron_st_nor_default_init, };const struct spi_nor_manufacturer spi_nor_micron = { .name ="micron" , - .parts = micron_parts, - .nparts =ARRAY_SIZE (micron_parts), - .fixups = µn_st_fixups, + .parts = micron_nor_parts, + .nparts =ARRAY_SIZE (micron_nor_parts), + .fixups = µn_st_nor_fixups, };const struct spi_nor_manufacturer spi_nor_st = { .name ="st" , - .parts = st_parts, - .nparts =ARRAY_SIZE (st_parts), - .fixups = µn_st_fixups, + .parts = st_nor_parts, + .nparts =ARRAY_SIZE (st_nor_parts), + .fixups = µn_st_nor_fixups, };
Signature · 1 line
2.30.2
Re: [PATCH v4 11/32] mtd: spi-nor: micron-st: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 12/32 mtd: spi-nor: spansion: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/spansion.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/mtd/spi-nor/spansion.c +17 -17
@@ -20,7 +20,7 @@#define SPINOR_OP_CYPRESS_RD_FAST 0xee/** -* spi_nor_cypress_octal_dtr_enable() - Enable octal DTR on Cypress flashes. +* cypress_nor_octal_dtr_enable() - Enable octal DTR on Cypress flashes. * @nor: pointer to a 'struct spi_nor' * @enable: whether to enable or disable Octal DTR *
@@ -29,7 +29,7 @@* * Return: 0 on success, -errno otherwise. */ -static int spi_nor_cypress_octal_dtr_enable (struct spi_nor *nor,bool enable) +static int cypress_nor_octal_dtr_enable (struct spi_nor *nor,bool enable) {struct spi_mem_op op;u8 *buf = nor->bouncebuf;
@@ -116,7 +116,7 @@ static int spi_nor_cypress_octal_dtr_enable(struct spi_nor *nor, bool enable)static void s28hs512t_default_init (struct spi_nor *nor) { - nor->params->octal_dtr_enable = spi_nor_cypress_octal_dtr_enable; + nor->params->octal_dtr_enable = cypress_nor_octal_dtr_enable; nor->params->writesize =16 ; }
@@ -183,9 +183,9 @@ static const struct spi_nor_fixups s28hs512t_fixups = { };static int -s25fs_s_post_bfpt_fixups (struct spi_nor *nor, -const struct sfdp_parameter_header *bfpt_header, -const struct sfdp_bfpt *bfpt) +s25fs_s_nor_post_bfpt_fixups (struct spi_nor *nor, +const struct sfdp_parameter_header *bfpt_header, +const struct sfdp_bfpt *bfpt) {/* * The S25FS-S chip family reports 512-byte pages in BFPT but
@@ -198,11 +198,11 @@ s25fs_s_post_bfpt_fixups(struct spi_nor *nor,return 0 ; } -static const struct spi_nor_fixups s25fs_s_fixups = { - .post_bfpt = s25fs_s_post_bfpt_fixups, +static const struct spi_nor_fixups s25fs_s_nor_fixups = { + .post_bfpt = s25fs_s_nor_post_bfpt_fixups, }; -static const struct flash_info spansion_parts[] = { +static const struct flash_info spansion_nor_parts[] = {/* Spansion/Cypress -- single (large) sector size only, at least * for the chips listed here (without boot sectors). */
@@ -229,7 +229,7 @@ static const struct flash_info spansion_parts[] = { { "s25fs128s1", INFO6(0x012018, 0x4d0181, 64 * 1024, 256) FLAGS(USE_CLSR) NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) - .fixups = &s25fs_s_fixups, }, + .fixups = &s25fs_s_nor_fixups, }, { "s25fs256s0", INFO6(0x010219, 0x4d0081, 256 * 1024, 128) FLAGS(USE_CLSR) NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
@@ -239,7 +239,7 @@ static const struct flash_info spansion_parts[] = { { "s25fs512s", INFO6(0x010220, 0x4d0081, 256 * 1024, 256) FLAGS(USE_CLSR) NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) - .fixups = &s25fs_s_fixups, }, + .fixups = &s25fs_s_nor_fixups, }, { "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024, 64) }, { "s25sl12801", INFO(0x012018, 0x0301, 64 * 1024, 256) }, { "s25fl129p0", INFO(0x012018, 0x4d00, 256 * 1024, 64)
@@ -294,7 +294,7 @@ static const struct flash_info spansion_parts[] = { }, }; -static void spansion_late_init (struct spi_nor *nor) +static void spansion_nor_late_init (struct spi_nor *nor) {if (nor->params->size <=SZ_16M )return ;
@@ -305,13 +305,13 @@ static void spansion_late_init(struct spi_nor *nor) nor->mtd.erasesize = nor->info->sector_size; } -static const struct spi_nor_fixups spansion_fixups = { - .late_init = spansion_late_init, +static const struct spi_nor_fixups spansion_nor_fixups = { + .late_init = spansion_nor_late_init, };const struct spi_nor_manufacturer spi_nor_spansion = { .name ="spansion" , - .parts = spansion_parts, - .nparts =ARRAY_SIZE (spansion_parts), - .fixups = &spansion_fixups, + .parts = spansion_nor_parts, + .nparts =ARRAY_SIZE (spansion_nor_parts), + .fixups = &spansion_nor_fixups, };
Signature · 1 line
2.30.2
Re: [PATCH v4 12/32] mtd: spi-nor: spansion: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 13/32 mtd: spi-nor: sst: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/sst.c | 44 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
drivers/mtd/spi-nor/sst.c +22 -22
@@ -13,12 +13,12 @@#define SST26VF_CR_BPNV BIT(3) -static int sst26vf_lock (struct spi_nor *nor,loff_t ofs,uint64_t len) +static int sst26vf_nor_lock (struct spi_nor *nor,loff_t ofs,uint64_t len) {return -EOPNOTSUPP ; } -static int sst26vf_unlock (struct spi_nor *nor,loff_t ofs,uint64_t len) +static int sst26vf_nor_unlock (struct spi_nor *nor,loff_t ofs,uint64_t len) {int ret;
@@ -38,27 +38,27 @@ static int sst26vf_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)return spi_nor_global_block_unlock (nor); } -static int sst26vf_is_locked (struct spi_nor *nor,loff_t ofs,uint64_t len) +static int sst26vf_nor_is_locked (struct spi_nor *nor,loff_t ofs,uint64_t len) {return -EOPNOTSUPP ; } -static const struct spi_nor_locking_ops sst26vf_locking_ops = { - .lock = sst26vf_lock, - .unlock = sst26vf_unlock, - .is_locked = sst26vf_is_locked, +static const struct spi_nor_locking_ops sst26vf_nor_locking_ops = { + .lock = sst26vf_nor_lock, + .unlock = sst26vf_nor_unlock, + .is_locked = sst26vf_nor_is_locked, }; -static void sst26vf_late_init (struct spi_nor *nor) +static void sst26vf_nor_late_init (struct spi_nor *nor) { - nor->params->locking_ops = &sst26vf_locking_ops; + nor->params->locking_ops = &sst26vf_nor_locking_ops; } -static const struct spi_nor_fixups sst26vf_fixups = { - .late_init = sst26vf_late_init, +static const struct spi_nor_fixups sst26vf_nor_fixups = { + .late_init = sst26vf_nor_late_init, }; -static const struct flash_info sst_parts[] = { +static const struct flash_info sst_nor_parts[] = {/* SST -- large erase sizes are "overlays", "sectors" are 4K */ { "sst25vf040b", INFO(0xbf258d, 0, 64 * 1024, 8)FLAGS (SPI_NOR_HAS_LOCK |SPI_NOR_SWP_IS_VOLATILE )
@@ -114,11 +114,11 @@ static const struct flash_info sst_parts[] = { { "sst26vf064b", INFO(0xbf2643, 0, 64 * 1024, 128) FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)NO_SFDP_FLAGS (SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ ) - .fixups = &sst26vf_fixups }, + .fixups = &sst26vf_nor_fixups }, }; -static int sst_write (struct mtd_info *mtd,loff_t to,size_t len, -size_t *retlen,const u_char *buf) +static int sst_nor_write (struct mtd_info *mtd,loff_t to,size_t len, +size_t *retlen,const u_char *buf) {struct spi_nor *nor =mtd_to_spi_nor (mtd);size_t actual =0 ;
@@ -203,19 +203,19 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,return ret; } -static void sst_late_init (struct spi_nor *nor) +static void sst_nor_late_init (struct spi_nor *nor) {if (nor->info->mfr_flags &SST_WRITE ) - nor->mtd._write = sst_write; + nor->mtd._write = sst_nor_write; } -static const struct spi_nor_fixups sst_fixups = { - .late_init = sst_late_init, +static const struct spi_nor_fixups sst_nor_fixups = { + .late_init = sst_nor_late_init, };const struct spi_nor_manufacturer spi_nor_sst = { .name ="sst" , - .parts = sst_parts, - .nparts =ARRAY_SIZE (sst_parts), - .fixups = &sst_fixups, + .parts = sst_nor_parts, + .nparts =ARRAY_SIZE (sst_nor_parts), + .fixups = &sst_nor_fixups, };
Signature · 1 line
2.30.2
Re: [PATCH v4 13/32] mtd: spi-nor: sst: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 14/32 mtd: spi-nor: winbond: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/winbond.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
drivers/mtd/spi-nor/winbond.c +15 -14
@@ -32,7 +32,7 @@ static const struct spi_nor_fixups w25q256_fixups = { .post_bfpt = w25q256_post_bfpt_fixups, }; -static const struct flash_info winbond_parts[] = { +static const struct flash_info winbond_nor_parts[] = {/* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */ { "w25x05", INFO(0xef3010, 0, 64 * 1024, 1)NO_SFDP_FLAGS (SECT_4K ) },
@@ -131,14 +131,15 @@ static const struct flash_info winbond_parts[] = { };/** -* winbond_set_4byte_addr_mode() - Set 4-byte address mode for Winbond flashes. +* winbond_nor_set_4byte_addr_mode() - Set 4-byte address mode for Winbond +* flashes. * @nor: pointer to 'struct spi_nor'. * @enable: true to enter the 4-byte address mode, false to exit the 4-byte * address mode. * * Return: 0 on success, -errno otherwise. */ -static int winbond_set_4byte_addr_mode (struct spi_nor *nor,bool enable) +static int winbond_nor_set_4byte_addr_mode (struct spi_nor *nor,bool enable) {int ret;
@@ -162,7 +163,7 @@ static int winbond_set_4byte_addr_mode(struct spi_nor *nor, bool enable)return spi_nor_write_disable (nor); } -static const struct spi_nor_otp_ops winbond_otp_ops = { +static const struct spi_nor_otp_ops winbond_nor_otp_ops = { .read = spi_nor_otp_read_secr, .write = spi_nor_otp_write_secr, .erase = spi_nor_otp_erase_secr,
@@ -170,25 +171,25 @@ static const struct spi_nor_otp_ops winbond_otp_ops = { .is_locked = spi_nor_otp_is_locked_sr2, }; -static void winbond_default_init (struct spi_nor *nor) +static void winbond_nor_default_init (struct spi_nor *nor) { - nor->params->set_4byte_addr_mode = winbond_set_4byte_addr_mode; + nor->params->set_4byte_addr_mode = winbond_nor_set_4byte_addr_mode; } -static void winbond_late_init (struct spi_nor *nor) +static void winbond_nor_late_init (struct spi_nor *nor) {if (nor->params->otp.org->n_regions) - nor->params->otp.ops = &winbond_otp_ops; + nor->params->otp.ops = &winbond_nor_otp_ops; } -static const struct spi_nor_fixups winbond_fixups = { - .default_init = winbond_default_init, - .late_init = winbond_late_init, +static const struct spi_nor_fixups winbond_nor_fixups = { + .default_init = winbond_nor_default_init, + .late_init = winbond_nor_late_init, };const struct spi_nor_manufacturer spi_nor_winbond = { .name ="winbond" , - .parts = winbond_parts, - .nparts =ARRAY_SIZE (winbond_parts), - .fixups = &winbond_fixups, + .parts = winbond_nor_parts, + .nparts =ARRAY_SIZE (winbond_nor_parts), + .fixups = &winbond_nor_fixups, };
Signature · 1 line
2.30.2
Re: [PATCH v4 14/32] mtd: spi-nor: winbond: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 15/32 mtd: spi-nor: xilinx: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/xilinx.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/mtd/spi-nor/xilinx.c +9 -9
@@ -8,7 +8,7 @@#include "core.h" -static const struct flash_info xilinx_parts[] = { +static const struct flash_info xilinx_nor_parts[] = {/* Xilinx S3AN Internal Flash */ {"3S50AN" ,S3AN_INFO (0x1f2200 ,64 ,264 ) }, {"3S200AN" ,S3AN_INFO (0x1f2400 ,256 ,264 ) },
@@ -26,7 +26,7 @@ static const struct flash_info xilinx_parts[] = {* Addr can safely be unsigned int, the biggest S3AN device is smaller than * 4 MiB. */ -static u32 s3an_convert_addr (struct spi_nor *nor,u32 addr) +static u32 s3an_nor_convert_addr (struct spi_nor *nor,u32 addr) {u32 page_size = nor->params->page_size;u32 offset, page;
@@ -73,25 +73,25 @@ static int xilinx_nor_setup(struct spi_nor *nor, nor->mtd.erasesize =8 * page_size; }else {/* Flash in Default addressing mode */ - nor->params->convert_addr = s3an_convert_addr; + nor->params->convert_addr = s3an_nor_convert_addr; nor->mtd.erasesize = nor->info->sector_size; }return 0 ; } -static void xilinx_late_init (struct spi_nor *nor) +static void xilinx_nor_late_init (struct spi_nor *nor) { nor->params->setup = xilinx_nor_setup; } -static const struct spi_nor_fixups xilinx_fixups = { - .late_init = xilinx_late_init, +static const struct spi_nor_fixups xilinx_nor_fixups = { + .late_init = xilinx_nor_late_init, };const struct spi_nor_manufacturer spi_nor_xilinx = { .name ="xilinx" , - .parts = xilinx_parts, - .nparts =ARRAY_SIZE (xilinx_parts), - .fixups = &xilinx_fixups, + .parts = xilinx_nor_parts, + .nparts =ARRAY_SIZE (xilinx_nor_parts), + .fixups = &xilinx_nor_fixups, };
Signature · 1 line
2.30.2
Re: [PATCH v4 15/32] mtd: spi-nor: xilinx: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 16/32 mtd: spi-nor: xmc: unify function names
In reply to Michael WalleTo avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_
There are no functional changes.
--- drivers/mtd/spi-nor/xmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/spi-nor/xmc.c +3 -3
@@ -8,7 +8,7 @@#include "core.h" -static const struct flash_info xmc_parts[] = { +static const struct flash_info xmc_nor_parts[] = {/* XMC (Wuhan Xinxin Semiconductor Manufacturing Corp.) */ { "XM25QH64A", INFO(0x207017, 0, 64 * 1024, 128) NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
@@ -20,6 +20,6 @@ static const struct flash_info xmc_parts[] = {const struct spi_nor_manufacturer spi_nor_xmc = { .name ="xmc" , - .parts = xmc_parts, - .nparts =ARRAY_SIZE (xmc_parts), + .parts = xmc_nor_parts, + .nparts =ARRAY_SIZE (xmc_nor_parts), };
Signature · 1 line
2.30.2
Re: [PATCH v4 16/32] mtd: spi-nor: xmc: unify function names
Quoted 9 lines · Michael Walle
To avoid name clashes unify all the function and static object names and use one of the following prefixes which should be sufficiently unique:
- <vendor>_nor_
- <flash_family>_nor_
- <flash_part>_There are no functional changes.
Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 17/32 mtd: spi-nor: slightly refactor the spi_nor_setup()
In reply to Michael WalleInstead of always using a function pointer (and initializing it to our default), just call the default function if the flash didn't set its own one. That will make the call flow easier to follow.
Also mark the parameter as optional now.
--- drivers/mtd/spi-nor/core.c | 10 +++++----- drivers/mtd/spi-nor/core.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/mtd/spi-nor/core.c +5 -5
@@ -2532,11 +2532,12 @@ static int spi_nor_setup(struct spi_nor *nor, {int ret; -if (nor->params->setup) { +if (nor->params->setup) ret = nor->params->setup (nor, hwcaps); -if (ret) -return ret; - } +else + ret =spi_nor_default_setup (nor, hwcaps); +if (ret) +return ret;return spi_nor_set_addr_width (nor); }
@@ -2786,7 +2787,6 @@ static void spi_nor_init_default_params(struct spi_nor *nor) params->quad_enable = spi_nor_sr2_bit1_quad_enable; params->set_4byte_addr_mode = spansion_set_4byte_addr_mode; - params->setup = spi_nor_default_setup; params->otp.org = &info->otp_org;/* Default to 16-bit Write Status (01h) Command */
drivers/mtd/spi-nor/core.h +4 -4
@@ -257,10 +257,10 @@ struct spi_nor_otp {* @convert_addr: converts an absolute address into something the flash * will understand. Particularly useful when pagesize is * not a power-of-2. -* @setup: configures the SPI NOR memory. Useful for SPI NOR -* flashes that have peculiarities to the SPI NOR standard -* e.g. different opcodes, specific address calculation, -* page size, etc. +* @setup: (optional) configures the SPI NOR memory. Useful for +* SPI NOR flashes that have peculiarities to the SPI NOR +* standard e.g. different opcodes, specific address +* calculation, page size, etc. * @locking_ops: SPI NOR locking methods. */ struct spi_nor_flash_parameter {
Signature · 1 line
2.30.2
PATCH v4 18/32 mtd: spi-nor: allow a flash to define its own ready() function
In reply to Michael WalleXilinx and Micron flashes have their own implementation of the spi_nor_ready() function. At the moment, the core will figure out which one to call according to some flags. Lay the foundation to make it possible that a flash can register its own ready() function.
--- drivers/mtd/spi-nor/core.c | 4 ++++ drivers/mtd/spi-nor/core.h | 4 ++++ 2 files changed, 8 insertions(+)
drivers/mtd/spi-nor/core.c +4 -0
@@ -794,6 +794,10 @@ static int spi_nor_ready(struct spi_nor *nor) {int sr, fsr; +/* Flashes might override the standard routine. */ +if (nor->params->ready) +return nor->params->ready (nor); +if (nor->flags &SNOR_F_READY_XSR_RDY ) sr =spi_nor_xsr_ready (nor);else
drivers/mtd/spi-nor/core.h +4 -0
@@ -261,6 +261,9 @@ struct spi_nor_otp {* SPI NOR flashes that have peculiarities to the SPI NOR * standard e.g. different opcodes, specific address * calculation, page size, etc. +* @ready: (optional) flashes might use a different mechanism +* than reading the status register to indicate they +* are ready for a new command * @locking_ops: SPI NOR locking methods. */ struct spi_nor_flash_parameter {
@@ -282,6 +285,7 @@ struct spi_nor_flash_parameter {int (*set_4byte_addr_mode)(struct spi_nor *nor,bool enable);u32 (*convert_addr)(struct spi_nor *nor,u32 addr);int (*setup)(struct spi_nor *nor,const struct spi_nor_hwcaps *hwcaps); +int (*ready)(struct spi_nor *nor);const struct spi_nor_locking_ops *locking_ops; };
Signature · 1 line
2.30.2
PATCH v4 19/32 mtd: spi-nor: export more function to be used in vendor modules
In reply to Michael WalleWe will move vendor specific code into the vendor modules and thus we will have to export these functions so they can be called.
--- drivers/mtd/spi-nor/core.c | 10 +++++----- drivers/mtd/spi-nor/core.h | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-)
drivers/mtd/spi-nor/core.c +5 -5
@@ -157,8 +157,8 @@ static int spi_nor_spimem_exec_op(struct spi_nor *nor, struct spi_mem_op *op)return spi_mem_exec_op (nor->spimem, op); } -static int spi_nor_controller_ops_read_reg (struct spi_nor *nor,u8 opcode, -u8 *buf,size_t len) +int spi_nor_controller_ops_read_reg (struct spi_nor *nor,u8 opcode, +u8 *buf,size_t len) {if (spi_nor_protocol_is_dtr (nor->reg_proto))return -EOPNOTSUPP ;
@@ -166,8 +166,8 @@ static int spi_nor_controller_ops_read_reg(struct spi_nor *nor, u8 opcode,return nor->controller_ops->read_reg (nor, opcode, buf, len); } -static int spi_nor_controller_ops_write_reg (struct spi_nor *nor,u8 opcode, -const u8 *buf,size_t len) +int spi_nor_controller_ops_write_reg (struct spi_nor *nor,u8 opcode, +const u8 *buf,size_t len) {if (spi_nor_protocol_is_dtr (nor->reg_proto))return -EOPNOTSUPP ;
@@ -683,7 +683,7 @@ static void spi_nor_clear_sr(struct spi_nor *nor)* * Return: 1 if ready, 0 if not ready, -errno on errors. */ -static int spi_nor_sr_ready (struct spi_nor *nor) +int spi_nor_sr_ready (struct spi_nor *nor) {int ret =spi_nor_read_sr (nor, nor->bouncebuf);
drivers/mtd/spi-nor/core.h +6 -0
@@ -558,6 +558,7 @@ int spi_nor_sr1_bit6_quad_enable(struct spi_nor *nor);int spi_nor_sr2_bit1_quad_enable (struct spi_nor *nor);int spi_nor_sr2_bit7_quad_enable (struct spi_nor *nor);int spi_nor_read_sr (struct spi_nor *nor,u8 *sr); +int spi_nor_sr_ready (struct spi_nor *nor);int spi_nor_read_cr (struct spi_nor *nor,u8 *cr);int spi_nor_write_sr (struct spi_nor *nor,const u8 *sr,size_t len);int spi_nor_write_sr_and_check (struct spi_nor *nor,u8 sr1);
@@ -603,6 +604,11 @@ void spi_nor_try_unlock_all(struct spi_nor *nor);void spi_nor_set_mtd_locking_ops (struct spi_nor *nor);void spi_nor_set_mtd_otp_ops (struct spi_nor *nor); +int spi_nor_controller_ops_read_reg (struct spi_nor *nor,u8 opcode, +u8 *buf,size_t len); +int spi_nor_controller_ops_write_reg (struct spi_nor *nor,u8 opcode, +const u8 *buf,size_t len); +static inline struct spi_nor *mtd_to_spi_nor (struct mtd_info *mtd) { return container_of(mtd, struct spi_nor, mtd);
Signature · 1 line
2.30.2
PATCH v4 20/32 mtd: spi-nor: guard _page_size parameter in S3AN_INFO()
In reply to Michael WalleThe _page_size marco parameter was missing parentheses around it. Add them.
--- drivers/mtd/spi-nor/core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/core.h +2 -2
@@ -469,9 +469,9 @@ struct flash_info { (_jedec_id) &0xff \ }, \ .id_len = 3, \ - .sector_size = (8*_page_size), \ + .sector_size = (8 * (_page_size)), \ .n_sectors = (_n_sectors), \ - .page_size = _page_size, \ + .page_size = (_page_size), \ .addr_width = 3, \ .flags = SPI_NOR_NO_FR | SPI_NOR_XSR_RDY,
Signature · 1 line
2.30.2
Re: [PATCH v4 20/32] mtd: spi-nor: guard _page_size parameter in S3AN_INFO()
Quoted 4 lines · Michael Walle
The
_page_sizemarco parameter was missing parentheses around it. Add them.Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 21/32 mtd: spi-nor: move all xilinx specifics into xilinx.c
In reply to Michael WalleMechanically move all the xilinx functions to its own module.
Then register the new flash specific ready() function.
--- drivers/mtd/spi-nor/core.c | 64 +------------------------------ drivers/mtd/spi-nor/core.h | 18 --------- drivers/mtd/spi-nor/xilinx.c | 73 ++++++++++++++++++++++++++++++++++++ include/linux/mtd/spi-nor.h | 9 ----- 4 files changed, 74 insertions(+), 90 deletions(-)
drivers/mtd/spi-nor/core.c +1 -63
@@ -598,57 +598,6 @@ int spi_nor_write_ear(struct spi_nor *nor, u8 ear)return ret; } -/** -* spi_nor_xread_sr() - Read the Status Register on S3AN flashes. -* @nor: pointer to 'struct spi_nor'. -* @sr: pointer to a DMA-able buffer where the value of the -* Status Register will be written. -* -* Return: 0 on success, -errno otherwise. -*/ -int spi_nor_xread_sr (struct spi_nor *nor,u8 *sr) -{ -int ret; - -if (nor->spimem) { -struct spi_mem_op op = -SPI_MEM_OP (SPI_MEM_OP_CMD (SPINOR_OP_XRDSR ,0 ), -SPI_MEM_OP_NO_ADDR , -SPI_MEM_OP_NO_DUMMY , -SPI_MEM_OP_DATA_IN (1 , sr,0 )); - -spi_nor_spimem_setup_op (nor, &op, nor->reg_proto); - - ret =spi_mem_exec_op (nor->spimem, &op); - }else { - ret =spi_nor_controller_ops_read_reg (nor,SPINOR_OP_XRDSR , sr, -1 ); - } - -if (ret) -dev_dbg (nor->dev,"error %d reading XRDSR\n" , ret); - -return ret; -} - -/** -* spi_nor_xsr_ready() - Query the Status Register of the S3AN flash to see if -* the flash is ready for new commands. -* @nor: pointer to 'struct spi_nor'. -* -* Return: 1 if ready, 0 if not ready, -errno on errors. -*/ -static int spi_nor_xsr_ready (struct spi_nor *nor) -{ -int ret; - - ret =spi_nor_xread_sr (nor, nor->bouncebuf); -if (ret) -return ret; - -return !!(nor->bouncebuf[0 ] &XSR_RDY ); -} -/** * spi_nor_clear_sr() - Clear the Status Register. * @nor: pointer to 'struct spi_nor'.
@@ -798,10 +747,7 @@ static int spi_nor_ready(struct spi_nor *nor)if (nor->params->ready)return nor->params->ready (nor); -if (nor->flags &SNOR_F_READY_XSR_RDY ) - sr =spi_nor_xsr_ready (nor); -else - sr =spi_nor_sr_ready (nor); + sr =spi_nor_sr_ready (nor);if (sr <0 )return sr; fsr = nor->flags &SNOR_F_USE_FSR ?spi_nor_fsr_ready (nor) :1 ;
@@ -2677,14 +2623,6 @@ static void spi_nor_init_flags(struct spi_nor *nor)if (flags &USE_FSR ) nor->flags |=SNOR_F_USE_FSR ; - -/* -* Make sure the XSR_RDY flag is set before calling -* spi_nor_wait_till_ready(). Xilinx S3AN share MFR -* with Atmel SPI NOR. -*/ -if (flags &SPI_NOR_XSR_RDY ) - nor->flags |=SNOR_F_READY_XSR_RDY ; }/**
drivers/mtd/spi-nor/core.h +0 -18
@@ -15,7 +15,6 @@ enum spi_nor_option_flags {SNOR_F_USE_FSR =BIT (0 ),SNOR_F_HAS_SR_TB =BIT (1 ),SNOR_F_NO_OP_CHIP_ERASE =BIT (2 ), -SNOR_F_READY_XSR_RDY =BIT (3 ),SNOR_F_USE_CLSR =BIT (4 ),SNOR_F_BROKEN_RESET =BIT (5 ), SNOR_F_4B_OPCODES = BIT(6),
@@ -351,8 +350,6 @@ struct spi_nor_fixups {* SPI_NOR_NO_FR: can't do fastread. * USE_CLSR: use CLSR command. * USE_FSR: use flag status register -* SPI_NOR_XSR_RDY: S3AN flashes have specific opcode to read the -* status register. * * @no_sfdp_flags: flags that indicate support that can be discovered via SFDP. * Used when SFDP tables are not defined in the flash. These
@@ -405,7 +402,6 @@ struct flash_info {#define SPI_NOR_NO_FR BIT(8)#define USE_CLSR BIT(9)#define USE_FSR BIT(10) -#define SPI_NOR_XSR_RDY BIT(11)u8 no_sfdp_flags;#define SPI_NOR_SKIP_SFDP BIT(0)
@@ -462,19 +458,6 @@ struct flash_info { .addr_width = (_addr_width), \ .flags = SPI_NOR_NO_ERASE | SPI_NOR_NO_FR, \ -#define S3AN_INFO (_jedec_id, _n_sectors, _page_size) \ - .id = { \ - ((_jedec_id) >> 16) & 0xff, \ - ((_jedec_id) >> 8) & 0xff, \ - (_jedec_id) & 0xff \ - }, \ - .id_len = 3, \ - .sector_size = (8 * (_page_size)), \ - .n_sectors = (_n_sectors), \ - .page_size = (_page_size), \ - .addr_width = 3, \ - .flags = SPI_NOR_NO_FR | SPI_NOR_XSR_RDY, -#define OTP_INFO (_len, _n_regions, _base, _offset) \ .otp_org = { \ .len = (_len), \
@@ -564,7 +547,6 @@ int spi_nor_write_sr(struct spi_nor *nor, const u8 *sr, size_t len);int spi_nor_write_sr_and_check (struct spi_nor *nor,u8 sr1);int spi_nor_write_16bit_cr_and_check (struct spi_nor *nor,u8 cr); -int spi_nor_xread_sr (struct spi_nor *nor,u8 *sr);ssize_t spi_nor_read_data (struct spi_nor *nor,loff_t from,size_t len,u8 *buf); ssize_t spi_nor_write_data(struct spi_nor *nor, loff_t to, size_t len,
drivers/mtd/spi-nor/xilinx.c +73 -0
91 lines not on this page · raw message
include/linux/mtd/spi-nor.h +0 -9
@@ -86,15 +86,6 @@#define SPINOR_OP_BP 0x02/* Byte program */ #define SPINOR_OP_AAI_WP 0xad/* Auto address increment word program */ -/* Used for S3AN flashes only */ -#define SPINOR_OP_XSE 0x50/* Sector erase */ -#define SPINOR_OP_XPP 0x82/* Page program */ -#define SPINOR_OP_XRDSR 0xd7/* Read status register */ - -#define XSR_PAGESIZE BIT(0)/* Page size in Po2 or Linear */ -#define XSR_RDY BIT(7)/* Ready */ - -/* Used for Macronix and Winbond flashes. */ #define SPINOR_OP_EN4B 0xb7/* Enter 4-byte mode */ #define SPINOR_OP_EX4B 0xe9/* Exit 4-byte mode */
Signature · 1 line
2.30.2
PATCH v4 22/32 mtd: spi-nor: xilinx: rename vendor specific functions and defines
In reply to Michael WalleDrop the generic spi_nor prefix for all the xilinx functions.
--- drivers/mtd/spi-nor/xilinx.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/mtd/spi-nor/xilinx.c +15 -15
@@ -8,9 +8,9 @@#include "core.h" -#define SPINOR_OP_XSE 0x50/* Sector erase */ -#define SPINOR_OP_XPP 0x82/* Page program */ -#define SPINOR_OP_XRDSR 0xd7/* Read status register */ +#define XILINX_OP_SE 0x50/* Sector erase */ +#define XILINX_OP_PP 0x82/* Page program */ +#define XILINX_OP_RDSR 0xd7/* Read status register */ #define XSR_PAGESIZE BIT(0)/* Page size in Po2 or Linear */ #define XSR_RDY BIT(7)/* Ready */
@@ -60,20 +60,20 @@ static u32 s3an_nor_convert_addr(struct spi_nor *nor, u32 addr) }/** -* spi_nor_xread_sr() - Read the Status Register on S3AN flashes. +* xilinx_nor_read_sr() - Read the Status Register on S3AN flashes. * @nor: pointer to 'struct spi_nor'. * @sr: pointer to a DMA-able buffer where the value of the * Status Register will be written. * * Return: 0 on success, -errno otherwise. */ -static int spi_nor_xread_sr (struct spi_nor *nor,u8 *sr) +static int xilinx_nor_read_sr (struct spi_nor *nor,u8 *sr) {int ret;if (nor->spimem) {struct spi_mem_op op = -SPI_MEM_OP (SPI_MEM_OP_CMD (SPINOR_OP_XRDSR ,0 ), +SPI_MEM_OP (SPI_MEM_OP_CMD (XILINX_OP_RDSR ,0 ),SPI_MEM_OP_NO_ADDR ,SPI_MEM_OP_NO_DUMMY ,SPI_MEM_OP_DATA_IN (1 , sr,0 ));
@@ -82,7 +82,7 @@ static int spi_nor_xread_sr(struct spi_nor *nor, u8 *sr) ret =spi_mem_exec_op (nor->spimem, &op); }else { - ret =spi_nor_controller_ops_read_reg (nor,SPINOR_OP_XRDSR , sr, + ret =spi_nor_controller_ops_read_reg (nor,XILINX_OP_RDSR , sr,1 ); }
@@ -93,17 +93,17 @@ static int spi_nor_xread_sr(struct spi_nor *nor, u8 *sr) }/** -* spi_nor_xsr_ready() - Query the Status Register of the S3AN flash to see if -* the flash is ready for new commands. +* xilinx_nor_sr_ready() - Query the Status Register of the S3AN flash to see +* if the flash is ready for new commands. * @nor: pointer to 'struct spi_nor'. * * Return: 1 if ready, 0 if not ready, -errno on errors. */ -static int spi_nor_xsr_ready (struct spi_nor *nor) +static int xilinx_nor_sr_ready (struct spi_nor *nor) {int ret; - ret =spi_nor_xread_sr (nor, nor->bouncebuf); + ret =xilinx_nor_read_sr (nor, nor->bouncebuf);if (ret)return ret;
@@ -116,12 +116,12 @@ static int xilinx_nor_setup(struct spi_nor *nor,u32 page_size;int ret; - ret =spi_nor_xread_sr (nor, nor->bouncebuf); + ret =xilinx_nor_read_sr (nor, nor->bouncebuf);if (ret)return ret; - nor->erase_opcode =SPINOR_OP_XSE ; - nor->program_opcode =SPINOR_OP_XPP ; + nor->erase_opcode =XILINX_OP_SE ; + nor->program_opcode =XILINX_OP_PP ; nor->read_opcode =SPINOR_OP_READ ; nor->flags |=SNOR_F_NO_OP_CHIP_ERASE ;
@@ -155,7 +155,7 @@ static int xilinx_nor_setup(struct spi_nor *nor,static void xilinx_nor_late_init (struct spi_nor *nor) { nor->params->setup = xilinx_nor_setup; - nor->params->ready = spi_nor_xsr_ready; + nor->params->ready = xilinx_nor_sr_ready; }static const struct spi_nor_fixups xilinx_nor_fixups = {
Signature · 1 line
2.30.2
Re: [PATCH v4 22/32] mtd: spi-nor: xilinx: rename vendor specific functions and defines
Quoted 3 lines · Michael Walle
Drop the generic
spi_norprefix for all the xilinx functions.Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 23/32 mtd: spi-nor: xilinx: correct the debug message
In reply to Michael WalleXRDSR is a combination of xilinx and the RDSR opcode, but the register is just the status register. Correct the debug message.
--- drivers/mtd/spi-nor/xilinx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/xilinx.c +1 -1
@@ -87,7 +87,7 @@ static int xilinx_nor_read_sr(struct spi_nor *nor, u8 *sr) }if (ret) -dev_dbg (nor->dev,"error %d reading XRDSR\n" , ret); +dev_dbg (nor->dev,"error %d reading SR\n" , ret);return ret; }
Signature · 1 line
2.30.2
PATCH v4 24/32 mtd: spi-nor: move all micron-st specifics into micron-st.c
In reply to Michael WalleThe flag status register is only available on micron flashes. Move all the functions around that into the micron module.
This is almost a mechanical move except for the spi_nor_fsr_ready() which now also checks the normal status register. Previously, this was done in spi_nor_ready().
--- drivers/mtd/spi-nor/core.c | 123 +---------------------------- drivers/mtd/spi-nor/micron-st.c | 133 ++++++++++++++++++++++++++++++++ include/linux/mtd/spi-nor.h | 8 -- 3 files changed, 134 insertions(+), 130 deletions(-)
drivers/mtd/spi-nor/core.c +1 -122
@@ -412,50 +412,6 @@ int spi_nor_read_sr(struct spi_nor *nor, u8 *sr)return ret; } -/** -* spi_nor_read_fsr() - Read the Flag Status Register. -* @nor: pointer to 'struct spi_nor' -* @fsr: pointer to a DMA-able buffer where the value of the -* Flag Status Register will be written. Should be at least 2 -* bytes. -* -* Return: 0 on success, -errno otherwise. -*/ -static int spi_nor_read_fsr (struct spi_nor *nor,u8 *fsr) -{ -int ret; - -if (nor->spimem) { -struct spi_mem_op op = -SPI_MEM_OP (SPI_MEM_OP_CMD (SPINOR_OP_RDFSR ,0 ), -SPI_MEM_OP_NO_ADDR , -SPI_MEM_OP_NO_DUMMY , -SPI_MEM_OP_DATA_IN (1 , fsr,0 )); - -if (nor->reg_proto ==SNOR_PROTO_8_8_8_DTR ) { - op.addr.nbytes = nor->params->rdsr_addr_nbytes; - op.dummy.nbytes = nor->params->rdsr_dummy; -/* -* We don't want to read only one byte in DTR mode. So, -* read 2 and then discard the second byte. -*/ - op.data.nbytes =2 ; - } - -spi_nor_spimem_setup_op (nor, &op, nor->reg_proto); - - ret =spi_mem_exec_op (nor->spimem, &op); - }else { - ret =spi_nor_controller_ops_read_reg (nor,SPINOR_OP_RDFSR , fsr, -1 ); - } - -if (ret) -dev_dbg (nor->dev,"error %d reading FSR\n" , ret); - -return ret; -} -/** * spi_nor_read_cr() - Read the Configuration Register using the * SPINOR_OP_RDCR (35h) command.
@@ -664,75 +620,6 @@ int spi_nor_sr_ready(struct spi_nor *nor)return !(nor->bouncebuf[0 ] &SR_WIP ); } -/** -* spi_nor_clear_fsr() - Clear the Flag Status Register. -* @nor: pointer to 'struct spi_nor'. -*/ -static void spi_nor_clear_fsr (struct spi_nor *nor) -{ -int ret; - -if (nor->spimem) { -struct spi_mem_op op = -SPI_MEM_OP (SPI_MEM_OP_CMD (SPINOR_OP_CLFSR ,0 ), -SPI_MEM_OP_NO_ADDR , -SPI_MEM_OP_NO_DUMMY , -SPI_MEM_OP_NO_DATA ); - -spi_nor_spimem_setup_op (nor, &op, nor->reg_proto); - - ret =spi_mem_exec_op (nor->spimem, &op); - }else { - ret =spi_nor_controller_ops_write_reg (nor,SPINOR_OP_CLFSR , -NULL ,0 ); - } - -if (ret) -dev_dbg (nor->dev,"error %d clearing FSR\n" , ret); -} - -/** -* spi_nor_fsr_ready() - Query the Flag Status Register to see if the flash is -* ready for new commands. -* @nor: pointer to 'struct spi_nor'. -* -* Return: 1 if ready, 0 if not ready, -errno on errors. -*/ -static int spi_nor_fsr_ready (struct spi_nor *nor) -{ -int ret =spi_nor_read_fsr (nor, nor->bouncebuf); - -if (ret) -return ret; - -if (nor->bouncebuf[0 ] & (FSR_E_ERR |FSR_P_ERR )) { -if (nor->bouncebuf[0 ] &FSR_E_ERR ) -dev_err (nor->dev,"Erase operation failed.\n" ); -else -dev_err (nor->dev,"Program operation failed.\n" ); - -if (nor->bouncebuf[0 ] &FSR_PT_ERR ) -dev_err (nor->dev, -"Attempted to modify a protected sector.\n" ); - -spi_nor_clear_fsr (nor); - -/* -* WEL bit remains set to one when an erase or page program -* error occurs. Issue a Write Disable command to protect -* against inadvertent writes that can possibly corrupt the -* contents of the memory. -*/ - ret =spi_nor_write_disable (nor); -if (ret) -return ret; - -return -EIO ; - } - -return !!(nor->bouncebuf[0 ] &FSR_READY ); -} -/** * spi_nor_ready() - Query the flash to see if it is ready for new commands. * @nor: pointer to 'struct spi_nor'.
@@ -741,19 +628,11 @@ static int spi_nor_fsr_ready(struct spi_nor *nor)*/ static int spi_nor_ready (struct spi_nor *nor) { -int sr, fsr; -/* Flashes might override the standard routine. */ if (nor->params->ready)return nor->params->ready (nor); - sr =spi_nor_sr_ready (nor); -if (sr <0 ) -return sr; - fsr = nor->flags &SNOR_F_USE_FSR ?spi_nor_fsr_ready (nor) :1 ; -if (fsr <0 ) -return fsr; -return sr && fsr; +return spi_nor_sr_ready (nor); }/**
drivers/mtd/spi-nor/micron-st.c +133 -0
159 lines not on this page · raw message
include/linux/mtd/spi-nor.h +0 -8
@@ -47,8 +47,6 @@#define SPINOR_OP_RDID 0x9f/* Read JEDEC ID */ #define SPINOR_OP_RDSFDP 0x5a/* Read SFDP */ #define SPINOR_OP_RDCR 0x35/* Read configuration register */ -#define SPINOR_OP_RDFSR 0x70/* Read flag status register */ -#define SPINOR_OP_CLFSR 0x50/* Clear flag status register */ #define SPINOR_OP_RDEAR 0xc8/* Read Extended Address Register */ #define SPINOR_OP_WREAR 0xc5/* Write Extended Address Register */ #define SPINOR_OP_SRSTEN 0x66/* Software Reset Enable */
@@ -126,12 +124,6 @@/* Enhanced Volatile Configuration Register bits */ #define EVCR_QUAD_EN_MICRON BIT(7)/* Micron Quad I/O */ -/* Flag Status Register bits */ -#define FSR_READY BIT(7)/* Device status, 0 = Busy, 1 = Ready */ -#define FSR_E_ERR BIT(5)/* Erase operation status */ -#define FSR_P_ERR BIT(4)/* Program operation status */ -#define FSR_PT_ERR BIT(1)/* Protection error bit */ -/* Status Register 2 bits. */ #define SR2_QUAD_EN_BIT1 BIT(1)#define SR2_LB1 BIT(3)/* Security Register Lock Bit 1 */
Signature · 1 line
2.30.2
PATCH v4 25/32 mtd: spi-nor: micron-st: convert USE_FSR to a manufacturer flag
In reply to Michael WalleNow that all functions using that flag are local to the micron module, we can convert the flag to a manufacturer one.
--- drivers/mtd/spi-nor/core.c | 3 -- drivers/mtd/spi-nor/core.h | 3 -- drivers/mtd/spi-nor/micron-st.c | 93 +++++++++++++++++++++------------ 3 files changed, 60 insertions(+), 39 deletions(-)
drivers/mtd/spi-nor/core.c +0 -3
@@ -2499,9 +2499,6 @@ static void spi_nor_init_flags(struct spi_nor *nor)if (flags &USE_CLSR ) nor->flags |=SNOR_F_USE_CLSR ; - -if (flags &USE_FSR ) - nor->flags |=SNOR_F_USE_FSR ; }/**
drivers/mtd/spi-nor/core.h +0 -3
@@ -12,7 +12,6 @@#define SPI_NOR_MAX_ID_LEN 6enum spi_nor_option_flags { -SNOR_F_USE_FSR =BIT (0 ),SNOR_F_HAS_SR_TB =BIT (1 ),SNOR_F_NO_OP_CHIP_ERASE =BIT (2 ),SNOR_F_USE_CLSR =BIT (4 ),
@@ -349,7 +348,6 @@ struct spi_nor_fixups {* NO_CHIP_ERASE: chip does not support chip erase. * SPI_NOR_NO_FR: can't do fastread. * USE_CLSR: use CLSR command. -* USE_FSR: use flag status register * * @no_sfdp_flags: flags that indicate support that can be discovered via SFDP. * Used when SFDP tables are not defined in the flash. These
@@ -401,7 +399,6 @@ struct flash_info {#define NO_CHIP_ERASE BIT(7)#define SPI_NOR_NO_FR BIT(8)#define USE_CLSR BIT(9) -#define USE_FSR BIT(10)u8 no_sfdp_flags;#define SPI_NOR_SKIP_SFDP BIT(0)
drivers/mtd/spi-nor/micron-st.c +60 -33
145 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v4 26/32 mtd: spi-nor: micron-st: rename vendor specific functions and defines
In reply to Michael WalleDrop the generic spi_nor prefix for all the micron-st functions.
--- drivers/mtd/spi-nor/micron-st.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/mtd/spi-nor/micron-st.c +10 -10
@@ -309,7 +309,7 @@ static int micron_st_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable) }/** -* spi_nor_read_fsr() - Read the Flag Status Register. +* micron_st_nor_read_fsr() - Read the Flag Status Register. * @nor: pointer to 'struct spi_nor' * @fsr: pointer to a DMA-able buffer where the value of the * Flag Status Register will be written. Should be at least 2
@@ -317,7 +317,7 @@ static int micron_st_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)* * Return: 0 on success, -errno otherwise. */ -static int spi_nor_read_fsr (struct spi_nor *nor,u8 *fsr) +static int micron_st_nor_read_fsr (struct spi_nor *nor,u8 *fsr) {int ret;
@@ -353,10 +353,10 @@ static int spi_nor_read_fsr(struct spi_nor *nor, u8 *fsr) }/** -* spi_nor_clear_fsr() - Clear the Flag Status Register. +* micron_st_nor_clear_fsr() - Clear the Flag Status Register. * @nor: pointer to 'struct spi_nor'. */ -static void spi_nor_clear_fsr (struct spi_nor *nor) +static void micron_st_nor_clear_fsr (struct spi_nor *nor) {int ret;
@@ -380,13 +380,13 @@ static void spi_nor_clear_fsr(struct spi_nor *nor) }/** -* spi_nor_fsr_ready() - Query the Flag Status Register to see if the flash is -* ready for new commands. +* micron_st_nor_fsr_ready() - Query the Flag Status Register to see if the +* flash is ready for new commands. * @nor: pointer to 'struct spi_nor'. * * Return: 1 if ready, 0 if not ready, -errno on errors. */ -static int spi_nor_fsr_ready (struct spi_nor *nor) +static int micron_st_nor_fsr_ready (struct spi_nor *nor) {int sr_ready, ret;
@@ -394,7 +394,7 @@ static int spi_nor_fsr_ready(struct spi_nor *nor)if (sr_ready <0 )return sr_ready; - ret =spi_nor_read_fsr (nor, nor->bouncebuf); + ret =micron_st_nor_read_fsr (nor, nor->bouncebuf);if (ret)return ret;
@@ -408,7 +408,7 @@ static int spi_nor_fsr_ready(struct spi_nor *nor)dev_err (nor->dev,"Attempted to modify a protected sector.\n" ); -spi_nor_clear_fsr (nor); +micron_st_nor_clear_fsr (nor);/* * WEL bit remains set to one when an erase or page program
@@ -437,7 +437,7 @@ static void micron_st_nor_default_init(struct spi_nor *nor)static void micron_st_nor_late_init (struct spi_nor *nor) {if (nor->info->mfr_flags &USE_FSR ) - nor->params->ready = spi_nor_fsr_ready; + nor->params->ready = micron_st_nor_fsr_ready; }static const struct spi_nor_fixups micron_st_nor_fixups = {
Signature · 1 line
2.30.2
Re: [PATCH v4 26/32] mtd: spi-nor: micron-st: rename vendor specific functions and defines
Quoted 43 lines · Michael Walle
Drop the generic
spi_norprefix for all the micron-st functions.Signed-off-by Michael Walle <[email protected]>--- drivers/mtd/spi-nor/micron-st.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)drivers/mtd/spi-nor/micron-st.c +4
-4@@ -309,7 +309,7 @@ static int micron_st_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable) }/** -* spi_nor_read_fsr() - Read the Flag Status Register. +* micron_st_nor_read_fsr() - Read the Flag Status Register. * @nor: pointer to 'struct spi_nor' * @fsr: pointer to a DMA-able buffer where the value of the * Flag Status Register will be written. Should be at least 2 @@ -317,7 +317,7 @@ static int micron_st_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)* * Return: 0 on success, -errno otherwise. */ -static int spi_nor_read_fsr (struct spi_nor *nor,u8 *fsr) +static int micron_st_nor_read_fsr (struct spi_nor *nor,u8 *fsr) {int ret;@@ -353,10 +353,10 @@ static int spi_nor_read_fsr(struct spi_nor *nor, u8 *fsr) }/** -* spi_nor_clear_fsr() - Clear the Flag Status Register. +* micron_st_nor_clear_fsr() - Clear the Flag Status Register. * @nor: pointer to 'struct spi_nor'. */ -static void spi_nor_clear_fsr (struct spi_nor *nor) +static void micron_st_nor_clear_fsr (struct spi_nor *nor) {int ret;
drivers/mtd/spi-nor/micron-st.c static void spi_nor_clear_fsr(struct spi_nor *nor) · line 384
Quoted 7 lines
drivers/mtd/spi-nor/micron-st.c +2
-2@@ -380,13 +380,13 @@ static void spi_nor_clear_fsr(struct spi_nor *nor) }/** -* spi_nor_fsr_ready() - Query the Flag Status Register to see if the flash is -* ready for new commands. +* micron_st_nor_fsr_ready() - Query the Flag Status Register to see if the +* flash is ready for new commands.
This is misleading. This function doesn't only query the FSR, but the SR as well. I think this should be renamed to micron_st_nor_ready(), and documentation updated to reflect that it checks for SR, and then FSR as well if the flag is specified.
Quoted 8 lines
drivers/mtd/spi-nor/micron-st.c +1
-1* @nor: pointer to 'struct spi_nor'. * * Return: 1 if ready, 0 if not ready, -errno on errors. */ -static int spi_nor_fsr_ready (struct spi_nor *nor) +static int micron_st_nor_fsr_ready (struct spi_nor *nor) {int sr_ready, ret;
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 27/32 mtd: spi-nor: spansion: slightly rework control flow in late_init()
In reply to Michael WalleDon't return early when the flash is smaller than or equal to 16MiB. We need to be able to register hooks for all sizes of flashes. This also has the benefit that it increases the readability of the code because the action, i.e. registering the fixups, is connected to the condition, i.e. flashes larger than 16MiB.
--- drivers/mtd/spi-nor/spansion.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/mtd/spi-nor/spansion.c +6 -7
@@ -296,13 +296,12 @@ static const struct flash_info spansion_nor_parts[] = {static void spansion_nor_late_init (struct spi_nor *nor) { -if (nor->params->size <=SZ_16M ) -return ; - - nor->flags |=SNOR_F_4B_OPCODES ; -/* No small sector erase for 4-byte command set */ - nor->erase_opcode =SPINOR_OP_SE ; - nor->mtd.erasesize = nor->info->sector_size; +if (nor->params->size >SZ_16M ) { + nor->flags |=SNOR_F_4B_OPCODES ; +/* No small sector erase for 4-byte command set */ + nor->erase_opcode =SPINOR_OP_SE ; + nor->mtd.erasesize = nor->info->sector_size; + } }static const struct spi_nor_fixups spansion_nor_fixups = {
Signature · 1 line
2.30.2
PATCH v4 28/32 mtd: spi-nor: move all spansion specifics into spansion.c
In reply to Michael WalleThe clear status register flags is only available on spansion flashes. Move all the functions around that into the spanion module.
--- drivers/mtd/spi-nor/core.c | 49 ------------------------ drivers/mtd/spi-nor/spansion.c | 70 ++++++++++++++++++++++++++++++++++ include/linux/mtd/spi-nor.h | 1 - 3 files changed, 70 insertions(+), 50 deletions(-)
drivers/mtd/spi-nor/core.c +0 -49
@@ -554,33 +554,6 @@ int spi_nor_write_ear(struct spi_nor *nor, u8 ear)return ret; } -/** -* spi_nor_clear_sr() - Clear the Status Register. -* @nor: pointer to 'struct spi_nor'. -*/ -static void spi_nor_clear_sr (struct spi_nor *nor) -{ -int ret; - -if (nor->spimem) { -struct spi_mem_op op = -SPI_MEM_OP (SPI_MEM_OP_CMD (SPINOR_OP_CLSR ,0 ), -SPI_MEM_OP_NO_ADDR , -SPI_MEM_OP_NO_DUMMY , -SPI_MEM_OP_NO_DATA ); - -spi_nor_spimem_setup_op (nor, &op, nor->reg_proto); - - ret =spi_mem_exec_op (nor->spimem, &op); - }else { - ret =spi_nor_controller_ops_write_reg (nor,SPINOR_OP_CLSR , -NULL ,0 ); - } - -if (ret) -dev_dbg (nor->dev,"error %d clearing SR\n" , ret); -} -/** * spi_nor_sr_ready() - Query the Status Register to see if the flash is ready * for new commands.
@@ -595,28 +568,6 @@ int spi_nor_sr_ready(struct spi_nor *nor)if (ret)return ret; -if (nor->flags &SNOR_F_USE_CLSR && - nor->bouncebuf[0 ] & (SR_E_ERR |SR_P_ERR )) { -if (nor->bouncebuf[0 ] &SR_E_ERR ) -dev_err (nor->dev,"Erase Error occurred\n" ); -else -dev_err (nor->dev,"Programming Error occurred\n" ); - -spi_nor_clear_sr (nor); - -/* -* WEL bit remains set to one when an erase or page program -* error occurs. Issue a Write Disable command to protect -* against inadvertent writes that can possibly corrupt the -* contents of the memory. -*/ - ret =spi_nor_write_disable (nor); -if (ret) -return ret; - -return -EIO ; - } -return !(nor->bouncebuf[0 ] &SR_WIP ); }
drivers/mtd/spi-nor/spansion.c +70 -0
88 lines not on this page · raw message
include/linux/mtd/spi-nor.h +0 -1
@@ -90,7 +90,6 @@/* Used for Spansion flashes only. */ #define SPINOR_OP_BRWR 0x17/* Bank register write */ -#define SPINOR_OP_CLSR 0x30/* Clear status register 1 */ /* Used for Micron flashes only. */ #define SPINOR_OP_RD_EVCR 0x65/* Read EVCR register */
Signature · 1 line
2.30.2
Re: [PATCH v4 28/32] mtd: spi-nor: move all spansion specifics into spansion.c
Quoted 10 lines · Michael Walle
The clear status register flags is only available on spansion flashes. Move all the functions around that into the spanion module.
Signed-off-by Michael Walle <[email protected]>--- drivers/mtd/spi-nor/core.c | 49 ------------------------ drivers/mtd/spi-nor/spansion.c | 70 ++++++++++++++++++++++++++++++++++ include/linux/mtd/spi-nor.h | 1 - 3 files changed, 70 insertions(+), 50 deletions(-)
[...]
Quoted 36 lines
drivers/mtd/spi-nor/spansion.c +21
-0@@ -8,6 +8,7 @@#include "core.h" +#define SPINOR_OP_CLSR 0x30/* Clear status register 1 */ #define SPINOR_OP_RD_ANY_REG 0x65/* Read any register */ #define SPINOR_OP_WR_ANY_REG 0x71/* Write any register */ #define SPINOR_REG_CYPRESS_CFR2V 0x00800003@@ -294,6 +295,72 @@ static const struct flash_info spansion_nor_parts[] = { }, }; +/** +* spi_nor_clear_sr() - Clear the Status Register. +* @nor: pointer to 'struct spi_nor'. +*/ +static void spi_nor_clear_sr (struct spi_nor *nor) +{ +int ret; + +if (nor->spimem) { +struct spi_mem_op op = +SPI_MEM_OP (SPI_MEM_OP_CMD (SPINOR_OP_CLSR ,0 ), +SPI_MEM_OP_NO_ADDR , +SPI_MEM_OP_NO_DUMMY , +SPI_MEM_OP_NO_DATA ); + +spi_nor_spimem_setup_op (nor, &op, nor->reg_proto); + + ret =spi_mem_exec_op (nor->spimem, &op); + }else { + ret = spi_nor_controller_ops_write_reg(nor, SPINOR_OP_CLSR,
drivers/mtd/spi-nor/spansion.c static const struct flash_info spansion_nor_parts[] = { · line 327
Quoted 10 lines
drivers/mtd/spi-nor/spansion.c +10
-0+ NULL, 0); + } + +if (ret) +dev_dbg (nor->dev,"error %d clearing SR\n" , ret); +} + +/** +* spi_nor_sr_ready_and_clear() - Query the Status Register to see if the flash +* is ready for new commands and clear it.
Nitpick: "... and clear it if there are any errors."
Looks good otherwise.
Quoted 64 lines
drivers/mtd/spi-nor/spansion.c +39
-0+* @nor: pointer to 'struct spi_nor'. +* +* Return: 1 if ready, 0 if not ready, -errno on errors. +*/ +static int spi_nor_sr_ready_and_clear (struct spi_nor *nor) +{ +int ret; + + ret =spi_nor_read_sr (nor, nor->bouncebuf); +if (ret) +return ret; + +if (nor->bouncebuf[0 ] & (SR_E_ERR |SR_P_ERR )) { +if (nor->bouncebuf[0 ] &SR_E_ERR ) +dev_err (nor->dev,"Erase Error occurred\n" ); +else +dev_err (nor->dev,"Programming Error occurred\n" ); + +spi_nor_clear_sr (nor); + +/* +* WEL bit remains set to one when an erase or page program +* error occurs. Issue a Write Disable command to protect +* against inadvertent writes that can possibly corrupt the +* contents of the memory. +*/ + ret =spi_nor_write_disable (nor); +if (ret) +return ret; + +return -EIO ; + } + +return !(nor->bouncebuf[0 ] &SR_WIP ); +} +static void spansion_nor_late_init (struct spi_nor *nor) {if (nor->params->size >SZ_16M ) {@@ -302,6 +369,9 @@ static void spansion_nor_late_init(struct spi_nor *nor) nor->erase_opcode =SPINOR_OP_SE ; nor->mtd.erasesize = nor->info->sector_size; } + +if (nor->flags &SNOR_F_USE_CLSR ) + nor->params->ready = spi_nor_sr_ready_and_clear; }static const struct spi_nor_fixups spansion_nor_fixups = {include/linux/mtd/spi-nor.h +0
-1@@ -90,7 +90,6 @@/* Used for Spansion flashes only. */ #define SPINOR_OP_BRWR 0x17/* Bank register write */ -#define SPINOR_OP_CLSR 0x30/* Clear status register 1 */ /* Used for Micron flashes only. */ #define SPINOR_OP_RD_EVCR 0x65/* Read EVCR register */ Signature · 1 line
2.30.2
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 29/32 mtd: spi-nor: spansion: convert USE_CLSR to a manufacturer flag
In reply to Michael WalleNow that all functions using that flag are local to the spansion module, we can convert the flag to a manufacturer one.
--- drivers/mtd/spi-nor/core.c | 3 -- drivers/mtd/spi-nor/core.h | 3 -- drivers/mtd/spi-nor/spansion.c | 55 +++++++++++++++++++++------------- 3 files changed, 34 insertions(+), 27 deletions(-)
drivers/mtd/spi-nor/core.c +0 -3
@@ -2447,9 +2447,6 @@ static void spi_nor_init_flags(struct spi_nor *nor)if (flags &NO_CHIP_ERASE ) nor->flags |=SNOR_F_NO_OP_CHIP_ERASE ; - -if (flags &USE_CLSR ) - nor->flags |=SNOR_F_USE_CLSR ; }/**
drivers/mtd/spi-nor/core.h +0 -3
@@ -14,7 +14,6 @@enum spi_nor_option_flags {SNOR_F_HAS_SR_TB =BIT (1 ),SNOR_F_NO_OP_CHIP_ERASE =BIT (2 ), -SNOR_F_USE_CLSR =BIT (4 ),SNOR_F_BROKEN_RESET =BIT (5 ),SNOR_F_4B_OPCODES =BIT (6 ),SNOR_F_HAS_4BAIT =BIT (7 ),
@@ -347,7 +346,6 @@ struct spi_nor_fixups {* SPI_NOR_NO_ERASE: no erase command needed. * NO_CHIP_ERASE: chip does not support chip erase. * SPI_NOR_NO_FR: can't do fastread. -* USE_CLSR: use CLSR command. * * @no_sfdp_flags: flags that indicate support that can be discovered via SFDP. * Used when SFDP tables are not defined in the flash. These
@@ -398,7 +396,6 @@ struct flash_info {#define SPI_NOR_NO_ERASE BIT(6)#define NO_CHIP_ERASE BIT(7)#define SPI_NOR_NO_FR BIT(8) -#define USE_CLSR BIT(9)u8 no_sfdp_flags;#define SPI_NOR_SKIP_SFDP BIT(0)
drivers/mtd/spi-nor/spansion.c +34 -21
90 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v4 30/32 mtd: spi-nor: spansion: rename vendor specific functions and defines
In reply to Michael WalleDrop the generic spi_nor prefix for all the spansion functions.
--- drivers/mtd/spi-nor/spansion.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/mtd/spi-nor/spansion.c +7 -7
@@ -309,10 +309,10 @@ static const struct flash_info spansion_nor_parts[] = { };/** -* spi_nor_clear_sr() - Clear the Status Register. +* spansion_nor_clear_sr() - Clear the Status Register. * @nor: pointer to 'struct spi_nor'. */ -static void spi_nor_clear_sr (struct spi_nor *nor) +static void spansion_nor_clear_sr (struct spi_nor *nor) {int ret;
@@ -336,13 +336,13 @@ static void spi_nor_clear_sr(struct spi_nor *nor) }/** -* spi_nor_sr_ready_and_clear() - Query the Status Register to see if the flash -* is ready for new commands and clear it. +* spansion_nor_sr_ready_and_clear() - Query the Status Register to see if the +* flash is ready for new commands and clear it. * @nor: pointer to 'struct spi_nor'. * * Return: 1 if ready, 0 if not ready, -errno on errors. */ -static int spi_nor_sr_ready_and_clear (struct spi_nor *nor) +static int spansion_nor_sr_ready_and_clear (struct spi_nor *nor) {int ret;
@@ -356,7 +356,7 @@ static int spi_nor_sr_ready_and_clear(struct spi_nor *nor)else dev_err (nor->dev,"Programming Error occurred\n" ); -spi_nor_clear_sr (nor); +spansion_nor_clear_sr (nor);/* * WEL bit remains set to one when an erase or page program
@@ -384,7 +384,7 @@ static void spansion_nor_late_init(struct spi_nor *nor) }if (nor->info->mfr_flags &USE_CLSR ) - nor->params->ready = spi_nor_sr_ready_and_clear; + nor->params->ready = spansion_nor_sr_ready_and_clear; }static const struct spi_nor_fixups spansion_nor_fixups = {
Signature · 1 line
2.30.2
Re: [PATCH v4 30/32] mtd: spi-nor: spansion: rename vendor specific functions and defines
Quoted 3 lines · Michael Walle
Drop the generic
spi_norprefix for all the spansion functions.Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 31/32 mtd: spi-nor: slightly change code style in spi_nor_sr_ready()
In reply to Michael WalleNow that there is almost no special case code left in spi_nor_sr_ready(), the return check looks odd. Move the function call closer to the return code checking.
--- drivers/mtd/spi-nor/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +2 -1
@@ -563,8 +563,9 @@ int spi_nor_write_ear(struct spi_nor *nor, u8 ear)*/ int spi_nor_sr_ready (struct spi_nor *nor) { -int ret =spi_nor_read_sr (nor, nor->bouncebuf); +int ret; + ret =spi_nor_read_sr (nor, nor->bouncebuf);if (ret)return ret;
Signature · 1 line
2.30.2
Re: [PATCH v4 31/32] mtd: spi-nor: slightly change code style in spi_nor_sr_ready()
Quoted 5 lines · Michael Walle
Now that there is almost no special case code left in
spi_nor_sr_ready(), the return check looks odd. Move the function call closer to the return code checking.Signed-off-by Michael Walle <[email protected]>
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
PATCH v4 32/32 mtd: spi-nor: renumber flags
In reply to Michael WalleAs we have deleted some flag, lets renumber them so there are no holes.
--- drivers/mtd/spi-nor/core.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/mtd/spi-nor/core.h +14 -14
@@ -12,20 +12,20 @@#define SPI_NOR_MAX_ID_LEN 6enum spi_nor_option_flags { -SNOR_F_HAS_SR_TB =BIT (1 ), -SNOR_F_NO_OP_CHIP_ERASE =BIT (2 ), -SNOR_F_BROKEN_RESET =BIT (5 ), -SNOR_F_4B_OPCODES =BIT (6 ), -SNOR_F_HAS_4BAIT =BIT (7 ), -SNOR_F_HAS_LOCK =BIT (8 ), -SNOR_F_HAS_16BIT_SR =BIT (9 ), -SNOR_F_NO_READ_CR =BIT (10 ), -SNOR_F_HAS_SR_TB_BIT6 =BIT (11 ), -SNOR_F_HAS_4BIT_BP =BIT (12 ), -SNOR_F_HAS_SR_BP3_BIT6 =BIT (13 ), -SNOR_F_IO_MODE_EN_VOLATILE =BIT (14 ), -SNOR_F_SOFT_RESET =BIT (15 ), -SNOR_F_SWP_IS_VOLATILE =BIT (16 ), +SNOR_F_HAS_SR_TB =BIT (0 ), +SNOR_F_NO_OP_CHIP_ERASE =BIT (1 ), +SNOR_F_BROKEN_RESET =BIT (2 ), +SNOR_F_4B_OPCODES =BIT (3 ), +SNOR_F_HAS_4BAIT =BIT (4 ), +SNOR_F_HAS_LOCK =BIT (5 ), +SNOR_F_HAS_16BIT_SR =BIT (6 ), +SNOR_F_NO_READ_CR =BIT (7 ), +SNOR_F_HAS_SR_TB_BIT6 =BIT (8 ), +SNOR_F_HAS_4BIT_BP =BIT (9 ), +SNOR_F_HAS_SR_BP3_BIT6 =BIT (10 ), +SNOR_F_IO_MODE_EN_VOLATILE =BIT (11 ), +SNOR_F_SOFT_RESET =BIT (12 ), +SNOR_F_SWP_IS_VOLATILE =BIT (13 ), };struct spi_nor_read_command {
Signature · 1 line
2.30.2
I would like some tested-by tags if possible. At least with a micron and a spansion flash. I think I have a micron and a spansion somewhere, I'll try to do a short test too.
Cheers,
ta
Pratyush Yadav
Tested-byQuoted 2 lines · On 22/02/22 08:59AM, [email protected] wrote:
I would like some tested-by tags if possible. At least with a micron and a spansion flash. I think I have a micron and a spansion somewhere, I'll try to do a short test too.
I still have some patches left to review in this series. But in the meantime, I have tested it on a Micron and Spansion flash. Ran through a few Erase/Program/Read cycles.
Quoted 3 lines
Cheers,
ta
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.