]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
spi: Add support for 4Byte addressing commands
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Sat, 27 Apr 2019 06:29:00 +0000 (11:59 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 4 Jun 2019 10:47:15 +0000 (12:47 +0200)
Thsi patch adds support for 4-byte addressing Read, write
and erase commands.

Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
drivers/mtd/spi/sf_internal.h
drivers/mtd/spi/spi_flash.c
drivers/spi/cadence_qspi.c

index b684cad8dd29a5719e34159e58f1b5894a295b62..343137226697729e6c62992eff79965e4fc5a884 100644 (file)
@@ -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
index 179b817ab5b8c4a384c7c8889624307833d51620..e5b0e6d949d6d5df851e18659b67d1b3962398f5 100644 (file)
@@ -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) ||
index f02ad009b152fb2c461657a9fc27aa708f7c7cb2..8db7e871ae13a3e47c6e94a0a74b05bc2ad4c004 100644 (file)
@@ -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,
 };