blob: a293a3b78e05741ff372229959aee31fb5b5e834 [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.
8 *
Thomas Gleixner61ecfa82005-11-07 11:15:31 +00009 * $Id: flashchip.h,v 1.18 2005/11/07 11:14:54 gleixner Exp $
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 */
12
13#ifndef __MTD_FLASHCHIP_H__
14#define __MTD_FLASHCHIP_H__
15
16/* For spinlocks. sched.h includes spinlock.h from whichever directory it
17 * 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 +000018 * has asm/spinlock.h, or 2.4, which has linux/spinlock.h
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 */
20#include <linux/sched.h>
21
Thomas Gleixner61ecfa82005-11-07 11:15:31 +000022typedef enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 FL_READY,
24 FL_STATUS,
25 FL_CFI_QUERY,
26 FL_JEDEC_QUERY,
27 FL_ERASING,
28 FL_ERASE_SUSPENDING,
29 FL_ERASE_SUSPENDED,
30 FL_WRITING,
31 FL_WRITING_TO_BUFFER,
Nicolas Pitref77814d2005-02-08 17:11:19 +000032 FL_OTP_WRITE,
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 FL_WRITE_SUSPENDING,
34 FL_WRITE_SUSPENDED,
35 FL_PM_SUSPENDED,
36 FL_SYNCING,
37 FL_UNLOADING,
38 FL_LOCKING,
39 FL_UNLOCKING,
40 FL_POINT,
41 FL_XIP_WHILE_ERASING,
42 FL_XIP_WHILE_WRITING,
43 FL_UNKNOWN
44} flstate_t;
45
46
47
Thomas Gleixner61ecfa82005-11-07 11:15:31 +000048/* NOTE: confusingly, this can be used to refer to more than one chip at a time,
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 if they're interleaved. This can even refer to individual partitions on
50 the same physical chip when present. */
51
52struct flchip {
53 unsigned long start; /* Offset within the map */
54 // unsigned long len;
55 /* We omit len for now, because when we group them together
56 we insist that they're all of the same size, and the chip size
57 is held in the next level up. If we get more versatile later,
58 it'll make it a damn sight harder to find which chip we want from
59 a given offset, and we'll want to add the per-chip length field
60 back in.
61 */
62 int ref_point_counter;
63 flstate_t state;
64 flstate_t oldstate;
65
Ben Dooks0514cd92005-03-14 18:27:18 +000066 unsigned int write_suspended:1;
67 unsigned int erase_suspended:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 unsigned long in_progress_block_addr;
69
70 spinlock_t *mutex;
71 spinlock_t _spinlock; /* We do it like this because sometimes they'll be shared. */
72 wait_queue_head_t wq; /* Wait on here when we're waiting for the chip
73 to be ready */
74 int word_write_time;
75 int buffer_write_time;
76 int erase_time;
77
78 void *priv;
79};
80
81/* This is used to handle contention on write/erase operations
82 between partitions of the same physical chip. */
83struct flchip_shared {
84 spinlock_t lock;
85 struct flchip *writing;
86 struct flchip *erasing;
87};
88
89
90#endif /* __MTD_FLASHCHIP_H__ */