[PATCH v2 4/8] mtd: spi-nor: spansion: switch set_octal_dtr method to use vreg_offset

Tudor Ambarus tudor.ambarus at linaro.org
Fri Jul 21 23:50:39 PDT 2023



On 22.07.2023 08:25, Tudor Ambarus wrote:
> 
> 
> On 21.07.2023 19:49, Tudor Ambarus wrote:
>>
>>>>  static int cypress_nor_set_octal_dtr(struct spi_nor *nor, bool enable)
>>>>  {
>>> const struct spi_nor_flash_parameter *params = nor->params;
>>>
>>>> +	if (!nor->params->vreg_offset) {
>>>
>>> wouldn't hurt to check for params->n_dice as well, even though one
>>> implies the other. In the next patch you have a loop with n-dice being
>>> the max number of elements. If n-dice becomes zero sometime, the loop is
>>> skipped. Thus:
>>>
>>> 	if (params->n_dice && !nor->params->vreg_offset)
>>>
>> 	if (!params->n_dice || !params->vreg_offset)
> 
> and this sanity check should be moved to s28hx_t_late_init(), this way
> we do it once, as it's needed when setting
> cypress_nor_sr_ready_and_clear() too.

and we shall switch s25hx_t flashes to use vreg_offset as well,
something like:

commit 0830e89c312ff5941dc1a7e0d251eb608c51c729 (HEAD -> spi-nor/next)
Author: Tudor Ambarus <tudor.ambarus at linaro.org>
Date:   Sat Jul 22 09:36:22 2023 +0300

    mtd: spi-nor: spansion: switch s25hx_t to use vreg_offset

    All s25hx_t flashes retrieve n_dice and vreg_offset from SFDP. Switch
    s25hx_t to always use vreg_offset in order to use the same code base
    for both single and multi chip package flashes.

    Signed-off-by: Tudor Ambarus <tudor.ambarus at linaro.org>

diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c
index 413573cdb4fc..4027f0038ce5 100644
--- a/drivers/mtd/spi-nor/spansion.c
+++ b/drivers/mtd/spi-nor/spansion.c
@@ -350,10 +350,6 @@ static int cypress_nor_quad_enable_volatile(struct
spi_nor *nor)
        u8 i;
        int ret;

-       if (!params->n_dice)
-               return cypress_nor_quad_enable_volatile_reg(nor,
-                                               SPINOR_REG_CYPRESS_CFR1V);
-
        for (i = 0; i < params->n_dice; i++) {
                addr = params->vreg_offset[i] + SPINOR_REG_CYPRESS_CFR1;
                ret = cypress_nor_quad_enable_volatile_reg(nor, addr);
@@ -659,15 +655,17 @@ static int s25hx_t_late_init(struct spi_nor *nor)
 {
        struct spi_nor_flash_parameter *params = nor->params;

+       if (!params->n_dice || !params->vreg_offset) {
+               dev_err(nor->dev, "%s failed. The volatile register
offset could not be retrieved from SFDP.\n",
+                       __func__);
+               return -EOPNOTSUPP;
+       }
+
        /* Fast Read 4B requires mode cycles */
        params->reads[SNOR_CMD_READ_FAST].num_mode_clocks = 8;
-
+       params->ready = cypress_nor_sr_ready_and_clear;
        cypress_nor_ecc_init(nor);

-       /* Replace ready() with multi die version */
-       if (params->n_dice)
-               params->ready = cypress_nor_sr_ready_and_clear;
-
        return 0;
 }

I'll send a v3 with all changes, it's easier this way.



More information about the linux-mtd mailing list