aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorKevin Cernekee <cernekee@gmail.com>2010-10-31 00:11:03 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-12-03 11:26:55 -0500
commit4b7f7422b0331e802f8b7c593e058ccee981cff5 (patch)
tree24276b0e9eff0122d3a1b2ecec1411ac6ffecbf5 /drivers
parentf0dff9bd00d2cffea160fb3fa015b77607458634 (diff)
mtd: m25p80: Add support for Macronix MX25L25635E
This is a 256Mbit (32MiB) part so minor changes were made to support 4-byte addressing. Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/devices/m25p80.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 80404e1a4d5e..96ae54e9650e 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -51,6 +51,10 @@
51#define OPCODE_WRDI 0x04 /* Write disable */ 51#define OPCODE_WRDI 0x04 /* Write disable */
52#define OPCODE_AAI_WP 0xad /* Auto address increment word program */ 52#define OPCODE_AAI_WP 0xad /* Auto address increment word program */
53 53
54/* Used for Macronix flashes only. */
55#define OPCODE_EN4B 0xb7 /* Enter 4-byte mode */
56#define OPCODE_EX4B 0xe9 /* Exit 4-byte mode */
57
54/* Status Register bits. */ 58/* Status Register bits. */
55#define SR_WIP 1 /* Write in progress */ 59#define SR_WIP 1 /* Write in progress */
56#define SR_WEL 2 /* Write enable latch */ 60#define SR_WEL 2 /* Write enable latch */
@@ -62,7 +66,7 @@
62 66
63/* Define max times to check status register before we give up. */ 67/* Define max times to check status register before we give up. */
64#define MAX_READY_WAIT_JIFFIES (40 * HZ) /* M25P16 specs 40s max chip erase */ 68#define MAX_READY_WAIT_JIFFIES (40 * HZ) /* M25P16 specs 40s max chip erase */
65#define MAX_CMD_SIZE 4 69#define MAX_CMD_SIZE 5
66 70
67#ifdef CONFIG_M25PXX_USE_FAST_READ 71#ifdef CONFIG_M25PXX_USE_FAST_READ
68#define OPCODE_READ OPCODE_FAST_READ 72#define OPCODE_READ OPCODE_FAST_READ
@@ -152,6 +156,16 @@ static inline int write_disable(struct m25p *flash)
152} 156}
153 157
154/* 158/*
159 * Enable/disable 4-byte addressing mode.
160 */
161static inline int set_4byte(struct m25p *flash, int enable)
162{
163 u8 code = enable ? OPCODE_EN4B : OPCODE_EX4B;
164
165 return spi_write_then_read(flash->spi, &code, 1, NULL, 0);
166}
167
168/*
155 * Service routine to read status register until ready, or timeout occurs. 169 * Service routine to read status register until ready, or timeout occurs.
156 * Returns non-zero if error. 170 * Returns non-zero if error.
157 */ 171 */
@@ -207,6 +221,7 @@ static void m25p_addr2cmd(struct m25p *flash, unsigned int addr, u8 *cmd)
207 cmd[1] = addr >> (flash->addr_width * 8 - 8); 221 cmd[1] = addr >> (flash->addr_width * 8 - 8);
208 cmd[2] = addr >> (flash->addr_width * 8 - 16); 222 cmd[2] = addr >> (flash->addr_width * 8 - 16);
209 cmd[3] = addr >> (flash->addr_width * 8 - 24); 223 cmd[3] = addr >> (flash->addr_width * 8 - 24);
224 cmd[4] = addr >> (flash->addr_width * 8 - 32);
210} 225}
211 226
212static int m25p_cmdsz(struct m25p *flash) 227static int m25p_cmdsz(struct m25p *flash)
@@ -607,7 +622,6 @@ struct flash_info {
607 .sector_size = (_sector_size), \ 622 .sector_size = (_sector_size), \
608 .n_sectors = (_n_sectors), \ 623 .n_sectors = (_n_sectors), \
609 .page_size = 256, \ 624 .page_size = 256, \
610 .addr_width = 3, \
611 .flags = (_flags), \ 625 .flags = (_flags), \
612 }) 626 })
613 627
@@ -653,6 +667,7 @@ static const struct spi_device_id m25p_ids[] = {
653 { "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, 0) }, 667 { "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, 0) },
654 { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) }, 668 { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) },
655 { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) }, 669 { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) },
670 { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) },
656 671
657 /* Spansion -- single (large) sector size only, at least 672 /* Spansion -- single (large) sector size only, at least
658 * for the chips listed here (without boot sectors). 673 * for the chips listed here (without boot sectors).
@@ -884,7 +899,17 @@ static int __devinit m25p_probe(struct spi_device *spi)
884 899
885 flash->mtd.dev.parent = &spi->dev; 900 flash->mtd.dev.parent = &spi->dev;
886 flash->page_size = info->page_size; 901 flash->page_size = info->page_size;
887 flash->addr_width = info->addr_width; 902
903 if (info->addr_width)
904 flash->addr_width = info->addr_width;
905 else {
906 /* enable 4-byte addressing if the device exceeds 16MiB */
907 if (flash->mtd.size > 0x1000000) {
908 flash->addr_width = 4;
909 set_4byte(flash, 1);
910 } else
911 flash->addr_width = 3;
912 }
888 913
889 dev_info(&spi->dev, "%s (%lld Kbytes)\n", id->name, 914 dev_info(&spi->dev, "%s (%lld Kbytes)\n", id->name,
890 (long long)flash->mtd.size >> 10); 915 (long long)flash->mtd.size >> 10);