2 * (C) Copyright 2006 DENX Software Engineering
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #if (CONFIG_COMMANDS & CFG_CMD_NAND)
31 * hardware specific access to control-lines
32 * function borrowed from Linux 2.6 (drivers/mtd/nand/ppchameleonevb.c)
34 static void ppchameleonevb_hwcontrol(struct mtd_info *mtdinfo, int cmd)
36 struct nand_chip *this = mtdinfo->priv;
37 ulong base = (ulong) this->IO_ADDR_W;
41 MACRO_NAND_CTL_SETCLE((unsigned long)base);
44 MACRO_NAND_CTL_CLRCLE((unsigned long)base);
47 MACRO_NAND_CTL_SETALE((unsigned long)base);
50 MACRO_NAND_CTL_CLRALE((unsigned long)base);
53 MACRO_NAND_ENABLE_CE((unsigned long)base);
56 MACRO_NAND_DISABLE_CE((unsigned long)base);
63 * read device ready pin
64 * function +/- borrowed from Linux 2.6 (drivers/mtd/nand/ppchameleonevb.c)
66 static int ppchameleonevb_device_ready(struct mtd_info *mtdinfo)
68 struct nand_chip *this = mtdinfo->priv;
71 /* use the base addr to find out which chip are we dealing with */
72 switch((ulong) this->IO_ADDR_W) {
74 rb_gpio_pin = CFG_NAND0_RDY;
77 rb_gpio_pin = CFG_NAND1_RDY;
79 default: /* this should never happen */
84 if (in32(GPIO0_IR) & rb_gpio_pin)
91 * Board-specific NAND initialization. The following members of the
92 * argument are board-specific (per include/linux/mtd/nand.h):
93 * - IO_ADDR_R?: address to read the 8 I/O lines of the flash device
94 * - IO_ADDR_W?: address to write the 8 I/O lines of the flash device
95 * - hwcontrol: hardwarespecific function for accesing control-lines
96 * - dev_ready: hardwarespecific function for accesing device ready/busy line
97 * - enable_hwecc?: function to enable (reset) hardware ecc generator. Must
98 * only be provided if a hardware ECC is available
99 * - eccmode: mode of ecc, see defines
100 * - chip_delay: chip dependent delay for transfering data from array to
102 * - options: various chip options. They can partly be set to inform
103 * nand_scan about special functionality. See the defines for further
105 * Members with a "?" were not set in the merged testing-NAND branch,
106 * so they are not set here either.
108 int board_nand_init(struct nand_chip *nand)
111 nand->hwcontrol = ppchameleonevb_hwcontrol;
112 nand->dev_ready = ppchameleonevb_device_ready;
113 nand->eccmode = NAND_ECC_SOFT;
114 nand->chip_delay = NAND_BIG_DELAY_US;
115 nand->options = NAND_SAMSUNG_LP_OPTIONS;
118 #endif /* (CONFIG_COMMANDS & CFG_CMD_NAND) */