mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
mtd: spi-nor: add support for DTR protocol
Double Transfer Rate (DTR) is SPI protocol in which data is transferred on each clock edge as opposed to on each clock cycle. Make framework-level changes to allow supporting flashes in DTR mode. Right now, mixed DTR modes are not supported. So, for example a mode like 4S-4D-4D will not work. All phases need to be either DTR or STR. The xSPI spec says that "The program commands provide SPI backward compatible commands for programming data...". So 8D-8D-8D page program opcodes are populated with using 1S-1S-1S opcodes. Signed-off-by: Pratyush Yadav <p.yadav@ti.com> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com> Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com> Link: https://lore.kernel.org/r/20201005153138.6437-4-p.yadav@ti.com
This commit is contained in:
committed by
Vignesh Raghavendra
parent
6e1bf55d72
commit
0e30f47232
+237
-82
File diff suppressed because it is too large
Load Diff
@@ -62,6 +62,7 @@ enum spi_nor_read_command_index {
|
|||||||
SNOR_CMD_READ_1_8_8,
|
SNOR_CMD_READ_1_8_8,
|
||||||
SNOR_CMD_READ_8_8_8,
|
SNOR_CMD_READ_8_8_8,
|
||||||
SNOR_CMD_READ_1_8_8_DTR,
|
SNOR_CMD_READ_1_8_8_DTR,
|
||||||
|
SNOR_CMD_READ_8_8_8_DTR,
|
||||||
|
|
||||||
SNOR_CMD_READ_MAX
|
SNOR_CMD_READ_MAX
|
||||||
};
|
};
|
||||||
@@ -78,6 +79,7 @@ enum spi_nor_pp_command_index {
|
|||||||
SNOR_CMD_PP_1_1_8,
|
SNOR_CMD_PP_1_1_8,
|
||||||
SNOR_CMD_PP_1_8_8,
|
SNOR_CMD_PP_1_8_8,
|
||||||
SNOR_CMD_PP_8_8_8,
|
SNOR_CMD_PP_8_8_8,
|
||||||
|
SNOR_CMD_PP_8_8_8_DTR,
|
||||||
|
|
||||||
SNOR_CMD_PP_MAX
|
SNOR_CMD_PP_MAX
|
||||||
};
|
};
|
||||||
@@ -311,6 +313,8 @@ struct flash_info {
|
|||||||
* BP3 is bit 6 of status register.
|
* BP3 is bit 6 of status register.
|
||||||
* Must be used with SPI_NOR_4BIT_BP.
|
* Must be used with SPI_NOR_4BIT_BP.
|
||||||
*/
|
*/
|
||||||
|
#define SPI_NOR_OCTAL_DTR_READ BIT(19) /* Flash supports octal DTR Read. */
|
||||||
|
#define SPI_NOR_OCTAL_DTR_PP BIT(20) /* Flash supports Octal DTR Page Program */
|
||||||
|
|
||||||
/* Part specific fixup hooks. */
|
/* Part specific fixup hooks. */
|
||||||
const struct spi_nor_fixups *fixups;
|
const struct spi_nor_fixups *fixups;
|
||||||
@@ -399,6 +403,9 @@ extern const struct spi_nor_manufacturer spi_nor_winbond;
|
|||||||
extern const struct spi_nor_manufacturer spi_nor_xilinx;
|
extern const struct spi_nor_manufacturer spi_nor_xilinx;
|
||||||
extern const struct spi_nor_manufacturer spi_nor_xmc;
|
extern const struct spi_nor_manufacturer spi_nor_xmc;
|
||||||
|
|
||||||
|
void spi_nor_spimem_setup_op(const struct spi_nor *nor,
|
||||||
|
struct spi_mem_op *op,
|
||||||
|
const enum spi_nor_protocol proto);
|
||||||
int spi_nor_write_enable(struct spi_nor *nor);
|
int spi_nor_write_enable(struct spi_nor *nor);
|
||||||
int spi_nor_write_disable(struct spi_nor *nor);
|
int spi_nor_write_disable(struct spi_nor *nor);
|
||||||
int spi_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable);
|
int spi_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable);
|
||||||
|
|||||||
@@ -1047,9 +1047,16 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 4BAIT is the only SFDP table that indicates page program support. */
|
/* 4BAIT is the only SFDP table that indicates page program support. */
|
||||||
if (pp_hwcaps & SNOR_HWCAPS_PP)
|
if (pp_hwcaps & SNOR_HWCAPS_PP) {
|
||||||
spi_nor_set_pp_settings(¶ms_pp[SNOR_CMD_PP],
|
spi_nor_set_pp_settings(¶ms_pp[SNOR_CMD_PP],
|
||||||
SPINOR_OP_PP_4B, SNOR_PROTO_1_1_1);
|
SPINOR_OP_PP_4B, SNOR_PROTO_1_1_1);
|
||||||
|
/*
|
||||||
|
* Since xSPI Page Program opcode is backward compatible with
|
||||||
|
* Legacy SPI, use Legacy SPI opcode there as well.
|
||||||
|
*/
|
||||||
|
spi_nor_set_pp_settings(¶ms_pp[SNOR_CMD_PP_8_8_8_DTR],
|
||||||
|
SPINOR_OP_PP_4B, SNOR_PROTO_8_8_8_DTR);
|
||||||
|
}
|
||||||
if (pp_hwcaps & SNOR_HWCAPS_PP_1_1_4)
|
if (pp_hwcaps & SNOR_HWCAPS_PP_1_1_4)
|
||||||
spi_nor_set_pp_settings(¶ms_pp[SNOR_CMD_PP_1_1_4],
|
spi_nor_set_pp_settings(¶ms_pp[SNOR_CMD_PP_1_1_4],
|
||||||
SPINOR_OP_PP_1_1_4_4B,
|
SPINOR_OP_PP_1_1_4_4B,
|
||||||
|
|||||||
+38
-13
@@ -182,6 +182,7 @@ enum spi_nor_protocol {
|
|||||||
SNOR_PROTO_1_2_2_DTR = SNOR_PROTO_DTR(1, 2, 2),
|
SNOR_PROTO_1_2_2_DTR = SNOR_PROTO_DTR(1, 2, 2),
|
||||||
SNOR_PROTO_1_4_4_DTR = SNOR_PROTO_DTR(1, 4, 4),
|
SNOR_PROTO_1_4_4_DTR = SNOR_PROTO_DTR(1, 4, 4),
|
||||||
SNOR_PROTO_1_8_8_DTR = SNOR_PROTO_DTR(1, 8, 8),
|
SNOR_PROTO_1_8_8_DTR = SNOR_PROTO_DTR(1, 8, 8),
|
||||||
|
SNOR_PROTO_8_8_8_DTR = SNOR_PROTO_DTR(8, 8, 8),
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline bool spi_nor_protocol_is_dtr(enum spi_nor_protocol proto)
|
static inline bool spi_nor_protocol_is_dtr(enum spi_nor_protocol proto)
|
||||||
@@ -228,7 +229,7 @@ struct spi_nor_hwcaps {
|
|||||||
* then Quad SPI protocols before Dual SPI protocols, Fast Read and lastly
|
* then Quad SPI protocols before Dual SPI protocols, Fast Read and lastly
|
||||||
* (Slow) Read.
|
* (Slow) Read.
|
||||||
*/
|
*/
|
||||||
#define SNOR_HWCAPS_READ_MASK GENMASK(14, 0)
|
#define SNOR_HWCAPS_READ_MASK GENMASK(15, 0)
|
||||||
#define SNOR_HWCAPS_READ BIT(0)
|
#define SNOR_HWCAPS_READ BIT(0)
|
||||||
#define SNOR_HWCAPS_READ_FAST BIT(1)
|
#define SNOR_HWCAPS_READ_FAST BIT(1)
|
||||||
#define SNOR_HWCAPS_READ_1_1_1_DTR BIT(2)
|
#define SNOR_HWCAPS_READ_1_1_1_DTR BIT(2)
|
||||||
@@ -245,11 +246,12 @@ struct spi_nor_hwcaps {
|
|||||||
#define SNOR_HWCAPS_READ_4_4_4 BIT(9)
|
#define SNOR_HWCAPS_READ_4_4_4 BIT(9)
|
||||||
#define SNOR_HWCAPS_READ_1_4_4_DTR BIT(10)
|
#define SNOR_HWCAPS_READ_1_4_4_DTR BIT(10)
|
||||||
|
|
||||||
#define SNOR_HWCAPS_READ_OCTAL GENMASK(14, 11)
|
#define SNOR_HWCAPS_READ_OCTAL GENMASK(15, 11)
|
||||||
#define SNOR_HWCAPS_READ_1_1_8 BIT(11)
|
#define SNOR_HWCAPS_READ_1_1_8 BIT(11)
|
||||||
#define SNOR_HWCAPS_READ_1_8_8 BIT(12)
|
#define SNOR_HWCAPS_READ_1_8_8 BIT(12)
|
||||||
#define SNOR_HWCAPS_READ_8_8_8 BIT(13)
|
#define SNOR_HWCAPS_READ_8_8_8 BIT(13)
|
||||||
#define SNOR_HWCAPS_READ_1_8_8_DTR BIT(14)
|
#define SNOR_HWCAPS_READ_1_8_8_DTR BIT(14)
|
||||||
|
#define SNOR_HWCAPS_READ_8_8_8_DTR BIT(15)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Page Program capabilities.
|
* Page Program capabilities.
|
||||||
@@ -260,18 +262,19 @@ struct spi_nor_hwcaps {
|
|||||||
* JEDEC/SFDP standard to define them. Also at this moment no SPI flash memory
|
* JEDEC/SFDP standard to define them. Also at this moment no SPI flash memory
|
||||||
* implements such commands.
|
* implements such commands.
|
||||||
*/
|
*/
|
||||||
#define SNOR_HWCAPS_PP_MASK GENMASK(22, 16)
|
#define SNOR_HWCAPS_PP_MASK GENMASK(23, 16)
|
||||||
#define SNOR_HWCAPS_PP BIT(16)
|
#define SNOR_HWCAPS_PP BIT(16)
|
||||||
|
|
||||||
#define SNOR_HWCAPS_PP_QUAD GENMASK(19, 17)
|
#define SNOR_HWCAPS_PP_QUAD GENMASK(19, 17)
|
||||||
#define SNOR_HWCAPS_PP_1_1_4 BIT(17)
|
#define SNOR_HWCAPS_PP_1_1_4 BIT(17)
|
||||||
#define SNOR_HWCAPS_PP_1_4_4 BIT(18)
|
#define SNOR_HWCAPS_PP_1_4_4 BIT(18)
|
||||||
#define SNOR_HWCAPS_PP_4_4_4 BIT(19)
|
#define SNOR_HWCAPS_PP_4_4_4 BIT(19)
|
||||||
|
|
||||||
#define SNOR_HWCAPS_PP_OCTAL GENMASK(22, 20)
|
#define SNOR_HWCAPS_PP_OCTAL GENMASK(23, 20)
|
||||||
#define SNOR_HWCAPS_PP_1_1_8 BIT(20)
|
#define SNOR_HWCAPS_PP_1_1_8 BIT(20)
|
||||||
#define SNOR_HWCAPS_PP_1_8_8 BIT(21)
|
#define SNOR_HWCAPS_PP_1_8_8 BIT(21)
|
||||||
#define SNOR_HWCAPS_PP_8_8_8 BIT(22)
|
#define SNOR_HWCAPS_PP_8_8_8 BIT(22)
|
||||||
|
#define SNOR_HWCAPS_PP_8_8_8_DTR BIT(23)
|
||||||
|
|
||||||
#define SNOR_HWCAPS_X_X_X (SNOR_HWCAPS_READ_2_2_2 | \
|
#define SNOR_HWCAPS_X_X_X (SNOR_HWCAPS_READ_2_2_2 | \
|
||||||
SNOR_HWCAPS_READ_4_4_4 | \
|
SNOR_HWCAPS_READ_4_4_4 | \
|
||||||
@@ -279,10 +282,14 @@ struct spi_nor_hwcaps {
|
|||||||
SNOR_HWCAPS_PP_4_4_4 | \
|
SNOR_HWCAPS_PP_4_4_4 | \
|
||||||
SNOR_HWCAPS_PP_8_8_8)
|
SNOR_HWCAPS_PP_8_8_8)
|
||||||
|
|
||||||
|
#define SNOR_HWCAPS_X_X_X_DTR (SNOR_HWCAPS_READ_8_8_8_DTR | \
|
||||||
|
SNOR_HWCAPS_PP_8_8_8_DTR)
|
||||||
|
|
||||||
#define SNOR_HWCAPS_DTR (SNOR_HWCAPS_READ_1_1_1_DTR | \
|
#define SNOR_HWCAPS_DTR (SNOR_HWCAPS_READ_1_1_1_DTR | \
|
||||||
SNOR_HWCAPS_READ_1_2_2_DTR | \
|
SNOR_HWCAPS_READ_1_2_2_DTR | \
|
||||||
SNOR_HWCAPS_READ_1_4_4_DTR | \
|
SNOR_HWCAPS_READ_1_4_4_DTR | \
|
||||||
SNOR_HWCAPS_READ_1_8_8_DTR)
|
SNOR_HWCAPS_READ_1_8_8_DTR | \
|
||||||
|
SNOR_HWCAPS_READ_8_8_8_DTR)
|
||||||
|
|
||||||
#define SNOR_HWCAPS_ALL (SNOR_HWCAPS_READ_MASK | \
|
#define SNOR_HWCAPS_ALL (SNOR_HWCAPS_READ_MASK | \
|
||||||
SNOR_HWCAPS_PP_MASK)
|
SNOR_HWCAPS_PP_MASK)
|
||||||
@@ -318,6 +325,22 @@ struct spi_nor_controller_ops {
|
|||||||
int (*erase)(struct spi_nor *nor, loff_t offs);
|
int (*erase)(struct spi_nor *nor, loff_t offs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum spi_nor_cmd_ext - describes the command opcode extension in DTR mode
|
||||||
|
* @SPI_NOR_EXT_NONE: no extension. This is the default, and is used in Legacy
|
||||||
|
* SPI mode
|
||||||
|
* @SPI_NOR_EXT_REPEAT: the extension is same as the opcode
|
||||||
|
* @SPI_NOR_EXT_INVERT: the extension is the bitwise inverse of the opcode
|
||||||
|
* @SPI_NOR_EXT_HEX: the extension is any hex value. The command and opcode
|
||||||
|
* combine to form a 16-bit opcode.
|
||||||
|
*/
|
||||||
|
enum spi_nor_cmd_ext {
|
||||||
|
SPI_NOR_EXT_NONE = 0,
|
||||||
|
SPI_NOR_EXT_REPEAT,
|
||||||
|
SPI_NOR_EXT_INVERT,
|
||||||
|
SPI_NOR_EXT_HEX,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Forward declarations that are used internally by the core and manufacturer
|
* Forward declarations that are used internally by the core and manufacturer
|
||||||
* drivers.
|
* drivers.
|
||||||
@@ -345,6 +368,7 @@ struct spi_nor_flash_parameter;
|
|||||||
* @program_opcode: the program opcode
|
* @program_opcode: the program opcode
|
||||||
* @sst_write_second: used by the SST write operation
|
* @sst_write_second: used by the SST write operation
|
||||||
* @flags: flag options for the current SPI NOR (SNOR_F_*)
|
* @flags: flag options for the current SPI NOR (SNOR_F_*)
|
||||||
|
* @cmd_ext_type: the command opcode extension type for DTR mode.
|
||||||
* @read_proto: the SPI protocol for read operations
|
* @read_proto: the SPI protocol for read operations
|
||||||
* @write_proto: the SPI protocol for write operations
|
* @write_proto: the SPI protocol for write operations
|
||||||
* @reg_proto: the SPI protocol for read_reg/write_reg/erase operations
|
* @reg_proto: the SPI protocol for read_reg/write_reg/erase operations
|
||||||
@@ -376,6 +400,7 @@ struct spi_nor {
|
|||||||
enum spi_nor_protocol reg_proto;
|
enum spi_nor_protocol reg_proto;
|
||||||
bool sst_write_second;
|
bool sst_write_second;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
|
enum spi_nor_cmd_ext cmd_ext_type;
|
||||||
|
|
||||||
const struct spi_nor_controller_ops *controller_ops;
|
const struct spi_nor_controller_ops *controller_ops;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user