From: Ilya Yanok <yanok@emcraft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mxc_nand: add nand driver for MX2/MX3
Date: Mon, 03 Aug 2009 06:01:03 +0400 [thread overview]
Message-ID: <4A7644DF.9020002@emcraft.com> (raw)
In-Reply-To: <20090728223735.GA6188@b07421-ec1.am.freescale.net>
Hi Scott,
thanks for the review.
Scott Wood wrote:
>> +/* OOB placement block for use with hardware ecc generation */
>> +static struct nand_ecclayout nand_hw_eccoob = {
>> + .eccbytes = 5,
>> + .eccpos = {6, 7, 8, 9, 10},
>> + .oobfree = {{0, 5}, {11, 5}, }
>> +};
>> +
>> +#ifndef CONFIG_MXC_NAND_HWECC
>> +static struct nand_ecclayout nand_hw_eccoob_soft = {
>> + .eccbytes = 6,
>> + .eccpos = {6, 7, 8, 9, 10, 11},
>> + .oobfree = {{0, 5}, {12, 4}, }
>> +};
>> +#endif
>>
>
> Why is one struct #ifndef, but the other isn't #ifdef?
>
Fixed.
>> +/*
>> + * This function requests the NANDFC to initate the transfer
>> + * of data currently in the NANDFC RAM buffer to the NAND device.
>> + */
>> +static void send_prog_page(struct mxc_nand_host *host, uint8_t buf_id,
>> + int spare_only)
>> +{
>> + MTDDEBUG(MTD_DEBUG_LEVEL3, "send_prog_page (%d)\n", spare_only);
>> +
>> + /* NANDFC buffer 0 is used for page read/write */
>> + writew(buf_id, &host->regs->nfc_buf_addr);
>>
>
> Comment does not match code.
>
Comment removed.
>> + /*
>> + * NANDFC buffer 1 is used for device status to prevent
>> + * corruption of read/write buffer on status requests.
>> + */
>> + writew(1, &host->regs->nfc_buf_addr);
>>
>
> From discussion on the previous patch:
>
>>> But it looks like buffer 1 is used for data with large page flash.
>>>
>>>
>> Well, we save first word of the buffer and then recover it.
>>
>
> So then there's no longer any special reason to use buffer 1 for status,
> and that comment is misleading...
>
Misleading comment removed.
>> +static u_char mxc_nand_read_byte(struct mtd_info *mtd)
>> +{
>> + struct nand_chip *nand_chip = mtd->priv;
>> + struct mxc_nand_host *host = nand_chip->priv;
>> + uint8_t ret = 0;
>> + uint16_t col, rd_word;
>> + uint16_t __iomem *main_buf =
>> + (uint16_t __iomem *)host->regs->main_area0;
>> + uint16_t __iomem *spare_buf =
>> + (uint16_t __iomem *)host->regs->spare_area0;
>> +
>> + /* Check for status request */
>> + if (host->status_request)
>> + return get_dev_status(host) & 0xFF;
>> +
>> + /* Get column for 16-bit access */
>> + col = host->col_addr >> 1;
>> +
>> + /* If we are accessing the spare region */
>> + if (host->spare_only)
>> + rd_word = readw(&spare_buf[col]);
>> + else
>> + rd_word = readw(&main_buf[col]);
>> +
>> + /* Pick upper/lower byte of word from RAM buffer */
>> + if (host->col_addr & 0x1)
>> + ret = (rd_word >> 8) & 0xFF;
>> + else
>> + ret = rd_word & 0xFF;
>>
>
> Use a union, as in read_buf(). Otherwise, this breaks on big-endian --
> you may not care, but it's better to not have such dependencies lurking
> in the code that could be reused who-knows-where.
>
Ok. Fixed.
>> + if (col & 1) {
>> + rd_word = readw(p);
>> + ret = (rd_word >> 8) & 0xff;
>> + rd_word = readw(&p[1]);
>> + ret |= (rd_word << 8) & 0xff00;
>>
>
> Again, this is unnecessary, but if you insist, use a union.
>
I understood that read_byte()/read_word() never mix up in existing code
but the API doesn't completely exclude such possibility so I'd like this
case to be treated correctly. I've updated the code to use union but if
you insist I'll remove this if clause completely.
>> +#ifdef CONFIG_MTD_NAND_MXC_FORCE_CE
>> + if (chip > 0) {
>> + MTDDEBUG(MTD_DEBUG_LEVEL0,
>> + "ERROR: Illegal chip select (chip = %d)\n", chip);
>>
>
> If it's an error, that's not exactly debug (especially since there's no
> way to propagate the error upwards)...
>
Changed to printf().
>> + return;
>> + }
>> +
>> + if (chip == -1) {
>> + writew(readw(&host->regs->nfc_config1) & ~NFC_CE,
>> + &host->regs->nfc_config1);
>> + return;
>> + }
>> +
>> + writew(readw(&host->regs->nfc_config1) | NFC_CE,
>> + &host->regs->nfc_config1);
>> +#endif
>>
>
> #else?
>
For me it just works (I've never defined CONFIG_MTD_NAND_MXC_FORCE_CE).
>> + if (column >= mtd->writesize) {
>> + /*
>> + * before sending SEQIN command for partial write,
>> + * we need read one page out. FSL NFC does not support
>> + * partial write. It alway send out 512+ecc+512+ecc ...
>> + * for large page nand flash. But for small page nand
>> + * flash, it does support SPARE ONLY operation.
>> + */
>> + if (host->pagesize_2k) {
>> + /* call ourself to read a page */
>> + mxc_nand_command(mtd, NAND_CMD_READ0, 0,
>> + page_addr);
>> + }
>>
>
> #ifdef CONFIG_MXC_NAND_HWECC?
>
Uh... I have to admit I don't really have clear understanding of this
problem and I can't find it's description in i.MX27 Reference Manual...
Maybe you can point me in some direction? For now I'm not sure if
putting this under #ifdef won't break something...
>> + /* 50 us command delay time */
>> + this->chip_delay = 5;
>>
>
> 5 or 50?
>
Comment fixed.
>> + host->pagesize_2k = 0;
>>
>
> Make this board-configurable. Has large page been tested? If not,
> perhaps it should stay out for now, given how weird it is on this
> controller.
>
I've never tested it with large page devices... So I'd vote to leave
large-page support disabled.
Regards, Ilya.
next prev parent reply other threads:[~2009-08-03 2:01 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-08 0:12 [U-Boot] [PATCH 0/7][v3] Support for LogicPD i.MX27-LITEKIT development board Ilya Yanok
2009-06-08 0:12 ` [U-Boot] [PATCH 1/7] mx27: basic cpu support Ilya Yanok
2009-06-20 13:13 ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-08 0:12 ` [U-Boot] [PATCH 2/7] serial_mx31: allow it to work with mx27 too and rename to serial_mxc Ilya Yanok
2009-06-20 13:18 ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-08 0:12 ` [U-Boot] [PATCH 3/7] fec_imx27: driver for FEC ethernet controller on i.MX27 Ilya Yanok
2009-07-17 10:57 ` [U-Boot] [PATCH] fec_mxc: " Ilya Yanok
2009-07-17 14:05 ` Ben Warren
2009-07-21 15:32 ` Ilya Yanok
2009-07-22 22:23 ` Jean-Christophe PLAGNIOL-VILLARD
2009-07-22 23:03 ` Ben Warren
2009-07-23 6:28 ` Ben Warren
2009-06-08 0:12 ` [U-Boot] [PATCH 4/7] mxc_nand: add nand driver for MX2/MX3 Ilya Yanok
2009-06-20 13:22 ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-22 23:43 ` Scott Wood
2009-06-23 20:03 ` Magnus Lilja
2009-07-03 19:03 ` Paul Thomas
2009-07-03 19:11 ` Paul Thomas
2009-07-17 10:48 ` Ilya Yanok
2009-07-17 10:53 ` [U-Boot] [PATCH] " Ilya Yanok
2009-07-22 21:33 ` Jean-Christophe PLAGNIOL-VILLARD
2009-07-28 22:37 ` Scott Wood
2009-08-03 1:45 ` Ilya Yanok
2009-08-04 23:32 ` Scott Wood
2009-08-10 22:32 ` Ilya Yanok
2009-08-11 22:53 ` Scott Wood
2009-08-03 2:01 ` Ilya Yanok [this message]
2009-08-03 16:58 ` Scott Wood
2009-07-17 16:00 ` [U-Boot] [PATCH 4/7] " Scott Wood
2009-06-08 0:12 ` [U-Boot] [PATCH 5/7] mxc-mmc: sdhc host driver for MX2 and MX3 proccessor Ilya Yanok
2009-06-21 11:04 ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-23 23:02 ` alfred steele
2009-08-07 20:13 ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-08 0:12 ` [U-Boot] [PATCH 6/7] arm: add support for CONFIG_GENERIC_MMC Ilya Yanok
2009-06-20 13:20 ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-08 0:12 ` [U-Boot] [PATCH 7/7] imx27lite: add support for imx27lite board from LogicPD Ilya Yanok
2009-06-21 11:21 ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-23 16:55 ` Detlev Zundel
2009-07-07 19:24 ` Wolfgang Denk
2009-07-17 11:00 ` [U-Boot] [PATCH] " Ilya Yanok
2009-07-22 21:37 ` Jean-Christophe PLAGNIOL-VILLARD
2009-07-22 22:17 ` Ilya Yanok
2009-07-23 21:37 ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-03 1:46 ` Ilya Yanok
2009-08-03 5:32 ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-03 8:19 ` Wolfgang Denk
2009-08-03 12:17 ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-03 14:35 ` Wolfgang Denk
2009-08-05 10:09 ` javier Martin
2009-08-05 12:30 ` javier Martin
2009-08-05 12:45 ` Wolfgang Denk
2009-08-05 14:17 ` javier Martin
2009-08-05 14:21 ` Wolfgang Denk
2009-08-05 15:01 ` javier Martin
2009-08-06 20:10 ` Wolfgang Denk
2009-08-07 7:18 ` javier Martin
2009-08-07 9:13 ` Wolfgang Denk
2009-08-06 19:29 ` [U-Boot] [PATCH] ARM EABI: add new helper functions resp. function names Wolfgang Denk
2009-08-08 6:50 ` Dirk Behme
2009-08-08 7:16 ` Wolfgang Denk
2009-08-08 7:39 ` Dirk Behme
2009-08-09 21:28 ` Wolfgang Denk
2009-08-10 22:32 ` [U-Boot] [PATCH] imx27lite: add support for imx27lite board from LogicPD Ilya Yanok
2009-08-11 18:47 ` Fabio Estevam
2009-08-11 19:12 ` Ilya Yanok
2009-08-14 7:03 ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-26 20:14 ` Wolfgang Denk
2009-08-26 20:43 ` Scott Wood
2009-09-01 20:10 ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-28 9:52 ` [U-Boot] [PATCH 0/7][v3] Support for LogicPD i.MX27-LITEKIT development board Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A7644DF.9020002@emcraft.com \
--to=yanok@emcraft.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox