aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mtd/cfi.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/mtd/cfi.h')
-rw-r--r--include/linux/mtd/cfi.h85
1 files changed, 73 insertions, 12 deletions
diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h
index 2ed8c585021e..e6b6a1c66bd5 100644
--- a/include/linux/mtd/cfi.h
+++ b/include/linux/mtd/cfi.h
@@ -1,7 +1,7 @@
1 1
2/* Common Flash Interface structures 2/* Common Flash Interface structures
3 * See http://support.intel.com/design/flash/technote/index.htm 3 * See http://support.intel.com/design/flash/technote/index.htm
4 * $Id: cfi.h,v 1.50 2004/11/20 12:46:51 dwmw2 Exp $ 4 * $Id: cfi.h,v 1.54 2005/06/06 23:04:36 tpoynor Exp $
5 */ 5 */
6 6
7#ifndef __MTD_CFI_H__ 7#ifndef __MTD_CFI_H__
@@ -148,6 +148,14 @@ struct cfi_pri_intelext {
148 uint8_t extra[0]; 148 uint8_t extra[0];
149} __attribute__((packed)); 149} __attribute__((packed));
150 150
151struct cfi_intelext_otpinfo {
152 uint32_t ProtRegAddr;
153 uint16_t FactGroups;
154 uint8_t FactProtRegSize;
155 uint16_t UserGroups;
156 uint8_t UserProtRegSize;
157} __attribute__((packed));
158
151struct cfi_intelext_blockinfo { 159struct cfi_intelext_blockinfo {
152 uint16_t NumIdentBlocks; 160 uint16_t NumIdentBlocks;
153 uint16_t BlockSize; 161 uint16_t BlockSize;
@@ -244,7 +252,7 @@ static inline uint32_t cfi_build_cmd_addr(uint32_t cmd_ofs, int interleave, int
244 * It looks too long to be inline, but in the common case it should almost all 252 * It looks too long to be inline, but in the common case it should almost all
245 * get optimised away. 253 * get optimised away.
246 */ 254 */
247static inline map_word cfi_build_cmd(u_char cmd, struct map_info *map, struct cfi_private *cfi) 255static inline map_word cfi_build_cmd(u_long cmd, struct map_info *map, struct cfi_private *cfi)
248{ 256{
249 map_word val = { {0} }; 257 map_word val = { {0} };
250 int wordwidth, words_per_bus, chip_mode, chips_per_word; 258 int wordwidth, words_per_bus, chip_mode, chips_per_word;
@@ -307,6 +315,69 @@ static inline map_word cfi_build_cmd(u_char cmd, struct map_info *map, struct cf
307} 315}
308#define CMD(x) cfi_build_cmd((x), map, cfi) 316#define CMD(x) cfi_build_cmd((x), map, cfi)
309 317
318
319static inline unsigned char cfi_merge_status(map_word val, struct map_info *map,
320 struct cfi_private *cfi)
321{
322 int wordwidth, words_per_bus, chip_mode, chips_per_word;
323 unsigned long onestat, res = 0;
324 int i;
325
326 /* We do it this way to give the compiler a fighting chance
327 of optimising away all the crap for 'bankwidth' larger than
328 an unsigned long, in the common case where that support is
329 disabled */
330 if (map_bankwidth_is_large(map)) {
331 wordwidth = sizeof(unsigned long);
332 words_per_bus = (map_bankwidth(map)) / wordwidth; // i.e. normally 1
333 } else {
334 wordwidth = map_bankwidth(map);
335 words_per_bus = 1;
336 }
337
338 chip_mode = map_bankwidth(map) / cfi_interleave(cfi);
339 chips_per_word = wordwidth * cfi_interleave(cfi) / map_bankwidth(map);
340
341 onestat = val.x[0];
342 /* Or all status words together */
343 for (i=1; i < words_per_bus; i++) {
344 onestat |= val.x[i];
345 }
346
347 res = onestat;
348 switch(chips_per_word) {
349 default: BUG();
350#if BITS_PER_LONG >= 64
351 case 8:
352 res |= (onestat >> (chip_mode * 32));
353#endif
354 case 4:
355 res |= (onestat >> (chip_mode * 16));
356 case 2:
357 res |= (onestat >> (chip_mode * 8));
358 case 1:
359 ;
360 }
361
362 /* Last, determine what the bit-pattern should be for a single
363 device, according to chip mode and endianness... */
364 switch (chip_mode) {
365 case 1:
366 break;
367 case 2:
368 res = cfi16_to_cpu(res);
369 break;
370 case 4:
371 res = cfi32_to_cpu(res);
372 break;
373 default: BUG();
374 }
375 return res;
376}
377
378#define MERGESTATUS(x) cfi_merge_status((x), map, cfi)
379
380
310/* 381/*
311 * Sends a CFI command to a bank of flash for the given geometry. 382 * Sends a CFI command to a bank of flash for the given geometry.
312 * 383 *
@@ -357,16 +428,6 @@ static inline void cfi_udelay(int us)
357 } 428 }
358} 429}
359 430
360static inline void cfi_spin_lock(spinlock_t *mutex)
361{
362 spin_lock_bh(mutex);
363}
364
365static inline void cfi_spin_unlock(spinlock_t *mutex)
366{
367 spin_unlock_bh(mutex);
368}
369
370struct cfi_extquery *cfi_read_pri(struct map_info *map, uint16_t adr, uint16_t size, 431struct cfi_extquery *cfi_read_pri(struct map_info *map, uint16_t adr, uint16_t size,
371 const char* name); 432 const char* name);
372struct cfi_fixup { 433struct cfi_fixup {