Gary Jennejohn | 73ccb34 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 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) |
Stefan Roese | 0988776 | 2010-09-16 14:30:37 +0200 | [diff] [blame] | 27 | #include <asm/ppc4xx-gpio.h> |
Scott Wood | ba22d10 | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 28 | #include <asm/io.h> |
Gary Jennejohn | 73ccb34 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 29 | #include <nand.h> |
| 30 | |
| 31 | /* |
| 32 | * hardware specific access to control-lines |
| 33 | */ |
Scott Wood | ba22d10 | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 34 | static void quad100hd_hwcontrol(struct mtd_info *mtd, |
| 35 | int cmd, unsigned int ctrl) |
Gary Jennejohn | 73ccb34 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 36 | { |
Scott Wood | ba22d10 | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 37 | struct nand_chip *this = mtd->priv; |
Gary Jennejohn | 73ccb34 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 38 | |
Scott Wood | ba22d10 | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 39 | if (ctrl & NAND_CTRL_CHANGE) { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 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)); |
Gary Jennejohn | 73ccb34 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 43 | } |
Scott Wood | ba22d10 | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 44 | |
| 45 | if (cmd != NAND_CMD_NONE) |
| 46 | writeb(cmd, this->IO_ADDR_W); |
Gary Jennejohn | 73ccb34 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | static int quad100hd_nand_ready(struct mtd_info *mtd) |
| 50 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 51 | return gpio_read_in_bit(CONFIG_SYS_NAND_RDY); |
Gary Jennejohn | 73ccb34 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | /* |
| 55 | * Main initialization routine |
| 56 | */ |
| 57 | int board_nand_init(struct nand_chip *nand) |
| 58 | { |
| 59 | /* Set address of hardware control function */ |
Scott Wood | ba22d10 | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 60 | nand->cmd_ctrl = quad100hd_hwcontrol; |
Gary Jennejohn | 73ccb34 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 61 | nand->dev_ready = quad100hd_nand_ready; |
Scott Wood | ba22d10 | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 62 | nand->ecc.mode = NAND_ECC_SOFT; |
Gary Jennejohn | 73ccb34 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 63 | /* 15 us command delay time */ |
| 64 | nand->chip_delay = 20; |
| 65 | |
| 66 | /* Return happy */ |
| 67 | return 0; |
| 68 | } |
| 69 | #endif /* CONFIG_CMD_NAND */ |