]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
sf: Set quad enable bit support
authorJagannadha Sutradharudu Teki <jaganna@xilinx.com>
Tue, 20 Aug 2013 07:22:26 +0000 (12:52 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 21 Aug 2013 07:55:24 +0000 (09:55 +0200)
This patch provides support to set the quad enable bit on flash.

quad enable bit needs to set before performing any quad IO
operations on respective SPI flashes.

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

index baed29b79570515c6f532ad147f650a7970fb704..6c266ac1a3656a04adfd810f31d82bf4b0d9999f 100644 (file)
@@ -407,6 +407,29 @@ int spi_flash_cmd_write_config(struct spi_flash *flash, u8 cr)
        return 0;
 }
 
+int spi_flash_set_qeb(struct spi_flash *flash)
+{
+       u8 qeb_status, cmd;
+       int ret;
+
+       cmd = CMD_READ_CONFIG;
+       ret = spi_flash_read_common(flash, &cmd, 1, &qeb_status, 1);
+       if (ret < 0) {
+               debug("SF: fail to read config register\n");
+               return ret;
+       }
+
+       if (qeb_status & STATUS_QEB) {
+               debug("SF: qeb is already set\n");
+       } else {
+               ret = spi_flash_cmd_write_config(flash, STATUS_QEB);
+               if (ret < 0)
+                       return ret;
+       }
+
+       return 0;
+}
+
 #ifdef CONFIG_SPI_FLASH_BAR
 int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel)
 {
@@ -624,6 +647,15 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
                goto err_manufacturer_probe;
 #endif
 
+       /* set the quad enable bit - only for quad commands */
+       if ((flash->read_cmd == CMD_READ_QUAD_OUTPUT_FAST) ||
+           (flash->write_cmd == CMD_QUAD_PAGE_PROGRAM)) {
+               if (spi_flash_set_qeb(flash)) {
+                       debug("SF: Fail to set qeb\n");
+                       goto err_manufacturer_probe;
+               }
+       }
+
 #ifdef CONFIG_OF_CONTROL
        if (spi_flash_decode_fdt(gd->fdt_blob, flash)) {
                debug("SF: FDT decode error\n");
index 1f105258b780af8af88cdf8597bc4d1e13882b30..4d4442343aae719ef0ec396f7d3d58b2a3610598 100644 (file)
@@ -22,6 +22,7 @@
 #define CMD_PAGE_PROGRAM               0x02
 #define CMD_WRITE_DISABLE              0x04
 #define CMD_READ_STATUS                        0x05
+#define CMD_READ_CONFIG                        0x35
 #define CMD_FLAG_STATUS                        0x70
 #define CMD_WRITE_ENABLE               0x06
 #define CMD_ERASE_4K                   0x20
@@ -46,6 +47,7 @@
 
 /* Common status */
 #define STATUS_WIP                     0x01
+#define STATUS_QEB                     0x02
 #define STATUS_PEC                     0x80
 
 /* Send a single-byte command to the device and read the response */