Bartlomiej Sieka | addb2e1 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 1 | /* |
| 2 | * linux/include/linux/mtd/nand.h |
| 3 | * |
| 4 | * Copyright (c) 2000 David Woodhouse <dwmw2@mvhi.com> |
| 5 | * Steven J. Hill <sjhill@cotw.com> |
| 6 | * Thomas Gleixner <gleixner@autronix.de> |
| 7 | * |
| 8 | * $Id: nand.h,v 1.7 2003/07/24 23:30:46 a0384864 Exp $ |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | * |
| 14 | * Info: |
| 15 | * Contains standard defines and IDs for NAND flash devices |
| 16 | * |
| 17 | * Changelog: |
| 18 | * 01-31-2000 DMW Created |
| 19 | * 09-18-2000 SJH Moved structure out of the Disk-On-Chip drivers |
| 20 | * so it can be used by other NAND flash device |
| 21 | * drivers. I also changed the copyright since none |
| 22 | * of the original contents of this file are specific |
| 23 | * to DoC devices. David can whack me with a baseball |
| 24 | * bat later if I did something naughty. |
| 25 | * 10-11-2000 SJH Added private NAND flash structure for driver |
| 26 | * 10-24-2000 SJH Added prototype for 'nand_scan' function |
| 27 | * 10-29-2001 TG changed nand_chip structure to support |
| 28 | * hardwarespecific function for accessing control lines |
| 29 | * 02-21-2002 TG added support for different read/write adress and |
| 30 | * ready/busy line access function |
| 31 | * 02-26-2002 TG added chip_delay to nand_chip structure to optimize |
| 32 | * command delay times for different chips |
| 33 | * 04-28-2002 TG OOB config defines moved from nand.c to avoid duplicate |
| 34 | * defines in jffs2/wbuf.c |
| 35 | */ |
| 36 | #ifndef __LINUX_MTD_NAND_LEGACY_H |
| 37 | #define __LINUX_MTD_NAND_LEGACY_H |
| 38 | |
Jean-Christophe PLAGNIOL-VILLARD | cc4a0ce | 2008-08-13 01:40:43 +0200 | [diff] [blame] | 39 | #ifndef CONFIG_NAND_LEGACY |
Bartlomiej Sieka | addb2e1 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 40 | #error This module is for the legacy NAND support |
| 41 | #endif |
| 42 | |
Wolfgang Grandegger | 6c86963 | 2009-01-16 18:55:54 +0100 | [diff] [blame^] | 43 | /* The maximum number of NAND chips in an array */ |
| 44 | #ifndef CONFIG_SYS_NAND_MAX_CHIPS |
| 45 | #define CONFIG_SYS_NAND_MAX_CHIPS 1 |
| 46 | #endif |
| 47 | |
Bartlomiej Sieka | addb2e1 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 48 | /* |
| 49 | * Standard NAND flash commands |
| 50 | */ |
| 51 | #define NAND_CMD_READ0 0 |
| 52 | #define NAND_CMD_READ1 1 |
| 53 | #define NAND_CMD_PAGEPROG 0x10 |
| 54 | #define NAND_CMD_READOOB 0x50 |
| 55 | #define NAND_CMD_ERASE1 0x60 |
| 56 | #define NAND_CMD_STATUS 0x70 |
| 57 | #define NAND_CMD_SEQIN 0x80 |
| 58 | #define NAND_CMD_READID 0x90 |
| 59 | #define NAND_CMD_ERASE2 0xd0 |
| 60 | #define NAND_CMD_RESET 0xff |
| 61 | |
| 62 | /* |
Bartlomiej Sieka | addb2e1 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 63 | * NAND Private Flash Chip Data |
| 64 | * |
| 65 | * Structure overview: |
| 66 | * |
| 67 | * IO_ADDR - address to access the 8 I/O lines of the flash device |
| 68 | * |
| 69 | * hwcontrol - hardwarespecific function for accesing control-lines |
| 70 | * |
| 71 | * dev_ready - hardwarespecific function for accesing device ready/busy line |
| 72 | * |
| 73 | * chip_lock - spinlock used to protect access to this structure |
| 74 | * |
| 75 | * wq - wait queue to sleep on if a NAND operation is in progress |
| 76 | * |
| 77 | * state - give the current state of the NAND device |
| 78 | * |
| 79 | * page_shift - number of address bits in a page (column address bits) |
| 80 | * |
| 81 | * data_buf - data buffer passed to/from MTD user modules |
| 82 | * |
| 83 | * data_cache - data cache for redundant page access and shadow for |
| 84 | * ECC failure |
| 85 | * |
| 86 | * ecc_code_buf - used only for holding calculated or read ECCs for |
| 87 | * a page read or written when ECC is in use |
| 88 | * |
| 89 | * reserved - padding to make structure fall on word boundary if |
| 90 | * when ECC is in use |
| 91 | */ |
| 92 | struct Nand { |
| 93 | char floor, chip; |
| 94 | unsigned long curadr; |
| 95 | unsigned char curmode; |
| 96 | /* Also some erase/write/pipeline info when we get that far */ |
| 97 | }; |
| 98 | |
| 99 | struct nand_chip { |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 100 | int page_shift; |
| 101 | u_char *data_buf; |
| 102 | u_char *data_cache; |
Bartlomiej Sieka | addb2e1 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 103 | int cache_page; |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 104 | u_char ecc_code_buf[6]; |
| 105 | u_char reserved[2]; |
Bartlomiej Sieka | addb2e1 | 2006-03-05 18:57:33 +0100 | [diff] [blame] | 106 | char ChipID; /* Type of DiskOnChip */ |
| 107 | struct Nand *chips; |
| 108 | int chipshift; |
| 109 | char* chips_name; |
| 110 | unsigned long erasesize; |
| 111 | unsigned long mfr; /* Flash IDs - only one type of flash per device */ |
| 112 | unsigned long id; |
| 113 | char* name; |
| 114 | int numchips; |
| 115 | char page256; |
| 116 | char pageadrlen; |
| 117 | unsigned long IO_ADDR; /* address to access the 8 I/O lines to the flash device */ |
| 118 | unsigned long totlen; |
| 119 | uint oobblock; /* Size of OOB blocks (e.g. 512) */ |
| 120 | uint oobsize; /* Amount of OOB data per block (e.g. 16) */ |
| 121 | uint eccsize; |
| 122 | int bus16; |
| 123 | }; |
| 124 | |
| 125 | /* |
| 126 | * NAND Flash Manufacturer ID Codes |
| 127 | */ |
| 128 | #define NAND_MFR_TOSHIBA 0x98 |
| 129 | #define NAND_MFR_SAMSUNG 0xec |
| 130 | |
| 131 | /* |
| 132 | * NAND Flash Device ID Structure |
| 133 | * |
| 134 | * Structure overview: |
| 135 | * |
| 136 | * name - Complete name of device |
| 137 | * |
| 138 | * manufacture_id - manufacturer ID code of device. |
| 139 | * |
| 140 | * model_id - model ID code of device. |
| 141 | * |
| 142 | * chipshift - total number of address bits for the device which |
| 143 | * is used to calculate address offsets and the total |
| 144 | * number of bytes the device is capable of. |
| 145 | * |
| 146 | * page256 - denotes if flash device has 256 byte pages or not. |
| 147 | * |
| 148 | * pageadrlen - number of bytes minus one needed to hold the |
| 149 | * complete address into the flash array. Keep in |
| 150 | * mind that when a read or write is done to a |
| 151 | * specific address, the address is input serially |
| 152 | * 8 bits at a time. This structure member is used |
| 153 | * by the read/write routines as a loop index for |
| 154 | * shifting the address out 8 bits at a time. |
| 155 | * |
| 156 | * erasesize - size of an erase block in the flash device. |
| 157 | */ |
| 158 | struct nand_flash_dev { |
| 159 | char * name; |
| 160 | int manufacture_id; |
| 161 | int model_id; |
| 162 | int chipshift; |
| 163 | char page256; |
| 164 | char pageadrlen; |
| 165 | unsigned long erasesize; |
| 166 | int bus16; |
| 167 | }; |
| 168 | |
| 169 | /* |
| 170 | * Constants for oob configuration |
| 171 | */ |
| 172 | #define NAND_NOOB_ECCPOS0 0 |
| 173 | #define NAND_NOOB_ECCPOS1 1 |
| 174 | #define NAND_NOOB_ECCPOS2 2 |
| 175 | #define NAND_NOOB_ECCPOS3 3 |
| 176 | #define NAND_NOOB_ECCPOS4 6 |
| 177 | #define NAND_NOOB_ECCPOS5 7 |
| 178 | #define NAND_NOOB_BADBPOS -1 |
| 179 | #define NAND_NOOB_ECCVPOS -1 |
| 180 | |
| 181 | #define NAND_JFFS2_OOB_ECCPOS0 0 |
| 182 | #define NAND_JFFS2_OOB_ECCPOS1 1 |
| 183 | #define NAND_JFFS2_OOB_ECCPOS2 2 |
| 184 | #define NAND_JFFS2_OOB_ECCPOS3 3 |
| 185 | #define NAND_JFFS2_OOB_ECCPOS4 6 |
| 186 | #define NAND_JFFS2_OOB_ECCPOS5 7 |
| 187 | #define NAND_JFFS2_OOB_BADBPOS 5 |
| 188 | #define NAND_JFFS2_OOB_ECCVPOS 4 |
| 189 | |
| 190 | #define NAND_JFFS2_OOB8_FSDAPOS 6 |
| 191 | #define NAND_JFFS2_OOB16_FSDAPOS 8 |
| 192 | #define NAND_JFFS2_OOB8_FSDALEN 2 |
| 193 | #define NAND_JFFS2_OOB16_FSDALEN 8 |
| 194 | |
| 195 | unsigned long nand_probe(unsigned long physadr); |
| 196 | #endif /* __LINUX_MTD_NAND_LEGACY_H */ |