]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
mtd: spi-nor: reset QSPI page on to 0 on reboot/shutdown
authorRanjit Waghmode <ranjit.waghmode@xilinx.com>
Tue, 24 Nov 2015 05:46:28 +0000 (11:16 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 26 Nov 2015 10:07:56 +0000 (11:07 +0100)
This patch adds functionality to reset the QSPI page on 0
on reboot or shutdown.

Signed-off-by: Ranjit Waghmode <ranjit.waghmode@xilinx.com>
Reviewed-by: Harini Katakam <harinik@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/mtd/devices/m25p80.c
drivers/mtd/spi-nor/spi-nor.c
include/linux/mtd/spi-nor.h

index 7b7dea26110628b2860ae5c3b5742ad554a218cf..ebc8d78f25cdeb46b255561389217f95da683ab1 100644 (file)
@@ -248,6 +248,13 @@ static int m25p_remove(struct spi_device *spi)
        return mtd_device_unregister(&flash->mtd);
 }
 
+static void m25p_shutdown(struct spi_device *spi)
+{
+       struct m25p *flash = spi_get_drvdata(spi);
+
+       spi_nor_shutdown(&flash->spi_nor);
+}
+
 /*
  * XXX This needs to be kept in sync with spi_nor_ids.  We can't share
  * it with spi-nor, because if this is built as a module then modpost
@@ -307,6 +314,7 @@ static struct spi_driver m25p80_driver = {
        .id_table       = m25p_ids,
        .probe  = m25p_probe,
        .remove = m25p_remove,
+       .shutdown = m25p_shutdown,
 
        /* REVISIT: many of these chips have deep power-down modes, which
         * should clearly be entered on suspend() to minimize power use.
index dd895452c403eb52b590a5929cfb731677fd52b8..1211fdd14d212a7db4e7c1f44c03cd6fcf61c692 100644 (file)
@@ -1796,6 +1796,14 @@ static const struct spi_device_id *spi_nor_match_id(const char *name)
        return NULL;
 }
 
+void spi_nor_shutdown(struct spi_nor *nor)
+{
+       if (nor->addr_width == 3 &&
+               (nor->mtd->size >> nor->shift) > 0x1000000)
+               write_ear(nor, 0);
+}
+EXPORT_SYMBOL_GPL(spi_nor_shutdown);
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Huang Shijie <shijie8@gmail.com>");
 MODULE_AUTHOR("Mike Lavender");
index d752c5cb4215fa06d124a25413cddb4b5e4f7900..a1001177cbffc0ae2f4143bdc35c8cbfd0a28f44 100644 (file)
@@ -236,4 +236,13 @@ struct spi_nor {
  */
 int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode);
 
+/**
+ * spi_nor_shutdown() - prepare for reboot
+ * @nor:       the spi_nor structure
+ *
+ * The drivers can use this fuction to get the address back to
+ * 0 as will be required for a ROM boot.
+ */
+void spi_nor_shutdown(struct spi_nor *nor);
+
 #endif