Skip to content

Commit fe488a5

Browse files
Cyrille PitchenCyrillePitchen
authored andcommitted
mtd: spi-nor: introduce Octo SPI protocols
This patch starts adding support to Octo SPI protocols (SPI x-y-8). Op codes for Fast Read and/or Page Program operations using Octo SPI protocols are not known yet (no JEDEC specification has defined them yet) but we'd rather introduce the Octo SPI protocols now so it's done as it should be. Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com> Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
1 parent 15f5533 commit fe488a5

2 files changed

Lines changed: 42 additions & 6 deletions

File tree

‎drivers/mtd/spi-nor/spi-nor.c‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,12 @@ enum spi_nor_read_command_index {
15271527
SNOR_CMD_READ_4_4_4,
15281528
SNOR_CMD_READ_1_4_4_DTR,
15291529

1530+
/* Octo SPI */
1531+
SNOR_CMD_READ_1_1_8,
1532+
SNOR_CMD_READ_1_8_8,
1533+
SNOR_CMD_READ_8_8_8,
1534+
SNOR_CMD_READ_1_8_8_DTR,
1535+
15301536
SNOR_CMD_READ_MAX
15311537
};
15321538

@@ -1538,6 +1544,11 @@ enum spi_nor_pp_command_index {
15381544
SNOR_CMD_PP_1_4_4,
15391545
SNOR_CMD_PP_4_4_4,
15401546

1547+
/* Octo SPI */
1548+
SNOR_CMD_PP_1_1_8,
1549+
SNOR_CMD_PP_1_8_8,
1550+
SNOR_CMD_PP_8_8_8,
1551+
15411552
SNOR_CMD_PP_MAX
15421553
};
15431554

@@ -1662,6 +1673,10 @@ static int spi_nor_hwcaps_read2cmd(u32 hwcaps)
16621673
{ SNOR_HWCAPS_READ_1_4_4, SNOR_CMD_READ_1_4_4 },
16631674
{ SNOR_HWCAPS_READ_4_4_4, SNOR_CMD_READ_4_4_4 },
16641675
{ SNOR_HWCAPS_READ_1_4_4_DTR, SNOR_CMD_READ_1_4_4_DTR },
1676+
{ SNOR_HWCAPS_READ_1_1_8, SNOR_CMD_READ_1_1_8 },
1677+
{ SNOR_HWCAPS_READ_1_8_8, SNOR_CMD_READ_1_8_8 },
1678+
{ SNOR_HWCAPS_READ_8_8_8, SNOR_CMD_READ_8_8_8 },
1679+
{ SNOR_HWCAPS_READ_1_8_8_DTR, SNOR_CMD_READ_1_8_8_DTR },
16651680
};
16661681

16671682
return spi_nor_hwcaps2cmd(hwcaps, hwcaps_read2cmd,
@@ -1675,6 +1690,9 @@ static int spi_nor_hwcaps_pp2cmd(u32 hwcaps)
16751690
{ SNOR_HWCAPS_PP_1_1_4, SNOR_CMD_PP_1_1_4 },
16761691
{ SNOR_HWCAPS_PP_1_4_4, SNOR_CMD_PP_1_4_4 },
16771692
{ SNOR_HWCAPS_PP_4_4_4, SNOR_CMD_PP_4_4_4 },
1693+
{ SNOR_HWCAPS_PP_1_1_8, SNOR_CMD_PP_1_1_8 },
1694+
{ SNOR_HWCAPS_PP_1_8_8, SNOR_CMD_PP_1_8_8 },
1695+
{ SNOR_HWCAPS_PP_8_8_8, SNOR_CMD_PP_8_8_8 },
16781696
};
16791697

