Skip to content

Commit b44574c

Browse files
committed
Merge tag 'spi-nor/for-6.14' into mtd/next
SPI NOR changes for 6.14 Notable changes: - Add flash entries for Atmel AT25SF321, Spansion S28HL256T, S28HL02GT. - Add support for vcc-supply regulators and their DT bindings. - Drop mx25u25635f entry. The flash shares its ID with mx25u25645g and both parts have an SFDP table. Removing their entry lets them be driven by the generic SFDP-based driver.
2 parents cd97c96 + 943e5f8 commit b44574c

File tree

7 files changed

+41
-19
lines changed

7 files changed

+41
-19
lines changed

Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ properties:
9696
If "broken-flash-reset" is present then having this property does not
9797
make any difference.
9898

99+
vcc-supply:
100+
description:
101+
Supply for the SPI NOR power.
102+
99103
spi-cpol: true
100104
spi-cpha: true
101105

drivers/mtd/spi-nor/atmel.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ static const struct flash_info atmel_nor_parts[] = {
238238
.flags = SPI_NOR_HAS_LOCK,
239239
.no_sfdp_flags = SECT_4K,
240240
.fixups = &at25fs_nor_fixups
241+
}, {
242+
.id = SNOR_ID(0x1f, 0x87, 0x01),
243+
.size = SZ_4M,
244+
.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
241245
},
242246
};
243247

