doc2000.h (1a247ba7fa5fb09f56892a09a990f03ce564b3e2) | doc2000.h (cfa460adfdefcc30d104e1a9ee44994ee349bb7b) |
---|---|
1/* 2 * Linux driver for Disk-On-Chip devices 3 * 4 * Copyright (C) 1999 Machine Vision Holdings, Inc. 5 * Copyright (C) 2001-2003 David Woodhouse <dwmw2@infradead.org> 6 * Copyright (C) 2002-2003 Greg Ungerer <gerg@snapgear.com> 7 * Copyright (C) 2002-2003 SnapGear Inc 8 * 9 * $Id: doc2000.h,v 1.25 2005/11/07 11:14:54 gleixner Exp $ 10 * 11 * Released under GPL 12 */ |
|
1 | 13 |
2/* Linux driver for Disk-On-Chip 2000 */ 3/* (c) 1999 Machine Vision Holdings, Inc. */ 4/* Author: David Woodhouse <dwmw2@mvhi.com> */ 5/* $Id: doc2000.h,v 1.15 2001/09/19 00:22:15 dwmw2 Exp $ */ 6 | |
7#ifndef __MTD_DOC2000_H__ 8#define __MTD_DOC2000_H__ 9 | 14#ifndef __MTD_DOC2000_H__ 15#define __MTD_DOC2000_H__ 16 |
10struct DiskOnChip; | 17#include <linux/mtd/mtd.h> 18#if 0 19#include <linux/mutex.h> 20#endif |
11 | 21 |
12#include <linux/mtd/nftl.h> 13 | |
14#define DoC_Sig1 0 15#define DoC_Sig2 1 16 17#define DoC_ChipID 0x1000 18#define DoC_DOCStatus 0x1001 19#define DoC_DOCControl 0x1002 20#define DoC_FloorSelect 0x1003 21#define DoC_CDSNControl 0x1004 --- 13 unchanged lines hidden (view full) --- 35#define DoC_ReadPipeInit 0x101d 36#define DoC_WritePipeTerm 0x101e 37#define DoC_LastDataRead 0x101f 38#define DoC_NOP 0x1020 39 40#define DoC_Mil_CDSN_IO 0x0800 41#define DoC_2k_CDSN_IO 0x1800 42 | 22#define DoC_Sig1 0 23#define DoC_Sig2 1 24 25#define DoC_ChipID 0x1000 26#define DoC_DOCStatus 0x1001 27#define DoC_DOCControl 0x1002 28#define DoC_FloorSelect 0x1003 29#define DoC_CDSNControl 0x1004 --- 13 unchanged lines hidden (view full) --- 43#define DoC_ReadPipeInit 0x101d 44#define DoC_WritePipeTerm 0x101e 45#define DoC_LastDataRead 0x101f 46#define DoC_NOP 0x1020 47 48#define DoC_Mil_CDSN_IO 0x0800 49#define DoC_2k_CDSN_IO 0x1800 50 |
43#define ReadDOC_(adr, reg) ((volatile unsigned char)(*(volatile __u8 *)(((unsigned long)adr)+((reg))))) 44#define WriteDOC_(d, adr, reg) do{ *(volatile __u8 *)(((unsigned long)adr)+((reg))) = (__u8)d; eieio();} while(0) | 51#define DoC_Mplus_NOP 0x1002 52#define DoC_Mplus_AliasResolution 0x1004 53#define DoC_Mplus_DOCControl 0x1006 54#define DoC_Mplus_AccessStatus 0x1008 55#define DoC_Mplus_DeviceSelect 0x1008 56#define DoC_Mplus_Configuration 0x100a 57#define DoC_Mplus_OutputControl 0x100c 58#define DoC_Mplus_FlashControl 0x1020 59#define DoC_Mplus_FlashSelect 0x1022 60#define DoC_Mplus_FlashCmd 0x1024 61#define DoC_Mplus_FlashAddress 0x1026 62#define DoC_Mplus_FlashData0 0x1028 63#define DoC_Mplus_FlashData1 0x1029 64#define DoC_Mplus_ReadPipeInit 0x102a 65#define DoC_Mplus_LastDataRead 0x102c 66#define DoC_Mplus_LastDataRead1 0x102d 67#define DoC_Mplus_WritePipeTerm 0x102e 68#define DoC_Mplus_ECCSyndrome0 0x1040 69#define DoC_Mplus_ECCSyndrome1 0x1041 70#define DoC_Mplus_ECCSyndrome2 0x1042 71#define DoC_Mplus_ECCSyndrome3 0x1043 72#define DoC_Mplus_ECCSyndrome4 0x1044 73#define DoC_Mplus_ECCSyndrome5 0x1045 74#define DoC_Mplus_ECCConf 0x1046 75#define DoC_Mplus_Toggle 0x1046 76#define DoC_Mplus_DownloadStatus 0x1074 77#define DoC_Mplus_CtrlConfirm 0x1076 78#define DoC_Mplus_Power 0x1fff |
45 | 79 |
46#define DOC_IOREMAP_LEN 0x4000 | 80/* How to access the device? 81 * On ARM, it'll be mmap'd directly with 32-bit wide accesses. 82 * On PPC, it's mmap'd and 16-bit wide. 83 * Others use readb/writeb 84 */ 85#if defined(__arm__) 86#define ReadDOC_(adr, reg) ((unsigned char)(*(volatile __u32 *)(((unsigned long)adr)+((reg)<<2)))) 87#define WriteDOC_(d, adr, reg) do{ *(volatile __u32 *)(((unsigned long)adr)+((reg)<<2)) = (__u32)d; wmb();} while(0) 88#define DOC_IOREMAP_LEN 0x8000 89#elif defined(__ppc__) 90#define ReadDOC_(adr, reg) ((unsigned char)(*(volatile __u16 *)(((unsigned long)adr)+((reg)<<1)))) 91#define WriteDOC_(d, adr, reg) do{ *(volatile __u16 *)(((unsigned long)adr)+((reg)<<1)) = (__u16)d; wmb();} while(0) 92#define DOC_IOREMAP_LEN 0x4000 93#else 94#define ReadDOC_(adr, reg) readb((void __iomem *)(adr) + (reg)) 95#define WriteDOC_(d, adr, reg) writeb(d, (void __iomem *)(adr) + (reg)) 96#define DOC_IOREMAP_LEN 0x2000 |
47 | 97 |
98#endif 99 100#if defined(__i386__) || defined(__x86_64__) 101#define USE_MEMCPY 102#endif 103 |
|
48/* These are provided to directly use the DoC_xxx defines */ 49#define ReadDOC(adr, reg) ReadDOC_(adr,DoC_##reg) 50#define WriteDOC(d, adr, reg) WriteDOC_(d,adr,DoC_##reg) 51 52#define DOC_MODE_RESET 0 53#define DOC_MODE_NORMAL 1 54#define DOC_MODE_RESERVED1 2 55#define DOC_MODE_RESERVED2 3 56 | 104/* These are provided to directly use the DoC_xxx defines */ 105#define ReadDOC(adr, reg) ReadDOC_(adr,DoC_##reg) 106#define WriteDOC(d, adr, reg) WriteDOC_(d,adr,DoC_##reg) 107 108#define DOC_MODE_RESET 0 109#define DOC_MODE_NORMAL 1 110#define DOC_MODE_RESERVED1 2 111#define DOC_MODE_RESERVED2 3 112 |
57#define DOC_MODE_MDWREN 4 | |
58#define DOC_MODE_CLR_ERR 0x80 | 113#define DOC_MODE_CLR_ERR 0x80 |
114#define DOC_MODE_RST_LAT 0x10 115#define DOC_MODE_BDECT 0x08 116#define DOC_MODE_MDWREN 0x04 |
|
59 | 117 |
60#define DOC_ChipID_UNKNOWN 0x00 | |
61#define DOC_ChipID_Doc2k 0x20 | 118#define DOC_ChipID_Doc2k 0x20 |
119#define DOC_ChipID_Doc2kTSOP 0x21 /* internal number for MTD */ |
|
62#define DOC_ChipID_DocMil 0x30 | 120#define DOC_ChipID_DocMil 0x30 |
121#define DOC_ChipID_DocMilPlus32 0x40 122#define DOC_ChipID_DocMilPlus16 0x41 |
|
63 64#define CDSN_CTRL_FR_B 0x80 | 123 124#define CDSN_CTRL_FR_B 0x80 |
125#define CDSN_CTRL_FR_B0 0x40 126#define CDSN_CTRL_FR_B1 0x80 127 |
|
65#define CDSN_CTRL_ECC_IO 0x20 66#define CDSN_CTRL_FLASH_IO 0x10 67#define CDSN_CTRL_WP 0x08 68#define CDSN_CTRL_ALE 0x04 69#define CDSN_CTRL_CLE 0x02 70#define CDSN_CTRL_CE 0x01 71 72#define DOC_ECC_RESET 0 73#define DOC_ECC_ERROR 0x80 74#define DOC_ECC_RW 0x20 75#define DOC_ECC__EN 0x08 76#define DOC_TOGGLE_BIT 0x04 77#define DOC_ECC_RESV 0x02 78#define DOC_ECC_IGNORE 0x01 79 | 128#define CDSN_CTRL_ECC_IO 0x20 129#define CDSN_CTRL_FLASH_IO 0x10 130#define CDSN_CTRL_WP 0x08 131#define CDSN_CTRL_ALE 0x04 132#define CDSN_CTRL_CLE 0x02 133#define CDSN_CTRL_CE 0x01 134 135#define DOC_ECC_RESET 0 136#define DOC_ECC_ERROR 0x80 137#define DOC_ECC_RW 0x20 138#define DOC_ECC__EN 0x08 139#define DOC_TOGGLE_BIT 0x04 140#define DOC_ECC_RESV 0x02 141#define DOC_ECC_IGNORE 0x01 142 |
143#define DOC_FLASH_CE 0x80 144#define DOC_FLASH_WP 0x40 145#define DOC_FLASH_BANK 0x02 146 |
|
80/* We have to also set the reserved bit 1 for enable */ 81#define DOC_ECC_EN (DOC_ECC__EN | DOC_ECC_RESV) 82#define DOC_ECC_DIS (DOC_ECC_RESV) 83 | 147/* We have to also set the reserved bit 1 for enable */ 148#define DOC_ECC_EN (DOC_ECC__EN | DOC_ECC_RESV) 149#define DOC_ECC_DIS (DOC_ECC_RESV) 150 |
151struct Nand { 152 char floor, chip; 153 unsigned long curadr; 154 unsigned char curmode; 155 /* Also some erase/write/pipeline info when we get that far */ 156}; 157 |
|
84#define MAX_FLOORS 4 85#define MAX_CHIPS 4 86 | 158#define MAX_FLOORS 4 159#define MAX_CHIPS 4 160 |
87#define MAX_FLOORS_MIL 4 | 161#define MAX_FLOORS_MIL 1 |
88#define MAX_CHIPS_MIL 1 89 | 162#define MAX_CHIPS_MIL 1 163 |
164#define MAX_FLOORS_MPLUS 2 165#define MAX_CHIPS_MPLUS 1 166 |
|
90#define ADDR_COLUMN 1 91#define ADDR_PAGE 2 92#define ADDR_COLUMN_PAGE 3 93 | 167#define ADDR_COLUMN 1 168#define ADDR_PAGE 2 169#define ADDR_COLUMN_PAGE 3 170 |
94struct Nand { 95 char floor, chip; 96 unsigned long curadr; 97 unsigned char curmode; 98 /* Also some erase/write/pipeline info when we get that far */ 99}; 100 | |
101struct DiskOnChip { 102 unsigned long physadr; | 171struct DiskOnChip { 172 unsigned long physadr; |
103 unsigned long virtadr; | 173 void __iomem *virtadr; |
104 unsigned long totlen; | 174 unsigned long totlen; |
105 char* name; 106 char ChipID; /* Type of DiskOnChip */ | 175 unsigned char ChipID; /* Type of DiskOnChip */ |
107 int ioreg; 108 | 176 int ioreg; 177 |
109 char* chips_name; | |
110 unsigned long mfr; /* Flash IDs - only one type of flash per device */ 111 unsigned long id; 112 int chipshift; 113 char page256; 114 char pageadrlen; | 178 unsigned long mfr; /* Flash IDs - only one type of flash per device */ 179 unsigned long id; 180 int chipshift; 181 char page256; 182 char pageadrlen; |
183 char interleave; /* Internal interleaving - Millennium Plus style */ |
|
115 unsigned long erasesize; 116 117 int curfloor; 118 int curchip; 119 120 int numchips; 121 struct Nand *chips; | 184 unsigned long erasesize; 185 186 int curfloor; 187 int curchip; 188 189 int numchips; 190 struct Nand *chips; |
122 123 int nftl_found; 124 struct NFTLrecord nftl; | 191 struct mtd_info *nextdoc; 192/* XXX U-BOOT XXX */ 193#if 0 194 struct mutex lock; 195#endif |
125}; 126 | 196}; 197 |
127#define SECTORSIZE 512 128 129/* Return codes from doc_write(), doc_read(), and doc_erase(). 130 */ 131#define DOC_OK 0 132#define DOC_EIO 1 133#define DOC_EINVAL 2 134#define DOC_EECC 3 135#define DOC_ETIMEOUT 4 136 137/* 138 * Function Prototypes 139 */ | |
140int doc_decode_ecc(unsigned char sector[512], unsigned char ecc1[6]); 141 | 198int doc_decode_ecc(unsigned char sector[512], unsigned char ecc1[6]); 199 |
142int doc_rw(struct DiskOnChip* this, int cmd, loff_t from, size_t len, 143 size_t *retlen, u_char *buf); 144int doc_read_ecc(struct DiskOnChip* this, loff_t from, size_t len, 145 size_t *retlen, u_char *buf, u_char *eccbuf); 146int doc_write_ecc(struct DiskOnChip* this, loff_t to, size_t len, 147 size_t *retlen, const u_char *buf, u_char *eccbuf); 148int doc_read_oob(struct DiskOnChip* this, loff_t ofs, size_t len, 149 size_t *retlen, u_char *buf); 150int doc_write_oob(struct DiskOnChip* this, loff_t ofs, size_t len, 151 size_t *retlen, const u_char *buf); 152int doc_erase (struct DiskOnChip* this, loff_t ofs, size_t len); 153 154void doc_probe(unsigned long physadr); 155 156void doc_print(struct DiskOnChip*); 157 | 200/* XXX U-BOOT XXX */ 201#if 1 |
158/* | 202/* |
159 * Standard NAND flash commands 160 */ 161#define NAND_CMD_READ0 0 162#define NAND_CMD_READ1 1 163#define NAND_CMD_PAGEPROG 0x10 164#define NAND_CMD_READOOB 0x50 165#define NAND_CMD_ERASE1 0x60 166#define NAND_CMD_STATUS 0x70 167#define NAND_CMD_SEQIN 0x80 168#define NAND_CMD_READID 0x90 169#define NAND_CMD_ERASE2 0xd0 170#define NAND_CMD_RESET 0xff 171 172/* | |
173 * NAND Flash Manufacturer ID Codes 174 */ | 203 * NAND Flash Manufacturer ID Codes 204 */ |
175#define NAND_MFR_TOSHIBA 0x98 176#define NAND_MFR_SAMSUNG 0xec | 205#define NAND_MFR_TOSHIBA 0x98 206#define NAND_MFR_SAMSUNG 0xec 207#endif |
177 | 208 |
178/* 179 * NAND Flash Device ID Structure 180 * 181 * Structure overview: 182 * 183 * name - Complete name of device 184 * 185 * manufacture_id - manufacturer ID code of device. 186 * 187 * model_id - model ID code of device. 188 * 189 * chipshift - total number of address bits for the device which 190 * is used to calculate address offsets and the total 191 * number of bytes the device is capable of. 192 * 193 * page256 - denotes if flash device has 256 byte pages or not. 194 * 195 * pageadrlen - number of bytes minus one needed to hold the 196 * complete address into the flash array. Keep in 197 * mind that when a read or write is done to a 198 * specific address, the address is input serially 199 * 8 bits at a time. This structure member is used 200 * by the read/write routines as a loop index for 201 * shifting the address out 8 bits at a time. 202 * 203 * erasesize - size of an erase block in the flash device. 204 */ 205struct nand_flash_dev { 206 char * name; 207 int manufacture_id; 208 int model_id; 209 int chipshift; 210 char page256; 211 char pageadrlen; 212 unsigned long erasesize; 213 int bus16; 214}; 215 | |
216#endif /* __MTD_DOC2000_H__ */ | 209#endif /* __MTD_DOC2000_H__ */ |