Skip to contentSkip to conversation

New denali nand driver (ported from kernel)

PATCH In review Enrico Jorns 2 participants 6 messages Sep 21, 2015 – Sep 23, 2015

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

cover New denali nand driver (ported from kernel)

This series adds the denali NAND driver that is used, for example, on socfpga platforms.

The driver is adapted from the mainline kernel driver with some bugfix patches from Altera.

Enrico Jorns (4):
mtd nand: added 'bits_per_cell' property mtd nand_denali: Add denali nand driver mtd denali: pass col argument to READID operation socfpga dts: set have-hw-ecc-fixup for nand

 arch/arm/dts/socfpga.dtsi         |    1 +
 drivers/mtd/nand/Kconfig          |   26 +
 drivers/mtd/nand/Makefile         |    3 +
 drivers/mtd/nand/denali.h         |  499 ++++++++++++
 drivers/mtd/nand/nand_base.c      |    2 +
 drivers/mtd/nand/nand_denali.c    | 1559 +++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/nand_denali_dt.c |  101 +++
 include/linux/mtd/nand.h          |   12 +
 8 files changed, 2203 insertions(+)
 create mode 100644 drivers/mtd/nand/denali.h
 create mode 100644 drivers/mtd/nand/nand_denali.c
 create mode 100644 drivers/mtd/nand/nand_denali_dt.c
Signature · 7 lines
2.5.1


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

PATCH 1/4 mtd nand: added 'bits_per_cell' property

This one is available in the kernel and used by the denali driver

---
 drivers/mtd/nand/nand_base.c |  2 ++
 include/linux/mtd/nand.h     | 12 ++++++++++++
 2 files changed, 14 insertions(+)
drivers/mtd/nand/nand_base.c +2 -0
index bf4110a..ca48f59 100644
@@ -2819,6 +2819,8 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
 	mtd->oobsize = le16_to_cpu(p->spare_bytes_per_page);
 	chip->chipsize = le32_to_cpu(p->blocks_per_lun);
 	chip->chipsize *= (uint64_t)mtd->erasesize * p->lun_count;
+	chip->bits_per_cell = p->bits_per_cell;
+
 	*busw = 0;
 	if (le16_to_cpu(p->features) & 1)
 		*busw = NAND_BUSWIDTH_16;