drivers/mtd/spi-nor/core.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/mtd/spi-nor.h>
1818
#include <linux/mutex.h>
1919
#include <linux/of_platform.h>
20+
#include <linux/regulator/consumer.h>
2021
#include <linux/sched/task_stack.h>
2122
#include <linux/sizes.h>
2223
#include <linux/slab.h>
@@ -3576,7 +3577,8 @@ static int spi_nor_create_write_dirmap(struct spi_nor *nor)
35763577
static int spi_nor_probe(struct spi_mem *spimem)
35773578
{
35783579
struct spi_device *spi = spimem->spi;
3579-
struct flash_platform_data *data = dev_get_platdata(&spi->dev);
3580+
struct device *dev = &spi->dev;
3581+
struct flash_platform_data *data = dev_get_platdata(dev);
35803582
struct spi_nor *nor;
35813583
/*
35823584
* Enable all caps by default. The core will mask them after
@@ -3586,13 +3588,17 @@ static int spi_nor_probe(struct spi_mem *spimem)
35863588
char *flash_name;
35873589
int ret;
35883590

3589-
nor = devm_kzalloc(&spi->dev, sizeof(*nor), GFP_KERNEL);
3591+
ret = devm_regulator_get_enable(dev, "vcc");
3592+
if (ret)
3593+
return ret;
3594+
3595+
nor = devm_kzalloc(dev, sizeof(*nor), GFP_KERNEL);
35903596
if (!nor)
35913597
return -ENOMEM;
35923598

35933599
nor->spimem = spimem;
3594-
nor->dev = &spi->dev;
3595-
spi_nor_set_flash_node(nor, spi->dev.of_node);
3600+
nor->dev = dev;
3601+
spi_nor_set_flash_node(nor, dev->of_node);
35963602

35973603
spi_mem_set_drvdata(spimem, nor);
35983604

@@ -3628,9 +3634,8 @@ static int spi_nor_probe(struct spi_mem *spimem)
36283634
*/
36293635
if (nor->params->page_size > PAGE_SIZE) {
36303636
nor->bouncebuf_size = nor->params->page_size;
3631-
devm_kfree(nor->dev, nor->bouncebuf);
3632-
nor->bouncebuf = devm_kmalloc(nor->dev,
3633-
nor->bouncebuf_size,
3637+
devm_kfree(dev, nor->bouncebuf);
3638+
nor->bouncebuf = devm_kmalloc(dev, nor->bouncebuf_size,
36343639
GFP_KERNEL);
36353640
if (!nor->bouncebuf)
36363641
return -ENOMEM;

drivers/mtd/spi-nor/core.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,11 @@ struct spi_nor_id {
448448
* @id: pointer to struct spi_nor_id or NULL, which means "no ID" (mostly
449449
* older chips).
450450
* @name: (obsolete) the name of the flash. Do not set it for new additions.
451-
* @size: the size of the flash in bytes.
451+
* @size: the size of the flash in bytes. The flash size is one
452+
* property parsed by the SFDP. We use it as an indicator
453+
* whether we need SFDP parsing for a particular flash.
454+
* I.e. non-legacy flash entries in flash_info will have
455+
* a size of zero iff SFDP should be used.
452456
* @sector_size: (optional) the size listed here is what works with
453457
* SPINOR_OP_SE, which isn't necessarily called a "sector" by
454458
* the vendor. Defaults to 64k.

drivers/mtd/spi-nor/macronix.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,6 @@ static const struct flash_info macronix_nor_parts[] = {
142142
.name = "mx25u12835f",
143143
.size = SZ_16M,
144144
.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
145-
}, {
146-
.id = SNOR_ID(0xc2, 0x25, 0x39),
147-
.name = "mx25u25635f",
148-
.size = SZ_32M,
149-
.no_sfdp_flags = SECT_4K,
150-
.fixup_flags = SPI_NOR_4B_OPCODES,
151145
}, {
152146
.id = SNOR_ID(0xc2, 0x25, 0x3a),
153147
.name = "mx25u51245g",
@@ -230,7 +224,8 @@ static int macronix_nor_octal_dtr_en(struct spi_nor *nor)
230224
return ret;
231225

232226
/* Read flash ID to make sure the switch was successful. */
233-
ret = spi_nor_read_id(nor, 4, 4, buf, SNOR_PROTO_8_8_8_DTR);
227+
ret = spi_nor_read_id(nor, nor->addr_nbytes, 4, buf,
228+
SNOR_PROTO_8_8_8_DTR);
234229
if (ret) {
235230
dev_dbg(nor->dev, "error %d reading JEDEC ID after enabling 8D-8D-8D mode\n", ret);
236231
return ret;

drivers/mtd/spi-nor/spansion.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,11 @@ static const struct flash_info spansion_nor_parts[] = {
957957
.name = "s25hs02gt",
958958
.mfr_flags = USE_CLPEF,
959959
.fixups = &s25hx_t_fixups
960+
}, {
961+
/* S28HL256T */
962+
.id = SNOR_ID(0x34, 0x5a, 0x19),
963+
.mfr_flags = USE_CLPEF,
964+
.fixups = &s28hx_t_fixups,
960965
}, {
961966
.id = SNOR_ID(0x34, 0x5a, 0x1a),
962967
.name = "s28hl512t",
@@ -967,6 +972,11 @@ static const struct flash_info spansion_nor_parts[] = {
967972
.name = "s28hl01gt",
968973
.mfr_flags = USE_CLPEF,
969974
.fixups = &s28hx_t_fixups,
975+
}, {
976+
/* S28HL02GT */
977+
.id = SNOR_ID(0x34, 0x5a, 0x1c),
978+
.mfr_flags = USE_CLPEF,
979+
.fixups = &s28hx_t_fixups,
970980
}, {
971981
.id = SNOR_ID(0x34, 0x5b, 0x19),
972982
.mfr_flags = USE_CLPEF,

drivers/mtd/spi-nor/sysfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static struct attribute *spi_nor_sysfs_entries[] = {
5050
};
5151

5252
static ssize_t sfdp_read(struct file *filp, struct kobject *kobj,
53-
struct bin_attribute *bin_attr, char *buf,
53+
const struct bin_attribute *bin_attr, char *buf,
5454
loff_t off, size_t count)
5555
{
5656
struct spi_device *spi = to_spi_device(kobj_to_dev(kobj));
@@ -62,9 +62,9 @@ static ssize_t sfdp_read(struct file *filp, struct kobject *kobj,
6262
return memory_read_from_buffer(buf, count, &off, nor->sfdp->dwords,
6363
sfdp_size);
6464
}
65-
static BIN_ATTR_RO(sfdp, 0);
65+
static const BIN_ATTR_RO(sfdp, 0);
6666

67-
static struct bin_attribute *spi_nor_sysfs_bin_entries[] = {
67+
static const struct bin_attribute *const spi_nor_sysfs_bin_entries[] = {
6868
&bin_attr_sfdp,
6969
NULL
7070
};
@@ -104,7 +104,7 @@ static const struct attribute_group spi_nor_sysfs_group = {
104104
.is_visible = spi_nor_sysfs_is_visible,
105105
.is_bin_visible = spi_nor_sysfs_is_bin_visible,
106106
.attrs = spi_nor_sysfs_entries,
107-
.bin_attrs = spi_nor_sysfs_bin_entries,
107+
.bin_attrs_new = spi_nor_sysfs_bin_entries,
108108
};
109109

110110
const struct attribute_group *spi_nor_sysfs_groups[] = {

0 commit comments

Comments
 (0)