Skip to content

Commit ef97dca

Browse files
automerging branch "kernel.org-palmer-linux/wip-is25wp256d" into "riscv-all"
2 parents 328762a + d391a66 commit ef97dca

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

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

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,22 @@ static const struct flash_info spi_nor_ids[] = {
10491049
SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
10501050
{ "is25lp128", INFO(0x9d6018, 0, 64 * 1024, 256,
10511051
SECT_4K | SPI_NOR_DUAL_READ) },
1052+
{ "is25wp032", INFO(0x9d7016, 0, 32 * 1024, 128,
1053+
SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
1054+
.quad_enable = macronix_quad_enable,
1055+
},
1056+
{ "is25wp064", INFO(0x9d7017, 0, 32 * 1024, 256,
1057+
SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
1058+
.quad_enable = macronix_quad_enable,
1059+
},
1060+
{ "is25wp128", INFO(0x9d7018, 0, 32 * 1024, 512,
1061+
SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
1062+
.quad_enable = macronix_quad_enable,
1063+
},
1064+
{ "is25wp256d", INFO(0x9d7019, 0, 32 * 1024, 1024,
1065+
SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES)
1066+
.quad_enable = macronix_quad_enable,
1067+
},
10521068

10531069
/* Macronix */
10541070
{ "mx25l512e", INFO(0xc22010, 0, 64 * 1024, 1, SECT_4K) },
@@ -1482,6 +1498,45 @@ static int macronix_quad_enable(struct spi_nor *nor)
14821498
return 0;
14831499
}
14841500

1501+
/**
1502+
* issi_unlock() - clear BP[0123] write-protection.
1503+
* @nor: pointer to a 'struct spi_nor'
1504+
*
1505+
* Bits [2345] of the Status Register are BP[0123].
1506+
* ISSI chips use a different block protection scheme than other chips.
1507+
* Just disable the write-protect unilaterally.
1508+
*
1509+
* Return: 0 on success, -errno otherwise.
1510+
*/
1511+
static int issi_unlock(struct spi_nor *nor)
1512+
{
1513+
int ret, val;
1514+
u8 mask = SR_BP0 | SR_BP1 | SR_BP2 | SR_BP3;
1515+
1516+
val = read_sr(nor);
1517+
if (val < 0)
1518+
return val;
1519+
if (!(val & mask))
1520+
return 0;
1521+
1522+
write_enable(nor);
1523+
1524+
write_sr(nor, val & ~mask);
1525+
1526+
ret = spi_nor_wait_till_ready(nor);
1527+
if (ret)
1528+
return ret;
1529+
1530+
ret = read_sr(nor);
1531+
if (ret > 0 && !(ret & mask)) {
1532+
dev_info(nor->dev, "ISSI Block Protection Bits cleared\n");
1533+
return 0;
1534+
} else {
1535+
dev_err(nor->dev, "ISSI Block Protection Bits not cleared\n");
1536+
return -EINVAL;
1537+
}
1538+
}
1539+
14851540
/*
14861541
* Write status Register and configuration register with 2 bytes
14871542
* The first byte will be written to the status register, while the
@@ -2714,6 +2769,9 @@ static int spi_nor_init(struct spi_nor *nor)
27142769
spi_nor_wait_till_ready(nor);
27152770
}
27162771

2772+
if (JEDEC_MFR(nor->info) == SNOR_MFR_ISSI)
2773+
issi_unlock(nor);
2774+
27172775
if (nor->quad_enable) {
27182776
err = nor->quad_enable(nor);
27192777
if (err) {
@@ -2893,7 +2951,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
28932951
if (ret)
28942952
return ret;
28952953

2896-
if (nor->addr_width) {
2954+
if (nor->addr_width && JEDEC_MFR(info) != SNOR_MFR_ISSI) {
28972955
/* already configured from SFDP */
28982956
} else if (info->addr_width) {
28992957
nor->addr_width = info->addr_width;

include/linux/mtd/spi-nor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define SNOR_MFR_ATMEL CFI_MFR_ATMEL
2424
#define SNOR_MFR_GIGADEVICE 0xc8
2525
#define SNOR_MFR_INTEL CFI_MFR_INTEL
26+
#define SNOR_MFR_ISSI 0x9d
2627
#define SNOR_MFR_MICRON CFI_MFR_ST /* ST Micro <--> Micron */
2728
#define SNOR_MFR_MACRONIX CFI_MFR_MACRONIX
2829
#define SNOR_MFR_SPANSION CFI_MFR_AMD
@@ -119,6 +120,7 @@
119120
#define SR_BP0 BIT(2) /* Block protect 0 */
120121
#define SR_BP1 BIT(3) /* Block protect 1 */
121122
#define SR_BP2 BIT(4) /* Block protect 2 */
123+
#define SR_BP3 BIT(5) /* Block protect 3 (on ISSI chips) */
122124
#define SR_TB BIT(5) /* Top/Bottom protect */
123125
#define SR_SRWD BIT(7) /* SR write protect */
124126
/* Spansion/Cypress specific status bits */

0 commit comments

Comments
 (0)