No subject
The code was written at 4 years ago.
I'll see if there is a better way, and it'll be updated at next version when I got luck.
Quoted 11 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ /* page read */ + for (off = 0; len > 0; len -= 4, off += 4) { + while (!(NAND_READ(®s->ior) & IOR_READY)) + ; + *(uint32_t *)(buf + off) = NAND_READ(®s->dr); + }Why do you need to check
IOR_READYhere but not inread_byte?
Because there is no any hardware access in 'read_byte'. The FTNANDC021 simplily does not support byte access by default. (I mean it's possible to update hardware RTL code,
but it's not the case to A369)
So I add some tricks to READ_ID, READ_OOB and READ_STATUS. The actual hardware access is performed at ftnandc021_cmdfunc(), The ftnandc021_read_byte() simpily access the cached data buffer.
Quoted 35 lines
Quoted 13 lines
(quoted diff) +2
-0+static void +ftnandc021_cmdfunc(struct mtd_info *mtd, unsigned cmd, int column, intpgidx)
(quoted diff) +10
-0+{ + struct nand_chip *chip = mtd->priv; + struct ftnandc021_chip *priv = chip->priv; + struct ftnandc021_regs *regs = priv->iobase; + + priv->cmd = cmd; + priv->pgidx = pgidx; + + switch (cmd) { + case NAND_CMD_READID: /* 0x90 */Review
Quoted 10 lines
(quoted diff) +10
-0+ if (ftnandc021_command(priv, FTNANDC021_CMD_RDID)) { + printf("ftnandc021: RDID failed.\n"); + } else { + put_unaligned_le32(NAND_READ(®s->idr[0]), + priv->buf); + put_unaligned_le32(NAND_READ(®s->idr[1]), + priv->buf + 4); + priv->off = 0; + } + break;Do error handling like this:
if (ftnandc021_command(priv, FTNANDC021_CMD_RDID)) { printf(...); break; } put_unaligned... ...
Quoted 2 lines
Why would it be unaligned?
Why_le32?
It's a historic issue, I think.
It's too long (4 years..) to me to recall the reason, and it's obviously not necessary right now, so it would be updated at next version.
Quoted 3 lines
Can you not read a byte at a time here?
No, the FTNANDC021 does not support byte access.
Quoted 10 lines
Quoted 10 lines
+/**
+ * hardware specific access to control-lines
+ * @mtd: MTD device structure
+ * @cmd: command to device
+ * @ctrl:
+ *NAND_NCE: bit 0 -> don't care
+ *NAND_CLE: bit 1 -> Command Latch
+ *NAND_ALE: bit 2 -> Address Latch
+ *
+ * NOTE: boards may use different bits for these!!
Quoted 10 lines
Review
Quoted 5 lines
+ */
(quoted diff) +4
-0+static void +ftnandc021_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) +{ +}Just leave the function pointer NULL.
Got it, thanks
Quoted 6 lines
Quoted 1 line
+
chip->ecc.mode=NAND_ECC_NONE;Really, no ECC at all? That is quite broken. There is absolutely no way to get access to the full OOB in order to do software ECC?
Quoted 10 lines
Or is it doing hardware ECC in a way that is transparent? You should still use
NAND_ECC_HARDin that case.Quoted 1 line
+
chip->ecc.layout=&ftnandc021_oob_2k;What if it's not 2K NAND?
Please see the comments above.
And it would be clean up at next version.
Quoted 25 lines
Quoted 16 lines
include/faraday/nand.h new file +8
-0@@ -0,0 +1,16 @@ +/* +* Faraday NAND Flash Controller +* +* (C) Copyright 2010 Faraday Technology +* Dante Su <[email protected]> +* +* This file is released under the terms of GPL v2 and any later version. +* See the file COPYING in the root directory of the source tree for details.
+ */include/faraday/nand.h
Quoted 5 lines
include/faraday/nand.h new file +5
-0+ +#ifndef _FARADAY_NAND_H +#define _FARADAY_NAND_H + +int ftnandc021_probe (struct nand_chip *chip);New drivers should use
CONFIG_SYS_NAND_SELF_INIT
Quoted 1 line
-Scott
--
Best wishes,
Kuo-Jung Su