Skip to contentSkip to conversation

NXP IFC nand driver

PATCH In review Renaud Barbier 2 participants 5 messages Aug 13, 2021 – Aug 23, 2021

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v3 cover NXP IFC nand driver

This version 3 of the patch addresses the follwoing comments:
* Move the NAND timings initialisation to the mach-layerscape machine
* fsl_chip_ctrl_init returns errors.
* NAND commit message specifies from where the driver is derived from.

Renaud Barbier (3):
ARM: atomic.h: add 64-bit counter support
nand: add NXP IFC nand driver
ls1046ardb: enable IFC NAND.

 arch/arm/configs/layerscape_defconfig |   11 +
 arch/arm/mach-layerscape/Makefile     |    1 +
 arch/arm/mach-layerscape/nand.c       |   44 ++
 drivers/mtd/nand/Kconfig              |    7 +
 drivers/mtd/nand/Makefile             |    1 +
 drivers/mtd/nand/fsl_ifc.h            |  116 +++
 drivers/mtd/nand/nand_fsl_ifc.c       | 1038 +++++++++++++++++++++++++
 include/asm-generic/atomic-long.h     |   63 --
 include/asm-generic/atomic.h          |   49 ++
 include/linux/fsl_ifc.h               |  305 ++++++++
 10 files changed, 1572 insertions(+), 63 deletions(-)
 create mode 100644 arch/arm/mach-layerscape/nand.c
 create mode 100644 drivers/mtd/nand/fsl_ifc.h
 create mode 100644 drivers/mtd/nand/nand_fsl_ifc.c
 create mode 100644 include/linux/fsl_ifc.h
Signature · 7 lines
2.27.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH v3 1/3 ARM: atomic.h: add 64-bit counter support

In preparation for the introduction of the FSL IFC nand driver for the layerscape CPU, add 64-bit counter support.

Remove functions calling undefined functions.

---
 include/asm-generic/atomic-long.h | 63 -------------------------------
 include/asm-generic/atomic.h      | 49 ++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 63 deletions(-)
include/asm-generic/atomic-long.h +0 -63
index 322d510f38..fd1fdad20f 100644
@@ -66,69 +66,6 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
 	atomic64_sub(i, v);
 }
 
-static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
-{
-	atomic64_t *v = (atomic64_t *)l;
-
-	return atomic64_sub_and_test(i, v);
-}
-
-static inline int atomic_long_dec_and_test(atomic_long_t *l)
-{
-	atomic64_t *v = (atomic64_t *)l;
-
-	return atomic64_dec_and_test(v);
-}
-
-static inline int atomic_long_inc_and_test(atomic_long_t *l)
-{
-	atomic64_t *v = (atomic64_t *)l;
-
-	return atomic64_inc_and_test(v);
-}
-
-static inline int atomic_long_add_negative(long i, atomic_long_t *l)
-{
-	atomic64_t *v = (atomic64_t *)l;
-
-	return atomic64_add_negative(i, v);
-}
-
-static inline long atomic_long_add_return(long i, atomic_long_t *l)
-{
-	atomic64_t *v = (atomic64_t *)l;
-
-	return (long)atomic64_add_return(i, v);
-}
-
-static inline long atomic_long_sub_return(long i, atomic_long_t *l)
-{
-	atomic64_t *v = (atomic64_t *)l;
-
-	return (long)atomic64_sub_return(i, v);
-}
-
-static inline long atomic_long_inc_return(atomic_long_t *l)
-{
-	atomic64_t *v = (atomic64_t *)l;
-
-	return (long)atomic64_inc_return(v);
-}
-
-static inline long atomic_long_dec_return(atomic_long_t *l)
-{
-	atomic64_t *v = (atomic64_t *)l;
-
-	return (long)atomic64_dec_return(v);
-}
-
-static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
-{
-	atomic64_t *v = (atomic64_t *)l;
-
-	return (long)atomic64_add_unless(v, a, u);
-}
-
 #define atomic_long_inc_not_zero(l) atomic64_inc_not_zero((atomic64_t *)(l))
 
 #define atomic_long_cmpxchg(l, old, new) \
include/asm-generic/atomic.h +49 -0

62 lines not on this page · raw message

Signature · 7 lines
2.27.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH v3 2/3 nand: add NXP IFC nand driver

In reply to Renaud Barbier

Add the NXP IFC nand driver support. This driver
can be used with the NXP QorIQ cores.

Originally, derived from U-boot commit cce573e (2015-10)

