Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | |
Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * struct flchip definition |
Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 4 | * |
| 5 | * Contains information about the location and state of a given flash device |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
| 7 | * (C) 2000 Red Hat. GPLd. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef __MTD_FLASHCHIP_H__ |
| 11 | #define __MTD_FLASHCHIP_H__ |
| 12 | |
| 13 | /* For spinlocks. sched.h includes spinlock.h from whichever directory it |
| 14 | * happens to be in - so we don't have to care whether we're on 2.2, which |
Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 15 | * has asm/spinlock.h, or 2.4, which has linux/spinlock.h |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | */ |
| 17 | #include <linux/sched.h> |
| 18 | |
Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 19 | typedef enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | FL_READY, |
| 21 | FL_STATUS, |
| 22 | FL_CFI_QUERY, |
| 23 | FL_JEDEC_QUERY, |
| 24 | FL_ERASING, |
| 25 | FL_ERASE_SUSPENDING, |
| 26 | FL_ERASE_SUSPENDED, |
| 27 | FL_WRITING, |
| 28 | FL_WRITING_TO_BUFFER, |
Nicolas Pitre | f77814d | 2005-02-08 17:11:19 +0000 | [diff] [blame] | 29 | FL_OTP_WRITE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | FL_WRITE_SUSPENDING, |
| 31 | FL_WRITE_SUSPENDED, |
| 32 | FL_PM_SUSPENDED, |
| 33 | FL_SYNCING, |
| 34 | FL_UNLOADING, |
| 35 | FL_LOCKING, |
| 36 | FL_UNLOCKING, |
| 37 | FL_POINT, |
| 38 | FL_XIP_WHILE_ERASING, |
| 39 | FL_XIP_WHILE_WRITING, |
Kevin Hao | c4a9f88 | 2007-10-02 13:56:04 -0700 | [diff] [blame] | 40 | FL_SHUTDOWN, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | FL_UNKNOWN |
| 42 | } flstate_t; |
| 43 | |
| 44 | |
| 45 | |
Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 46 | /* NOTE: confusingly, this can be used to refer to more than one chip at a time, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | if they're interleaved. This can even refer to individual partitions on |
| 48 | the same physical chip when present. */ |
| 49 | |
| 50 | struct flchip { |
| 51 | unsigned long start; /* Offset within the map */ |
| 52 | // unsigned long len; |
| 53 | /* We omit len for now, because when we group them together |
| 54 | we insist that they're all of the same size, and the chip size |
| 55 | is held in the next level up. If we get more versatile later, |
| 56 | it'll make it a damn sight harder to find which chip we want from |
| 57 | a given offset, and we'll want to add the per-chip length field |
| 58 | back in. |
| 59 | */ |
| 60 | int ref_point_counter; |
| 61 | flstate_t state; |
| 62 | flstate_t oldstate; |
| 63 | |
Ben Dooks | 0514cd9 | 2005-03-14 18:27:18 +0000 | [diff] [blame] | 64 | unsigned int write_suspended:1; |
| 65 | unsigned int erase_suspended:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | unsigned long in_progress_block_addr; |
| 67 | |
| 68 | spinlock_t *mutex; |
| 69 | spinlock_t _spinlock; /* We do it like this because sometimes they'll be shared. */ |
| 70 | wait_queue_head_t wq; /* Wait on here when we're waiting for the chip |
| 71 | to be ready */ |
| 72 | int word_write_time; |
| 73 | int buffer_write_time; |
| 74 | int erase_time; |
| 75 | |
Anders Grafström | e93cafe | 2008-08-05 18:37:41 +0200 | [diff] [blame^] | 76 | int word_write_time_max; |
| 77 | int buffer_write_time_max; |
| 78 | int erase_time_max; |
| 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | void *priv; |
| 81 | }; |
| 82 | |
| 83 | /* This is used to handle contention on write/erase operations |
| 84 | between partitions of the same physical chip. */ |
| 85 | struct flchip_shared { |
| 86 | spinlock_t lock; |
| 87 | struct flchip *writing; |
| 88 | struct flchip *erasing; |
| 89 | }; |
| 90 | |
| 91 | |
| 92 | #endif /* __MTD_FLASHCHIP_H__ */ |