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> 28#include <asm/io.h> 29#include <nand.h> 30 31/* 32 * hardware specific access to control-lines 33 */ 34static void quad100hd_hwcontrol(struct mtd_info *mtd, 35 int cmd, unsigned int ctrl) 36{ 37 struct nand_chip *this = mtd->priv; 38 39 if (ctrl & NAND_CTRL_CHANGE) { 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)); 43 } 44 45 if (cmd != NAND_CMD_NONE) 46 writeb(cmd, this->IO_ADDR_W); 47} 48 49static int quad100hd_nand_ready(struct mtd_info *mtd) 50{ 51 return gpio_read_in_bit(CONFIG_SYS_NAND_RDY); 52} 53 54/* 55 * Main initialization routine 56 */ 57int board_nand_init(struct nand_chip *nand) 58{ 59 /* Set address of hardware control function */ 60 nand->cmd_ctrl = quad100hd_hwcontrol; 61 nand->dev_ready = quad100hd_nand_ready; 62 nand->ecc.mode = NAND_ECC_SOFT; 63 /* 15 us command delay time */ 64 nand->chip_delay = 20; 65 66 /* Return happy */ 67 return 0; 68} 69#endif /* CONFIG_CMD_NAND */ 70