]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mtd: spi-nor-core: Enable octal DTR mode when possible
authorPratyush Yadav <p.yadav@ti.com>
Fri, 25 Jun 2021 19:17:21 +0000 (00:47 +0530)
committerJagan Teki <jagan@amarulasolutions.com>
Mon, 28 Jun 2021 06:33:57 +0000 (12:03 +0530)
Allow flashes to specify a hook to enable octal DTR mode. Use this hook
whenever possible to get optimal transfer speeds.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
drivers/mtd/spi/spi-nor-core.c
include/linux/mtd/spi-nor.h

index b9d3101d579f8f649e7ed4a35c8ccbfe13ca5a12..cdb464813bb462794af4f3b3a6b380d6a41fd057 100644 (file)
@@ -2888,10 +2888,41 @@ static int spi_nor_setup(struct spi_nor *nor, const struct flash_info *info,
        return nor->setup(nor, info, params);
 }
 
+/** spi_nor_octal_dtr_enable() - enable Octal DTR I/O if needed
+ * @nor:                 pointer to a 'struct spi_nor'
+ *
+ * Return: 0 on success, -errno otherwise.
+ */
+static int spi_nor_octal_dtr_enable(struct spi_nor *nor)
+{
+       int ret;
+
+       if (!nor->octal_dtr_enable)
+               return 0;
+
+       if (!(nor->read_proto == SNOR_PROTO_8_8_8_DTR &&
+             nor->write_proto == SNOR_PROTO_8_8_8_DTR))
+               return 0;
+
+       ret = nor->octal_dtr_enable(nor);
+       if (ret)
+               return ret;
+
+       nor->reg_proto = SNOR_PROTO_8_8_8_DTR;
+
+       return 0;
+}
+
 static int spi_nor_init(struct spi_nor *nor)
 {
        int err;
 
+       err = spi_nor_octal_dtr_enable(nor);
+       if (err) {
+               dev_dbg(nor->dev, "Octal DTR mode not supported\n");
+               return err;
+       }
+
        /*
         * Atmel, SST, Intel/Numonyx, and others serial NOR tend to power up
         * with the software protection bits set
index 295583ed294382df48d59eb177234f15a3fb3e8b..aae814f55747c3cd5fd2328a06aeaaa7a78592ee 100644 (file)
@@ -477,6 +477,7 @@ struct spi_flash {
  * @flash_is_locked:   [FLASH-SPECIFIC] check if a region of the SPI NOR is
  *                     completely locked
  * @quad_enable:       [FLASH-SPECIFIC] enables SPI NOR quad mode
+ * @octal_dtr_enable:  [FLASH-SPECIFIC] enables SPI NOR octal DTR mode.
  * @priv:              the private data
  */
 struct spi_nor {
@@ -524,6 +525,7 @@ struct spi_nor {
        int (*flash_unlock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
        int (*flash_is_locked)(struct spi_nor *nor, loff_t ofs, uint64_t len);
        int (*quad_enable)(struct spi_nor *nor);
+       int (*octal_dtr_enable)(struct spi_nor *nor);
 
        void *priv;
 /* Compatibility for spi_flash, remove once sf layer is merged with mtd */