Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 2 | /* |
| 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 Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <nand.h> |
Tom Rini | 1cefed1 | 2021-09-22 14:50:35 -0400 | [diff] [blame] | 11 | #include <linux/mtd/rawnand.h> |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 12 | #include <asm/io.h> |
| 13 | |
| 14 | /* |
| 15 | * Hardware specific access to control-lines |
| 16 | */ |
| 17 | static void nand_addr_hwcontrol(struct mtd_info *mtd, int cmd, uint ctrl) |
| 18 | { |
Scott Wood | 17cb4b8 | 2016-05-30 13:57:56 -0500 | [diff] [blame] | 19 | struct nand_chip *this = mtd_to_nand(mtd); |
Peter Tyser | 1f03cbf | 2008-12-23 16:32:00 -0600 | [diff] [blame] | 20 | ulong IO_ADDR_W; |
| 21 | |
| 22 | if (ctrl & NAND_CTRL_CHANGE) { |
| 23 | IO_ADDR_W = (ulong)this->IO_ADDR_W; |
| 24 | |
| 25 | IO_ADDR_W &= ~(CONFIG_SYS_NAND_ACTL_CLE | |
| 26 | CONFIG_SYS_NAND_ACTL_ALE | |
| 27 | CONFIG_SYS_NAND_ACTL_NCE); |
| 28 | if (ctrl & NAND_CLE) |
| 29 | IO_ADDR_W |= CONFIG_SYS_NAND_ACTL_CLE; |
| 30 | if (ctrl & NAND_ALE) |
| 31 | IO_ADDR_W |= CONFIG_SYS_NAND_ACTL_ALE; |
| 32 | if (ctrl & NAND_NCE) |
| 33 | IO_ADDR_W |= CONFIG_SYS_NAND_ACTL_NCE; |
| 34 | |
| 35 | this->IO_ADDR_W = (void *)IO_ADDR_W; |
| 36 | } |
| 37 | |
| 38 | if (cmd != NAND_CMD_NONE) |
| 39 | writeb(cmd, this->IO_ADDR_W); |
| 40 | } |
| 41 | |
| 42 | int board_nand_init(struct nand_chip *nand) |
| 43 | { |
| 44 | nand->ecc.mode = NAND_ECC_SOFT; |
| 45 | nand->cmd_ctrl = nand_addr_hwcontrol; |
| 46 | nand->chip_delay = CONFIG_SYS_NAND_ACTL_DELAY; |
| 47 | |
| 48 | return 0; |
| 49 | } |