Commit | Line | Data |
---|---|---|
1da177e4 | 1 | |
61ecfa87 | 2 | /* |
1da177e4 | 3 | * struct flchip definition |
61ecfa87 TG |
4 | * |
5 | * Contains information about the location and state of a given flash device | |
1da177e4 LT |
6 | * |
7 | * (C) 2000 Red Hat. GPLd. | |
1da177e4 LT |
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 | |
61ecfa87 | 15 | * has asm/spinlock.h, or 2.4, which has linux/spinlock.h |
1da177e4 LT |
16 | */ |
17 | #include <linux/sched.h> | |
c4e77376 | 18 | #include <linux/mutex.h> |
1da177e4 | 19 | |
61ecfa87 | 20 | typedef enum { |
1da177e4 LT |
21 | FL_READY, |
22 | FL_STATUS, | |
23 | FL_CFI_QUERY, | |
24 | FL_JEDEC_QUERY, | |
25 | FL_ERASING, | |
26 | FL_ERASE_SUSPENDING, | |
27 | FL_ERASE_SUSPENDED, | |
28 | FL_WRITING, | |
29 | FL_WRITING_TO_BUFFER, | |
f77814dd | 30 | FL_OTP_WRITE, |
1da177e4 LT |
31 | FL_WRITE_SUSPENDING, |
32 | FL_WRITE_SUSPENDED, | |
33 | FL_PM_SUSPENDED, | |
34 | FL_SYNCING, | |
35 | FL_UNLOADING, | |
36 | FL_LOCKING, | |
37 | FL_UNLOCKING, | |
38 | FL_POINT, | |
39 | FL_XIP_WHILE_ERASING, | |
40 | FL_XIP_WHILE_WRITING, | |
c4a9f88d | 41 | FL_SHUTDOWN, |
30631cb8 AR |
42 | /* These 2 come from nand_state_t, which has been unified here */ |
43 | FL_READING, | |
44 | FL_CACHEDPRG, | |
72073027 | 45 | /* These 4 come from onenand_state_t, which has been unified here */ |
30631cb8 AR |
46 | FL_RESETING, |
47 | FL_OTPING, | |
72073027 MK |
48 | FL_PREPARING_ERASE, |
49 | FL_VERIFYING_ERASE, | |
30631cb8 | 50 | |
1da177e4 LT |
51 | FL_UNKNOWN |
52 | } flstate_t; | |
53 | ||
54 | ||
55 | ||
61ecfa87 | 56 | /* NOTE: confusingly, this can be used to refer to more than one chip at a time, |
1da177e4 LT |
57 | if they're interleaved. This can even refer to individual partitions on |
58 | the same physical chip when present. */ | |
59 | ||
60 | struct flchip { | |
61 | unsigned long start; /* Offset within the map */ | |
62 | // unsigned long len; | |
63 | /* We omit len for now, because when we group them together | |
64 | we insist that they're all of the same size, and the chip size | |
65 | is held in the next level up. If we get more versatile later, | |
66 | it'll make it a damn sight harder to find which chip we want from | |
67 | a given offset, and we'll want to add the per-chip length field | |
68 | back in. | |
69 | */ | |
70 | int ref_point_counter; | |
71 | flstate_t state; | |
72 | flstate_t oldstate; | |
73 | ||
0514cd93 BD |
74 | unsigned int write_suspended:1; |
75 | unsigned int erase_suspended:1; | |
1da177e4 LT |
76 | unsigned long in_progress_block_addr; |
77 | ||
c4e77376 | 78 | struct mutex mutex; |
1da177e4 LT |
79 | wait_queue_head_t wq; /* Wait on here when we're waiting for the chip |
80 | to be ready */ | |
81 | int word_write_time; | |
82 | int buffer_write_time; | |
83 | int erase_time; | |
84 | ||
e93cafe4 AG |
85 | int word_write_time_max; |
86 | int buffer_write_time_max; | |
87 | int erase_time_max; | |
88 | ||
1da177e4 LT |
89 | void *priv; |
90 | }; | |
91 | ||
92 | /* This is used to handle contention on write/erase operations | |
93 | between partitions of the same physical chip. */ | |
94 | struct flchip_shared { | |
95 | spinlock_t lock; | |
96 | struct flchip *writing; | |
97 | struct flchip *erasing; | |
98 | }; | |
99 | ||
100 | ||
101 | #endif /* __MTD_FLASHCHIP_H__ */ |