3 * Marvell Semiconductor <www.marvell.com>
4 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <asm/arch/kirkwood.h>
30 /* NAND Flash Soc registers */
31 struct kwnandf_registers {
32 u32 rd_params; /* 0x10418 */
33 u32 wr_param; /* 0x1041c */
34 u8 pad[0x10470 - 0x1041c - 4];
35 u32 ctrl; /* 0x10470 */
38 static struct kwnandf_registers *nf_reg =
39 (struct kwnandf_registers *)KW_NANDF_BASE;
42 * hardware specific access to control-lines/bits
44 #define NAND_ACTCEBOOT_BIT 0x02
46 static void kw_nand_hwcontrol(struct mtd_info *mtd, int cmd,
49 struct nand_chip *nc = mtd->priv;
52 if (cmd == NAND_CMD_NONE)
56 offs = (1 << 0); /* Commands with A[1:0] == 01 */
57 else if (ctrl & NAND_ALE)
58 offs = (1 << 1); /* Addresses with A[1:0] == 10 */
62 writeb(cmd, nc->IO_ADDR_W + offs);
65 void kw_nand_select_chip(struct mtd_info *mtd, int chip)
69 data = readl(&nf_reg->ctrl);
70 data |= NAND_ACTCEBOOT_BIT;
71 writel(data, &nf_reg->ctrl);
74 int board_nand_init(struct nand_chip *nand)
76 nand->options = NAND_COPYBACK | NAND_CACHEPRG | NAND_NO_PADDING;
77 #if defined(CONFIG_NAND_ECC_BCH)
78 nand->ecc.mode = NAND_ECC_SOFT_BCH;
80 nand->ecc.mode = NAND_ECC_SOFT;
82 nand->cmd_ctrl = kw_nand_hwcontrol;
83 nand->chip_delay = 40;
84 nand->select_chip = kw_nand_select_chip;