Skip to contentSkip to conversation

mtd: Add open firmware GPIO NAND driver

PATCH In review Matthias Fuchs 2 participants 4 messages Jan 25, 2009 – Jan 26, 2009

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

PATCH 1/1 mtd: Add open firmware GPIO NAND driver

This patch adds a GPIO based nand driver that is configured through the open firmware flat device tree. It's based on the gpio platform nand driver.

The driver is tested on a PPC405EP based PowerPC board with a single 8 bit NAND chip. nCE, ALE, CLE and RDY are connected to the CPUs GPIO pins GPIO1..4.

The driver does not handle:
- 16 bit NAND chips (no hardware for testing)
- any other interfacing than ALE, CLE, nCE, RDY via GPIO and databus via 8 bit mem'mapped access
- multiple NAND chips

Just as an idea: this driver could replace ppchameleonevb.c.

---
 drivers/mtd/nand/Kconfig   |    6 +
 drivers/mtd/nand/Makefile  |    1 +
 drivers/mtd/nand/of_gpio.c |  366 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 373 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/nand/of_gpio.c
drivers/mtd/nand/Kconfig +6 -0
index 8b12e6e..1853c63 100644
@@ -62,6 +62,12 @@ config MTD_NAND_GPIO
 	help
 	  This enables a GPIO based NAND flash driver.
 
+config MTD_NAND_OF_GPIO
+	tristate "Open Firmware GPIO NAND Flash driver"
+	depends on GENERIC_GPIO && PPC_OF
+	help
+	  This enables a GPIO based NAND flash driver.
+
 config MTD_NAND_SPIA
 	tristate "NAND Flash device on SPIA board"
 	depends on ARCH_P720T
drivers/mtd/nand/Makefile +1 -0
index b661586..d89332b 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_MTD_NAND_CS553X)		+= cs553x_nand.o
 obj-$(CONFIG_MTD_NAND_NDFC)		+= ndfc.o
 obj-$(CONFIG_MTD_NAND_ATMEL)		+= atmel_nand.o
 obj-$(CONFIG_MTD_NAND_GPIO)		+= gpio.o
+obj-$(CONFIG_MTD_NAND_OF_GPIO)		+= of_gpio.o
 obj-$(CONFIG_MTD_NAND_CM_X270)		+= cmx270_nand.o
 obj-$(CONFIG_MTD_NAND_BASLER_EXCITE)	+= excite_nandflash.o
 obj-$(CONFIG_MTD_NAND_PXA3xx)		+= pxa3xx_nand.o
drivers/mtd/nand/of_gpio.c new file +366 -0

366 lines not on this page · raw message

Signature · 1 line
1.5.6.3
#1 lore raw

Hello Matthias,

Quoted 3 lines · Matthias Fuchs

This patch adds a GPIO based nand driver that is configured through the open firmware flat device tree. It's based on the gpio platform nand driver.

As there are some identical functions in this driver and the original platform based driver, I think it will be easier to maintain those functions if they are used by both drivers. Do you think it is feasible to share the code among those two?

Kind regards,

Wolfram

Signature · 2 lines
  Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
#2 lore raw

Hi Wolfram,

first I thought about adding the device tree code to the platform driver. But if you look at the code you will see that there are many places where the drivers differ. Merging my code with the platform driver will bring a lot of #ifdefs and I do not like that! The identical functions are only a very few lines.

There is also some common code with the ndfc driver :-)

Matthias

Quoted 16 lines · Wolfram Sang

Hello Matthias,

Quoted 3 lines · Matthias Fuchs

This patch adds a GPIO based nand driver that is configured through the open firmware flat device tree. It's based on the gpio platform nand driver.

As there are some identical functions in this driver and the original platform based driver, I think it will be easier to maintain those functions if they are used by both drivers. Do you think it is feasible to share the code among those two?

Kind regards,

Wolfram

#3 lore raw

Hi Matthias,

Quoted 4 lines · Matthias Fuchs

first I thought about adding the device tree code to the platform driver. But if you look at the code you will see that there are many places where the drivers differ. Merging my code with the platform driver will bring a lot of #ifdefs and I do not like that! The identical functions are only a very few lines.

Okay, that's why I asked :) When I did the of-version of mtd-ram, it was luckily possible to make a generic init function and call them from both, platform and of. I just wanted to know if such an approach was considered.

Regards,

Wolfram

Signature · 2 lines
  Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry