From cbcc15acfe2ead8db4781ea8be4c92628e18ebe7 Mon Sep 17 00:00:00 2001 From: Antony Arun T Date: Thu, 6 Dec 2018 14:36:42 +0530 Subject: [PATCH] ipq6018: choose spi nand bus number and cs number from dts Change-Id: Ic9d2fed8ca8d656d7b0ab1f2a4eb1fc55aeb1133 Signed-off-by: Antony Arun T --- drivers/mtd/spi/spi_nand.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/spi/spi_nand.c b/drivers/mtd/spi/spi_nand.c index 278989b466..8fa3721e1d 100644 --- a/drivers/mtd/spi/spi_nand.c +++ b/drivers/mtd/spi/spi_nand.c @@ -12,6 +12,7 @@ */ #include +#include #include #include #include @@ -36,6 +37,8 @@ #define spi_print(...) printf("spi_nand: " __VA_ARGS__) +DECLARE_GLOBAL_DATA_PTR; + struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE]; int verify_3bit_ecc(int status); int verify_2bit_ecc(int status); @@ -1006,6 +1009,9 @@ int spi_nand_init(void) struct nand_chip *chip; struct ipq40xx_spinand_info *info; int ret; + int node; + u8 bus = CONFIG_SF_DEFAULT_BUS; + u8 cs = CONFIG_SF_SPI_NAND_CS; info = (struct ipq40xx_spinand_info *)malloc( sizeof(struct ipq40xx_spinand_info)); @@ -1015,10 +1021,15 @@ int spi_nand_init(void) } memset(info, '0', sizeof(struct ipq40xx_spinand_info)); - flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS, - CONFIG_SF_SPI_NAND_CS, - CONFIG_SF_DEFAULT_SPEED, - CONFIG_SF_DEFAULT_MODE); + node = fdt_path_offset(gd->fdt_blob, "/spi/spi_nand"); + if (node >= 0) { + bus = fdtdec_get_uint(gd->fdt_blob, + node, "bus-num", CONFIG_SF_DEFAULT_BUS); + cs = fdtdec_get_uint(gd->fdt_blob, + node, "cs", CONFIG_SF_SPI_NAND_CS); + } + flash = spi_flash_probe(bus, cs, CONFIG_SF_DEFAULT_SPEED, + CONFIG_SF_DEFAULT_MODE); if (!flash) { free(info); spi_print("Id could not be mapped\n");