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. |
| 8 | * |
Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 9 | * $Id: flashchip.h,v 1.18 2005/11/07 11:14:54 gleixner Exp $ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 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 Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 18 | * has asm/spinlock.h, or 2.4, which has linux/spinlock.h |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | */ |
| 20 | #include <linux/sched.h> |
| 21 | |
Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 22 | typedef enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | 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 Pitre | f77814d | 2005-02-08 17:11:19 +0000 | [diff] [blame] | 32 | FL_OTP_WRITE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | 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, |
Kevin Hao | c4a9f88 | 2007-10-02 13:56:04 -0700 | [diff] [blame^] | 43 | FL_SHUTDOWN, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | FL_UNKNOWN |
| 45 | } flstate_t; |
| 46 | |
| 47 | |
| 48 | |
Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 49 | /* 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] | 50 | if they're interleaved. This can even refer to individual partitions on |
| 51 | the same physical chip when present. */ |
| 52 | |
| 53 | struct flchip { |
| 54 | unsigned long start; /* Offset within the map */ |
| 55 | // unsigned long len; |
| 56 | /* We omit len for now, because when we group them together |
| 57 | we insist that they're all of the same size, and the chip size |
| 58 | is held in the next level up. If we get more versatile later, |
| 59 | it'll make it a damn sight harder to find which chip we want from |
| 60 | a given offset, and we'll want to add the per-chip length field |
| 61 | back in. |
| 62 | */ |
| 63 | int ref_point_counter; |
| 64 | flstate_t state; |
| 65 | flstate_t oldstate; |
| 66 | |
Ben Dooks | 0514cd9 | 2005-03-14 18:27:18 +0000 | [diff] [blame] | 67 | unsigned int write_suspended:1; |
| 68 | unsigned int erase_suspended:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | unsigned long in_progress_block_addr; |
| 70 | |
| 71 | spinlock_t *mutex; |
| 72 | spinlock_t _spinlock; /* We do it like this because sometimes they'll be shared. */ |
| 73 | wait_queue_head_t wq; /* Wait on here when we're waiting for the chip |
| 74 | to be ready */ |
| 75 | int word_write_time; |
| 76 | int buffer_write_time; |
| 77 | int erase_time; |
| 78 | |
| 79 | void *priv; |
| 80 | }; |
| 81 | |
| 82 | /* This is used to handle contention on write/erase operations |
| 83 | between partitions of the same physical chip. */ |
| 84 | struct flchip_shared { |
| 85 | spinlock_t lock; |
| 86 | struct flchip *writing; |
| 87 | struct flchip *erasing; |
| 88 | }; |
| 89 | |
| 90 | |
| 91 | #endif /* __MTD_FLASHCHIP_H__ */ |