]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/mtd/spi-nor/stm32-quadspi.c
Merge tag 'kvm-4.13-2' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[karo-tx-linux.git] / drivers / mtd / spi-nor / stm32-quadspi.c
index ae45f81b8cd33fdea3cbedccbd0a1cc11575cd38..86c0931543c538c340421786db8bc4ef5d88a55c 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/reset.h>
+#include <linux/sizes.h>
 
 #define QUADSPI_CR             0x00
 #define CR_EN                  BIT(0)
@@ -192,15 +193,15 @@ static void stm32_qspi_set_framemode(struct spi_nor *nor,
        cmd->framemode = CCR_IMODE_1;
 
        if (read) {
-               switch (nor->flash_read) {
-               case SPI_NOR_NORMAL:
-               case SPI_NOR_FAST:
+               switch (nor->read_proto) {
+               default:
+               case SNOR_PROTO_1_1_1:
                        dmode = CCR_DMODE_1;
                        break;
-               case SPI_NOR_DUAL:
+               case SNOR_PROTO_1_1_2:
                        dmode = CCR_DMODE_2;
                        break;
-               case SPI_NOR_QUAD:
+               case SNOR_PROTO_1_1_4:
                        dmode = CCR_DMODE_4;
                        break;
                }
@@ -375,7 +376,7 @@ static ssize_t stm32_qspi_read(struct spi_nor *nor, loff_t from, size_t len,
        struct stm32_qspi_cmd cmd;
        int err;
 
-       dev_dbg(qspi->dev, "read(%#.2x): buf:%p from:%#.8x len:%#x\n",
+       dev_dbg(qspi->dev, "read(%#.2x): buf:%p from:%#.8x len:%#zx\n",
                nor->read_opcode, buf, (u32)from, len);
 
        memset(&cmd, 0, sizeof(cmd));
@@ -402,7 +403,7 @@ static ssize_t stm32_qspi_write(struct spi_nor *nor, loff_t to, size_t len,
        struct stm32_qspi_cmd cmd;
        int err;
 
-       dev_dbg(dev, "write(%#.2x): buf:%p to:%#.8x len:%#x\n",
+       dev_dbg(dev, "write(%#.2x): buf:%p to:%#.8x len:%#zx\n",
                nor->program_opcode, buf, (u32)to, len);
 
        memset(&cmd, 0, sizeof(cmd));
@@ -480,7 +481,12 @@ static void stm32_qspi_unprep(struct spi_nor *nor, enum spi_nor_ops ops)
 static int stm32_qspi_flash_setup(struct stm32_qspi *qspi,
                                  struct device_node *np)
 {
-       u32 width, flash_read, presc, cs_num, max_rate = 0;
+       struct spi_nor_hwcaps hwcaps = {
+               .mask = SNOR_HWCAPS_READ |
+                       SNOR_HWCAPS_READ_FAST |
+                       SNOR_HWCAPS_PP,
+       };
+       u32 width, presc, cs_num, max_rate = 0;
        struct stm32_qspi_flash *flash;
        struct mtd_info *mtd;
        int ret;
@@ -499,12 +505,10 @@ static int stm32_qspi_flash_setup(struct stm32_qspi *qspi,
                width = 1;
 
        if (width == 4)
-               flash_read = SPI_NOR_QUAD;
+               hwcaps.mask |= SNOR_HWCAPS_READ_1_1_4;
        else if (width == 2)
-               flash_read = SPI_NOR_DUAL;
-       else if (width == 1)
-               flash_read = SPI_NOR_NORMAL;
-       else
+               hwcaps.mask |= SNOR_HWCAPS_READ_1_1_2;
+       else if (width != 1)
                return -EINVAL;
 
        flash = &qspi->flash[cs_num];
@@ -539,7 +543,7 @@ static int stm32_qspi_flash_setup(struct stm32_qspi *qspi,
         */
        flash->fsize = FSIZE_VAL(SZ_1K);
 
-       ret = spi_nor_scan(&flash->nor, NULL, flash_read);
+       ret = spi_nor_scan(&flash->nor, NULL, &hwcaps);
        if (ret) {
                dev_err(qspi->dev, "device scan failed\n");
                return ret;