]>
Commit | Line | Data |
---|---|---|
73ccb341 GJ |
1 | /* |
2 | * (C) Copyright 2008 | |
3 | * Gary Jennejohn, DENX Software Engineering GmbH, garyj@denx.de | |
4 | * | |
1a459660 | 5 | * SPDX-License-Identifier: GPL-2.0+ |
73ccb341 GJ |
6 | */ |
7 | ||
8 | #include <common.h> | |
9 | #include <config.h> | |
10 | #if defined(CONFIG_CMD_NAND) | |
09887762 | 11 | #include <asm/ppc4xx-gpio.h> |
ba22d10f | 12 | #include <asm/io.h> |
73ccb341 GJ |
13 | #include <nand.h> |
14 | ||
15 | /* | |
16 | * hardware specific access to control-lines | |
17 | */ | |
ba22d10f SW |
18 | static void quad100hd_hwcontrol(struct mtd_info *mtd, |
19 | int cmd, unsigned int ctrl) | |
73ccb341 | 20 | { |
ba22d10f | 21 | struct nand_chip *this = mtd->priv; |
73ccb341 | 22 | |
ba22d10f | 23 | if (ctrl & NAND_CTRL_CHANGE) { |
6d0f6bcf JCPV |
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)); | |
73ccb341 | 27 | } |
ba22d10f SW |
28 | |
29 | if (cmd != NAND_CMD_NONE) | |
30 | writeb(cmd, this->IO_ADDR_W); | |
73ccb341 GJ |
31 | } |
32 | ||
33 | static int quad100hd_nand_ready(struct mtd_info *mtd) | |
34 | { | |
6d0f6bcf | 35 | return gpio_read_in_bit(CONFIG_SYS_NAND_RDY); |
73ccb341 GJ |
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 */ | |
ba22d10f | 44 | nand->cmd_ctrl = quad100hd_hwcontrol; |
73ccb341 | 45 | nand->dev_ready = quad100hd_nand_ready; |
ba22d10f | 46 | nand->ecc.mode = NAND_ECC_SOFT; |
73ccb341 GJ |
47 | /* 15 us command delay time */ |
48 | nand->chip_delay = 20; | |
49 | ||
50 | /* Return happy */ | |
51 | return 0; | |
52 | } | |
53 | #endif /* CONFIG_CMD_NAND */ |