Gary Jennejohn | 0ec4f30 | 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 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Gary Jennejohn | 0ec4f30 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <config.h> |
| 10 | #if defined(CONFIG_CMD_NAND) |
Stefan Roese | de21eab | 2010-09-16 14:30:37 +0200 | [diff] [blame] | 11 | #include <asm/ppc4xx-gpio.h> |
Scott Wood | a59e62d | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 12 | #include <asm/io.h> |
Gary Jennejohn | 0ec4f30 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 13 | #include <nand.h> |
| 14 | |
| 15 | /* |
| 16 | * hardware specific access to control-lines |
| 17 | */ |
Scott Wood | a59e62d | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 18 | static void quad100hd_hwcontrol(struct mtd_info *mtd, |
| 19 | int cmd, unsigned int ctrl) |
Gary Jennejohn | 0ec4f30 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 20 | { |
Scott Wood | a59e62d | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 21 | struct nand_chip *this = mtd->priv; |
Gary Jennejohn | 0ec4f30 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 22 | |
Scott Wood | a59e62d | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 23 | if (ctrl & NAND_CTRL_CHANGE) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 24 | gpio_write_bit(CONFIG_SYS_NAND_CLE, !!(ctrl & NAND_CLE)); |
| 25 | gpio_write_bit(CONFIG_SYS_NAND_ALE, !!(ctrl & NAND_ALE)); |
| 26 | gpio_write_bit(CONFIG_SYS_NAND_CE, !(ctrl & NAND_NCE)); |
Gary Jennejohn | 0ec4f30 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 27 | } |
Scott Wood | a59e62d | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 28 | |
| 29 | if (cmd != NAND_CMD_NONE) |
| 30 | writeb(cmd, this->IO_ADDR_W); |
Gary Jennejohn | 0ec4f30 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | static int quad100hd_nand_ready(struct mtd_info *mtd) |
| 34 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 35 | return gpio_read_in_bit(CONFIG_SYS_NAND_RDY); |
Gary Jennejohn | 0ec4f30 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | /* |
| 39 | * Main initialization routine |
| 40 | */ |
| 41 | int board_nand_init(struct nand_chip *nand) |
| 42 | { |
| 43 | /* Set address of hardware control function */ |
Scott Wood | a59e62d | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 44 | nand->cmd_ctrl = quad100hd_hwcontrol; |
Gary Jennejohn | 0ec4f30 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 45 | nand->dev_ready = quad100hd_nand_ready; |
Scott Wood | a59e62d | 2008-08-13 18:03:40 -0500 | [diff] [blame] | 46 | nand->ecc.mode = NAND_ECC_SOFT; |
Gary Jennejohn | 0ec4f30 | 2008-04-28 14:04:32 +0200 | [diff] [blame] | 47 | /* 15 us command delay time */ |
| 48 | nand->chip_delay = 20; |
| 49 | |
| 50 | /* Return happy */ |
| 51 | return 0; |
| 52 | } |
| 53 | #endif /* CONFIG_CMD_NAND */ |