Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Kevin Cernekee and committed by
David Woodhouse
4b7f7422 f0dff9bd

+28 -3
+28 -3
drivers/mtd/devices/m25p80.c
··· 51 51 #define OPCODE_WRDI 0x04 /* Write disable */ 52 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 58 /* Status Register bits. */ 55 59 #define SR_WIP 1 /* Write in progress */ 56 60 #define SR_WEL 2 /* Write enable latch */ ··· 66 62 67 63 /* Define max times to check status register before we give up. */ 68 64 #define MAX_READY_WAIT_JIFFIES (40 * HZ) /* M25P16 specs 40s max chip erase */ 69 - #define MAX_CMD_SIZE 4 65 + #define MAX_CMD_SIZE 5 70 66 71 67 #ifdef CONFIG_M25PXX_USE_FAST_READ 72 68 #define OPCODE_READ OPCODE_FAST_READ ··· 156 152 } 157 153 158 154 /* 155 + * Enable/disable 4-byte addressing mode. 156 + */ 157 + static inline int set_4byte(struct m25p *flash, int enable) 158 + { 159 + u8 code = enable ? OPCODE_EN4B : OPCODE_EX4B; 160 + 161 + return spi_write_then_read(flash->spi, &code, 1, NULL, 0); 162 + } 163 + 164 + /* 159 165 * Service routine to read status register until ready, or timeout occurs. 160 166 * Returns non-zero if error. 161 167 */ ··· 221 207 cmd[1] = addr >> (flash->addr_width * 8 - 8); 222 208 cmd[2] = addr >> (flash->addr_width * 8 - 16); 223 209 cmd[3] = addr >> (flash->addr_width * 8 - 24); 210 + cmd[4] = addr >> (flash->addr_width * 8 - 32); 224 211 } 225 212 226 213 static int m25p_cmdsz(struct m25p *flash) ··· 622 607 .sector_size = (_sector_size), \ 623 608 .n_sectors = (_n_sectors), \ 624 609 .page_size = 256, \ 625 - .addr_width = 3, \ 626 610 .flags = (_flags), \ 627 611 }) 628 612 ··· 667 653 { "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, 0) }, 668 654 { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) }, 669 655 { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) }, 656 + { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) }, 670 657 671 658 /* Spansion -- single (large) sector size only, at least 672 659 * for the chips listed here (without boot sectors). ··· 899 884 900 885 flash->mtd.dev.parent = &spi->dev; 901 886 flash->page_size = info->page_size; 902 - flash->addr_width = info->addr_width; 887 + 888 + if (info->addr_width) 889 + flash->addr_width = info->addr_width; 890 + else { 891 + /* enable 4-byte addressing if the device exceeds 16MiB */ 892 + if (flash->mtd.size > 0x1000000) { 893 + flash->addr_width = 4; 894 + set_4byte(flash, 1); 895 + } else 896 + flash->addr_width = 3; 897 + } 903 898 904 899 dev_info(&spi->dev, "%s (%lld Kbytes)\n", id->name, 905 900 (long long)flash->mtd.size >> 10);