dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2006 Detlev Zundel, dzu@denx.de |
| 3 | * (C) Copyright 2006 DENX Software Engineering |
| 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> |
William Juul | cfa460a | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 25 | #include <asm/io.h> |
dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 26 | |
Jon Loeliger | 3fe0010 | 2007-07-09 18:38:39 -0500 | [diff] [blame] | 27 | #if defined(CONFIG_CMD_NAND) |
dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 28 | |
| 29 | #include <nand.h> |
| 30 | |
| 31 | #if defined(CONFIG_IDS852_REV1) |
| 32 | /* |
| 33 | * hardware specific access to control-lines |
| 34 | */ |
William Juul | cfa460a | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 35 | static void nc650_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) |
dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 36 | { |
| 37 | struct nand_chip *this = mtd->priv; |
| 38 | |
William Juul | 5e1dae5 | 2007-11-09 13:32:30 +0100 | [diff] [blame] | 39 | if (ctrl & NAND_CTRL_CHANGE) { |
William Juul | cfa460a | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 40 | if ( ctrl & NAND_CLE ) |
| 41 | this->IO_ADDR_W += 2; |
| 42 | else |
| 43 | this->IO_ADDR_W -= 2; |
| 44 | if ( ctrl & NAND_ALE ) |
| 45 | this->IO_ADDR_W += 1; |
| 46 | else |
| 47 | this->IO_ADDR_W -= 1; |
dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 48 | } |
William Juul | cfa460a | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 49 | |
William Juul | 5e1dae5 | 2007-11-09 13:32:30 +0100 | [diff] [blame] | 50 | if (cmd != NAND_CMD_NONE) |
William Juul | 4cbb651 | 2007-11-08 10:39:53 +0100 | [diff] [blame] | 51 | writeb(cmd, this->IO_ADDR_W); |
dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 52 | } |
| 53 | #elif defined(CONFIG_IDS852_REV2) |
| 54 | /* |
| 55 | * hardware specific access to control-lines |
| 56 | */ |
William Juul | cfa460a | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 57 | static void nc650_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) |
dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 58 | { |
| 59 | struct nand_chip *this = mtd->priv; |
| 60 | |
William Juul | 5e1dae5 | 2007-11-09 13:32:30 +0100 | [diff] [blame] | 61 | if (ctrl & NAND_CTRL_CHANGE) { |
William Juul | cfa460a | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 62 | if ( ctrl & NAND_CLE ) |
| 63 | writeb(0, (volatile __u8 *) this->IO_ADDR_W + 0xa); |
| 64 | else |
| 65 | writeb(0, (volatile __u8 *) this->IO_ADDR_W) + 0x8); |
| 66 | if ( ctrl & NAND_ALE ) |
| 67 | writeb(0, (volatile __u8 *) this->IO_ADDR_W) + 0x9); |
| 68 | else |
| 69 | writeb(0, (volatile __u8 *) this->IO_ADDR_W) + 0x8); |
| 70 | if ( ctrl & NAND_NCE ) |
| 71 | writeb(0, (volatile __u8 *) this->IO_ADDR_W) + 0x8); |
| 72 | else |
| 73 | writeb(0, (volatile __u8 *) this->IO_ADDR_W) + 0xc); |
dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 74 | } |
William Juul | cfa460a | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 75 | |
William Juul | 5e1dae5 | 2007-11-09 13:32:30 +0100 | [diff] [blame] | 76 | if (cmd != NAND_CMD_NONE) |
William Juul | cfa460a | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 77 | writeb(cmd, this->IO_ADDR_W); |
dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 78 | } |
| 79 | #else |
| 80 | #error Unknown IDS852 module revision |
| 81 | #endif |
| 82 | |
| 83 | /* |
| 84 | * Board-specific NAND initialization. The following members of the |
| 85 | * argument are board-specific (per include/linux/mtd/nand.h): |
| 86 | * - IO_ADDR_R?: address to read the 8 I/O lines of the flash device |
| 87 | * - IO_ADDR_W?: address to write the 8 I/O lines of the flash device |
William Juul | cfa460a | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 88 | * - cmd_ctrl: hardwarespecific function for accesing control-lines |
dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 89 | * - dev_ready: hardwarespecific function for accesing device ready/busy line |
| 90 | * - enable_hwecc?: function to enable (reset) hardware ecc generator. Must |
| 91 | * only be provided if a hardware ECC is available |
William Juul | cfa460a | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 92 | * - eccm.ode: mode of ecc, see defines |
dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 93 | * - chip_delay: chip dependent delay for transfering data from array to |
| 94 | * read regs (tR) |
| 95 | * - options: various chip options. They can partly be set to inform |
| 96 | * nand_scan about special functionality. See the defines for further |
| 97 | * explanation |
| 98 | * Members with a "?" were not set in the merged testing-NAND branch, |
| 99 | * so they are not set here either. |
| 100 | */ |
Heiko Schocher | fa23044 | 2006-12-21 17:17:02 +0100 | [diff] [blame] | 101 | int board_nand_init(struct nand_chip *nand) |
dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 102 | { |
| 103 | |
William Juul | cfa460a | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 104 | nand->cmd_ctrl = nc650_hwcontrol; |
| 105 | nand->ecc.mode = NAND_ECC_SOFT; |
dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 106 | nand->chip_delay = 12; |
| 107 | /* nand->options = NAND_SAMSUNG_LP_OPTIONS;*/ |
Heiko Schocher | fa23044 | 2006-12-21 17:17:02 +0100 | [diff] [blame] | 108 | return 0; |
dzu@denx.de | 56a4a63 | 2006-04-19 15:27:11 +0200 | [diff] [blame] | 109 | } |
Jon Loeliger | 3fe0010 | 2007-07-09 18:38:39 -0500 | [diff] [blame] | 110 | #endif |