[U-Boot-Users] NAND flash implementation

Hi,
We ran into a problem while implementing NAND flash initialisation.
What happens in U-Boot (correct me if I'm wrong):
In drivers/nand/nand.c the function nand_init() calls nand_init_chip() CFG_MAX_NAND_DEVICE times. the function nand_init_chip() calls board_nand_init() and subsequently nand_scan() if nand_scan() returns something != 0 then it is assumed that there is not really a NAND device there
In boards/prodrive/pbnb3/nand.c (to take an existing example) the function board_nand_init() fills in hardware specific functions and returns (it's a void function)
Our hardware has a special bus controller to which up to 5 devices can be connected. NAND flash is one of the device types that can be connected. Each such device is controlled by a so called "profile". Before we can access a NAND flash connected to such a profile we read from the profile if a NAND flash is connected. If not, we do not touch it.
The problem is that board_nand_init() is a void function and always succeeds. In our case we would like to check the profile in board_nand_init() and return an error if no NAND exists. Subsequently nand_init_chip() would not do a nand_scan() for a failing board_nand_init(). Attached is what a patch would look like.
We looked at nand_scan() but it returns != 0 only after calling a lot board specific functions. In our case this would not do as the board specific functions would seriously fail if no NAND device is connected.
Regards, Hans Zuidam -- Hans Zuidam Sen. Systems Engineer, BL DTS ICE, Philips Semiconductors
Building A410, Room 3.40 High Tech Campus 41, 5656 AE Eindhoven, The Netherlands Tel. +31 (0)40 2746579 E-Mail: hans.zuidam@philips.com

Dear Hans,
in message OFDB2783A0.0E64E142-ONC12571DF.004AD8D6-C12571DF.0052CD21@philips.com you wrote:
The problem is that board_nand_init() is a void function and always succeeds. In our case we would like to check the profile in board_nand_init() and return an error if no NAND exists. Subsequently nand_init_chip() would not do a nand_scan() for a failing board_nand_init(). Attached is what a patch would look like.
Can you keep the information about what is attached where in a (board specific) private data structure?
Best regards,
Wolfgang Denk

Hi Wolfgang,
wd@denx.de wrote on 04-09-2006 21:09:43:
Can you keep the information about what is attached where in a (board specific) private data structure?
I am not quite sure what you mean.
We would (as per normal) keep all private data in a ``struct nand_chip''. Both ``struct nand_chip nand_chip[]'' and ``ulong base_address[]'' as per normal with the base addresses set to the "profiles" we want to scan for NAND existence (normally all 5 of them) and CFG_MAX_NAND_DEVICE set to the number of profiles to scan/use. In case no NAND device exists at a profile we cannot touch it at all. The profiles are initialised during power-up from an I2C ROM which holds the board configuration.
The best and least intrusive solution we could come up with is therefore changing board_nand_init() to return != 0 if no nand_scan() should be done for a particular NAND device. It's not a totally nice solution (board_nand_init as a name becomes somewhat of a misnomer,) but we could not find a better solution. Maybe we are missing something.
Regards, Hans Zuidam -- Hans Zuidam Sen. Systems Engineer, BL DTS ICE, Philips Semiconductors
Building A410, Room 3.40 High Tech Campus 41, 5656 AE Eindhoven, The Netherlands Tel. +31 (0)40 2746579 E-Mail: hans.zuidam@philips.com

Dear Hans,
in message OF22DDFE86.CF87E4ED-ONC12571E0.00270479-C12571E0.002B760F@philips.com you wrote:
The best and least intrusive solution we could come up with is therefore changing board_nand_init() to return != 0 if no nand_scan() should be done for a particular NAND device. It's not a totally nice solution
I agree that board_nand_init() could / should be changed to return a status code, and that this could be used to disable further accesses to a specific device.
Best regards,
Wolfgang Denk
participants (2)
-
Hans Zuidam
-
Wolfgang Denk