aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices
diff options
context:
space:
mode:
authorRobert Jarzmik <robert.jarzmik@free.fr>2011-11-19 10:02:56 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-01-09 13:07:28 -0500
commite4b2a96aeb2b3dfee8d19d0335c6151d4cca4631 (patch)
tree05fba96057ccb827c490b1f8c502882b16f20899 /drivers/mtd/devices
parentd13d19ece39f20bf097782e1812a9c31a5a4fcf1 (diff)
mtd: docg3: add suspend and resume
Add functions to powerdown and powerup from suspend, in order to save power. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Reviewed-by: Ivan Djelic <ivan.djelic@parrot.com> Reviewed-by: Mike Dunn <mikedunn@newsguy.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r--drivers/mtd/devices/docg3.c75
-rw-r--r--drivers/mtd/devices/docg3.h6
2 files changed, 80 insertions, 1 deletions
diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index 26cc17909b16..d94c759d3ea7 100644
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -45,7 +45,6 @@
45 * As no specification is available from M-Systems/Sandisk, this drivers lacks 45 * As no specification is available from M-Systems/Sandisk, this drivers lacks
46 * several functions available on the chip, as : 46 * several functions available on the chip, as :
47 * - IPL write 47 * - IPL write
48 * - powerdown / powerup
49 * 48 *
50 * The bus data width (8bits versus 16bits) is not handled (if_cfg flag), and 49 * The bus data width (8bits versus 16bits) is not handled (if_cfg flag), and
51 * the driver assumes a 16bits data bus. 50 * the driver assumes a 16bits data bus.
@@ -1756,6 +1755,78 @@ static void doc_release_device(struct mtd_info *mtd)
1756} 1755}
1757 1756
1758/** 1757/**
1758 * docg3_resume - Awakens docg3 floor
1759 * @pdev: platfrom device
1760 *
1761 * Returns 0 (always successfull)
1762 */
1763static int docg3_resume(struct platform_device *pdev)
1764{
1765 int i;
1766 struct mtd_info **docg3_floors, *mtd;
1767 struct docg3 *docg3;
1768
1769 docg3_floors = platform_get_drvdata(pdev);
1770 mtd = docg3_floors[0];
1771 docg3 = mtd->priv;
1772
1773 doc_dbg("docg3_resume()\n");
1774 for (i = 0; i < 12; i++)
1775 doc_readb(docg3, DOC_IOSPACE_IPL);
1776 return 0;
1777}
1778
1779/**
1780 * docg3_suspend - Put in low power mode the docg3 floor
1781 * @pdev: platform device
1782 * @state: power state
1783 *
1784 * Shuts off most of docg3 circuitery to lower power consumption.
1785 *
1786 * Returns 0 if suspend succeeded, -EIO if chip refused suspend
1787 */
1788static int docg3_suspend(struct platform_device *pdev, pm_message_t state)
1789{
1790 int floor, i;
1791 struct mtd_info **docg3_floors, *mtd;
1792 struct docg3 *docg3;
1793 u8 ctrl, pwr_down;
1794
1795 docg3_floors = platform_get_drvdata(pdev);
1796 for (floor = 0; floor < DOC_MAX_NBFLOORS; floor++) {
1797 mtd = docg3_floors[floor];
1798 if (!mtd)
1799 continue;
1800 docg3 = mtd->priv;
1801
1802 doc_writeb(docg3, floor, DOC_DEVICESELECT);
1803 ctrl = doc_register_readb(docg3, DOC_FLASHCONTROL);
1804 ctrl &= ~DOC_CTRL_VIOLATION & ~DOC_CTRL_CE;
1805 doc_writeb(docg3, ctrl, DOC_FLASHCONTROL);
1806
1807 for (i = 0; i < 10; i++) {
1808 usleep_range(3000, 4000);
1809 pwr_down = doc_register_readb(docg3, DOC_POWERMODE);
1810 if (pwr_down & DOC_POWERDOWN_READY)
1811 break;
1812 }
1813 if (pwr_down & DOC_POWERDOWN_READY) {
1814 doc_dbg("docg3_suspend(): floor %d powerdown ok\n",
1815 floor);
1816 } else {
1817 doc_err("docg3_suspend(): floor %d powerdown failed\n",
1818 floor);
1819 return -EIO;
1820 }
1821 }
1822
1823 mtd = docg3_floors[0];
1824 docg3 = mtd->priv;
1825 doc_set_asic_mode(docg3, DOC_ASICMODE_POWERDOWN);
1826 return 0;
1827}
1828
1829/**
1759 * doc_probe - Probe the IO space for a DiskOnChip G3 chip 1830 * doc_probe - Probe the IO space for a DiskOnChip G3 chip
1760 * @pdev: platform device 1831 * @pdev: platform device
1761 * 1832 *
@@ -1860,6 +1931,8 @@ static struct platform_driver g3_driver = {
1860 .name = "docg3", 1931 .name = "docg3",
1861 .owner = THIS_MODULE, 1932 .owner = THIS_MODULE,
1862 }, 1933 },
1934 .suspend = docg3_suspend,
1935 .resume = docg3_resume,
1863 .remove = __exit_p(docg3_release), 1936 .remove = __exit_p(docg3_release),
1864}; 1937};
1865 1938
diff --git a/drivers/mtd/devices/docg3.h b/drivers/mtd/devices/docg3.h
index 33db7272c460..cd70b181f797 100644
--- a/drivers/mtd/devices/docg3.h
+++ b/drivers/mtd/devices/docg3.h
@@ -127,6 +127,7 @@
127 127
128#define DOC_ASICMODECONFIRM 0x1072 128#define DOC_ASICMODECONFIRM 0x1072
129#define DOC_CHIPID_INV 0x1074 129#define DOC_CHIPID_INV 0x1074
130#define DOC_POWERMODE 0x107c
130 131
131/* 132/*
132 * Flash sequences 133 * Flash sequences
@@ -239,6 +240,11 @@
239#define DOC_READADDR_ADDR_MASK 0x1fff 240#define DOC_READADDR_ADDR_MASK 0x1fff
240 241
241/* 242/*
243 * Flash register : DOC_POWERMODE
244 */
245#define DOC_POWERDOWN_READY 0x80
246
247/*
242 * Status of erase and write operation 248 * Status of erase and write operation
243 */ 249 */
244#define DOC_PLANES_STATUS_FAIL 0x01 250#define DOC_PLANES_STATUS_FAIL 0x01