Skip to content

Commit e570f78

Browse files
committed
mtd: spi-nor: Allow post_sfdp hook to return errors
Multi die flashes like s25hl02gt need to determine the page_size at run-time by querying a configuration register for each die. Since the number of dice is determined in an optional SFDP table, SCCR MC, the page size configuration must be done in the post_sfdp hook. Allow post_sfdp to return errors, as reading the configuration register might return errors. Link: https://lore.kernel.org/r/924ab710f128448ec62537cfbb377336e390043c.1680849425.git.Takahiro.Kuwano@infineon.com Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent 120c94a commit e570f78

4 files changed

Lines changed: 25 additions & 10 deletions

File tree

drivers/mtd/spi-nor/core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ struct spi_nor_fixups {
426426
int (*post_bfpt)(struct spi_nor *nor,
427427
const struct sfdp_parameter_header *bfpt_header,
428428
const struct sfdp_bfpt *bfpt);
429-
void (*post_sfdp)(struct spi_nor *nor);
429+
int (*post_sfdp)(struct spi_nor *nor);
430430
void (*late_init)(struct spi_nor *nor);
431431
};
432432

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static void mt35xu512aba_default_init(struct spi_nor *nor)
131131
nor->params->octal_dtr_enable = micron_st_nor_octal_dtr_enable;
132132
}
133133

134-
static void mt35xu512aba_post_sfdp_fixup(struct spi_nor *nor)
134+
static int mt35xu512aba_post_sfdp_fixup(struct spi_nor *nor)
135135
{
136136
/* Set the Fast Read settings. */
137137
nor->params->hwcaps.mask |= SNOR_HWCAPS_READ_8_8_8_DTR;
@@ -149,6 +149,8 @@ static void mt35xu512aba_post_sfdp_fixup(struct spi_nor *nor)
149149
* disable it.
150150
*/
151151
nor->params->quad_enable = NULL;
152+
153+
return 0;
152154
}
153155

154156
static const struct spi_nor_fixups mt35xu512aba_fixups = {

drivers/mtd/spi-nor/sfdp.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,14 +1260,21 @@ static int spi_nor_parse_sccr(struct spi_nor *nor,
12601260
* Used to tweak various flash parameters when information provided by the SFDP
12611261
* tables are wrong.
12621262
*/
1263-
static void spi_nor_post_sfdp_fixups(struct spi_nor *nor)
1263+
static int spi_nor_post_sfdp_fixups(struct spi_nor *nor)
12641264
{
1265+
int ret;
1266+
12651267
if (nor->manufacturer && nor->manufacturer->fixups &&
1266-
nor->manufacturer->fixups->post_sfdp)
1267-
nor->manufacturer->fixups->post_sfdp(nor);
1268+
nor->manufacturer->fixups->post_sfdp) {
1269+
ret = nor->manufacturer->fixups->post_sfdp(nor);
1270+
if (ret)
1271+
return ret;
1272+
}
12681273

12691274
if (nor->info->fixups && nor->info->fixups->post_sfdp)
1270-
nor->info->fixups->post_sfdp(nor);
1275+
return nor->info->fixups->post_sfdp(nor);
1276+
1277+
return 0;
12711278
}
12721279

12731280
/**
@@ -1477,7 +1484,7 @@ int spi_nor_parse_sfdp(struct spi_nor *nor)
14771484
}
14781485
}
14791486

1480-
spi_nor_post_sfdp_fixups(nor);
1487+
err = spi_nor_post_sfdp_fixups(nor);
14811488
exit:
14821489
kfree(param_headers);
14831490
return err;

drivers/mtd/spi-nor/spansion.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ s25fs256t_post_bfpt_fixup(struct spi_nor *nor,
370370
return cypress_nor_get_page_size(nor);
371371
}
372372

373-
static void s25fs256t_post_sfdp_fixup(struct spi_nor *nor)
373+
static int s25fs256t_post_sfdp_fixup(struct spi_nor *nor)
374374
{
375375
struct spi_nor_flash_parameter *params = nor->params;
376376

@@ -379,6 +379,8 @@ static void s25fs256t_post_sfdp_fixup(struct spi_nor *nor)
379379
spi_nor_set_pp_settings(&params->page_programs[SNOR_CMD_PP_1_1_4],
380380
SPINOR_OP_PP_1_1_4_4B,
381381
SNOR_PROTO_1_1_4);
382+
383+
return 0;
382384
}
383385

384386
static void s25fs256t_late_init(struct spi_nor *nor)
@@ -409,7 +411,7 @@ s25hx_t_post_bfpt_fixup(struct spi_nor *nor,
409411
return cypress_nor_get_page_size(nor);
410412
}
411413

412-
static void s25hx_t_post_sfdp_fixup(struct spi_nor *nor)
414+
static int s25hx_t_post_sfdp_fixup(struct spi_nor *nor)
413415
{
414416
struct spi_nor_erase_type *erase_type =
415417
nor->params->erase_map.erase_type;
@@ -431,6 +433,8 @@ static void s25hx_t_post_sfdp_fixup(struct spi_nor *nor)
431433
break;
432434
}
433435
}
436+
437+
return 0;
434438
}
435439

436440
static void s25hx_t_late_init(struct spi_nor *nor)
@@ -463,7 +467,7 @@ static int cypress_nor_octal_dtr_enable(struct spi_nor *nor, bool enable)
463467
cypress_nor_octal_dtr_dis(nor);
464468
}
465469

466-
static void s28hx_t_post_sfdp_fixup(struct spi_nor *nor)
470+
static int s28hx_t_post_sfdp_fixup(struct spi_nor *nor)
467471
{
468472
/*
469473
* On older versions of the flash the xSPI Profile 1.0 table has the
@@ -489,6 +493,8 @@ static void s28hx_t_post_sfdp_fixup(struct spi_nor *nor)
489493
* actual value for that is 4.
490494
*/
491495
nor->params->rdsr_addr_nbytes = 4;
496+
497+
return 0;
492498
}
493499

494500
static int s28hx_t_post_bfpt_fixup(struct spi_nor *nor,

0 commit comments

Comments
 (0)