mtd: spi-nor: allow a flash to define its own ready() function
authorMichael Walle <michael@walle.cc>
Wed, 23 Feb 2022 13:43:44 +0000 (14:43 +0100)
committerTudor Ambarus <tudor.ambarus@microchip.com>
Fri, 25 Feb 2022 16:11:17 +0000 (18:11 +0200)
Xilinx and Micron flashes have their own implementation of the
spi_nor_ready() function. At the moment, the core will figure out
which one to call according to some flags. Lay the foundation to
make it possible that a flash can register its own ready()
function.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20220223134358.1914798-19-michael@walle.cc
drivers/mtd/spi-nor/core.c
drivers/mtd/spi-nor/core.h

index 4d2036cdce42fb48033d68e7d802d5247369f5d2..390a9ab413b7fb4a35cc92a9b1422975af5f46a2 100644 (file)
@@ -794,6 +794,10 @@ static int spi_nor_ready(struct spi_nor *nor)
 {
        int sr, fsr;
 
+       /* Flashes might override the standard routine. */
+       if (nor->params->ready)
+               return nor->params->ready(nor);
+
        if (nor->flags & SNOR_F_READY_XSR_RDY)
                sr = spi_nor_xsr_ready(nor);
        else
index 4fe16b5aa3f5de00bfbe992891d3164596c3fc10..fdc8c0f31f5cf462863900a41ccfd693b72d8485 100644 (file)
@@ -261,6 +261,9 @@ struct spi_nor_otp {
  *                     SPI NOR flashes that have peculiarities to the SPI NOR
  *                     standard e.g. different opcodes, specific address
  *                     calculation, page size, etc.
+ * @ready:             (optional) flashes might use a different mechanism
+ *                     than reading the status register to indicate they
+ *                     are ready for a new command
  * @locking_ops:       SPI NOR locking methods.
  */
 struct spi_nor_flash_parameter {
@@ -282,6 +285,7 @@ struct spi_nor_flash_parameter {
        int (*set_4byte_addr_mode)(struct spi_nor *nor, bool enable);
        u32 (*convert_addr)(struct spi_nor *nor, u32 addr);
        int (*setup)(struct spi_nor *nor, const struct spi_nor_hwcaps *hwcaps);
+       int (*ready)(struct spi_nor *nor);
 
        const struct spi_nor_locking_ops *locking_ops;
 };