blob: d0bf422ae374a19ae41d81e41db3c1b60447d293 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001
Thomas Gleixner61ecfa82005-11-07 11:15:31 +00002/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * struct flchip definition
Thomas Gleixner61ecfa82005-11-07 11:15:31 +00004 *
5 * Contains information about the location and state of a given flash device
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * (C) 2000 Red Hat. GPLd.
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 */
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 Gleixner61ecfa82005-11-07 11:15:31 +000015 * has asm/spinlock.h, or 2.4, which has linux/spinlock.h
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 */
17#include <linux/sched.h>
18
Thomas Gleixner61ecfa82005-11-07 11:15:31 +000019typedef enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 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 Pitref77814d2005-02-08 17:11:19 +000029 FL_OTP_WRITE,
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 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 Haoc4a9f882007-10-02 13:56:04 -070040 FL_SHUTDOWN,
Alessandro Rubini30631cb2009-09-20 23:28:14 +020041 /* These 2 come from nand_state_t, which has been unified here */
42 FL_READING,
43 FL_CACHEDPRG,
Mika Korhonen72073022009-10-23 07:50:43 +020044 /* These 4 come from onenand_state_t, which has been unified here */
Alessandro Rubini30631cb2009-09-20 23:28:14 +020045 FL_RESETING,
46 FL_OTPING,
Mika Korhonen72073022009-10-23 07:50:43 +020047 FL_PREPARING_ERASE,
48 FL_VERIFYING_ERASE,
Alessandro Rubini30631cb2009-09-20 23:28:14 +020049
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 FL_UNKNOWN
51} flstate_t;
52
53
54
Thomas Gleixner61ecfa82005-11-07 11:15:31 +000055/* NOTE: confusingly, this can be used to refer to more than one chip at a time,
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 if they're interleaved. This can even refer to individual partitions on
57 the same physical chip when present. */
58
59struct flchip {
60 unsigned long start; /* Offset within the map */
61 // unsigned long len;
62 /* We omit len for now, because when we group them together
63 we insist that they're all of the same size, and the chip size
64 is held in the next level up. If we get more versatile later,
65 it'll make it a damn sight harder to find which chip we want from
66 a given offset, and we'll want to add the per-chip length field
67 back in.
68 */
69 int ref_point_counter;
70 flstate_t state;
71 flstate_t oldstate;
72
Ben Dooks0514cd92005-03-14 18:27:18 +000073 unsigned int write_suspended:1;
74 unsigned int erase_suspended:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 unsigned long in_progress_block_addr;
76
77 spinlock_t *mutex;
78 spinlock_t _spinlock; /* We do it like this because sometimes they'll be shared. */
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
Anders Grafströme93cafe2008-08-05 18:37:41 +020085 int word_write_time_max;
86 int buffer_write_time_max;
87 int erase_time_max;
88
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 void *priv;
90};
91
92/* This is used to handle contention on write/erase operations
93 between partitions of the same physical chip. */
94struct flchip_shared {
95 spinlock_t lock;
96 struct flchip *writing;
97 struct flchip *erasing;
98};
99
100
101#endif /* __MTD_FLASHCHIP_H__ */