16801698
return spi_nor_hwcaps2cmd(hwcaps, hwcaps_pp2cmd,
@@ -1772,7 +1790,9 @@ static int spi_nor_setup(struct spi_nor *nor, const struct flash_info *info,
17721790
/* SPI n-n-n protocols are not supported yet. */
17731791
ignored_mask = (SNOR_HWCAPS_READ_2_2_2 |
17741792
SNOR_HWCAPS_READ_4_4_4 |
1775-
SNOR_HWCAPS_PP_4_4_4);
1793+
SNOR_HWCAPS_READ_8_8_8 |
1794+
SNOR_HWCAPS_PP_4_4_4 |
1795+
SNOR_HWCAPS_PP_8_8_8);
17761796
if (shared_mask & ignored_mask) {
17771797
dev_dbg(nor->dev,
17781798
"SPI n-n-n protocols are not supported yet.\n");

‎include/linux/mtd/spi-nor.h‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,18 @@ enum spi_nor_protocol {
161161
SNOR_PROTO_1_1_1 = SNOR_PROTO_STR(1, 1, 1),
162162
SNOR_PROTO_1_1_2 = SNOR_PROTO_STR(1, 1, 2),
163163
SNOR_PROTO_1_1_4 = SNOR_PROTO_STR(1, 1, 4),
164+
SNOR_PROTO_1_1_8 = SNOR_PROTO_STR(1, 1, 8),
164165
SNOR_PROTO_1_2_2 = SNOR_PROTO_STR(1, 2, 2),
165166
SNOR_PROTO_1_4_4 = SNOR_PROTO_STR(1, 4, 4),
167+
SNOR_PROTO_1_8_8 = SNOR_PROTO_STR(1, 8, 8),
166168
SNOR_PROTO_2_2_2 = SNOR_PROTO_STR(2, 2, 2),
167169
SNOR_PROTO_4_4_4 = SNOR_PROTO_STR(4, 4, 4),
170+
SNOR_PROTO_8_8_8 = SNOR_PROTO_STR(8, 8, 8),
168171

169172
SNOR_PROTO_1_1_1_DTR = SNOR_PROTO_DTR(1, 1, 1),
170173
SNOR_PROTO_1_2_2_DTR = SNOR_PROTO_DTR(1, 2, 2),
171174
SNOR_PROTO_1_4_4_DTR = SNOR_PROTO_DTR(1, 4, 4),
175+
SNOR_PROTO_1_8_8_DTR = SNOR_PROTO_DTR(1, 8, 8),
172176
};
173177

174178
static inline bool spi_nor_protocol_is_dtr(enum spi_nor_protocol proto)
@@ -308,10 +312,11 @@ struct spi_nor_hwcaps {
308312
/*
309313
*(Fast) Read capabilities.
310314
* MUST be ordered by priority: the higher bit position, the higher priority.
311-
* As a matter of performances, it is relevant to use Quad SPI protocols first,
312-
* then Dual SPI protocols before Fast Read and lastly (Slow) Read.
315+
* As a matter of performances, it is relevant to use Octo SPI protocols first,
316+
* then Quad SPI protocols before Dual SPI protocols, Fast Read and lastly
317+
* (Slow) Read.
313318
*/
314-
#define SNOR_HWCAPS_READ_MASK GENMASK(10, 0)
319+
#define SNOR_HWCAPS_READ_MASK GENMASK(14, 0)
315320
#define SNOR_HWCAPS_READ BIT(0)
316321
#define SNOR_HWCAPS_READ_FAST BIT(1)
317322
#define SNOR_HWCAPS_READ_1_1_1_DTR BIT(2)
@@ -328,23 +333,34 @@ struct spi_nor_hwcaps {
328333
#define SNOR_HWCAPS_READ_4_4_4 BIT(9)
329334
#define SNOR_HWCAPS_READ_1_4_4_DTR BIT(10)
330335

336+
#define SNOR_HWCPAS_READ_OCTO GENMASK(14, 11)
337+
#define SNOR_HWCAPS_READ_1_1_8 BIT(11)
338+
#define SNOR_HWCAPS_READ_1_8_8 BIT(12)
339+
#define SNOR_HWCAPS_READ_8_8_8 BIT(13)
340+
#define SNOR_HWCAPS_READ_1_8_8_DTR BIT(14)
341+
331342
/*
332343
* Page Program capabilities.
333344
* MUST be ordered by priority: the higher bit position, the higher priority.
334-
* Like (Fast) Read capabilities, Quad SPI protocols are preferred to the
345+
* Like (Fast) Read capabilities, Octo/Quad SPI protocols are preferred to the
335346
* legacy SPI 1-1-1 protocol.
336347
* Note that Dual Page Programs are not supported because there is no existing
337348
* JEDEC/SFDP standard to define them. Also at this moment no SPI flash memory
338349
* implements such commands.
339350
*/
340-
#define SNOR_HWCAPS_PP_MASK GENMASK(19, 16)
351+
#define SNOR_HWCAPS_PP_MASK GENMASK(22, 16)
341352
#define SNOR_HWCAPS_PP BIT(16)
342353

343354
#define SNOR_HWCAPS_PP_QUAD GENMASK(19, 17)
344355
#define SNOR_HWCAPS_PP_1_1_4 BIT(17)
345356
#define SNOR_HWCAPS_PP_1_4_4 BIT(18)
346357
#define SNOR_HWCAPS_PP_4_4_4 BIT(19)
347358

359+
#define SNOR_HWCAPS_PP_OCTO GENMASK(22, 20)
360+
#define SNOR_HWCAPS_PP_1_1_8 BIT(20)
361+
#define SNOR_HWCAPS_PP_1_8_8 BIT(21)
362+
#define SNOR_HWCAPS_PP_8_8_8 BIT(22)
363+
348364
/**
349365
* spi_nor_scan() - scan the SPI NOR
350366
* @nor: the spi_nor structure

0 commit comments

Comments
 (0)