From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/4] nand: lpc32xx: add SLC NAND controller support
Date: Fri, 17 Jul 2015 18:12:10 -0500 [thread overview]
Message-ID: <1437174730.2993.206.camel@freescale.com> (raw)
In-Reply-To: <1437173231-28528-2-git-send-email-vz@mleia.com>
On Sat, 2015-07-18 at 01:47 +0300, Vladimir Zapolskiy wrote:
> +/* TAC register bits, be aware of overflows */
> +#define TAC_W_RDY(n) (max_t(uint32_t, (n), 0xF) << 28)
> +#define TAC_W_WIDTH(n) (max_t(uint32_t, (n), 0xF) << 24)
> +#define TAC_W_HOLD(n) (max_t(uint32_t, (n), 0xF) << 20)
> +#define TAC_W_SETUP(n) (max_t(uint32_t, (n), 0xF) << 16)
> +#define TAC_R_RDY(n) (max_t(uint32_t, (n), 0xF) << 12)
> +#define TAC_R_WIDTH(n) (max_t(uint32_t, (n), 0xF) << 8)
> +#define TAC_R_HOLD(n) (max_t(uint32_t, (n), 0xF) << 4)
> +#define TAC_R_SETUP(n) (max_t(uint32_t, (n), 0xF) << 0)
> +
> +static struct lpc32xx_nand_slc_registers __iomem
> *lpc32xx_nand_slc_registers
> + = (struct lpc32xx_nand_slc_registers __iomem *)SLC_NAND_BASE;
s/registers/regs/ might help the formatting here...
> +static void lpc32xx_nand_cmd_ctrl(struct mtd_info *mtd,
> + int cmd, unsigned int ctrl)
> +{
> + debug("ctrl: 0x%08x, cmd: 0x%08x\n", ctrl, cmd);
> +
> + if (ctrl & NAND_NCE)
> + setbits_le32(&lpc32xx_nand_slc_registers->cfg, CFG_CE_LOW);
> + else
> + clrbits_le32(&lpc32xx_nand_slc_registers->cfg, CFG_CE_LOW);
> +
> + if (cmd == NAND_CMD_NONE)
> + return;
> +
> + if (ctrl & NAND_CLE)
> + writel(cmd & 0xFF, &lpc32xx_nand_slc_registers->cmd);
> + else /* if (ctrl & NAND_ALE) */
> + writel(cmd & 0xFF, &lpc32xx_nand_slc_registers->addr);
> +}
Why is "if (ctrl & NAND_ALE())" commented out? I think it'd be better if
wrong uses of this function didn't silently cause address cycles (which could
hide a bug if ALE is what was desired).
> +static void lpc32xx_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
> +{
> + while (len-- > 0)
> + *buf++ = (uint8_t)readl(&lpc32xx_nand_slc_registers->data);
> +}
> +
> +static uint8_t lpc32xx_read_byte(struct mtd_info *mtd)
> +{
> + return (uint8_t)readl(&lpc32xx_nand_slc_registers->data);
> +}
You've still got a couple unneeded casts here.
> +/*
> + * LPC32xx has only one SLC NAND controller, don't utilize
> + * CONFIG_SYS_NAND_SELF_INIT to be able to reuse this function
> + * both in SPL NAND and U-boot images.
> + */
> +int board_nand_init(struct nand_chip *lpc32xx_chip)
> +{
> + lpc32xx_chip->cmd_ctrl = lpc32xx_nand_cmd_ctrl;
> + lpc32xx_chip->dev_ready = lpc32xx_nand_dev_ready;
> +
> + /*
> + * Hardware ECC calculation is not supported by the driver,
> + * because it requires DMA support, see LPC32x0 User Manual,
> + * note after SLC_ECC register description (UM10326, p.198)
> + */
> + lpc32xx_chip->ecc.mode = NAND_ECC_SOFT;
> +
> + /*
> + * The implementation of these functions is quite common, but
> + * they MUST be defined, because access to data register
> + * is strictly 32-bit aligned.
> + */
> + lpc32xx_chip->read_buf = lpc32xx_read_buf;
> + lpc32xx_chip->read_byte = lpc32xx_read_byte;
> + lpc32xx_chip->write_buf = lpc32xx_write_buf;
> + lpc32xx_chip->write_byte = lpc32xx_write_byte;
> +
> + /*
> + * Use default ECC layout, but these values are predefined
> + * for both small and large page NAND flash devices.
> + */
> + lpc32xx_chip->ecc.size = 256;
> + lpc32xx_chip->ecc.bytes = 3;
> + lpc32xx_chip->ecc.strength = 1;
Please use a space before '=', not a tab. This doesn't even line up right,
if that's what you were trying to do...
> +
> +#if defined(CONFIG_SYS_NAND_USE_FLASH_BBT)
> + lpc32xx_chip->bbt_options |= NAND_BBT_USE_FLASH;
> +#endif
Likewise
-Scott
next prev parent reply other threads:[~2015-07-17 23:12 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-17 22:46 [U-Boot] [PATCH v2 0/4] lpc32xx: devkit3250 board update Vladimir Zapolskiy
2015-07-17 22:47 ` [U-Boot] [PATCH v2 1/4] spl: nand: simple: replace readb() with chip specific read_buf() Vladimir Zapolskiy
2015-07-28 1:22 ` Scott Wood
2015-08-13 13:18 ` [U-Boot] [U-Boot, v2, " Tom Rini
2015-07-17 22:47 ` [U-Boot] [PATCH v2 2/4] nand: lpc32xx: add SLC NAND controller support Vladimir Zapolskiy
2015-07-17 23:12 ` Scott Wood [this message]
2015-07-17 23:38 ` Vladimir Zapolskiy
2015-07-17 23:53 ` Scott Wood
2015-07-17 23:55 ` Scott Wood
2015-07-18 0:05 ` Vladimir Zapolskiy
2015-07-17 23:49 ` [U-Boot] [PATCH v3 " Vladimir Zapolskiy
2015-07-18 0:07 ` [U-Boot] [PATCH v4 " Vladimir Zapolskiy
2015-07-27 16:25 ` Vladimir Zapolskiy
2015-07-28 1:23 ` Scott Wood
2015-07-29 18:46 ` LEMIEUX, SYLVAIN
2015-08-13 13:18 ` [U-Boot] [U-Boot, v4, " Tom Rini
2015-07-17 22:47 ` [U-Boot] [PATCH v2 3/4] lpc32xx: devkit3250: update of board configuration Vladimir Zapolskiy
2015-08-13 13:18 ` [U-Boot] [U-Boot, v2, " Tom Rini
2015-07-17 22:47 ` [U-Boot] [PATCH v2 4/4] lpc32xx: devkit3250: add spl build support Vladimir Zapolskiy
2015-08-13 13:18 ` [U-Boot] [U-Boot, v2, " Tom Rini
2015-08-10 14:34 ` [U-Boot] [PATCH v2 0/4] lpc32xx: devkit3250 board update Vladimir Zapolskiy
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=1437174730.2993.206.camel@freescale.com \
--to=scottwood@freescale.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.