From 42bd19ce6c7bffef402ad6dd639c33686f485d29 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Wed, 15 Jun 2016 21:09:22 +0200 Subject: mtd: nand: add common DT init code These are already-documented common bindings for NAND chips. Let's handle them in nand_base. If NAND controller drivers need to act on this data before bringing up the NAND chip (e.g., fill out ECC callback functions, change HW modes, etc.), then they can do so between calling nand_scan_ident() and nand_scan_tail(). The original commit has been slightly reworked to use the fdtdec_xxx() helpers (instead of the of_xxxx() ones). Signed-off-by: Brian Norris Signed-off-by: Boris Brezillon Acked-by: Hans de Goede --- include/linux/mtd/nand.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index b5a02c3382..29aae43cf2 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -590,6 +590,7 @@ struct nand_buffers { * flash device * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the * flash device. + * @flash_node: [BOARDSPECIFIC] device node describing this instance * @read_byte: [REPLACEABLE] read one byte from the chip * @read_word: [REPLACEABLE] read one word from the chip * @write_byte: [REPLACEABLE] write a single byte to the chip on the @@ -689,6 +690,8 @@ struct nand_chip { void __iomem *IO_ADDR_R; void __iomem *IO_ADDR_W; + int flash_node; + uint8_t (*read_byte)(struct mtd_info *mtd); u16 (*read_word)(struct mtd_info *mtd); void (*write_byte)(struct mtd_info *mtd, uint8_t byte); -- cgit From 4ccae81cdadce39e925f3e8c96567fd911568000 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 15 Jun 2016 21:09:23 +0200 Subject: mtd: nand: Add the sunxi NAND controller driver We already have an SPL driver for the sunxi NAND controller, now add the normal/standard one. The source has been copied from Linux 4.6 with a few changes to make it work in u-boot. Signed-off-by: Boris Brezillon Acked-by: Hans de Goede --- include/configs/sunxi-common.h | 2 ++ include/fdtdec.h | 1 + include/nand.h | 3 +++ 3 files changed, 6 insertions(+) (limited to 'include') diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index 635890122d..f55192609c 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -135,6 +135,8 @@ #ifdef CONFIG_NAND_SUNXI #define CONFIG_SPL_NAND_SUPPORT 1 +#define CONFIG_SYS_NAND_ONFI_DETECTION +#define CONFIG_SYS_MAX_NAND_DEVICE 8 #endif #ifdef CONFIG_SPL_SPI_SUNXI diff --git a/include/fdtdec.h b/include/fdtdec.h index 151c590ed1..70ea0bfc0b 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -155,6 +155,7 @@ enum fdt_compat_id { COMPAT_INTEL_BAYTRAIL_FSP, /* Intel Bay Trail FSP */ COMPAT_INTEL_BAYTRAIL_FSP_MDP, /* Intel FSP memory-down params */ COMPAT_INTEL_IVYBRIDGE_FSP, /* Intel Ivy Bridge FSP */ + COMPAT_SUNXI_NAND, /* SUNXI NAND controller */ COMPAT_COUNT, }; diff --git a/include/nand.h b/include/nand.h index 627b21769b..b6eb223fb6 100644 --- a/include/nand.h +++ b/include/nand.h @@ -142,3 +142,6 @@ __attribute__((noreturn)) void nand_boot(void); int get_nand_env_oob(struct mtd_info *mtd, unsigned long *result); #endif int spl_nand_erase_one(int block, int page); + +/* platform specific init functions */ +void sunxi_nand_init(void); -- cgit From c1fe6b5b5e540e8c94a1be4e1119ee17ad5af5e7 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 15 Jun 2016 21:09:26 +0200 Subject: mtd: nand: Increase the max OOB size Some NANDs are now exposing 1664 OOB bytes per page. Adjust the NAND_MAX_OOBSIZE value accordingly. Signed-off-by: Boris Brezillon --- include/linux/mtd/nand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 29aae43cf2..87d72dbad6 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -48,7 +48,7 @@ extern void nand_wait_ready(struct mtd_info *mtd); * is supported now. If you add a chip with bigger oobsize/page * adjust this accordingly. */ -#define NAND_MAX_OOBSIZE 1216 +#define NAND_MAX_OOBSIZE 1664 #define NAND_MAX_PAGESIZE 16384 /* -- cgit From a0dfa88b4e12c00414a4058823e0eec8c216f1d7 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 15 Jun 2016 21:09:27 +0200 Subject: sunxi: nand: Increase CONFIG_SYS_NAND_MAX_ECCPOS value On some sunxi boards we have NANDs exposing 1664 OOB bytes per page. Define the CONFIG_SYS_NAND_MAX_ECCPOS value accordingly. Signed-off-by: Boris Brezillon --- include/configs/sunxi-common.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index f55192609c..b9aa62b2af 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -134,6 +134,7 @@ #define CONFIG_SERIAL_TAG #ifdef CONFIG_NAND_SUNXI +#define CONFIG_SYS_NAND_MAX_ECCPOS 1664 #define CONFIG_SPL_NAND_SUPPORT 1 #define CONFIG_SYS_NAND_ONFI_DETECTION #define CONFIG_SYS_MAX_NAND_DEVICE 8 -- cgit From 59441ac3c135c412c679bdd1c82c8f2a9b805bbc Mon Sep 17 00:00:00 2001 From: Steve Rae Date: Wed, 29 Jun 2016 13:50:59 -0700 Subject: mtd: fix compiler warnings - add missing declaration - update debug output format specifiers Signed-off-by: Steve Rae --- include/linux/mtd/mtd.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index cf20674549..779eea035c 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -500,5 +500,10 @@ int mtd_arg_off(const char *arg, int *idx, loff_t *off, loff_t *size, int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off, loff_t *size, loff_t *maxsize, int devtype, uint64_t chipsize); + +/* drivers/mtd/mtdcore.c */ +void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset, + const uint64_t length, uint64_t *len_incl_bad, + int *truncated); #endif #endif /* __MTD_MTD_H__ */ -- cgit