Merge tag 'u-boot-rockchip-20200501' of https://gitlab.denx.de/u-boot/custodians...
[platform/kernel/u-boot.git] / drivers / mtd / nand / spi / core.c
index 08f853a..397dfa4 100644 (file)
@@ -24,6 +24,8 @@
 #include <errno.h>
 #include <spi.h>
 #include <spi-mem.h>
+#include <dm/device_compat.h>
+#include <dm/devres.h>
 #include <linux/mtd/spinand.h>
 #endif
 
@@ -829,8 +831,29 @@ static const struct nand_ops spinand_ops = {
        .isbad = spinand_isbad,
 };
 
+static const struct spinand_manufacturer *spinand_manufacturers[] = {
+       &gigadevice_spinand_manufacturer,
+       &macronix_spinand_manufacturer,
+       &micron_spinand_manufacturer,
+       &toshiba_spinand_manufacturer,
+       &winbond_spinand_manufacturer,
+};
+
 static int spinand_manufacturer_detect(struct spinand_device *spinand)
 {
+       unsigned int i;
+       int ret;
+
+       for (i = 0; i < ARRAY_SIZE(spinand_manufacturers); i++) {
+               ret = spinand_manufacturers[i]->ops->detect(spinand);
+               if (ret > 0) {
+                       spinand->manufacturer = spinand_manufacturers[i];
+                       return 0;
+               } else if (ret < 0) {
+                       return ret;
+               }
+       }
+
        return -ENOTSUPP;
 }
 
@@ -1001,7 +1024,7 @@ static int spinand_noecc_ooblayout_free(struct mtd_info *mtd, int section,
 
 static const struct mtd_ooblayout_ops spinand_noecc_ooblayout = {
        .ecc = spinand_noecc_ooblayout_ecc,
-       .free = spinand_noecc_ooblayout_free,
+       .rfree = spinand_noecc_ooblayout_free,
 };
 
 static int spinand_init(struct spinand_device *spinand)