]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
sf: Add configuration register writing support
authorJagannadha Sutradharudu Teki <jaganna@xilinx.com>
Tue, 20 Aug 2013 07:13:42 +0000 (12:43 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 21 Aug 2013 07:55:24 +0000 (09:55 +0200)
This patch provides support to program a flash config register.

Configuration register contains the control bits used to configure
the different configurations and security features of a device.

User need to set these bits through spi_flash_cmd_write_config()
based on their usage.

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

index 93a9479bc76bafad4274c08ec77697209f7dba06..baed29b79570515c6f532ad147f650a7970fb704 100644 (file)
@@ -384,6 +384,29 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr)
        return 0;
 }
 
+int spi_flash_cmd_write_config(struct spi_flash *flash, u8 cr)
+{
+       u8 cmd, data[2];
+       int ret;
+
+       cmd = CMD_READ_STATUS;
+       ret = spi_flash_read_common(flash, &cmd, 1, &data[0], 1);
+       if (ret < 0) {
+               debug("SF: fail to read status register\n");
+               return ret;
+       }
+
+       cmd = CMD_WRITE_STATUS;
+       data[1] = cr;
+       ret = spi_flash_write_common(flash, &cmd, 1, &data, 2);
+       if (ret < 0) {
+               debug("SF: fail to write config register\n");
+               return ret;
+       }
+
+       return 0;
+}
+
 #ifdef CONFIG_SPI_FLASH_BAR
 int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel)
 {
index af1afa96c9dfe5d757650b84d605d4200da8a0fa..1f105258b780af8af88cdf8597bc4d1e13882b30 100644 (file)
@@ -94,6 +94,9 @@ static inline int spi_flash_cmd_write_disable(struct spi_flash *flash)
 /* Program the status register. */
 int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr);
 
+/* Program the config register */
+int spi_flash_cmd_write_config(struct spi_flash *flash, u8 cr);
+
 #ifdef CONFIG_SPI_FLASH_BAR
 /* Program the bank address register */
 int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel);