Skip to content

Commit

Permalink
Merge tag 'spi-nor/for-6.14' into mtd/next
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Miquel Raynal committed Jan 24, 2025
2 parents cd97c96 + 943e5f8 commit b44574c
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 19 deletions.
4 changes: 4 additions & 0 deletions Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ properties:
If "broken-flash-reset" is present then having this property does not
make any difference.

vcc-supply:
description:
Supply for the SPI NOR power.

spi-cpol: true
spi-cpha: true

Expand Down
4 changes: 4 additions & 0 deletions drivers/mtd/spi-nor/atmel.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ static const struct flash_info atmel_nor_parts[] = {
.flags = SPI_NOR_HAS_LOCK,
.no_sfdp_flags = SECT_4K,
.fixups = &at25fs_nor_fixups
}, {
.id = SNOR_ID(0x1f, 0x87, 0x01),
.size = SZ_4M,
.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
},
};

Expand Down
19 changes: 12 additions & 7 deletions drivers/mtd/spi-nor/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/mtd/spi-nor.h>
#include <linux/mutex.h>
#include <linux/of_platform.h>
#include <linux/regulator/consumer.h>
#include <linux/sched/task_stack.h>
#include <linux/sizes.h>
#include <linux/slab.h>
Expand Down Expand Up @@ -3576,7 +3577,8 @@ static int spi_nor_create_write_dirmap(struct spi_nor *nor)
static int spi_nor_probe(struct spi_mem *spimem)
{
struct spi_device *spi = spimem->spi;
struct flash_platform_data *data = dev_get_platdata(&spi->dev);
struct device *dev = &spi->dev;
struct flash_platform_data *data = dev_get_platdata(dev);
struct spi_nor *nor;
/*
* Enable all caps by default. The core will mask them after
Expand All @@ -3586,13 +3588,17 @@ static int spi_nor_probe(struct spi_mem *spimem)
char *flash_name;
int ret;

nor = devm_kzalloc(&spi->dev, sizeof(*nor), GFP_KERNEL);
ret = devm_regulator_get_enable(dev, "vcc");
if (ret)
return ret;

nor = devm_kzalloc(dev, sizeof(*nor), GFP_KERNEL);
if (!nor)
return -ENOMEM;

nor->spimem = spimem;
nor->dev = &spi->dev;
spi_nor_set_flash_node(nor, spi->dev.of_node);
nor->dev = dev;
spi_nor_set_flash_node(nor, dev->of_node);

spi_mem_set_drvdata(spimem, nor);

Expand Down Expand Up @@ -3628,9 +3634,8 @@ static int spi_nor_probe(struct spi_mem *spimem)
*/
if (nor->params->page_size > PAGE_SIZE) {
nor->bouncebuf_size = nor->params->page_size;
devm_kfree(nor->dev, nor->bouncebuf);
nor->bouncebuf = devm_kmalloc(nor->dev,
nor->bouncebuf_size,
devm_kfree(dev, nor->bouncebuf);
nor->bouncebuf = devm_kmalloc(dev, nor->bouncebuf_size,
GFP_KERNEL);
if (!nor->bouncebuf)
return -ENOMEM;
Expand Down
6 changes: 5 additions & 1 deletion drivers/mtd/spi-nor/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,11 @@ struct spi_nor_id {
* @id: pointer to struct spi_nor_id or NULL, which means "no ID" (mostly
* older chips).
* @name: (obsolete) the name of the flash. Do not set it for new additions.
* @size: the size of the flash in bytes.
* @size: the size of the flash in bytes. The flash size is one
* property parsed by the SFDP. We use it as an indicator
* whether we need SFDP parsing for a particular flash.
* I.e. non-legacy flash entries in flash_info will have
* a size of zero iff SFDP should be used.
* @sector_size: (optional) the size listed here is what works with
* SPINOR_OP_SE, which isn't necessarily called a "sector" by
* the vendor. Defaults to 64k.
Expand Down
9 changes: 2 additions & 7 deletions drivers/mtd/spi-nor/macronix.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,6 @@ static const struct flash_info macronix_nor_parts[] = {
.name = "mx25u12835f",
.size = SZ_16M,
.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
}, {
.id = SNOR_ID(0xc2, 0x25, 0x39),
.name = "mx25u25635f",
.size = SZ_32M,
.no_sfdp_flags = SECT_4K,
.fixup_flags = SPI_NOR_4B_OPCODES,
}, {
.id = SNOR_ID(0xc2, 0x25, 0x3a),
.name = "mx25u51245g",
Expand Down Expand Up @@ -230,7 +224,8 @@ static int macronix_nor_octal_dtr_en(struct spi_nor *nor)
return ret;

/* Read flash ID to make sure the switch was successful. */
ret = spi_nor_read_id(nor, 4, 4, buf, SNOR_PROTO_8_8_8_DTR);
ret = spi_nor_read_id(nor, nor->addr_nbytes, 4, buf,
SNOR_PROTO_8_8_8_DTR);
if (ret) {
dev_dbg(nor->dev, "error %d reading JEDEC ID after enabling 8D-8D-8D mode\n", ret);
return ret;
Expand Down
10 changes: 10 additions & 0 deletions drivers/mtd/spi-nor/spansion.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,11 @@ static const struct flash_info spansion_nor_parts[] = {
.name = "s25hs02gt",
.mfr_flags = USE_CLPEF,
.fixups = &s25hx_t_fixups
}, {
/* S28HL256T */
.id = SNOR_ID(0x34, 0x5a, 0x19),
.mfr_flags = USE_CLPEF,
.fixups = &s28hx_t_fixups,
}, {
.id = SNOR_ID(0x34, 0x5a, 0x1a),
.name = "s28hl512t",
Expand All @@ -967,6 +972,11 @@ static const struct flash_info spansion_nor_parts[] = {
.name = "s28hl01gt",
.mfr_flags = USE_CLPEF,
.fixups = &s28hx_t_fixups,
}, {
/* S28HL02GT */
.id = SNOR_ID(0x34, 0x5a, 0x1c),
.mfr_flags = USE_CLPEF,
.fixups = &s28hx_t_fixups,
}, {
.id = SNOR_ID(0x34, 0x5b, 0x19),
.mfr_flags = USE_CLPEF,
Expand Down
8 changes: 4 additions & 4 deletions drivers/mtd/spi-nor/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static struct attribute *spi_nor_sysfs_entries[] = {
};

static ssize_t sfdp_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, char *buf,
const struct bin_attribute *bin_attr, char *buf,
loff_t off, size_t count)
{
struct spi_device *spi = to_spi_device(kobj_to_dev(kobj));
Expand All @@ -62,9 +62,9 @@ static ssize_t sfdp_read(struct file *filp, struct kobject *kobj,
return memory_read_from_buffer(buf, count, &off, nor->sfdp->dwords,
sfdp_size);
}
static BIN_ATTR_RO(sfdp, 0);
static const BIN_ATTR_RO(sfdp, 0);

static struct bin_attribute *spi_nor_sysfs_bin_entries[] = {
static const struct bin_attribute *const spi_nor_sysfs_bin_entries[] = {
&bin_attr_sfdp,
NULL
};
Expand Down Expand Up @@ -104,7 +104,7 @@ static const struct attribute_group spi_nor_sysfs_group = {
.is_visible = spi_nor_sysfs_is_visible,
.is_bin_visible = spi_nor_sysfs_is_bin_visible,
.attrs = spi_nor_sysfs_entries,
.bin_attrs = spi_nor_sysfs_bin_entries,
.bin_attrs_new = spi_nor_sysfs_bin_entries,
};

const struct attribute_group *spi_nor_sysfs_groups[] = {
Expand Down

0 comments on commit b44574c

Please sign in to comment.