From: Siva Durga Prasad Paladugu Date: Sat, 27 Apr 2019 06:29:00 +0000 (+0530) Subject: spi: Add support for 4Byte addressing commands X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9ba61fc244f1f0d27c066dbe8bda1fc4942c3be3;p=thirdparty%2Fu-boot.git spi: Add support for 4Byte addressing commands Thsi patch adds support for 4-byte addressing Read, write and erase commands. Signed-off-by: Siva Durga Prasad Paladugu --- diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index b684cad8dd2..34313722669 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -45,10 +45,12 @@ enum spi_nor_option_flags { #define CMD_ERASE_4K 0x20 #define CMD_ERASE_CHIP 0xc7 #define CMD_ERASE_64K 0xd8 +#define CMD_ERASE_64K_4B 0xdc /* Write commands */ #define CMD_WRITE_STATUS 0x01 #define CMD_PAGE_PROGRAM 0x02 +#define CMD_PAGE_PROGRAM_4B 0x12 #define CMD_WRITE_DISABLE 0x04 #define CMD_WRITE_ENABLE 0x06 #define CMD_QUAD_PAGE_PROGRAM 0x32 @@ -64,6 +66,7 @@ enum spi_nor_option_flags { #define CMD_READ_QUAD_OUTPUT_FAST 0x6b #define CMD_READ_QUAD_IO_FAST 0xeb #define CMD_READ_OCTAL_OUTPUT_FAST 0x8B +#define CMD_READ_OCTAL_OUTPUT_FAST_4B 0x7C #define CMD_READ_ID 0x9f #define CMD_READ_STATUS 0x05 #define CMD_READ_STATUS1 0x35 diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 179b817ab5b..e5b0e6d949d 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -1698,6 +1698,12 @@ int spi_flash_scan(struct spi_flash *flash) flash->write_cmd = CMD_PAGE_PROGRAM; } + if (spi->mode & SPI_RX_OCTAL && info->flags & RD_OCTAL && + flash->spi->bytemode) { + flash->read_cmd = CMD_READ_OCTAL_OUTPUT_FAST_4B; + flash->write_cmd = CMD_PAGE_PROGRAM_4B; + flash->erase_cmd = CMD_ERASE_64K_4B; + } /* Set the quad enable bit - only for quad commands */ if ((flash->read_cmd == CMD_READ_QUAD_OUTPUT_FAST) || diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c index f02ad009b15..8db7e871ae1 100644 --- a/drivers/spi/cadence_qspi.c +++ b/drivers/spi/cadence_qspi.c @@ -150,6 +150,15 @@ static int cadence_spi_set_speed(struct udevice *bus, uint hz) return 0; } +static int cadence_spi_child_pre_probe(struct udevice *bus) +{ + struct spi_slave *slave = dev_get_parent_priv(bus); + + slave->bytemode = SPI_4BYTE_MODE; + + return 0; +} + static int cadence_spi_probe(struct udevice *bus) { struct cadence_spi_platdata *plat = bus->platdata; @@ -345,4 +354,5 @@ U_BOOT_DRIVER(cadence_spi) = { .platdata_auto_alloc_size = sizeof(struct cadence_spi_platdata), .priv_auto_alloc_size = sizeof(struct cadence_spi_priv), .probe = cadence_spi_probe, + .child_pre_probe = cadence_spi_child_pre_probe, };