---
 drivers/mtd/nand/Kconfig        |    7 +
 drivers/mtd/nand/Makefile       |    1 +
 drivers/mtd/nand/fsl_ifc.h      |  116 ++++
 drivers/mtd/nand/nand_fsl_ifc.c | 1038 +++++++++++++++++++++++++++++++
 include/linux/fsl_ifc.h         |  305 +++++++++
 5 files changed, 1467 insertions(+)
 create mode 100644 drivers/mtd/nand/fsl_ifc.h
 create mode 100644 drivers/mtd/nand/nand_fsl_ifc.c
 create mode 100644 include/linux/fsl_ifc.h
drivers/mtd/nand/Kconfig +7 -0
index c69e5ce4e1..cf9f1fdc0c 100644
@@ -42,6 +42,13 @@ config NAND_IMX
 	  and later, which use the GPMI NAND controller from the MXS series. 
 	  See the i.MX 'mxs' driver for those chips.
 
+config NAND_FSL_IFC
+	bool
+	prompt "FSL IFC NAND driver"
+	depends on ARCH_LAYERSCAPE
+	help
+	  Freescale IFC NAND driver for various chips.
+
 config NAND_MXS
 	bool
 	select STMP_DEVICE
drivers/mtd/nand/Makefile +1 -0
index f6e5b41e94..4fd14ddd63 100644
@@ -22,3 +22,4 @@ pbl-$(CONFIG_NAND_S3C24XX)		+= nand_s3c24xx.o
 obj-$(CONFIG_NAND_MXS)			+= nand_mxs.o
 obj-$(CONFIG_MTD_NAND_DENALI)		+= nand_denali.o
 obj-$(CONFIG_MTD_NAND_DENALI_DT)	+= nand_denali_dt.o
+obj-$(CONFIG_NAND_FSL_IFC)		+= nand_fsl_ifc.o
drivers/mtd/nand/fsl_ifc.h new file +116 -0

116 lines not on this page · raw message

drivers/mtd/nand/nand_fsl_ifc.c new file +1038 -0

1,038 lines not on this page · raw message

include/linux/fsl_ifc.h new file +305 -0

305 lines not on this page · raw message

Signature · 7 lines
2.27.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH v3 3/3 ls1046ardb: enable IFC NAND.

In reply to Renaud Barbier

Set the NAND timings and enable the IFC NAND driver.

---
 arch/arm/configs/layerscape_defconfig | 11 +++++++
 arch/arm/mach-layerscape/Makefile     |  1 +
 arch/arm/mach-layerscape/nand.c       | 44 +++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)
 create mode 100644 arch/arm/mach-layerscape/nand.c
arch/arm/configs/layerscape_defconfig +11 -0
index 394cd95c98..fb8e885353 100644
@@ -34,6 +34,10 @@ CONFIG_CMD_GO=y
 CONFIG_CMD_RESET=y
 CONFIG_CMD_UIMAGE=y
 CONFIG_CMD_PARTITION=y
+CONFIG_CMD_MOUNT=y
+CONFIG_CMD_UBI=y
+CONFIG_CMD_UBIFORMAT=y
+CONFIG_CMD_UMOUNT=y
 CONFIG_CMD_EXPORT=y
 CONFIG_CMD_LOADENV=y
 CONFIG_CMD_PRINTENV=y
@@ -69,6 +73,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_LED=y
 CONFIG_CMD_SPI=y
+CONFIG_CMD_NAND=y
 CONFIG_CMD_LED_TRIGGER=y
 CONFIG_CMD_WD=y
 CONFIG_CMD_BAREBOX_UPDATE=y
@@ -85,6 +90,10 @@ CONFIG_DP83867_PHY=y
 CONFIG_REALTEK_PHY=y
 CONFIG_NET_DSA_MV88E6XXX=y
 CONFIG_DRIVER_SPI_FSL_QUADSPI=y
+CONFIG_NAND=y
+CONFIG_NAND_FSL_IFC=y
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_BEB_LIMIT=20
 CONFIG_I2C=y
 CONFIG_I2C_IMX=y
 CONFIG_I2C_MUX=y
@@ -112,5 +121,7 @@ CONFIG_FS_NFS=y
 CONFIG_FS_FAT=y
 CONFIG_FS_FAT_WRITE=y
 CONFIG_FS_FAT_LFN=y
+CONFIG_FS_UBIFS=y
+CONFIG_FS_UBIFS_COMPRESSION_LZO=y
 CONFIG_ZLIB=y
 CONFIG_LZO_DECOMPRESS=y