include/linux/mtd/nand.h +12 -0
index 3c7509f..f126cd9 100644
@@ -430,6 +430,7 @@ struct nand_buffers {
  * @badblockbits:	[INTERN] minimum number of set bits in a good block's
  *			bad block marker position; i.e., BBM == 11110111b is
  *			not bad when badblockbits == 7
+ * @bits_per_cell:	[INTERN] number of bits per cell. i.e., 1 means SLC.
  * @cellinfo:		[INTERN] MLC/multichip data from chip ident
  * @numchips:		[INTERN] number of physical chips
  * @chipsize:		[INTERN] the size of one chip for multichip arrays
@@ -506,6 +507,7 @@ struct nand_chip {
 	int pagebuf;
 	unsigned int pagebuf_bitflips;
 	int subpagesize;
+	uint8_t bits_per_cell;
 	uint8_t cellinfo;
 	int badblockpos;
 	int badblockbits;
@@ -722,4 +724,14 @@ static inline int onfi_get_sync_timing_mode(struct nand_chip *chip)
 	return le16_to_cpu(chip->onfi_params.src_sync_timing_mode);
 }
 
+/*
+ * Check if it is a SLC nand.
+ * The !nand_is_slc() can be used to check the MLC/TLC nand chips.
+ * We do not distinguish the MLC and TLC now.
+ */
+static inline bool nand_is_slc(struct nand_chip *chip)
+{
+	return chip->bits_per_cell == 1;
+}
+
 #endif /* __LINUX_MTD_NAND_H */
Signature · 7 lines
2.5.1


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

PATCH 2/4 mtd nand_denali: Add denali nand driver

In reply to Enrico Jorns

The driver is based on the denali driver from the linux kernel

---
 drivers/mtd/nand/Kconfig          |   26 +
 drivers/mtd/nand/Makefile         |    3 +
 drivers/mtd/nand/denali.h         |  499 ++++++++++++
 drivers/mtd/nand/nand_denali.c    | 1559 +++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/nand_denali_dt.c |  101 +++
 5 files changed, 2188 insertions(+)
 create mode 100644 drivers/mtd/nand/denali.h
 create mode 100644 drivers/mtd/nand/nand_denali.c
 create mode 100644 drivers/mtd/nand/nand_denali_dt.c
drivers/mtd/nand/Kconfig +26 -0
index a75540b..ff26584 100644
@@ -140,4 +140,30 @@ config MTD_NAND_NOMADIK
 	help
 	  Driver for the NAND flash controller on the Nomadik, with ECC.
 
+config MTD_NAND_DENALI
+        tristate "Support Denali NAND controller"
+        depends on HAS_DMA
+        help
+          Enable support for the Denali NAND controller.  This should be
+          combined with either the PCI or platform drivers to provide device
+          registration.
+
+config MTD_NAND_DENALI_DT
+        tristate "Support Denali NAND controller as a DT device"
+        depends on HAVE_CLK && MTD_NAND_DENALI
+        help
+          Enable the driver for NAND flash on platforms using a Denali NAND
+          controller as a DT device.
+
+if MTD_NAND_DENALI
+
+config MTD_NAND_DENALI_TIMING_MODE
+	int "Overrides default ONFI timing mode."
+	default -1
+	range -1 5
+	help
+	   -1 indicates use default timings
+
+endif
+
 endif
drivers/mtd/nand/Makefile +3 -0
index a0b3198..8809238 100644
@@ -16,3 +16,6 @@ obj-$(CONFIG_NAND_ATMEL)		+= atmel_nand.o
 obj-$(CONFIG_NAND_S3C24XX)		+= nand_s3c24xx.o
 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
+
drivers/mtd/nand/denali.h new file +499 -0

499 lines not on this page · raw message

drivers/mtd/nand/nand_denali.c new file +1559 -0

1,559 lines not on this page · raw message

drivers/mtd/nand/nand_denali_dt.c new file +101 -0

101 lines not on this page · raw message

Signature · 7 lines
2.5.1


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

PATCH 3/4 mtd denali: pass col argument to READID operation

In reply to Enrico Jorns

A read id operation followed by 0x00 reads the device ID while a read id operation followed by 0x20 reads the possible ONFI identifier.

As the READID function did not propagate the second id parameter but had a hard-coded call for 0x90 0x00, reading the ONFI identifier was not possible and thus chips werde not detected (tested with MT29F8G08ABABAWP)

---
 drivers/mtd/nand/nand_denali.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/nand_denali.c +1 -1
index f2d9cb7..0ff4734 100644
@@ -1251,7 +1251,7 @@ static void denali_cmdfunc(struct mtd_info *mtd, unsigned int cmd, int col,
 		 */
 		addr = MODE_11 | BANK(denali->flash_bank);
 		index_addr(denali, addr | 0, 0x90);
-		index_addr(denali, addr | 1, 0);
+		index_addr(denali, addr | 1, col);
 		for (i = 0; i < 8; i++) {
 			index_addr_read_data(denali, addr | 2, &id);
 			write_byte_to_buf(denali, id);
Signature · 7 lines
2.5.1


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

PATCH 4/4 socfpga dts: set have-hw-ecc-fixup for nand

In reply to Enrico Jorns

This enables the denali driver ecc fixup as it is enabled in the kernel dts, too, and the tested MT29F8G08ABABAWP does not work properly without it when having ecc fixup active in kernel.

---
 arch/arm/dts/socfpga.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/arm/dts/socfpga.dtsi +1 -0
index 14c0654..e673541 100644
@@ -540,6 +540,7 @@
 			interrupts = <0x0 0x90 0x4>;
 			dma-mask = <0xffffffff>;
 			clocks = <&nand_clk>;
+			have-hw-ecc-fixup;
 			status = "disabled";
 		};
 
Signature · 7 lines
2.5.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw
In reply to Enrico Jorns
Quoted 11 lines · Enrico Jorns

This series adds the denali NAND driver that is used, for example, on socfpga platforms.

The driver is adapted from the mainline kernel driver with some bugfix patches from Altera.

Enrico Jorns (4):
mtd nand: added 'bits_per_cell' property mtd nand_denali: Add denali nand driver mtd denali: pass col argument to READID operation socfpga dts: set have-hw-ecc-fixup for nand

Applied all but the last one which does not apply. We currently do not have the nand node you add a property to.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 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