Subject: Re: mpc5200b configure nand driver via dts

From: Wolfgang Grandegger <[email-masked]>
Date: Mon, 12 Jan 2009 16:59:21 +0100

Grant Likely wrote:
> On Mon, Jan 12, 2009 at 2:07 AM,  <[email-masked]> wrote:
>> hello,
>>
>> I have some problems with an mpc5200b based board. It's nearly compatible to
>> the lite5200b board.
>> I connected an samsung k9k8g08u0a nand flash via the lpb bus. This works
>> fine with an self written nand driver.
>> Now I try to use the standard nand driver from linux and configure it via
>> the dts file. But this doesn't work and I get
>> the following output:
>>
>>   nand@1,0 {  //cs1
>>    compatible = "samsung, k9k8g08u08", "cfi-flash";
>                                           ^^^^^^^^^
> 
> NAND Flash is not a CFI flash device.  The cfi-flash driver won't work with it.
> 
>> Now my questions are:
>>  Is there any error in the dts configuration?
>>  Is it principle posible to configure a nand flash via the dts file (in
>> combination with mpc5200b)?
> 
> It is possible to *describe* the NAND flash via the dts file.  The dts
> file doesn't configure anything.  It just describes the hardware
> layout so that you can write or bind the appropriate driver to the
> device.  I don't know if a device tree binding has been defined for
> NAND flash yet.

I find 3 MTD NAND drivers with OF bindings in linux-2.6/drivers/mtd/nand

  $ grep -l of_device *.c
  fsl_elbc_nand.c
  fsl_upm.c
  pasemi_nand.c

The bindings for the FSL UPM are described in
http://lxr.linux.no/linux+v2.6.28/Documentation/powerpc/dts-bindings/fsl/upm-nand.txt.
Something similar is needed for his board (NAND connected to lpb) as well.

>>  I read in some forums that the nand flash must be activated in the u-boot
>> before it can be configured via dts.
> 
> You definitely need to set up the CS line for the NAND before using it
> in Linux.  Typically this is done in U-Boot, but in a pinch it can be
> done in the platform support code (arch/powerpc/platforms/52xx/*)

Yep, and also the R/B pin should be handled somehow, preferably using
the OF GPIO interface.

Wolfgang.