Skip to content

Commit 47228ca

Browse files
Merge tag 'spi-nor/for-4.12-v2' of git://github.com/spi-nor/linux into MTD
From Cyrille: """ This pull request contains the following notable changes: - fixes in the hisi SPI controller driver. - fixes in the intel SPI controller driver. - fixes in the Mediatek SPI controller driver. - fixes to some SPI flash memories not supported the Chip Erase command. - add support to some new memory parts (Winbond, Macronix, Micron, ESMT). - add new driver for the STM32 QSPI controller. """
2 parents 57e363b + 8abe904 commit 47228ca

File tree

7 files changed

+749
-6
lines changed

7 files changed

+749
-6
lines changed

drivers/mtd/spi-nor/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,11 @@ config SPI_INTEL_SPI_PLATFORM
106106
To compile this driver as a module, choose M here: the module
107107
will be called intel-spi-platform.
108108

109+
config SPI_STM32_QUADSPI
110+
tristate "STM32 Quad SPI controller"
111+
depends on ARCH_STM32
112+
help
113+
This enables support for the STM32 Quad SPI controller.
114+
We only connect the NOR to this controller.
115+
109116
endif # MTD_SPI_NOR

drivers/mtd/spi-nor/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ obj-$(CONFIG_MTD_MT81xx_NOR) += mtk-quadspi.o
88
obj-$(CONFIG_SPI_NXP_SPIFI) += nxp-spifi.o
99
obj-$(CONFIG_SPI_INTEL_SPI) += intel-spi.o
1010
obj-$(CONFIG_SPI_INTEL_SPI_PLATFORM) += intel-spi-platform.o
11+
obj-$(CONFIG_SPI_STM32_QUADSPI) += stm32-quadspi.o

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,11 @@ static int hisi_spi_nor_probe(struct platform_device *pdev)
448448
if (!host->buffer)
449449
return -ENOMEM;
450450

451+
ret = clk_prepare_enable(host->clk);
452+
if (ret)
453+
return ret;
454+
451455
mutex_init(&host->lock);
452-
clk_prepare_enable(host->clk);
453456
hisi_spi_nor_init(host);
454457
ret = hisi_spi_nor_register_all(host);
455458
if (ret)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ static void intel_spi_fill_partition(struct intel_spi *ispi,
704704
* whole partition read-only to be on the safe side.
705705
*/
706706
if (intel_spi_is_protected(ispi, base, limit))
707-
ispi->writeable = 0;
707+
ispi->writeable = false;
708708

709709
end = (limit << 12) + 4096;
710710
if (end > part->size)
@@ -728,7 +728,7 @@ struct intel_spi *intel_spi_probe(struct device *dev,
728728

729729
ispi->base = devm_ioremap_resource(dev, mem);
730730
if (IS_ERR(ispi->base))
731-
return ispi->base;
731+
return ERR_CAST(ispi->base);
732732

733733
ispi->dev = dev;
734734
ispi->info = info;

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@
104104
#define MTK_NOR_MAX_RX_TX_SHIFT 6
105105
/* can shift up to 56 bits (7 bytes) transfer by MTK_NOR_PRG_CMD */
106106
#define MTK_NOR_MAX_SHIFT 7
107+
/* nor controller 4-byte address mode enable bit */
108+
#define MTK_NOR_4B_ADDR_EN BIT(4)
107109

108110
/* Helpers for accessing the program data / shift data registers */
109111
#define MTK_NOR_PRG_REG(n) (MTK_NOR_PRGDATA0_REG + 4 * (n))
@@ -230,10 +232,35 @@ static int mt8173_nor_write_buffer_disable(struct mt8173_nor *mt8173_nor)
230232
10000);
231233
}
232234

235+
static void mt8173_nor_set_addr_width(struct mt8173_nor *mt8173_nor)
236+
{
237+
u8 val;
238+
struct spi_nor *nor = &mt8173_nor->nor;
239+
240+
val = readb(mt8173_nor->base + MTK_NOR_DUAL_REG);
241+
242+
switch (nor->addr_width) {
243+
case 3:
244+
val &= ~MTK_NOR_4B_ADDR_EN;
245+
break;
246+
case 4:
247+
val |= MTK_NOR_4B_ADDR_EN;
248+
break;
249+
default:
250+
dev_warn(mt8173_nor->dev, "Unexpected address width %u.\n",
251+
nor->addr_width);
252+
break;
253+
}
254+
255+
writeb(val, mt8173_nor->base + MTK_NOR_DUAL_REG);
256+
}
257+
233258
static void mt8173_nor_set_addr(struct mt8173_nor *mt8173_nor, u32 addr)
234259
{
235260
int i;
236261

262+
mt8173_nor_set_addr_width(mt8173_nor);
263+
237264
for (i = 0; i < 3; i++) {
238265
writeb(addr & 0xff, mt8173_nor->base + MTK_NOR_RADR0_REG + i * 4);
239266
addr >>= 8;

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct flash_info {
8585
* Use dedicated 4byte address op codes
8686
* to support memory size above 128Mib.
8787
*/
88+
#define NO_CHIP_ERASE BIT(12) /* Chip does not support chip erase */
8889
};
8990

9091
#define JEDEC_MFR(info) ((info)->id[0])
@@ -960,6 +961,8 @@ static const struct flash_info spi_nor_ids[] = {
960961

961962
/* ESMT */
962963
{ "f25l32pa", INFO(0x8c2016, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) },
964+
{ "f25l32qa", INFO(0x8c4116, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) },
965+
{ "f25l64qa", INFO(0x8c4117, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_HAS_LOCK) },
963966

964967
/* Everspin */
965968
{ "mr25h256", CAT25_INFO( 32 * 1024, 1, 256, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
@@ -1013,11 +1016,14 @@ static const struct flash_info spi_nor_ids[] = {
10131016
{ "mx25l3205d", INFO(0xc22016, 0, 64 * 1024, 64, SECT_4K) },
10141017
{ "mx25l3255e", INFO(0xc29e16, 0, 64 * 1024, 64, SECT_4K) },
10151018
{ "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, SECT_4K) },
1019+
{ "mx25u2033e", INFO(0xc22532, 0, 64 * 1024, 4, SECT_4K) },
1020+
{ "mx25u4035", INFO(0xc22533, 0, 64 * 1024, 8, SECT_4K) },
1021+
{ "mx25u8035", INFO(0xc22534, 0, 64 * 1024, 16, SECT_4K) },
10161022
{ "mx25u6435f", INFO(0xc22537, 0, 64 * 1024, 128, SECT_4K) },
10171023
{ "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) },
10181024
{ "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) },
10191025
{ "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) },
1020-
{ "mx25u25635f", INFO(0xc22539, 0, 64 * 1024, 512, SECT_4K) },
1026+
{ "mx25u25635f", INFO(0xc22539, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_4B_OPCODES) },
10211027
{ "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },
10221028
{ "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ) },
10231029
{ "mx66l1g55g", INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) },
@@ -1031,10 +1037,11 @@ static const struct flash_info spi_nor_ids[] = {
10311037
{ "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_QUAD_READ) },
10321038
{ "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_QUAD_READ) },
10331039
{ "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ) },
1040+
{ "n25q256ax1", INFO(0x20bb19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ) },
10341041
{ "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
10351042
{ "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
1036-
{ "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
1037-
{ "n25q00a", INFO(0x20bb21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) },
1043+
{ "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) },
1044+
{ "n25q00a", INFO(0x20bb21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) },
10381045

10391046
/* PMC */
10401047
{ "pm25lv512", INFO(0, 0, 32 * 1024, 2, SECT_4K_PMC) },
@@ -1128,6 +1135,9 @@ static const struct flash_info spi_nor_ids[] = {
11281135
{ "w25x80", INFO(0xef3014, 0, 64 * 1024, 16, SECT_4K) },
11291136
{ "w25x16", INFO(0xef3015, 0, 64 * 1024, 32, SECT_4K) },
11301137
{ "w25x32", INFO(0xef3016, 0, 64 * 1024, 64, SECT_4K) },
1138+
{ "w25q20cl", INFO(0xef4012, 0, 64 * 1024, 4, SECT_4K) },
1139+
{ "w25q20bw", INFO(0xef5012, 0, 64 * 1024, 4, SECT_4K) },
1140+
{ "w25q20ew", INFO(0xef6012, 0, 64 * 1024, 4, SECT_4K) },
11311141
{ "w25q32", INFO(0xef4016, 0, 64 * 1024, 64, SECT_4K) },
11321142
{
11331143
"w25q32dw", INFO(0xef6016, 0, 64 * 1024, 64,
@@ -1629,6 +1639,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
16291639
nor->flags |= SNOR_F_USE_FSR;
16301640
if (info->flags & SPI_NOR_HAS_TB)
16311641
nor->flags |= SNOR_F_HAS_SR_TB;
1642+
if (info->flags & NO_CHIP_ERASE)
1643+
nor->flags |= SNOR_F_NO_OP_CHIP_ERASE;
16321644

16331645
#ifdef CONFIG_MTD_SPI_NOR_USE_4K_SECTORS
16341646
/* prefer "small sector" erase if possible */

0 commit comments

Comments
 (0)