Skip to content

Commit 706fd00

Browse files
Kuwano-sanambarus
authored andcommitted
mtd: spi-nor: Extract volatile register offset from SCCR map
In use of multi-chip devices, we need to access registers in each die for configuration and status check. The number of dice in the device and volatile register offsets for each die are essential to iterate register access ops. The volatile register offset for the first die resides in the 1st DWORD of SCCR map. Allocate the table and copy the offset value. The table may be allocated when the SCCR map for multi-chip is parsed. Since we cannot assume SCCR parse is always in ahead of SCCR multi-chip, we need to check if the table is already allocated or not. Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com> Link: https://lore.kernel.org/r/e2cc39ad6e0e02dd8288c4def9bb201a3f564425.1680849425.git.Takahiro.Kuwano@infineon.com Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent e570f78 commit 706fd00

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

drivers/mtd/spi-nor/core.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ struct spi_nor_otp {
352352
* in octal DTR mode.
353353
* @rdsr_addr_nbytes: dummy address bytes needed for Read Status Register
354354
* command in octal DTR mode.
355+
* @n_dice: number of dice in the flash memory.
356+
* @vreg_offset: volatile register offset for each die.
355357
* @hwcaps: describes the read and page program hardware
356358
* capabilities.
357359
* @reads: read capabilities ordered by priority: the higher index
@@ -385,6 +387,8 @@ struct spi_nor_flash_parameter {
385387
u8 addr_mode_nbytes;
386388
u8 rdsr_dummy;
387389
u8 rdsr_addr_nbytes;
390+
u8 n_dice;
391+
u32 *vreg_offset;
388392

389393
struct spi_nor_hwcaps hwcaps;
390394
struct spi_nor_read_command reads[SNOR_CMD_READ_MAX];

drivers/mtd/spi-nor/sfdp.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,7 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,
12261226
static int spi_nor_parse_sccr(struct spi_nor *nor,
12271227
const struct sfdp_parameter_header *sccr_header)
12281228
{
1229+
struct spi_nor_flash_parameter *params = nor->params;
12291230
u32 *dwords, addr;
12301231
size_t len;
12311232
int ret;
@@ -1242,6 +1243,18 @@ static int spi_nor_parse_sccr(struct spi_nor *nor,
12421243

12431244
le32_to_cpu_array(dwords, sccr_header->length);
12441245

1246+
/* Address offset for volatile registers (die 0) */
1247+
if (!params->vreg_offset) {
1248+
params->vreg_offset = devm_kmalloc(nor->dev, sizeof(*dwords),
1249+
GFP_KERNEL);
1250+
if (!params->vreg_offset) {
1251+
ret = -ENOMEM;
1252+
goto out;
1253+
}
1254+
}
1255+
params->vreg_offset[0] = dwords[SFDP_DWORD(1)];
1256+
params->n_dice = 1;
1257+
12451258
if (FIELD_GET(SCCR_DWORD22_OCTAL_DTR_EN_VOLATILE,
12461259
dwords[SFDP_DWORD(22)]))
12471260
nor->flags |= SNOR_F_IO_MODE_EN_VOLATILE;

0 commit comments

Comments
 (0)