1 typedef struct Flash Flash;
2 typedef struct Flashchip Flashchip;
3 typedef struct Flashpart Flashpart;
4 typedef struct Flashregion Flashregion;
24 * physical erase block regions
27 int n; /* number of blocks in region */
28 ulong start; /* physical base address (allowing for banks) */
31 ulong eraseshift; /* log2(erasesize) */
32 ulong pagesize; /* if non-0, size of pages within erase block */
33 ulong pageshift; /* log2(pagesize) */
34 ulong spares; /* spare bytes per page, for ecc, etc. */
38 * one of a set of chips in a given region
42 Flashregion regions[Maxflashregion];
44 uchar id; /* flash manufacturer ID */
45 ushort devid; /* flash device ID */
46 int width; /* bytes per flash line */
47 int maxwb; /* max write buffer size */
48 ulong devsize; /* physical device size */
49 int alg; /* programming algorithm (if CFI) */
50 int protect; /* software protection */
54 * structure defining a contiguous region of flash memory
57 QLock; /* interlock on flash operations */
60 /* following are filled in before calling Flash.reset */
64 int xip; /* executing in place: don't query */
67 /* following are filled in by the reset routine */
68 int (*eraseall)(Flash*);
69 int (*erasezone)(Flash*, Flashregion*, ulong);
70 /* (optional) reads of correct width and alignment */
71 int (*read)(Flash*, ulong, void*, long);
72 /* writes of correct width and alignment */
73 int (*write)(Flash*, ulong, void*, long);
74 int (*suspend)(Flash*);
75 int (*resume)(Flash*);
76 int (*attach)(Flash*);
78 /* following might be filled in by either archflashreset or reset routine */
80 Flashregion regions[Maxflashregion];
82 uchar id; /* flash manufacturer ID */
83 ushort devid; /* flash device ID */
84 int width; /* bytes per flash line */
85 int interleave; /* addresses are interleaved across set of chips */
86 int bshift; /* byte addresses are shifted */
87 ulong cmask; /* command mask for interleaving */
88 int maxwb; /* max write buffer size */
89 ulong devsize; /* physical device size */
90 int alg; /* programming algorithm (if CFI) */
91 void* data; /* flash type routines' private storage, or nil */
92 Flashpart part[Maxflashpart]; /* logical partitions */
93 int protect; /* software protection */
94 char* sort; /* "nand", "nor", "serial", nil (unspecified) */
98 * called by link routine of driver for specific flash type: arguments are
99 * conventional name for card type/model, and card driver's reset routine.
101 void addflashcard(char*, int (*)(Flash*));
104 * called by devflash.c:/^flashreset; if flash exists,
105 * sets type, address, and size in bytes of flash
106 * and returns 0; returns -1 if flash doesn't exist
108 int archflashreset(int, Flash*);
111 * enable/disable write protect
113 void archflashwp(Flash*, int);
116 * flash access taking width and interleave into account
118 int flashget(Flash*, ulong);
119 void flashput(Flash*, ulong, int);
122 * Architecture specific routines for managing nand devices
126 * do any device spcific initialisation
128 void archnand_init(Flash*);
131 * if claim is 1, claim device exclusively, and enable it (power it up)
132 * if claim is 0, release, and disable it (power it down)
133 * claiming may be as simple as a qlock per device
135 void archnand_claim(Flash*, int claim);
138 * set command latch enable (CLE) and address latch enable (ALE)
141 void archnand_setCLEandALE(Flash*, int cle, int ale);
144 * write a sequence of bytes to the device
146 void archnand_write(Flash*, void *buf, int len);
149 * read a sequence of bytes from the device
150 * if buf is 0, throw away the data
152 void archnand_read(Flash*, void *buf, int len);