Skip to content
Snippets Groups Projects
Commit cf6b11dc authored by Jagan Teki's avatar Jagan Teki
Browse files

sf: Discover the bank addr commands


Bank/Extended addr commands are specific to particular
flash vendor so discover them based on the idocode0.

Assign the discovered bank commands to spi_flash members
so-that the bank read/write will use their specific operations.

Signed-off-by: default avatarJagannadha Sutradharudu Teki <jaganna@xilinx.com>
parent c9fcb59d
No related branches found
No related tags found
No related merge requests found
...@@ -304,6 +304,27 @@ int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel) ...@@ -304,6 +304,27 @@ int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel)
return 0; return 0;
} }
int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0)
{
/* discover bank cmds */
switch (idcode0) {
case SPI_FLASH_SPANSION_IDCODE0:
flash->bank_read_cmd = CMD_BANKADDR_BRRD;
flash->bank_write_cmd = CMD_BANKADDR_BRWR;
break;
case SPI_FLASH_STMICRO_IDCODE0:
case SPI_FLASH_WINBOND_IDCODE0:
flash->bank_read_cmd = CMD_EXTNADDR_RDEAR;
flash->bank_write_cmd = CMD_EXTNADDR_WREAR;
break;
default:
printf("SF: Unsupported bank commands %02x\n", idcode0);
return -1;
}
return 0;
}
#ifdef CONFIG_OF_CONTROL #ifdef CONFIG_OF_CONTROL
int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash) int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
{ {
......
...@@ -28,6 +28,17 @@ ...@@ -28,6 +28,17 @@
#define CMD_ERASE_64K 0xd8 #define CMD_ERASE_64K 0xd8
#define CMD_ERASE_CHIP 0xc7 #define CMD_ERASE_CHIP 0xc7
/* Manufacture ID's */
#define SPI_FLASH_SPANSION_IDCODE0 0x01
#define SPI_FLASH_STMICRO_IDCODE0 0x20
#define SPI_FLASH_WINBOND_IDCODE0 0xef
/* Bank addr access commands */
#define CMD_BANKADDR_BRWR 0x17
#define CMD_BANKADDR_BRRD 0x16
#define CMD_EXTNADDR_WREAR 0xC5
#define CMD_EXTNADDR_RDEAR 0xC8
/* Common status */ /* Common status */
#define STATUS_WIP 0x01 #define STATUS_WIP 0x01
...@@ -80,6 +91,9 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr); ...@@ -80,6 +91,9 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr);
/* Program the bank address register */ /* Program the bank address register */
int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel); int spi_flash_cmd_bankaddr_write(struct spi_flash *flash, u8 bank_sel);
/* Configure the BAR - discover the bank cmds */
int spi_flash_bank_config(struct spi_flash *flash, u8 idcode0);
/* /*
* Same as spi_flash_cmd_read() except it also claims/releases the SPI * Same as spi_flash_cmd_read() except it also claims/releases the SPI
* bus. Used as common part of the ->read() operation. * bus. Used as common part of the ->read() operation.
......
...@@ -38,6 +38,10 @@ struct spi_flash { ...@@ -38,6 +38,10 @@ struct spi_flash {
u32 page_size; u32 page_size;
/* Erase (sector) size */ /* Erase (sector) size */
u32 sector_size; u32 sector_size;
/* Bank read cmd */
u8 bank_read_cmd;
/* Bank write cmd */
u8 bank_write_cmd;
void *memory_map; /* Address of read-only SPI flash access */ void *memory_map; /* Address of read-only SPI flash access */
int (*read)(struct spi_flash *flash, u32 offset, int (*read)(struct spi_flash *flash, u32 offset,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment