mini6410 nand

Reggie
Hi all, I've been looking at the 6410 and it's nand driver, it seems that
we're in the same boat on the 6410 boards as we were on the mini210S, a
binary blob and no source code, is that correct? I see the same type of
s3c_nand_mlc.fo file as we've got on the mini210S, s5p_nand_mlc.fo, so I am
 assuming that it's the same situation.

If that is the case then I think I spotted something very significant in
the s3c_nand.c file in the mini210S kernel sources :)

If you checkout the kernel source for the mini210 (or any of the 210 boards
in fact) look in drivers/mtd/nand/s3c_nand.c and search for the following
functions:
s3c_nand_write_page_8bit
s3c_nand_read_page_8bit
s3c_nand_read_oob_8bit
s3c_nand_write_oob_8bit
s3c_nand_correct_data_8bit
s3c_nand_calculate_hwecc_8bit
s3c_nand_enable_hwecc_8bit
s3c_nand_wait_encdone
s3c_nand_wait_decdone
s3c_nand_wait_eccbusy_8bit

At first I thought these were just a set of s5pv210 specific functions for
8bit ecc, just left in there because the 16bit code was in the .fo file. 
They're not :)  The registers are all wrong, by wrong I mean the register
names are not the same, and the 3 main functions for handling 8bit aren't
quite the same.  I checked against the new nand drivers we have just
released and a barebox 8bit nand driver, they're quite different.

With that in mind, I checked the s3c6410 datasheet, as it does 8bit ecc and
my hunch was correct, the 8bit functions in the s3c_nand.c code are made
for the s3c6440!

If you check the same s3c_nand.c file from the mini/tiny6410 kernel sources
you will see that these functions do not exist in source code.

If you compile a 6410 kernel from fa sources and check system.map in a text
editor, search for s3c_nand and you will see all of the functions that are
inside the nand binary, we have most of the same function names in the 210
s3c_nand.c code, it appears there are 5 functions that we do not have in
the 210 code:
s3c_nand_block_bad
s3c_nand_fast_iow
s3c_nand_fast_ior
s3c_nand_ext_finit
s3c_nand_mlc_probe

the fast_io functions aren't a problem, I believe these are common
functions amongst the s3c/s5p nand drivers.  The same goes for the
mlc_probe and the ext_finit functions, they appear to be similar enough to
the s5p_nand_mlc.c functions that we wrote for it to be relatively simple
to use those as a basis.

Interestingly we have an 'extra' 8bit function:
s3c_nand_wait_eccbusy_8bit

This function is used to wait for the ecc engine to finish whatever it's
doing, which is the same for the encdone/decdone functions, they're very
necessary, so I can only assume that they have been handled with some
simple code in the appropriate functions, or they're using the
s3c_nand_wait_ functions from the s3c_nand.c code.


In conclusion, I think it should be possible to transplant the s3c_nand.c
functions from the 210 sources into the 6410 code and make an open source
nand driver for the mini/tiny6410 boards.

All of the above needs to be thoroughly checked against the datasheets, I
only checked one of the 8bit functions so far but there is no other purpose
for those functions in the s3c_nand.c file from the 210 sources.

Juergen Beisert
The 6410 SoC has two checksum units: One for small SLC NANDs with a weak
ECC sum and one for MLC NANDs with a much stronger checksum (reed-solomon).
There is also a driver for the MLC NANDs available (used for the Tiny6410
which comes with a 4 kiB page sized MLC). I would guess Samsung re-uses
this MLC checksum unit in their more recent SoCs like the 210 is. A
mainline kernel style driver for the MLC NANDs would be really helpful for
all the Tiny6410 users.

Reggie
Hi Jeurgen,they seem fairly similar between the 6410/210 boards, however
they're sufficiently different for neither to be a drop in replacement for
each other.

Hopefully now we've released the 16bit mini210 driver and when I'm done
getting them ported into barebox I'll have some time to look at the 6410, I
thought for now though that the least I could do was share the information
I'd learnt :)

elmo23x
This is very interseting. I tried to port the nand blob to a newer kernel,
but all I was able to do is to read the filesystem. I always got error when
I tried to write :(

Any news on this? :)

elmo23x
static void s3c_nand_wait_ecc_busy_8bit (void)
{
        void __ iomem * regs = s3c_nand.regs;
        / / While (readl (S3C_NF8ECCERR0) & S3C_NFESTAT0_ECCBUSY) {}
        while (readl (regs + S3C_NF8ECCERR0) & S3C_NFECCERR0_ECCBUSY) {}
}

Colin
Hi Reggie,

Is this why fw_setenv returns the error I asked about here:
http://www.friendlyarm.net/forum/topic/5124?