mtd: spi-nor: drop \t after #define
Subsystems (4)
PATCH 1/9 mtd: spi-nor: drop \t after #define
Spacing is a little non-standard here.
---
Series based on l2-mtd.git/spinor:
http://git.infradead.org/l2-mtd.git
include/linux/mtd/spi-nor.h | 68 ++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-)
include/linux/mtd/spi-nor.h +34 -34
@@ -2,50 +2,50 @@#define __LINUX_MTD_SPI_NOR_H/* Flash opcodes. */ -#define OPCODE_WREN 0x06/* Write enable */ -#define OPCODE_RDSR 0x05/* Read status register */ -#define OPCODE_WRSR 0x01/* Write status register 1 byte */ -#define OPCODE_NORM_READ 0x03/* Read data bytes (low frequency) */ -#define OPCODE_FAST_READ 0x0b/* Read data bytes (high frequency) */ -#define OPCODE_DUAL_READ 0x3b/* Read data bytes (Dual SPI) */ -#define OPCODE_QUAD_READ 0x6b/* Read data bytes (Quad SPI) */ -#define OPCODE_PP 0x02/* Page program (up to 256 bytes) */ -#define OPCODE_BE_4K 0x20/* Erase 4KiB block */ -#define OPCODE_BE_4K_PMC 0xd7/* Erase 4KiB block on PMC chips */ -#define OPCODE_BE_32K 0x52/* Erase 32KiB block */ -#define OPCODE_CHIP_ERASE 0xc7/* Erase whole flash chip */ -#define OPCODE_SE 0xd8/* Sector erase (usually 64KiB) */ -#define OPCODE_RDID 0x9f/* Read JEDEC ID */ -#define OPCODE_RDCR 0x35/* Read configuration register */ +#define OPCODE_WREN 0x06/* Write enable */ +#define OPCODE_RDSR 0x05/* Read status register */ +#define OPCODE_WRSR 0x01/* Write status register 1 byte */ +#define OPCODE_NORM_READ 0x03/* Read data bytes (low frequency) */ +#define OPCODE_FAST_READ 0x0b/* Read data bytes (high frequency) */ +#define OPCODE_DUAL_READ 0x3b/* Read data bytes (Dual SPI) */ +#define OPCODE_QUAD_READ 0x6b/* Read data bytes (Quad SPI) */ +#define OPCODE_PP 0x02/* Page program (up to 256 bytes) */ +#define OPCODE_BE_4K 0x20/* Erase 4KiB block */ +#define OPCODE_BE_4K_PMC 0xd7/* Erase 4KiB block on PMC chips */ +#define OPCODE_BE_32K 0x52/* Erase 32KiB block */ +#define OPCODE_CHIP_ERASE 0xc7/* Erase whole flash chip */ +#define OPCODE_SE 0xd8/* Sector erase (usually 64KiB) */ +#define OPCODE_RDID 0x9f/* Read JEDEC ID */ +#define OPCODE_RDCR 0x35/* Read configuration register */ /* 4-byte address opcodes - used on Spansion and some Macronix flashes. */ -#define OPCODE_NORM_READ_4B 0x13/* Read data bytes (low frequency) */ -#define OPCODE_FAST_READ_4B 0x0c/* Read data bytes (high frequency) */ -#define OPCODE_DUAL_READ_4B 0x3c/* Read data bytes (Dual SPI) */ -#define OPCODE_QUAD_READ_4B 0x6c/* Read data bytes (Quad SPI) */ -#define OPCODE_PP_4B 0x12/* Page program (up to 256 bytes) */ -#define OPCODE_SE_4B 0xdc/* Sector erase (usually 64KiB) */ +#define OPCODE_NORM_READ_4B 0x13/* Read data bytes (low frequency) */ +#define OPCODE_FAST_READ_4B 0x0c/* Read data bytes (high frequency) */ +#define OPCODE_DUAL_READ_4B 0x3c/* Read data bytes (Dual SPI) */ +#define OPCODE_QUAD_READ_4B 0x6c/* Read data bytes (Quad SPI) */ +#define OPCODE_PP_4B 0x12/* Page program (up to 256 bytes) */ +#define OPCODE_SE_4B 0xdc/* Sector erase (usually 64KiB) */ /* Used for SST flashes only. */ -#define OPCODE_BP 0x02/* Byte program */ -#define OPCODE_WRDI 0x04/* Write disable */ -#define OPCODE_AAI_WP 0xad/* Auto address increment word program */ +#define OPCODE_BP 0x02/* Byte program */ +#define OPCODE_WRDI 0x04/* Write disable */ +#define OPCODE_AAI_WP 0xad/* Auto address increment word program */ /* Used for Macronix and Winbond flashes. */ -#define OPCODE_EN4B 0xb7/* Enter 4-byte mode */ -#define OPCODE_EX4B 0xe9/* Exit 4-byte mode */ +#define OPCODE_EN4B 0xb7/* Enter 4-byte mode */ +#define OPCODE_EX4B 0xe9/* Exit 4-byte mode */ /* Used for Spansion flashes only. */ -#define OPCODE_BRWR 0x17/* Bank register write */ +#define OPCODE_BRWR 0x17/* Bank register write */ /* Status Register bits. */ -#define SR_WIP 1/* Write in progress */ -#define SR_WEL 2/* Write enable latch */ +#define SR_WIP 1/* Write in progress */ +#define SR_WEL 2/* Write enable latch */ /* meaning of other SR_* bits may differ between vendors */ -#define SR_BP0 4/* Block protect 0 */ -#define SR_BP1 8/* Block protect 1 */ -#define SR_BP2 0x10/* Block protect 2 */ -#define SR_SRWD 0x80/* SR write protect */ +#define SR_BP0 4/* Block protect 0 */ +#define SR_BP1 8/* Block protect 1 */ +#define SR_BP2 0x10/* Block protect 2 */ +#define SR_SRWD 0x80/* SR write protect */ #define SR_QUAD_EN_MX 0x40/* Macronix Quad I/O */
@@ -86,7 +86,7 @@ struct spi_nor_xfer_cfg {u8 dummy_cycles; }; -#define SPI_NOR_MAX_CMD_SIZE 8 +#define SPI_NOR_MAX_CMD_SIZE 8enum spi_nor_ops {SPI_NOR_OPS_READ =0 ,SPI_NOR_OPS_WRITE ,
Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/9 mtd: spi-nor: re-name OPCODE_* to SPINOR_OP_*
Qualify these with a better namespace, and prepare them for use in more drivers.
--- drivers/mtd/devices/m25p80.c | 4 +-- drivers/mtd/spi-nor/fsl-quadspi.c | 58 +++++++++++++++++------------------ drivers/mtd/spi-nor/spi-nor.c | 64 +++++++++++++++++++-------------------- include/linux/mtd/spi-nor.h | 54 ++++++++++++++++----------------- 4 files changed, 90 insertions(+), 90 deletions(-)
drivers/mtd/devices/m25p80.c +2 -2
@@ -86,7 +86,7 @@ static void m25p80_write(struct spi_nor *nor, loff_t to, size_t len,spi_message_init (&m); -if (nor->program_opcode ==OPCODE_AAI_WP && nor->sst_write_second) +if (nor->program_opcode ==SPINOR_OP_AAI_WP && nor->sst_write_second) cmd_sz =1 ; flash->command[0 ] = nor->program_opcode;
@@ -171,7 +171,7 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset)return ret;/* Send write enable, then erase commands. */ - ret = nor->write_reg (nor,OPCODE_WREN ,NULL ,0 ,0 ); + ret = nor->write_reg (nor,SPINOR_OP_WREN ,NULL ,0 ,0 );if (ret)return ret;
drivers/mtd/spi-nor/fsl-quadspi.c +29 -29
154 lines not on this page · raw message
drivers/mtd/spi-nor/spi-nor.c +32 -32
212 lines not on this page · raw message
include/linux/mtd/spi-nor.h +27 -27
68 lines not on this page · raw message
Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/9 mtd: spi-nor: unify read opcode variants with ST SPI FSM
In reply to Brian Norrisserial_flash_cmds.h defines our opcodes a little differently. Let's borrow its naming, since it's borrowed from the SFDP standard, and it's more extensible.
This prepares us for merging serial_flash_cmds.h and spi-nor.h opcode listing.
--- drivers/mtd/spi-nor/spi-nor.c | 16 ++++++++-------- include/linux/mtd/spi-nor.h | 24 ++++++++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-)
drivers/mtd/spi-nor/spi-nor.c +8 -8
@@ -1010,16 +1010,16 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,/* Default commands */ switch (nor->flash_read) {case SPI_NOR_QUAD : - nor->read_opcode =SPINOR_OP_QUAD_READ ; + nor->read_opcode =SPINOR_OP_READ_1_1_4 ;break ;case SPI_NOR_DUAL : - nor->read_opcode =SPINOR_OP_DUAL_READ ; + nor->read_opcode =SPINOR_OP_READ_1_1_2 ;break ;case SPI_NOR_FAST : - nor->read_opcode =SPINOR_OP_FAST_READ ; + nor->read_opcode =SPINOR_OP_READ_FAST ;break ;case SPI_NOR_NORMAL : - nor->read_opcode =SPINOR_OP_NORM_READ ; + nor->read_opcode =SPINOR_OP_READ ;break ;default :dev_err (dev,"No Read opcode defined\n" );
@@ -1037,16 +1037,16 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,/* Dedicated 4-byte command set */ switch (nor->flash_read) {case SPI_NOR_QUAD : - nor->read_opcode =SPINOR_OP_QUAD_READ_4B ; + nor->read_opcode =SPINOR_OP_READ4_1_1_4 ;break ;case SPI_NOR_DUAL : - nor->read_opcode =SPINOR_OP_DUAL_READ_4B ; + nor->read_opcode =SPINOR_OP_READ4_1_1_2 ;break ;case SPI_NOR_FAST : - nor->read_opcode =SPINOR_OP_FAST_READ_4B ; + nor->read_opcode =SPINOR_OP_READ4_FAST ;break ;case SPI_NOR_NORMAL : - nor->read_opcode =SPINOR_OP_NORM_READ_4B ; + nor->read_opcode =SPINOR_OP_READ4 ;break ; } nor->program_opcode =SPINOR_OP_PP_4B ;
include/linux/mtd/spi-nor.h +16 -8
@@ -1,14 +1,22 @@#ifndef __LINUX_MTD_SPI_NOR_H#define __LINUX_MTD_SPI_NOR_H +/* +* Note on opcode nomenclature: some opcodes have a format like +* SPINOR_OP_FUNCTION{4,}_x_y_z. The numbers x, y, and z stand for the number +* of I/O lines used for the opcode, address, and data (respectively). The +* FUNCTION has an optional suffix of '4', to represent an opcode which +* requires a 4-byte (32-bit) address. +*/ +/* Flash opcodes. */ #define SPINOR_OP_WREN 0x06/* Write enable */ #define SPINOR_OP_RDSR 0x05/* Read status register */ #define SPINOR_OP_WRSR 0x01/* Write status register 1 byte */ -#define SPINOR_OP_NORM_READ 0x03/* Read data bytes (low frequency) */ -#define SPINOR_OP_FAST_READ 0x0b/* Read data bytes (high frequency) */ -#define SPINOR_OP_DUAL_READ 0x3b/* Read data bytes (Dual SPI) */ -#define SPINOR_OP_QUAD_READ 0x6b/* Read data bytes (Quad SPI) */ +#define SPINOR_OP_READ 0x03/* Read data bytes (low frequency) */ +#define SPINOR_OP_READ_FAST 0x0b/* Read data bytes (high frequency) */ +#define SPINOR_OP_READ_1_1_2 0x3b/* Read data bytes (Dual SPI) */ +#define SPINOR_OP_READ_1_1_4 0x6b/* Read data bytes (Quad SPI) */ #define SPINOR_OP_PP 0x02/* Page program (up to 256 bytes) */ #define SPINOR_OP_BE_4K 0x20/* Erase 4KiB block */ #define SPINOR_OP_BE_4K_PMC 0xd7/* Erase 4KiB block on PMC chips */
@@ -19,10 +27,10 @@#define SPINOR_OP_RDCR 0x35/* Read configuration register */ /* 4-byte address opcodes - used on Spansion and some Macronix flashes. */ -#define SPINOR_OP_NORM_READ_4B 0x13/* Read data bytes (low frequency) */ -#define SPINOR_OP_FAST_READ_4B 0x0c/* Read data bytes (high frequency) */ -#define SPINOR_OP_DUAL_READ_4B 0x3c/* Read data bytes (Dual SPI) */ -#define SPINOR_OP_QUAD_READ_4B 0x6c/* Read data bytes (Quad SPI) */ +#define SPINOR_OP_READ4 0x13/* Read data bytes (low frequency) */ +#define SPINOR_OP_READ4_FAST 0x0c/* Read data bytes (high frequency) */ +#define SPINOR_OP_READ4_1_1_2 0x3c/* Read data bytes (Dual SPI) */ +#define SPINOR_OP_READ4_1_1_4 0x6c/* Read data bytes (Quad SPI) */ #define SPINOR_OP_PP_4B 0x12/* Page program (up to 256 bytes) */ #define SPINOR_OP_SE_4B 0xdc/* Sector erase (usually 64KiB) */
Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/9 Documentation: spi-nor: rewrite some portions
In reply to Brian Norris---
WIP. This could be improved more (e.g., don't spend too much time documenting history; just document the current framework)
Documentation/mtd/spi-nor.txt | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
Documentation/mtd/spi-nor.txt +15 -12
@@ -1,16 +1,20 @@ SPI NOR framework ============================================ -Part I - why we need this framework? +Part I - Why do we need this framework? ------------------------------------- -The SPI bus controller only deals with the byte stream. -Some controller does not works like a SPI bus controller, it works -like a SPI NOR controller instead, such as the Freescale's QuadSPI controller. +SPI bus controllers (drivers/spi/) only deal with streams of bytes; the bus +controller operates agnostic of the specific device attached. However, some +controllers (such as Freescale's QuadSPI controller) cannot easily handle +arbitrary streams of bytes, but rather are designed specifically for SPI NOR. -The Freescale's QuadSPI controller should know the NOR commands to -find the right LUT sequence. Unfortunately, the old code can not meet -this requirement. +Specifically, Freescale's QuadSPI controller must know the NOR commands to +find the right LUT sequence. Unfortunately, the SPI subsystem has no notion of +opcodes, addresses, or data payloads; a SPI controller simply knows to send or +receive bytes (Tx and Rx). Therefore, we must define a new layering scheme under +which the controller driver is aware of the opcodes, addressing, and other +details of the SPI NOR protocol. Part II - How does the framework work? -------------------------------------
@@ -40,7 +44,7 @@ m25p80 code anymore. ------------------------ SPI NOR chip - With the SPI NOR controller driver(Freescale QuadSPI), it looks like: + With the SPI NOR controller driver (Freescale QuadSPI), it looks like: MTD ------------------------ SPI NOR framework
@@ -53,7 +57,6 @@ Part III - How can the drivers use the framework ------------------------------------- The main API is the spi_nor_scan(). Before you call the hook, you should -initialize the necessary fields for spi_nor{}. -Please see the drivers/mtd/spi-nor/spi-nor.c for detail. -Please also reference to the fsl-quadspi.c when you want to write a new driver -for a SPI NOR controller. +initialize the necessary fields for spi_nor{}. Please see the +drivers/mtd/spi-nor/spi-nor.c for detail. Please also refer to the fsl-quadspi.c +when you want to write a new driver for a SPI NOR controller.
Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/9 mtd: spi-nor: shorten Kconfig naming
In reply to Brian Norris--- drivers/mtd/Makefile | 2 +- drivers/mtd/devices/Kconfig | 2 +- drivers/mtd/spi-nor/Kconfig | 11 ++++++++--- drivers/mtd/spi-nor/Makefile | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-)
drivers/mtd/Makefile +1 -1
@@ -32,5 +32,5 @@ inftl-objs := inftlcore.o inftlmount.o obj-y += chips/ lpddr/ maps/ devices/ nand/ onenand/ tests/ -obj-$(CONFIG_MTD_SPI_NOR_BASE) += spi-nor/ +obj-$(CONFIG_MTD_SPI_NOR) += spi-nor/ obj-$(CONFIG_MTD_UBI) += ubi/
drivers/mtd/devices/Kconfig +1 -1
@@ -80,7 +80,7 @@ config MTD_DATAFLASH_OTP config MTD_M25P80 tristate "Support most SPI Flash chips (AT26DF, M25P, W25X, ...)" - depends on SPI_MASTER && MTD_SPI_NOR_BASE + depends on SPI_MASTER && MTD_SPI_NOR help This enables access to most modern SPI flash chips, used for program and data storage. Series supported include Atmel AT26DF,
drivers/mtd/spi-nor/Kconfig +8 -3
@@ -1,12 +1,17 @@ -config MTD_SPI_NOR_BASE - bool "the framework for SPI-NOR support" +config MTD_SPI_NOR + bool "SPI-NOR device support" depends on MTD help This is the framework for the SPI NOR which can be used by the SPI device drivers and the SPI-NOR device driver. + +if MTD_SPI_NOR + config SPI_FSL_QUADSPI tristate "Freescale Quad SPI controller" - depends on ARCH_MXC && MTD_SPI_NOR_BASE + depends on ARCH_MXC help This enables support for the Quad SPI controller in master mode. We only connect the NOR to this controller now. + +endif # MTD_SPI_NOR
drivers/mtd/spi-nor/Makefile +1 -1
@@ -1,2 +1,2 @@ -obj-$(CONFIG_MTD_SPI_NOR_BASE) += spi-nor.o +obj-$(CONFIG_MTD_SPI_NOR) += spi-nor.o obj-$(CONFIG_SPI_FSL_QUADSPI) += fsl-quadspi.o
Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 6/9 mtd: st_spi_fsm: fixup Kconfig dependency
In reply to Brian NorrisI hear that this driver should depend on ARCH_STI, and that "SH" is not actually a real symbol. At the same time, let's allow compile-testing on other ARCH'es.
--- drivers/mtd/devices/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/devices/Kconfig +1 -1
@@ -212,7 +212,7 @@ config MTD_DOCG3 config MTD_ST_SPI_FSM tristate "ST Microelectronics SPI FSM Serial Flash Controller" - depends on ARM || SH + depends on ARCH_STI || COMPILE_TEST help This provides an MTD device driver for the ST Microelectronics SPI Fast Sequence Mode (FSM) Serial Flash Controller and support
Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/9 mtd: st_spi_fsm: kill duplicate CMD definitions
In reply to Brian NorrisThese are also in serial_flash_cmds.h. (FWIW, I didn't know the C preprocessor allowed redefinitions without warning like this.)
--- drivers/mtd/devices/st_spi_fsm.c | 36 ------------------------------------ 1 file changed, 36 deletions(-)
drivers/mtd/devices/st_spi_fsm.c +0 -36
@@ -201,42 +201,6 @@#define STFSM_MAX_WAIT_SEQ_MS 1000/* FSM execution time */ -/* Flash Commands */ -#define FLASH_CMD_WREN 0x06 -#define FLASH_CMD_WRDI 0x04 -#define FLASH_CMD_RDID 0x9f -#define FLASH_CMD_RDSR 0x05 -#define FLASH_CMD_RDSR2 0x35 -#define FLASH_CMD_WRSR 0x01 -#define FLASH_CMD_SE_4K 0x20 -#define FLASH_CMD_SE_32K 0x52 -#define FLASH_CMD_SE 0xd8 -#define FLASH_CMD_CHIPERASE 0xc7 - -#define FLASH_CMD_READ 0x03/* READ */ -#define FLASH_CMD_READ_FAST 0x0b/* FAST READ */ -#define FLASH_CMD_READ_1_1_2 0x3b/* DUAL OUTPUT READ */ -#define FLASH_CMD_READ_1_2_2 0xbb/* DUAL I/O READ */ -#define FLASH_CMD_READ_1_1_4 0x6b/* QUAD OUTPUT READ */ -#define FLASH_CMD_READ_1_4_4 0xeb/* QUAD I/O READ */ - -#define FLASH_CMD_WRITE 0x02/* PAGE PROGRAM */ -#define FLASH_CMD_WRITE_1_1_2 0xa2/* DUAL INPUT PROGRAM */ -#define FLASH_CMD_WRITE_1_2_2 0xd2/* DUAL INPUT EXT PROGRAM */ -#define FLASH_CMD_WRITE_1_1_4 0x32/* QUAD INPUT PROGRAM */ -#define FLASH_CMD_WRITE_1_4_4 0x12/* QUAD INPUT EXT PROGRAM */ - -#define FLASH_CMD_EN4B_ADDR 0xb7/* Enter 4-byte address mode */ -#define FLASH_CMD_EX4B_ADDR 0xe9/* Exit 4-byte address mode */ - -/* READ commands with 32-bit addressing (N25Q256 and S25FLxxxS) */ -#define FLASH_CMD_READ4 0x13 -#define FLASH_CMD_READ4_FAST 0x0c -#define FLASH_CMD_READ4_1_1_2 0x3c -#define FLASH_CMD_READ4_1_2_2 0xbc -#define FLASH_CMD_READ4_1_1_4 0x6c -#define FLASH_CMD_READ4_1_4_4 0xec -/* S25FLxxxS commands */ #define S25FL_CMD_WRITE4_1_1_4 0x34#define S25FL_CMD_SE4 0xdc
Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 8/9 mtd: st_spi_fsm: replace FLACH_CMD_* with SPINOR_OP_*
In reply to Brian NorrisBegin to unify the differences between serial_flash_cmds.h and spi-nor.h.
--- drivers/mtd/devices/serial_flash_cmds.h | 62 +++++++++--------- drivers/mtd/devices/st_spi_fsm.c | 112 ++++++++++++++++---------------- 2 files changed, 87 insertions(+), 87 deletions(-)
drivers/mtd/devices/serial_flash_cmds.h +31 -31
@@ -13,43 +13,43 @@#define _MTD_SERIAL_FLASH_CMDS_H/* Generic Flash Commands/OPCODEs */ -#define FLASH_CMD_WREN 0x06 -#define FLASH_CMD_WRDI 0x04 -#define FLASH_CMD_RDID 0x9f -#define FLASH_CMD_RDSR 0x05 -#define FLASH_CMD_RDSR2 0x35 -#define FLASH_CMD_WRSR 0x01 -#define FLASH_CMD_SE_4K 0x20 -#define FLASH_CMD_SE_32K 0x52 -#define FLASH_CMD_SE 0xd8 -#define FLASH_CMD_CHIPERASE 0xc7 -#define FLASH_CMD_WRVCR 0x81 -#define FLASH_CMD_RDVCR 0x85 +#define SPINOR_OP_WREN 0x06 +#define SPINOR_OP_WRDI 0x04 +#define SPINOR_OP_RDID 0x9f +#define SPINOR_OP_RDSR 0x05 +#define SPINOR_OP_RDSR2 0x35 +#define SPINOR_OP_WRSR 0x01 +#define SPINOR_OP_SE_4K 0x20 +#define SPINOR_OP_SE_32K 0x52 +#define SPINOR_OP_SE 0xd8 +#define SPINOR_OP_CHIPERASE 0xc7 +#define SPINOR_OP_WRVCR 0x81 +#define SPINOR_OP_RDVCR 0x85/* JEDEC Standard - Serial Flash Discoverable Parmeters (SFDP) Commands */ -#define FLASH_CMD_READ 0x03/* READ */ -#define FLASH_CMD_READ_FAST 0x0b/* FAST READ */ -#define FLASH_CMD_READ_1_1_2 0x3b/* DUAL OUTPUT READ */ -#define FLASH_CMD_READ_1_2_2 0xbb/* DUAL I/O READ */ -#define FLASH_CMD_READ_1_1_4 0x6b/* QUAD OUTPUT READ */ -#define FLASH_CMD_READ_1_4_4 0xeb/* QUAD I/O READ */ +#define SPINOR_OP_READ 0x03/* READ */ +#define SPINOR_OP_READ_FAST 0x0b/* FAST READ */ +#define SPINOR_OP_READ_1_1_2 0x3b/* DUAL OUTPUT READ */ +#define SPINOR_OP_READ_1_2_2 0xbb/* DUAL I/O READ */ +#define SPINOR_OP_READ_1_1_4 0x6b/* QUAD OUTPUT READ */ +#define SPINOR_OP_READ_1_4_4 0xeb/* QUAD I/O READ */ -#define FLASH_CMD_WRITE 0x02/* PAGE PROGRAM */ -#define FLASH_CMD_WRITE_1_1_2 0xa2/* DUAL INPUT PROGRAM */ -#define FLASH_CMD_WRITE_1_2_2 0xd2/* DUAL INPUT EXT PROGRAM */ -#define FLASH_CMD_WRITE_1_1_4 0x32/* QUAD INPUT PROGRAM */ -#define FLASH_CMD_WRITE_1_4_4 0x12/* QUAD INPUT EXT PROGRAM */ +#define SPINOR_OP_WRITE 0x02/* PAGE PROGRAM */ +#define SPINOR_OP_WRITE_1_1_2 0xa2/* DUAL INPUT PROGRAM */ +#define SPINOR_OP_WRITE_1_2_2 0xd2/* DUAL INPUT EXT PROGRAM */ +#define SPINOR_OP_WRITE_1_1_4 0x32/* QUAD INPUT PROGRAM */ +#define SPINOR_OP_WRITE_1_4_4 0x12/* QUAD INPUT EXT PROGRAM */ -#define FLASH_CMD_EN4B_ADDR 0xb7/* Enter 4-byte address mode */ -#define FLASH_CMD_EX4B_ADDR 0xe9/* Exit 4-byte address mode */ +#define SPINOR_OP_EN4B_ADDR 0xb7/* Enter 4-byte address mode */ +#define SPINOR_OP_EX4B_ADDR 0xe9/* Exit 4-byte address mode */ /* READ commands with 32-bit addressing */ -#define FLASH_CMD_READ4 0x13 -#define FLASH_CMD_READ4_FAST 0x0c -#define FLASH_CMD_READ4_1_1_2 0x3c -#define FLASH_CMD_READ4_1_2_2 0xbc -#define FLASH_CMD_READ4_1_1_4 0x6c -#define FLASH_CMD_READ4_1_4_4 0xec +#define SPINOR_OP_READ4 0x13 +#define SPINOR_OP_READ4_FAST 0x0c +#define SPINOR_OP_READ4_1_1_2 0x3c +#define SPINOR_OP_READ4_1_2_2 0xbc +#define SPINOR_OP_READ4_1_1_4 0x6c +#define SPINOR_OP_READ4_1_4_4 0xec/* Configuration flags */ #define FLASH_FLAG_SINGLE 0x000000ff
drivers/mtd/devices/st_spi_fsm.c +56 -56
275 lines not on this page · raw message
Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 9/9 mtd: st_spi_fsm: begin using spi-nor.h opcodes
In reply to Brian NorrisMany of the serial_flash_cmds.h opcodes are duplicated with spi-nor.h. Let's begin to unify them.
--- drivers/mtd/devices/serial_flash_cmds.h | 20 -------------------- drivers/mtd/devices/st_spi_fsm.c | 9 +++++---- 2 files changed, 5 insertions(+), 24 deletions(-)
drivers/mtd/devices/serial_flash_cmds.h +0 -20
@@ -13,25 +13,12 @@#define _MTD_SERIAL_FLASH_CMDS_H/* Generic Flash Commands/OPCODEs */ -#define SPINOR_OP_WREN 0x06 -#define SPINOR_OP_WRDI 0x04 -#define SPINOR_OP_RDID 0x9f -#define SPINOR_OP_RDSR 0x05#define SPINOR_OP_RDSR2 0x35 -#define SPINOR_OP_WRSR 0x01 -#define SPINOR_OP_SE_4K 0x20 -#define SPINOR_OP_SE_32K 0x52 -#define SPINOR_OP_SE 0xd8 -#define SPINOR_OP_CHIPERASE 0xc7#define SPINOR_OP_WRVCR 0x81#define SPINOR_OP_RDVCR 0x85/* JEDEC Standard - Serial Flash Discoverable Parmeters (SFDP) Commands */ -#define SPINOR_OP_READ 0x03/* READ */ -#define SPINOR_OP_READ_FAST 0x0b/* FAST READ */ -#define SPINOR_OP_READ_1_1_2 0x3b/* DUAL OUTPUT READ */ #define SPINOR_OP_READ_1_2_2 0xbb/* DUAL I/O READ */ -#define SPINOR_OP_READ_1_1_4 0x6b/* QUAD OUTPUT READ */ #define SPINOR_OP_READ_1_4_4 0xeb/* QUAD I/O READ */ #define SPINOR_OP_WRITE 0x02/* PAGE PROGRAM */
@@ -40,15 +27,8 @@#define SPINOR_OP_WRITE_1_1_4 0x32/* QUAD INPUT PROGRAM */ #define SPINOR_OP_WRITE_1_4_4 0x12/* QUAD INPUT EXT PROGRAM */ -#define SPINOR_OP_EN4B_ADDR 0xb7/* Enter 4-byte address mode */ -#define SPINOR_OP_EX4B_ADDR 0xe9/* Exit 4-byte address mode */ -/* READ commands with 32-bit addressing */ -#define SPINOR_OP_READ4 0x13 -#define SPINOR_OP_READ4_FAST 0x0c -#define SPINOR_OP_READ4_1_1_2 0x3c#define SPINOR_OP_READ4_1_2_2 0xbc -#define SPINOR_OP_READ4_1_1_4 0x6c#define SPINOR_OP_READ4_1_4_4 0xec/* Configuration flags */
drivers/mtd/devices/st_spi_fsm.c +5 -4
@@ -19,6 +19,7 @@#include <linux/mfd/syscon.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> +#include <linux/mtd/spi-nor.h> #include <linux/sched.h> #include <linux/delay.h> #include <linux/io.h>
@@ -522,7 +523,7 @@ static int stfsm_mx25_en_32bit_addr_seq(struct stfsm_seq *seq) { seq->seq_opc[0 ] = (SEQ_OPC_PADS_1 |SEQ_OPC_CYCLES (8 ) | -SEQ_OPC_OPCODE (SPINOR_OP_EN4B_ADDR ) | +SEQ_OPC_OPCODE (SPINOR_OP_EN4B ) |SEQ_OPC_CSDEASSERT ); seq->seq[0 ] =STFSM_INST_CMD1 ;
@@ -630,7 +631,7 @@ static struct stfsm_seq stfsm_seq_erase_chip = { SEQ_OPC_OPCODE(SPINOR_OP_WREN) | SEQ_OPC_CSDEASSERT), (SEQ_OPC_PADS_1 |SEQ_OPC_CYCLES (8 ) | - SEQ_OPC_OPCODE(SPINOR_OP_CHIPERASE) | SEQ_OPC_CSDEASSERT), + SEQ_OPC_OPCODE(SPINOR_OP_CHIP_ERASE) | SEQ_OPC_CSDEASSERT), }, .seq = { STFSM_INST_CMD1,
@@ -665,7 +666,7 @@ static struct stfsm_seq stfsm_seq_write_status = {static int stfsm_n25q_en_32bit_addr_seq (struct stfsm_seq *seq) { seq->seq_opc[0 ] = (SEQ_OPC_PADS_1 |SEQ_OPC_CYCLES (8 ) | -SEQ_OPC_OPCODE (SPINOR_OP_EN4B_ADDR )); +SEQ_OPC_OPCODE (SPINOR_OP_EN4B )); seq->seq_opc[1 ] = (SEQ_OPC_PADS_1 |SEQ_OPC_CYCLES (8 ) |SEQ_OPC_OPCODE (SPINOR_OP_WREN ) |SEQ_OPC_CSDEASSERT );
@@ -788,7 +789,7 @@ static int stfsm_write_fifo(struct stfsm *fsm, const uint32_t *buf,static int stfsm_enter_32bit_addr (struct stfsm *fsm,int enter) {struct stfsm_seq *seq = &fsm->stfsm_seq_en_32bit_addr; -uint32_t cmd = enter ?SPINOR_OP_EN4B_ADDR :SPINOR_OP_EX4B_ADDR ; +uint32_t cmd = enter ?SPINOR_OP_EN4B :SPINOR_OP_EX4B ; seq->seq_opc[0] = (SEQ_OPC_PADS_1 | SEQ_OPC_CYCLES(8) |
Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 17 lines · Brian Norris
Spacing is a little non-standard here.
Signed-off-by Brian Norris <[email protected]>---
Series based on l2-mtd.git/spinor:http://git.infradead.org/l2-mtd.git
include/linux/mtd/spi-nor.h | 68++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-)
include/linux/mtd/spi-nor.h +0
-0
include/linux/mtd/spi-nor.h line 7
Quoted 6 lines
include/linux/mtd/spi-nor.h +0
-3@@ -2,50 +2,50 @@#define __LINUX_MTD_SPI_NOR_H/* Flash opcodes. */ -#define OPCODE_WREN 0x06/* Write enable */ -#define OPCODE_RDSR 0x05/* Read status register */ -#define OPCODE_WRSR 0x01/* Write status register 1 byte
*/
include/linux/mtd/spi-nor.h line 8
Quoted 1 line
include/linux/mtd/spi-nor.h +0
-1-#define OPCODE_NORM_READ 0x03/* Read data bytes (low
frequency) */
include/linux/mtd/spi-nor.h line 9
Quoted 1 line
include/linux/mtd/spi-nor.h +0
-1-#define OPCODE_FAST_READ 0x0b/* Read data bytes (high
frequency) */
include/linux/mtd/spi-nor.h
Quoted 3 lines
include/linux/mtd/spi-nor.h +0
-3-#define OPCODE_DUAL_READ 0x3b/* Read data bytes (Dual SPI) */ -#define OPCODE_QUAD_READ 0x6b/* Read data bytes (Quad SPI) */ -#define OPCODE_PP 0x02/* Page program (up to 256
bytes) */
include/linux/mtd/spi-nor.h line 14
Quoted 2 lines
include/linux/mtd/spi-nor.h +0
-2-#define OPCODE_BE_4K 0x20/* Erase 4KiB block */ -#define OPCODE_BE_4K_PMC 0xd7/* Erase 4KiB block on PMC chips
*/
include/linux/mtd/spi-nor.h
Quoted 3 lines
include/linux/mtd/spi-nor.h +0
-3-#define OPCODE_BE_32K 0x52/* Erase 32KiB block */ -#define OPCODE_CHIP_ERASE 0xc7/* Erase whole flash chip */ -#define OPCODE_SE 0xd8/* Sector erase (usually 64KiB)
*/
include/linux/mtd/spi-nor.h line 19
Quoted 2 lines
include/linux/mtd/spi-nor.h +0
-2-#define OPCODE_RDID 0x9f/* Read JEDEC ID */ -#define OPCODE_RDCR 0x35/* Read configuration register
*/
include/linux/mtd/spi-nor.h line 11
Quoted 7 lines
include/linux/mtd/spi-nor.h +7
-0+#define OPCODE_WREN 0x06/* Write enable */ +#define OPCODE_RDSR 0x05/* Read status register */ +#define OPCODE_WRSR 0x01/* Write status register 1 byte */ +#define OPCODE_NORM_READ 0x03/* Read data bytes (low frequency) */ +#define OPCODE_FAST_READ 0x0b/* Read data bytes (high frequency) */ +#define OPCODE_DUAL_READ 0x3b/* Read data bytes (Dual SPI) */ +#define OPCODE_QUAD_READ 0x6b/* Read data bytes (Quad SPI) */
This is still a little non-standard -- or rather -- inconsistent here. You should use space after #define and \t after the name I'd say. I'd also say these two slipped your attention as the others do it just like that.
include/linux/mtd/spi-nor.h line 19
Quoted 8 lines
include/linux/mtd/spi-nor.h +8
-0+#define OPCODE_PP 0x02/* Page program (up to 256 bytes) */ +#define OPCODE_BE_4K 0x20/* Erase 4KiB block */ +#define OPCODE_BE_4K_PMC 0xd7/* Erase 4KiB block on PMC chips */ +#define OPCODE_BE_32K 0x52/* Erase 32KiB block */ +#define OPCODE_CHIP_ERASE 0xc7/* Erase whole flash chip */ +#define OPCODE_SE 0xd8/* Sector erase (usually 64KiB) */ +#define OPCODE_RDID 0x9f/* Read JEDEC ID */ +#define OPCODE_RDCR 0x35/* Read configuration register */
DTTO here.
include/linux/mtd/spi-nor.h line 21
Quoted 2 lines
include/linux/mtd/spi-nor.h +0
-1/* 4-byte address opcodes - used on Spansion and some Macronix flashes. */ -#define OPCODE_NORM_READ_4B 0x13/* Read data bytes (low
frequency) */
include/linux/mtd/spi-nor.h line 22
Quoted 1 line
include/linux/mtd/spi-nor.h +0
-1-#define OPCODE_FAST_READ_4B 0x0c/* Read data bytes (high
frequency) */
include/linux/mtd/spi-nor.h
Quoted 3 lines
include/linux/mtd/spi-nor.h +0
-3-#define OPCODE_DUAL_READ_4B 0x3c/* Read data bytes (Dual SPI) */ -#define OPCODE_QUAD_READ_4B 0x6c/* Read data bytes (Quad SPI) */ -#define OPCODE_PP_4B 0x12/* Page program (up to 256
bytes) */
include/linux/mtd/spi-nor.h line 26
Quoted 1 line
include/linux/mtd/spi-nor.h +0
-1-#define OPCODE_SE_4B 0xdc/* Sector erase (usually 64KiB)
*/
include/linux/mtd/spi-nor.h line 25
Quoted 4 lines
include/linux/mtd/spi-nor.h +4
-0+#define OPCODE_NORM_READ_4B 0x13/* Read data bytes (low frequency) */ +#define OPCODE_FAST_READ_4B 0x0c/* Read data bytes (high frequency) */ +#define OPCODE_DUAL_READ_4B 0x3c/* Read data bytes (Dual SPI) */ +#define OPCODE_QUAD_READ_4B 0x6c/* Read data bytes (Quad SPI) */
This comment here is indented with spaces, while the other comments are indented with tabs ;-/
[...]
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/9] mtd: spi-nor: re-name OPCODE_* to SPINOR_OP_*
In reply to Brian NorrisQuoted 4 lines · Brian Norris
Qualify these with a better namespace, and prepare them for use in more drivers.
Signed-off-by Brian Norris <[email protected]>
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/9] mtd: spi-nor: unify read opcode variants with ST SPI FSM
In reply to Brian NorrisQuoted 8 lines · Brian Norris
serial_flash_cmds.hdefines our opcodes a little differently. Let's borrow its naming, since it's borrowed from the SFDP standard, and it's more extensible.This prepares us for merging
serial_flash_cmds.handspi-nor.hopcode listing.Signed-off-by Brian Norris <[email protected]>
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/9] Documentation: spi-nor: rewrite some portions
In reply to Brian NorrisQuoted 13 lines · Brian Norris
Signed-off-by Brian Norris <[email protected]>---
WIP. This could be improved more (e.g., don't spend too much time documenting history; just document the current framework)Documentation/mtd/spi-nor.txt | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)Documentation/mtd/spi-nor.txt +0
-0
Documentation/mtd/spi-nor.txt line 5
Quoted 6 lines
Documentation/mtd/spi-nor.txt +1
-1@@ -1,16 +1,20 @@ SPI NOR framework ============================================ -Part I - why we need this framework? +Part I - Why do we need this framework? -------------------------------------
The underline is not matching the length of the text now ;-)
Quoted 9 lines
Documentation/mtd/spi-nor.txt +0
-3-The SPI bus controller only deals with the byte stream. -Some controller does not works like a SPI bus controller, it works -like a SPI NOR controller instead, such as the Freescale's QuadSPIcontroller. +SPI bus controllers (
drivers/spi/) only deal with streams of bytes; the bus +controller operates agnostic of the specific device attached. However, some +controllers (such as Freescale's QuadSPI controller) cannot easily handle +arbitrary streams of bytes, but rather are designed specifically for SPI NOR.
You use the word 'specifically' here and below quick after one another, that doesn't sound nice when you read the text.
Documentation/mtd/spi-nor.txt line 12
Quoted 4 lines
Documentation/mtd/spi-nor.txt +1
-3-The Freescale's QuadSPI controller should know the NOR commands to -find the right LUT sequence. Unfortunately, the old code can not meet -this requirement. +Specifically, Freescale's QuadSPI controller must know the NOR commands to
[...]
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 5/9] mtd: spi-nor: shorten Kconfig naming
In reply to Brian NorrisQuoted 7 lines · Brian Norris
Signed-off-by Brian Norris <[email protected]>--- drivers/mtd/Makefile | 2 +- drivers/mtd/devices/Kconfig | 2 +- drivers/mtd/spi-nor/Kconfig | 11 ++++++++--- drivers/mtd/spi-nor/Makefile | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-)
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · Marek Vasut
include/linux/mtd/spi-nor.h line 11
Quoted 2 lines · Brian Norris
include/linux/mtd/spi-nor.h +2
-0+#define OPCODE_DUAL_READ 0x3b/* Read data bytes (Dual SPI) */ +#define OPCODE_QUAD_READ 0x6b/* Read data bytes (Quad SPI) */ This is still a little non-standard -- or rather -- inconsistent here. You should use space after #define and \t after the name I'd say. I'd also say these two slipped your attention as the others do it just like that.
Thanks. I think I noticed this at one point, but in my patch juggling, I never straightened it out. I'll send v2 eventually. And in the meantime, I'm keeping my patches here:
http://git.infradead.org/users/norris/linux-mtd.git/shortlog/refs/heads/spinor
Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/9] Documentation: spi-nor: rewrite some portions
In reply to Marek VasutQuoted 17 lines · Marek Vasut
Quoted 16 lines · Brian Norris
Signed-off-by Brian Norris <[email protected]>---
WIP. This could be improved more (e.g., don't spend too much time documenting history; just document the current framework)Documentation/mtd/spi-nor.txt | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)Documentation/mtd/spi-nor.txt +0
-0@@ -1,16 +1,20 @@ SPI NOR framework ============================================
Quoted 5 lines
Documentation/mtd/spi-nor.txt line 5
Quoted 3 lines
Documentation/mtd/spi-nor.txt +1
-1-Part I - why we need this framework? +Part I - Why do we need this framework? -------------------------------------The underline is not matching the length of the text now ;-)
It wasn't exactly matching in the first place. But I'll adjust all the headings so the line is exactly as long as the text.
Quoted 12 lines
Quoted 9 lines
Documentation/mtd/spi-nor.txt +0
-3-The SPI bus controller only deals with the byte stream. -Some controller does not works like a SPI bus controller, it works -like a SPI NOR controller instead, such as the Freescale's QuadSPIcontroller. +SPI bus controllers (
drivers/spi/) only deal with streams of bytes; the bus +controller operates agnostic of the specific device attached. However, some +controllers (such as Freescale's QuadSPI controller) cannot easily handle +arbitrary streams of bytes, but rather are designed specifically for SPI NOR.You use the word 'specifically' here and below quick after one another, that doesn't sound nice when you read the text.
Sure, thanks for pointing it out.
Quoted 4 lines
Documentation/mtd/spi-nor.txt line 12
Quoted 4 lines
Documentation/mtd/spi-nor.txt +1
-3-The Freescale's QuadSPI controller should know the NOR commands to -find the right LUT sequence. Unfortunately, the old code can not meet -this requirement. +Specifically, Freescale's QuadSPI controller must know the NOR commands to
My changes are pushed here temporarily, and I'll send v2 in the next day or so:
http://git.infradead.org/users/norris/linux-mtd.git/shortlog/refs/heads/spinor
Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Brian Norris
Spacing is a little non-standard here.
Signature · 1 line
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 5/9] mtd: spi-nor: shorten Kconfig naming
In reply to Brian NorrisQuoted 70 lines · Brian Norris
Signed-off-by Brian Norris <[email protected]>--- drivers/mtd/Makefile | 2 +- drivers/mtd/devices/Kconfig | 2 +- drivers/mtd/spi-nor/Kconfig | 11 ++++++++--- drivers/mtd/spi-nor/Makefile | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-)drivers/mtd/Makefile +1
-1@@ -32,5 +32,5 @@ inftl-objs := inftlcore.o inftlmount.o obj-y += chips/ lpddr/ maps/ devices/ nand/ onenand/ tests/ -obj-$(CONFIG_MTD_SPI_NOR_BASE) += spi-nor/ +obj-$(CONFIG_MTD_SPI_NOR) += spi-nor/ obj-$(CONFIG_MTD_UBI) += ubi/drivers/mtd/devices/Kconfig +1
-1@@ -80,7 +80,7 @@ config MTD_DATAFLASH_OTP config MTD_M25P80 tristate "Support most SPI Flash chips (AT26DF, M25P, W25X, ...)" - depends on SPI_MASTER && MTD_SPI_NOR_BASE + depends on SPI_MASTER && MTD_SPI_NOR help This enables access to most modern SPI flash chips, used for program and data storage. Series supported include Atmel AT26DF,drivers/mtd/spi-nor/Kconfig +8
-3@@ -1,12 +1,17 @@ -config MTD_SPI_NOR_BASE - bool "the framework for SPI-NOR support" +config MTD_SPI_NOR + bool "SPI-NOR device support" depends on MTD help This is the framework for the SPI NOR which can be used by the SPI device drivers and the SPI-NOR device driver. + +if MTD_SPI_NOR + config SPI_FSL_QUADSPI tristate "Freescale Quad SPI controller" - depends on ARCH_MXC && MTD_SPI_NOR_BASE + depends on ARCH_MXC help This enables support for the Quad SPI controller in master mode. We only connect the NOR to this controller now. + +endif # MTD_SPI_NORdrivers/mtd/spi-nor/Makefile +1
-1@@ -1,2 +1,2 @@ -obj-$(CONFIG_MTD_SPI_NOR_BASE) += spi-nor.o +obj-$(CONFIG_MTD_SPI_NOR) += spi-nor.o obj-$(CONFIG_SPI_FSL_QUADSPI) += fsl-quadspi.oSignature · 1 line
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/9] mtd: spi-nor: re-name OPCODE_* to SPINOR_OP_*
In reply to Brian NorrisQuoted 512 lines · Brian Norris
Qualify these with a better namespace, and prepare them for use in more drivers.
Signed-off-by Brian Norris <[email protected]>--- drivers/mtd/devices/m25p80.c | 4 +-- drivers/mtd/spi-nor/fsl-quadspi.c | 58 +++++++++++++++++------------------ drivers/mtd/spi-nor/spi-nor.c | 64 +++++++++++++++++++-------------------- include/linux/mtd/spi-nor.h | 54 ++++++++++++++++----------------- 4 files changed, 90 insertions(+), 90 deletions(-)drivers/mtd/devices/m25p80.c +2
-2@@ -86,7 +86,7 @@ static void m25p80_write(struct spi_nor *nor, loff_t to, size_t len,spi_message_init (&m); -if (nor->program_opcode ==OPCODE_AAI_WP && nor->sst_write_second) +if (nor->program_opcode ==SPINOR_OP_AAI_WP && nor->sst_write_second) cmd_sz =1 ; flash->command[0 ] = nor->program_opcode;@@ -171,7 +171,7 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset)return ret;/* Send write enable, then erase commands. */ - ret = nor->write_reg (nor,OPCODE_WREN ,NULL ,0 ,0 ); + ret = nor->write_reg (nor,SPINOR_OP_WREN ,NULL ,0 ,0 );if (ret)return ret;drivers/mtd/spi-nor/fsl-quadspi.c +29
-29@@ -294,12 +294,12 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q) lut_base =SEQID_QUAD_READ *4 ;if (q->nor_size <=SZ_16M ) { - cmd =OPCODE_QUAD_READ ; + cmd =SPINOR_OP_QUAD_READ ; addrlen =ADDR24BIT ; dummy =8 ; }else {/* use the 4-byte address */ - cmd =OPCODE_QUAD_READ ; + cmd =SPINOR_OP_QUAD_READ ; addrlen =ADDR32BIT ; dummy =8 ; }@@ -311,17 +311,17 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q)/* Write enable */ lut_base =SEQID_WREN *4 ; -writel (LUT0 (CMD ,PAD1 ,OPCODE_WREN ), base +QUADSPI_LUT (lut_base)); +writel (LUT0 (CMD ,PAD1 ,SPINOR_OP_WREN ), base +QUADSPI_LUT (lut_base));/* Page Program */ lut_base =SEQID_PP *4 ;if (q->nor_size <=SZ_16M ) { - cmd =OPCODE_PP ; + cmd =SPINOR_OP_PP ; addrlen =ADDR24BIT ; }else {/* use the 4-byte address */ - cmd =OPCODE_PP ; + cmd =SPINOR_OP_PP ; addrlen =ADDR32BIT ; }@@ -331,18 +331,18 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q)/* Read Status */ lut_base =SEQID_RDSR *4 ; -writel (LUT0 (CMD ,PAD1 ,OPCODE_RDSR ) |LUT1 (READ ,PAD1 ,0x1 ), +writel (LUT0 (CMD ,PAD1 ,SPINOR_OP_RDSR ) |LUT1 (READ ,PAD1 ,0x1 ), base +QUADSPI_LUT (lut_base));/* Erase a sector */ lut_base =SEQID_SE *4 ;if (q->nor_size <=SZ_16M ) { - cmd =OPCODE_SE ; + cmd =SPINOR_OP_SE ; addrlen =ADDR24BIT ; }else {/* use the 4-byte address */ - cmd =OPCODE_SE ; + cmd =SPINOR_OP_SE ; addrlen =ADDR32BIT ; }@@ -351,35 +351,35 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q)/* Erase the whole chip */ lut_base =SEQID_CHIP_ERASE *4 ; -writel (LUT0 (CMD ,PAD1 ,OPCODE_CHIP_ERASE ), +writel (LUT0 (CMD ,PAD1 ,SPINOR_OP_CHIP_ERASE ), base +QUADSPI_LUT (lut_base));/* READ ID */ lut_base =SEQID_RDID *4 ; -writel (LUT0 (CMD ,PAD1 ,OPCODE_RDID ) |LUT1 (READ ,PAD1 ,0x8 ), +writel (LUT0 (CMD ,PAD1 ,SPINOR_OP_RDID ) |LUT1 (READ ,PAD1 ,0x8 ), base +QUADSPI_LUT (lut_base));/* Write Register */ lut_base =SEQID_WRSR *4 ; -writel (LUT0 (CMD ,PAD1 ,OPCODE_WRSR ) |LUT1 (WRITE ,PAD1 ,0x2 ), +writel (LUT0 (CMD ,PAD1 ,SPINOR_OP_WRSR ) |LUT1 (WRITE ,PAD1 ,0x2 ), base +QUADSPI_LUT (lut_base));/* Read Configuration Register */ lut_base =SEQID_RDCR *4 ; -writel (LUT0 (CMD ,PAD1 ,OPCODE_RDCR ) |LUT1 (READ ,PAD1 ,0x1 ), +writel (LUT0 (CMD ,PAD1 ,SPINOR_OP_RDCR ) |LUT1 (READ ,PAD1 ,0x1 ), base +QUADSPI_LUT (lut_base));/* Write disable */ lut_base =SEQID_WRDI *4 ; -writel (LUT0 (CMD ,PAD1 ,OPCODE_WRDI ), base +QUADSPI_LUT (lut_base)); +writel (LUT0 (CMD ,PAD1 ,SPINOR_OP_WRDI ), base +QUADSPI_LUT (lut_base));/* Enter 4 Byte Mode (Micron) */ lut_base =SEQID_EN4B *4 ; -writel (LUT0 (CMD ,PAD1 ,OPCODE_EN4B ), base +QUADSPI_LUT (lut_base)); +writel (LUT0 (CMD ,PAD1 ,SPINOR_OP_EN4B ), base +QUADSPI_LUT (lut_base));/* Enter 4 Byte Mode (Spansion) */ lut_base =SEQID_BRWR *4 ; -writel (LUT0 (CMD ,PAD1 ,OPCODE_BRWR ), base +QUADSPI_LUT (lut_base)); +writel (LUT0 (CMD ,PAD1 ,SPINOR_OP_BRWR ), base +QUADSPI_LUT (lut_base));fsl_qspi_lock_lut (q); }@@ -388,29 +388,29 @@ static void fsl_qspi_init_lut(struct fsl_qspi *q)static int fsl_qspi_get_seqid (struct fsl_qspi *q,u8 cmd) {switch (cmd) { -case OPCODE_QUAD_READ : +case SPINOR_OP_QUAD_READ :return SEQID_QUAD_READ ; -case OPCODE_WREN : +case SPINOR_OP_WREN :return SEQID_WREN ; -case OPCODE_WRDI : +case SPINOR_OP_WRDI :return SEQID_WRDI ; -case OPCODE_RDSR : +case SPINOR_OP_RDSR :return SEQID_RDSR ; -case OPCODE_SE : +case SPINOR_OP_SE :return SEQID_SE ; -case OPCODE_CHIP_ERASE : +case SPINOR_OP_CHIP_ERASE :return SEQID_CHIP_ERASE ; -case OPCODE_PP : +case SPINOR_OP_PP :return SEQID_PP ; -case OPCODE_RDID : +case SPINOR_OP_RDID :return SEQID_RDID ; -case OPCODE_WRSR : +case SPINOR_OP_WRSR :return SEQID_WRSR ; -case OPCODE_RDCR : +case SPINOR_OP_RDCR :return SEQID_RDCR ; -case OPCODE_EN4B : +case SPINOR_OP_EN4B :return SEQID_EN4B ; -case OPCODE_BRWR : +case SPINOR_OP_BRWR :return SEQID_BRWR ;default :dev_err (q->dev,"Unsupported cmd 0x%.2x\n" , cmd);@@ -688,7 +688,7 @@ static int fsl_qspi_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len,if (ret)return ret; -if (opcode ==OPCODE_CHIP_ERASE ) +if (opcode ==SPINOR_OP_CHIP_ERASE )fsl_qspi_invalid (q); }else if (len >0 ) {@@ -750,7 +750,7 @@ static int fsl_qspi_erase(struct spi_nor *nor, loff_t offs)return ret;/* Send write enable, then erase commands. */ - ret = nor->write_reg (nor,OPCODE_WREN ,NULL ,0 ,0 ); + ret = nor->write_reg (nor,SPINOR_OP_WREN ,NULL ,0 ,0 );if (ret)return ret;drivers/mtd/spi-nor/spi-nor.c +32
-32@@ -34,7 +34,7 @@ static int read_sr(struct spi_nor *nor)int ret;u8 val; - ret = nor->read_reg (nor,OPCODE_RDSR , &val,1 ); + ret = nor->read_reg (nor,SPINOR_OP_RDSR , &val,1 );if (ret <0 ) {pr_err ("error %d reading SR\n" , (int ) ret);return ret;@@ -53,7 +53,7 @@ static int read_cr(struct spi_nor *nor)int ret;u8 val; - ret = nor->read_reg (nor,OPCODE_RDCR , &val,1 ); + ret = nor->read_reg (nor,SPINOR_OP_RDCR , &val,1 );if (ret <0 ) {dev_err (nor->dev,"error %d reading CR\n" , ret);return ret;@@ -87,7 +87,7 @@ static inline int spi_nor_read_dummy_cycles(struct spi_nor *nor)static inline int write_sr (struct spi_nor *nor,u8 val) { nor->cmd_buf[0 ] = val; -return nor->write_reg (nor,OPCODE_WRSR , nor->cmd_buf,1 ,0 ); +return nor->write_reg (nor,SPINOR_OP_WRSR , nor->cmd_buf,1 ,0 ); }/* @@ -96,7 +96,7 @@ static inline int write_sr(struct spi_nor *nor, u8 val)*/ static inline int write_enable (struct spi_nor *nor) { -return nor->write_reg (nor,OPCODE_WREN ,NULL ,0 ,0 ); +return nor->write_reg (nor,SPINOR_OP_WREN ,NULL ,0 ,0 ); }/* @@ -104,7 +104,7 @@ static inline int write_enable(struct spi_nor *nor)*/ static inline int write_disable (struct spi_nor *nor) { -return nor->write_reg (nor,OPCODE_WRDI ,NULL ,0 ,0 ); +return nor->write_reg (nor,SPINOR_OP_WRDI ,NULL ,0 ,0 ); }static inline struct spi_nor *mtd_to_spi_nor (struct mtd_info *mtd)@@ -128,7 +128,7 @@ static inline int set_4byte(struct spi_nor *nor, u32 jedec_id, int enable)if (need_wren)write_enable (nor); - cmd = enable ?OPCODE_EN4B :OPCODE_EX4B ; + cmd = enable ?SPINOR_OP_EN4B :SPINOR_OP_EX4B ; status = nor->write_reg (nor, cmd,NULL ,0 ,0 );if (need_wren)write_disable (nor);@@ -137,7 +137,7 @@ static inline int set_4byte(struct spi_nor *nor, u32 jedec_id, int enable)default :/* Spansion style */ nor->cmd_buf[0 ] = enable <<7 ; -return nor->write_reg (nor,OPCODE_BRWR , nor->cmd_buf,1 ,0 ); +return nor->write_reg (nor,SPINOR_OP_BRWR , nor->cmd_buf,1 ,0 ); } }@@ -189,7 +189,7 @@ static int erase_chip(struct spi_nor *nor)/* Send write enable, then erase commands. */ write_enable (nor); -return nor->write_reg (nor,OPCODE_CHIP_ERASE ,NULL ,0 ,0 ); +return nor->write_reg (nor,SPINOR_OP_CHIP_ERASE ,NULL ,0 ,0 ); }static int spi_nor_lock_and_prep (struct spi_nor *nor,enum spi_nor_ops ops)@@ -249,7 +249,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) }/* REVISIT in some cases we could speed up erasing large regions -* by using OPCODE_SE instead of OPCODE_BE_4K. We may have set up +* by using SPINOR_OP_SE instead of SPINOR_OP_BE_4K. We may have set up * to use "small sector erase", but that's not always optimal. */ @@ -381,7 +381,7 @@ struct flash_info {u32 jedec_id;u16 ext_id; -/* The size listed here is what works with OPCODE_SE, which isn't +/* The size listed here is what works with SPINOR_OP_SE, which isn't * necessarily called a "sector" by the vendor. */ unsigned sector_size;@@ -391,11 +391,11 @@ struct flash_info {u16 addr_width;u16 flags; -#define SECT_4K 0x01/* OPCODE_BE_4K works uniformly */ +#define SECT_4K 0x01/* SPINOR_OP_BE_4K works uniformly */ #define SPI_NOR_NO_ERASE 0x02/* No erase command needed */ #define SST_WRITE 0x04/* use SST byte programming */ #define SPI_NOR_NO_FR 0x08/* Can't do fastread */ -#define SECT_4K_PMC 0x10/* OPCODE_BE_4K_PMC works uniformly */ +#define SECT_4K_PMC 0x10/* SPINOR_OP_BE_4K_PMC works uniformly */ #define SPI_NOR_DUAL_READ 0x20/* Flash supports Dual Read */ #define SPI_NOR_QUAD_READ 0x40/* Flash supports Quad Read */ };@@ -594,7 +594,7 @@ static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor)u16 ext_jedec;struct flash_info *info; - tmp = nor->read_reg (nor,OPCODE_RDID , id,5 ); + tmp = nor->read_reg (nor,SPINOR_OP_RDID , id,5 );if (tmp <0 ) {dev_dbg (nor->dev," error %d reading JEDEC ID\n" , tmp);return ERR_PTR (tmp);@@ -666,7 +666,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, actual = to %2 ;/* Start write from odd address. */ if (actual) { - nor->program_opcode =OPCODE_BP ; + nor->program_opcode =SPINOR_OP_BP ;/* write one byte. */ nor->write (nor, to,1 , retlen, buf);@@ -678,7 +678,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,/* Write out most of the data here. */ for (; actual < len -1 ; actual +=2 ) { - nor->program_opcode =OPCODE_AAI_WP ; + nor->program_opcode =SPINOR_OP_AAI_WP ;/* write two bytes. */ nor->write (nor, to,2 , retlen, buf + actual);@@ -699,7 +699,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,if (actual != len) {write_enable (nor); - nor->program_opcode =OPCODE_BP ; + nor->program_opcode =SPINOR_OP_BP ; nor->write (nor, to,1 , retlen, buf + actual); ret =wait_till_ready (nor);@@ -773,7 +773,7 @@ static int macronix_quad_enable(struct spi_nor *nor)write_enable (nor); nor->cmd_buf[0 ] = val |SR_QUAD_EN_MX ; - nor->write_reg (nor,OPCODE_WRSR , nor->cmd_buf,1 ,0 ); + nor->write_reg (nor,SPINOR_OP_WRSR , nor->cmd_buf,1 ,0 );if (wait_till_ready (nor))return 1 ;@@ -798,7 +798,7 @@ static int write_sr_cr(struct spi_nor *nor, u16 val) nor->cmd_buf[0 ] = val &0xff ; nor->cmd_buf[1 ] = (val >>8 ); -return nor->write_reg (nor,OPCODE_WRSR , nor->cmd_buf,2 ,0 ); +return nor->write_reg (nor,SPINOR_OP_WRSR , nor->cmd_buf,2 ,0 ); }static int spansion_quad_enable (struct spi_nor *nor)@@ -963,13 +963,13 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,/* prefer "small sector" erase if possible */ if (info->flags &SECT_4K ) { - nor->erase_opcode =OPCODE_BE_4K ; + nor->erase_opcode =SPINOR_OP_BE_4K ; mtd->erasesize =4096 ; }else if (info->flags &SECT_4K_PMC ) { - nor->erase_opcode =OPCODE_BE_4K_PMC ; + nor->erase_opcode =SPINOR_OP_BE_4K_PMC ; mtd->erasesize =4096 ; }else { - nor->erase_opcode =OPCODE_SE ; + nor->erase_opcode =SPINOR_OP_SE ; mtd->erasesize = info->sector_size; }@@ -1010,23 +1010,23 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,/* Default commands */ switch (nor->flash_read) {case SPI_NOR_QUAD : - nor->read_opcode =OPCODE_QUAD_READ ; + nor->read_opcode =SPINOR_OP_QUAD_READ ;break ;case SPI_NOR_DUAL : - nor->read_opcode =OPCODE_DUAL_READ ; + nor->read_opcode =SPINOR_OP_DUAL_READ ;break ;case SPI_NOR_FAST : - nor->read_opcode =OPCODE_FAST_READ ; + nor->read_opcode =SPINOR_OP_FAST_READ ;break ;case SPI_NOR_NORMAL : - nor->read_opcode =OPCODE_NORM_READ ; + nor->read_opcode =SPINOR_OP_NORM_READ ;break ;default :dev_err (dev,"No Read opcode defined\n" );return -EINVAL ; } - nor->program_opcode =OPCODE_PP ; + nor->program_opcode =SPINOR_OP_PP ;if (info->addr_width) nor->addr_width = info->addr_width;@@ -1037,21 +1037,21 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,/* Dedicated 4-byte command set */ switch (nor->flash_read) {case SPI_NOR_QUAD : - nor->read_opcode =OPCODE_QUAD_READ_4B ; + nor->read_opcode =SPINOR_OP_QUAD_READ_4B ;break ;case SPI_NOR_DUAL : - nor->read_opcode =OPCODE_DUAL_READ_4B ; + nor->read_opcode =SPINOR_OP_DUAL_READ_4B ;break ;case SPI_NOR_FAST : - nor->read_opcode =OPCODE_FAST_READ_4B ; + nor->read_opcode =SPINOR_OP_FAST_READ_4B ;break ;case SPI_NOR_NORMAL : - nor->read_opcode =OPCODE_NORM_READ_4B ; + nor->read_opcode =SPINOR_OP_NORM_READ_4B ;break ; } - nor->program_opcode =OPCODE_PP_4B ; + nor->program_opcode =SPINOR_OP_PP_4B ;/* No small sector erase for 4-byte command set */ - nor->erase_opcode =OPCODE_SE_4B ; + nor->erase_opcode =SPINOR_OP_SE_4B ; mtd->erasesize = info->sector_size; }else set_4byte (nor, info->jedec_id,1 );include/linux/mtd/spi-nor.h +27
-27@@ -2,41 +2,41 @@#define __LINUX_MTD_SPI_NOR_H/* Flash opcodes. */ -#define OPCODE_WREN 0x06/* Write enable */ -#define OPCODE_RDSR 0x05/* Read status register */ -#define OPCODE_WRSR 0x01/* Write status register 1 byte */ -#define OPCODE_NORM_READ 0x03/* Read data bytes (low frequency) */ -#define OPCODE_FAST_READ 0x0b/* Read data bytes (high frequency) */ -#define OPCODE_DUAL_READ 0x3b/* Read data bytes (Dual SPI) */ -#define OPCODE_QUAD_READ 0x6b/* Read data bytes (Quad SPI) */ -#define OPCODE_PP 0x02/* Page program (up to 256 bytes) */ -#define OPCODE_BE_4K 0x20/* Erase 4KiB block */ -#define OPCODE_BE_4K_PMC 0xd7/* Erase 4KiB block on PMC chips */ -#define OPCODE_BE_32K 0x52/* Erase 32KiB block */ -#define OPCODE_CHIP_ERASE 0xc7/* Erase whole flash chip */ -#define OPCODE_SE 0xd8/* Sector erase (usually 64KiB) */ -#define OPCODE_RDID 0x9f/* Read JEDEC ID */ -#define OPCODE_RDCR 0x35/* Read configuration register */ +#define SPINOR_OP_WREN 0x06/* Write enable */ +#define SPINOR_OP_RDSR 0x05/* Read status register */ +#define SPINOR_OP_WRSR 0x01/* Write status register 1 byte */ +#define SPINOR_OP_NORM_READ 0x03/* Read data bytes (low frequency) */ +#define SPINOR_OP_FAST_READ 0x0b/* Read data bytes (high frequency) */ +#define SPINOR_OP_DUAL_READ 0x3b/* Read data bytes (Dual SPI) */ +#define SPINOR_OP_QUAD_READ 0x6b/* Read data bytes (Quad SPI) */ +#define SPINOR_OP_PP 0x02/* Page program (up to 256 bytes) */ +#define SPINOR_OP_BE_4K 0x20/* Erase 4KiB block */ +#define SPINOR_OP_BE_4K_PMC 0xd7/* Erase 4KiB block on PMC chips */ +#define SPINOR_OP_BE_32K 0x52/* Erase 32KiB block */ +#define SPINOR_OP_CHIP_ERASE 0xc7/* Erase whole flash chip */ +#define SPINOR_OP_SE 0xd8/* Sector erase (usually 64KiB) */ +#define SPINOR_OP_RDID 0x9f/* Read JEDEC ID */ +#define SPINOR_OP_RDCR 0x35/* Read configuration register */ /* 4-byte address opcodes - used on Spansion and some Macronix flashes. */ -#define OPCODE_NORM_READ_4B 0x13/* Read data bytes (low frequency) */ -#define OPCODE_FAST_READ_4B 0x0c/* Read data bytes (high frequency) */ -#define OPCODE_DUAL_READ_4B 0x3c/* Read data bytes (Dual SPI) */ -#define OPCODE_QUAD_READ_4B 0x6c/* Read data bytes (Quad SPI) */ -#define OPCODE_PP_4B 0x12/* Page program (up to 256 bytes) */ -#define OPCODE_SE_4B 0xdc/* Sector erase (usually 64KiB) */ +#define SPINOR_OP_NORM_READ_4B 0x13/* Read data bytes (low frequency) */ +#define SPINOR_OP_FAST_READ_4B 0x0c/* Read data bytes (high frequency) */ +#define SPINOR_OP_DUAL_READ_4B 0x3c/* Read data bytes (Dual SPI) */ +#define SPINOR_OP_QUAD_READ_4B 0x6c/* Read data bytes (Quad SPI) */ +#define SPINOR_OP_PP_4B 0x12/* Page program (up to 256 bytes) */ +#define SPINOR_OP_SE_4B 0xdc/* Sector erase (usually 64KiB) */ /* Used for SST flashes only. */ -#define OPCODE_BP 0x02/* Byte program */ -#define OPCODE_WRDI 0x04/* Write disable */ -#define OPCODE_AAI_WP 0xad/* Auto address increment word program */ +#define SPINOR_OP_BP 0x02/* Byte program */ +#define SPINOR_OP_WRDI 0x04/* Write disable */ +#define SPINOR_OP_AAI_WP 0xad/* Auto address increment word program */ /* Used for Macronix and Winbond flashes. */ -#define OPCODE_EN4B 0xb7/* Enter 4-byte mode */ -#define OPCODE_EX4B 0xe9/* Exit 4-byte mode */ +#define SPINOR_OP_EN4B 0xb7/* Enter 4-byte mode */ +#define SPINOR_OP_EX4B 0xe9/* Exit 4-byte mode */ /* Used for Spansion flashes only. */ -#define OPCODE_BRWR 0x17/* Bank register write */ +#define SPINOR_OP_BRWR 0x17/* Bank register write */ /* Status Register bits. */ #define SR_WIP 1/* Write in progress */ Signature · 1 line
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/9] mtd: spi-nor: unify read opcode variants with ST SPI FSM
In reply to Brian NorrisQuoted 64 lines · Brian Norris
serial_flash_cmds.hdefines our opcodes a little differently. Let's borrow its naming, since it's borrowed from the SFDP standard, and it's more extensible.This prepares us for merging
serial_flash_cmds.handspi-nor.hopcode listing.Signed-off-by Brian Norris <[email protected]>--- drivers/mtd/spi-nor/spi-nor.c | 16 ++++++++-------- include/linux/mtd/spi-nor.h | 24 ++++++++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-)drivers/mtd/spi-nor/spi-nor.c +8
-8@@ -1010,16 +1010,16 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,/* Default commands */ switch (nor->flash_read) {case SPI_NOR_QUAD : - nor->read_opcode =SPINOR_OP_QUAD_READ ; + nor->read_opcode =SPINOR_OP_READ_1_1_4 ;break ;case SPI_NOR_DUAL : - nor->read_opcode =SPINOR_OP_DUAL_READ ; + nor->read_opcode =SPINOR_OP_READ_1_1_2 ;break ;case SPI_NOR_FAST : - nor->read_opcode =SPINOR_OP_FAST_READ ; + nor->read_opcode =SPINOR_OP_READ_FAST ;break ;case SPI_NOR_NORMAL : - nor->read_opcode =SPINOR_OP_NORM_READ ; + nor->read_opcode =SPINOR_OP_READ ;break ;default :dev_err (dev,"No Read opcode defined\n" );@@ -1037,16 +1037,16 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,/* Dedicated 4-byte command set */ switch (nor->flash_read) {case SPI_NOR_QUAD : - nor->read_opcode =SPINOR_OP_QUAD_READ_4B ; + nor->read_opcode =SPINOR_OP_READ4_1_1_4 ;break ;case SPI_NOR_DUAL : - nor->read_opcode =SPINOR_OP_DUAL_READ_4B ; + nor->read_opcode =SPINOR_OP_READ4_1_1_2 ;break ;case SPI_NOR_FAST : - nor->read_opcode =SPINOR_OP_FAST_READ_4B ; + nor->read_opcode =SPINOR_OP_READ4_FAST ;break ;case SPI_NOR_NORMAL : - nor->read_opcode =SPINOR_OP_NORM_READ_4B ; + nor->read_opcode =SPINOR_OP_READ4 ;break ; } nor->program_opcode =SPINOR_OP_PP_4B ;include/linux/mtd/spi-nor.h +0
-0
include/linux/mtd/spi-nor.h line 7
Quoted 7 lines
include/linux/mtd/spi-nor.h +4
-0@@ -1,14 +1,22 @@#ifndef __LINUX_MTD_SPI_NOR_H#define __LINUX_MTD_SPI_NOR_H +/* +* Note on opcode nomenclature: some opcodes have a format like +* SPINOR_OP_FUNCTION{4,}_x_y_z. The numbers x, y, and z stand for the number +* of I/O lines used for the opcode, address, and data (respectively). The
I like this naming.
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/9] mtd: spi-nor: unify read opcode variants with ST SPI FSM
In reply to Brian NorrisQuoted 11 lines · Brian Norris
serial_flash_cmds.hdefines our opcodes a little differently. Let's borrow its naming, since it's borrowed from the SFDP standard, and it's more extensible.This prepares us for merging
serial_flash_cmds.handspi-nor.hopcode listing.Signed-off-by Brian Norris <[email protected]>--- drivers/mtd/spi-nor/spi-nor.c | 16 ++++++++-------- include/linux/mtd/spi-nor.h | 24 ++++++++++++++++--------
Please also change the fsl-quadspi.c which also uses the opcodes.
thanks
Huang Shijie
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 9/9] mtd: st_spi_fsm: begin using spi-nor.h opcodes
In reply to Brian NorrisQuoted 9 lines · Brian Norris
Many of the
serial_flash_cmds.hopcodes are duplicated withspi-nor.h. Let's begin to unify them.Signed-off-by Brian Norris <[email protected]>Cc Lee Jones <[email protected]>--- drivers/mtd/devices/serial_flash_cmds.h | 20 -------------------- drivers/mtd/devices/st_spi_fsm.c | 9 +++++---- 2 files changed, 5 insertions(+), 24 deletions(-)
So long as the underlying Op Codes havent changed:
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 8/9] mtd: st_spi_fsm: replace FLACH_CMD_* with SPINOR_OP_*
In reply to Brian NorrisQuoted 9 lines
Begin to unify the differences between
serial_flash_cmds.handspi-nor.h.Signed-off-by Brian Norris <[email protected]>Cc Lee Jones <[email protected]>--- drivers/mtd/devices/serial_flash_cmds.h | 62 +++++++++--------- drivers/mtd/devices/st_spi_fsm.c | 112 ++++++++++++++++---------------- 2 files changed, 87 insertions(+), 87 deletions(-)
Nice.
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 7/9] mtd: st_spi_fsm: kill duplicate CMD definitions
In reply to Brian NorrisQuoted 2 lines
These are also in
serial_flash_cmds.h. (FWIW, I didn't know the C preprocessor allowed redefinitions without warning like this.)
Right, I would have expected that too. I'll investigate.
JOOI, have you build tested your changes?
Non-tested:
Quoted 53 lines
Signed-off-by Brian Norris <[email protected]>Cc Lee Jones <[email protected]>--- drivers/mtd/devices/st_spi_fsm.c | 36 ------------------------------------ 1 file changed, 36 deletions(-)drivers/mtd/devices/st_spi_fsm.c +0
-36@@ -201,42 +201,6 @@#define STFSM_MAX_WAIT_SEQ_MS 1000/* FSM execution time */ -/* Flash Commands */ -#define FLASH_CMD_WREN 0x06 -#define FLASH_CMD_WRDI 0x04 -#define FLASH_CMD_RDID 0x9f -#define FLASH_CMD_RDSR 0x05 -#define FLASH_CMD_RDSR2 0x35 -#define FLASH_CMD_WRSR 0x01 -#define FLASH_CMD_SE_4K 0x20 -#define FLASH_CMD_SE_32K 0x52 -#define FLASH_CMD_SE 0xd8 -#define FLASH_CMD_CHIPERASE 0xc7 - -#define FLASH_CMD_READ 0x03/* READ */ -#define FLASH_CMD_READ_FAST 0x0b/* FAST READ */ -#define FLASH_CMD_READ_1_1_2 0x3b/* DUAL OUTPUT READ */ -#define FLASH_CMD_READ_1_2_2 0xbb/* DUAL I/O READ */ -#define FLASH_CMD_READ_1_1_4 0x6b/* QUAD OUTPUT READ */ -#define FLASH_CMD_READ_1_4_4 0xeb/* QUAD I/O READ */ - -#define FLASH_CMD_WRITE 0x02/* PAGE PROGRAM */ -#define FLASH_CMD_WRITE_1_1_2 0xa2/* DUAL INPUT PROGRAM */ -#define FLASH_CMD_WRITE_1_2_2 0xd2/* DUAL INPUT EXT PROGRAM */ -#define FLASH_CMD_WRITE_1_1_4 0x32/* QUAD INPUT PROGRAM */ -#define FLASH_CMD_WRITE_1_4_4 0x12/* QUAD INPUT EXT PROGRAM */ - -#define FLASH_CMD_EN4B_ADDR 0xb7/* Enter 4-byte address mode */ -#define FLASH_CMD_EX4B_ADDR 0xe9/* Exit 4-byte address mode */ - -/* READ commands with 32-bit addressing (N25Q256 and S25FLxxxS) */ -#define FLASH_CMD_READ4 0x13 -#define FLASH_CMD_READ4_FAST 0x0c -#define FLASH_CMD_READ4_1_1_2 0x3c -#define FLASH_CMD_READ4_1_2_2 0xbc -#define FLASH_CMD_READ4_1_1_4 0x6c -#define FLASH_CMD_READ4_1_4_4 0xec -/* S25FLxxxS commands */ #define S25FL_CMD_WRITE4_1_1_4 0x34#define S25FL_CMD_SE4 0xdc
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 6/9] mtd: st_spi_fsm: fixup Kconfig dependency
In reply to Brian NorrisQuoted 9 lines · Brian Norris
I hear that this driver should depend on
ARCH_STI, and that "SH" is not actually a real symbol. At the same time, let's allow compile-testing on other ARCH'es.Signed-off-by Brian Norris <[email protected]>Cc Lee Jones <[email protected]>--- drivers/mtd/devices/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 7/9] mtd: st_spi_fsm: kill duplicate CMD definitions
In reply to Brian NorrisQuoted 2 lines · Brian Norris
These are also in
serial_flash_cmds.h. (FWIW, I didn't know the C preprocessor allowed redefinitions without warning like this.)
Cpp only complains when the redefinitions are different.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 7/9] mtd: st_spi_fsm: kill duplicate CMD definitions
In reply to Lee JonesQuoted 1 line · Lee Jones
JOOI, have you build tested your changes?
Yes, I compile-tested yours. (But as Huang noticed, I failed to build fsl-quadspi; my bad.)
Quoted 2 lines
Non-tested:
Acked-by Lee Jones <[email protected]>
Thanks. I'll be sending out v2 with a few tweaks to the other parts of this series.
Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 7/9] mtd: st_spi_fsm: kill duplicate CMD definitions
In reply to Geert UytterhoevenQuoted 6 lines · Geert Uytterhoeven
Quoted 2 lines · Brian Norris
These are also in
serial_flash_cmds.h. (FWIW, I didn't know the C preprocessor allowed redefinitions without warning like this.)Cpp only complains when the redefinitions are different.
Good to know. Thanks.
Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/9] mtd: spi-nor: unify read opcode variants with ST SPI FSM
In reply to Huang ShijieQuoted 5 lines · Huang Shijie
Quoted 4 lines · Brian Norris
serial_flash_cmds.hdefines our opcodes a little differently. Let's borrow its naming, since it's borrowed from the SFDP standard, and it's more extensible.
Quoted 8 lines
Quoted 7 lines
This prepares us for merging
serial_flash_cmds.handspi-nor.hopcode listing.Signed-off-by Brian Norris <[email protected]>--- drivers/mtd/spi-nor/spi-nor.c | 16 ++++++++-------- include/linux/mtd/spi-nor.h | 24 ++++++++++++++++--------Please also change the
fsl-quadspi.cwhich also uses the opcodes.
My bad. I missed compiling this driver. Fixed in v2.
Thanks,
Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html