1 From 207662a9270cc542709fbab0d25fbc361b39748c Mon Sep 17 00:00:00 2001
2 From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
3 Date: Wed, 7 Nov 2012 15:13:49 +0100
4 Subject: sf: macronix: add support for 4-byte address mode
6 Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
8 --- a/drivers/mtd/spi/macronix.c
9 +++ b/drivers/mtd/spi/macronix.c
12 #include "spi_flash_internal.h"
14 +#define MX25XX_EN4B 0xb7 /* Enter 4-byte mode */
16 struct macronix_spi_flash_params {
19 @@ -79,6 +81,13 @@ static const struct macronix_spi_flash_p
23 +static __maybe_unused int macronix_set_4byte_mode(struct spi_flash *flash)
25 + struct spi_slave *spi = flash->spi;
27 + return spi_flash_cmd(spi, MX25XX_EN4B, NULL, 0);
30 int spi_flash_probe_macronix(struct spi_flash *flash, u8 *idcode)
32 const struct macronix_spi_flash_params *params;
33 @@ -106,6 +115,11 @@ int spi_flash_probe_macronix(struct spi_
34 flash->sector_size = 256 * 16 * 16;
35 flash->size = flash->sector_size * params->nr_blocks;
37 +#ifdef CONFIG_SPI_FLASH_4BYTE_MODE
38 + if (flash->size > (1 << 24))
39 + flash->set_4byte_mode = macronix_set_4byte_mode;
42 /* Clear BP# bits for read-only flash */
43 spi_flash_cmd_write_status(flash, 0);