arch/arm/mach-layerscape/Makefile +1 -0
index 854a327c91..99da7b2af0 100644
@@ -6,3 +6,4 @@ obj-pbl-y += boot.o
 pbl-y += xload-qspi.o xload.o
 obj-$(CONFIG_ARCH_LAYERSCAPE_PPA) += ppa.o ppa-entry.o
 obj-$(CONFIG_BOOTM) += pblimage.o
+obj-$(CONFIG_NAND_FSL_IFC) += nand.o
arch/arm/mach-layerscape/nand.c new file +44 -0

44 lines not on this page · raw message

Signature · 7 lines
2.27.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

Re: [PATCH 3/3] ls1046ardb: enable IFC NAND.

Quoted 71 lines · Renaud Barbier

Set the NAND timings and enable the IFC NAND driver.

---
 arch/arm/configs/layerscape_defconfig | 11 +++++++
 arch/arm/mach-layerscape/Makefile     |  1 +
 arch/arm/mach-layerscape/nand.c       | 44 +++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)
 create mode 100644 arch/arm/mach-layerscape/nand.c
arch/arm/configs/layerscape_defconfig +11 -0
index 394cd95c98..fb8e885353 100644
@@ -34,6 +34,10 @@ CONFIG_CMD_GO=y
 CONFIG_CMD_RESET=y
 CONFIG_CMD_UIMAGE=y
 CONFIG_CMD_PARTITION=y
+CONFIG_CMD_MOUNT=y
+CONFIG_CMD_UBI=y
+CONFIG_CMD_UBIFORMAT=y
+CONFIG_CMD_UMOUNT=y
 CONFIG_CMD_EXPORT=y
 CONFIG_CMD_LOADENV=y
 CONFIG_CMD_PRINTENV=y
@@ -69,6 +73,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_LED=y
 CONFIG_CMD_SPI=y
+CONFIG_CMD_NAND=y
 CONFIG_CMD_LED_TRIGGER=y
 CONFIG_CMD_WD=y
 CONFIG_CMD_BAREBOX_UPDATE=y
@@ -85,6 +90,10 @@ CONFIG_DP83867_PHY=y
 CONFIG_REALTEK_PHY=y
 CONFIG_NET_DSA_MV88E6XXX=y
 CONFIG_DRIVER_SPI_FSL_QUADSPI=y
+CONFIG_NAND=y
+CONFIG_NAND_FSL_IFC=y
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_BEB_LIMIT=20
 CONFIG_I2C=y
 CONFIG_I2C_IMX=y
 CONFIG_I2C_MUX=y
@@ -112,5 +121,7 @@ CONFIG_FS_NFS=y
 CONFIG_FS_FAT=y
 CONFIG_FS_FAT_WRITE=y
 CONFIG_FS_FAT_LFN=y
+CONFIG_FS_UBIFS=y
+CONFIG_FS_UBIFS_COMPRESSION_LZO=y
 CONFIG_ZLIB=y
 CONFIG_LZO_DECOMPRESS=y
arch/arm/mach-layerscape/Makefile +1 -0
index 854a327c91..99da7b2af0 100644
@@ -6,3 +6,4 @@ obj-pbl-y += boot.o
 pbl-y += xload-qspi.o xload.o
 obj-$(CONFIG_ARCH_LAYERSCAPE_PPA) += ppa.o ppa-entry.o
 obj-$(CONFIG_BOOTM) += pblimage.o
+obj-$(CONFIG_NAND_FSL_IFC) += nand.o
arch/arm/mach-layerscape/nand.c new file +4 -0
new file mode 100644
index 0000000000..b36c6b3c46
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <common.h>
+#include <init.h>

arch/arm/mach-layerscape/nand.c line 14

Quoted 10 lines
arch/arm/mach-layerscape/nand.c new file +10 -0
+#include <of_address.h>
+#include <linux/fsl_ifc.h>
+
+static int rdb_nand_init(void)
+{
+	struct device_node *np;
+	void __iomem *ifc;
+
+	if (!of_machine_is_compatible("fsl,ls1046a-rdb"))
+		return 0;

The code as such is board specific and thus should be in arch/arm/boards/ls1046ardb/. We could make a architecture specific helper function from it which is then called by the board code, but the values written to the registers below are probably very board specific anyway, so with a generic helper function we wouldn't win that much.

I moved rdb_nand_init() to the board code while applying.

Thanks
Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox