Commit 6cba6fdf96f13a0533187b9c16608d9ca44add40

Authored by Jagannadha Sutradharudu Teki
1 parent 3163aaa63f

sf: ops: Add configuration register writing support

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.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>

Showing 1 changed file with 24 additions and 0 deletions Side-by-side Diff

drivers/mtd/spi/sf_ops.c
... ... @@ -38,6 +38,30 @@
38 38 return 0;
39 39 }
40 40  
  41 +static int spi_flash_cmd_write_config(struct spi_flash *flash, u8 cr)
  42 +{
  43 + u8 data[2];
  44 + u8 cmd;
  45 + int ret;
  46 +
  47 + cmd = CMD_READ_STATUS;
  48 + ret = spi_flash_read_common(flash, &cmd, 1, &data[0], 1);
  49 + if (ret < 0) {
  50 + debug("SF: fail to read status register\n");
  51 + return ret;
  52 + }
  53 +
  54 + cmd = CMD_WRITE_STATUS;
  55 + data[1] = cr;
  56 + ret = spi_flash_write_common(flash, &cmd, 1, &data, 2);
  57 + if (ret) {
  58 + debug("SF: fail to write config register\n");
  59 + return ret;
  60 + }
  61 +
  62 + return 0;
  63 +}
  64 +
41 65 #ifdef CONFIG_SPI_FLASH_BAR
42 66 static int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel)
43 67 {