blob: 4e52838c90951fe5946b9068244868baf6e7609a [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Peter Tyserf3c970c2008-12-23 16:32:00 -06002/*
3 * Copyright 2008 Extreme Engineering Solutions, Inc.
4 *
5 * This driver support NAND devices which have address lines
6 * connected as ALE and CLE inputs.
Peter Tyserf3c970c2008-12-23 16:32:00 -06007 */
8
9#include <common.h>
10#include <nand.h>
11#include <asm/io.h>
12
13/*
14 * Hardware specific access to control-lines
15 */
16static void nand_addr_hwcontrol(struct mtd_info *mtd, int cmd, uint ctrl)
17{
Scott Wood17fed142016-05-30 13:57:56 -050018 struct nand_chip *this = mtd_to_nand(mtd);
Peter Tyserf3c970c2008-12-23 16:32:00 -060019 ulong IO_ADDR_W;
20
21 if (ctrl & NAND_CTRL_CHANGE) {
22 IO_ADDR_W = (ulong)this->IO_ADDR_W;
23
24 IO_ADDR_W &= ~(CONFIG_SYS_NAND_ACTL_CLE |
25 CONFIG_SYS_NAND_ACTL_ALE |
26 CONFIG_SYS_NAND_ACTL_NCE);
27 if (ctrl & NAND_CLE)
28 IO_ADDR_W |= CONFIG_SYS_NAND_ACTL_CLE;
29 if (ctrl & NAND_ALE)
30 IO_ADDR_W |= CONFIG_SYS_NAND_ACTL_ALE;
31 if (ctrl & NAND_NCE)
32 IO_ADDR_W |= CONFIG_SYS_NAND_ACTL_NCE;
33
34 this->IO_ADDR_W = (void *)IO_ADDR_W;
35 }
36
37 if (cmd != NAND_CMD_NONE)
38 writeb(cmd, this->IO_ADDR_W);
39}
40
41int board_nand_init(struct nand_chip *nand)
42{
43 nand->ecc.mode = NAND_ECC_SOFT;
44 nand->cmd_ctrl = nand_addr_hwcontrol;
45 nand->chip_delay = CONFIG_SYS_NAND_ACTL_DELAY;
46
47 return 0;
48}