]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/quad100hd/nand.c
rename CFG_ macros to CONFIG_SYS
[people/ms/u-boot.git] / board / quad100hd / nand.c
CommitLineData
73ccb341
GJ
1/*
2 * (C) Copyright 2008
3 * Gary Jennejohn, DENX Software Engineering GmbH, garyj@denx.de
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <config.h>
26#if defined(CONFIG_CMD_NAND)
27#include <asm/gpio.h>
ba22d10f 28#include <asm/io.h>
73ccb341
GJ
29#include <nand.h>
30
31/*
32 * hardware specific access to control-lines
33 */
ba22d10f
SW
34static void quad100hd_hwcontrol(struct mtd_info *mtd,
35 int cmd, unsigned int ctrl)
73ccb341 36{
ba22d10f 37 struct nand_chip *this = mtd->priv;
73ccb341 38
ba22d10f 39 if (ctrl & NAND_CTRL_CHANGE) {
6d0f6bcf
JCPV
40 gpio_write_bit(CONFIG_SYS_NAND_CLE, !!(ctrl & NAND_CLE));
41 gpio_write_bit(CONFIG_SYS_NAND_ALE, !!(ctrl & NAND_ALE));
42 gpio_write_bit(CONFIG_SYS_NAND_CE, !(ctrl & NAND_NCE));
73ccb341 43 }
ba22d10f
SW
44
45 if (cmd != NAND_CMD_NONE)
46 writeb(cmd, this->IO_ADDR_W);
73ccb341
GJ
47}
48
49static int quad100hd_nand_ready(struct mtd_info *mtd)
50{
6d0f6bcf 51 return gpio_read_in_bit(CONFIG_SYS_NAND_RDY);
73ccb341
GJ
52}
53
54/*
55 * Main initialization routine
56 */
57int board_nand_init(struct nand_chip *nand)
58{
59 /* Set address of hardware control function */
ba22d10f 60 nand->cmd_ctrl = quad100hd_hwcontrol;
73ccb341 61 nand->dev_ready = quad100hd_nand_ready;
ba22d10f 62 nand->ecc.mode = NAND_ECC_SOFT;
73ccb341
GJ
63 /* 15 us command delay time */
64 nand->chip_delay = 20;
65
66 /* Return happy */
67 return 0;
68}
69#endif /* CONFIG_CMD_NAND */