sf: Add macronix set QEB support
authorJagannadha Sutradharudu Teki <jaganna@xilinx.com>
Thu, 26 Dec 2013 08:43:36 +0000 (14:13 +0530)
committerJagannadha Sutradharudu Teki <jaganna@xilinx.com>
Sat, 11 Jan 2014 11:21:37 +0000 (16:51 +0530)
This patch adds set QEB support for macronix flash devices
which are trying to program/read quad operations.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
drivers/mtd/spi/sf_internal.h
drivers/mtd/spi/sf_ops.c
drivers/mtd/spi/sf_probe.c

index a9f5a8111bea1eba1719246086d65b9e1cccf7aa..c69b53de15502f93a3aba41490b9ce7c4c951f6d 100644 (file)
@@ -17,6 +17,7 @@
 /* CFI Manufacture ID's */
 #define SPI_FLASH_CFI_MFR_SPANSION     0x01
 #define SPI_FLASH_CFI_MFR_STMICRO      0x20
+#define SPI_FLASH_CFI_MFR_MACRONIX     0xc2
 #define SPI_FLASH_CFI_MFR_WINBOND      0xef
 
 /* SECT flags */
@@ -61,6 +62,7 @@
 /* Common status */
 #define STATUS_WIP                     0x01
 #define STATUS_QEB_WINSPAN             (1 << 1)
+#define STATUS_QEB_MXIC                        (1 << 6)
 #define STATUS_PEC                     0x80
 
 /* Flash timeout values */
@@ -102,6 +104,9 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len);
 /* Program the status register */
 int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr);
 
+/* Set quad enbale bit for macronix flashes */
+int spi_flash_set_qeb_mxic(struct spi_flash *flash);
+
 /* Set quad enbale bit for winbond and spansion flashes */
 int spi_flash_set_qeb_winspan(struct spi_flash *flash);
 
index 6adee325cb2cb45c3be81c786624d43f52aef84b..05fbcbd43d09602f8b6c6659eca8e191be11e6b4 100644 (file)
@@ -39,6 +39,32 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)
        return 0;
 }
 
+#ifdef CONFIG_SPI_FLASH_MACRONIX
+int spi_flash_set_qeb_mxic(struct spi_flash *flash)
+{
+       u8 qeb_status;
+       u8 cmd;
+       int ret;
+
+       cmd = CMD_READ_STATUS;
+       ret = spi_flash_read_common(flash, &cmd, 1, &qeb_status, 1);
+       if (ret < 0) {
+               debug("SF: fail to read status register\n");
+               return ret;
+       }
+
+       if (qeb_status & STATUS_QEB_MXIC) {
+               debug("SF: Quad enable bit is already set\n");
+       } else {
+               ret = spi_flash_cmd_write_status(flash, STATUS_QEB_MXIC);
+               if (ret < 0)
+                       return ret;
+       }
+
+       return ret;
+}
+#endif
+
 #if defined(CONFIG_SPI_FLASH_SPANSION) || defined(CONFIG_SPI_FLASH_WINBOND)
 static int spi_flash_cmd_write_config(struct spi_flash *flash, u8 cr)
 {
index 8bd06eea62385d671002c850dc50422a78ca566e..88d1d0a88e8dbdfd48b4fdf4a530451cde4879ad 100644 (file)
@@ -31,6 +31,10 @@ static u8 spi_read_cmds_array[] = {
 static int spi_flash_set_qeb(struct spi_flash *flash, u8 idcode0)
 {
        switch (idcode0) {
+#ifdef CONFIG_SPI_FLASH_MACRONIX
+       case SPI_FLASH_CFI_MFR_MACRONIX:
+               return spi_flash_set_qeb_mxic(flash);
+#endif
 #if defined(CONFIG_SPI_FLASH_SPANSION) || defined(CONFIG_SPI_FLASH_WINBOND)
        case SPI_FLASH_CFI_MFR_SPANSION:
        case SPI_FLASH_CFI_MFR_WINBOND: