Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 1 | /* |
David Woodhouse | a1452a3 | 2010-08-08 20:58:20 +0100 | [diff] [blame] | 2 | * Copyright © 2000 Red Hat UK Limited |
| 3 | * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org> |
Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 4 | * |
David Woodhouse | a1452a3 | 2010-08-08 20:58:20 +0100 | [diff] [blame] | 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * |
David Woodhouse | a1452a3 | 2010-08-08 20:58:20 +0100 | [diff] [blame] | 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #ifndef __MTD_FLASHCHIP_H__ |
| 22 | #define __MTD_FLASHCHIP_H__ |
| 23 | |
| 24 | /* For spinlocks. sched.h includes spinlock.h from whichever directory it |
| 25 | * 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] | 26 | * has asm/spinlock.h, or 2.4, which has linux/spinlock.h |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | */ |
| 28 | #include <linux/sched.h> |
Stefani Seibold | c4e7737 | 2010-04-18 22:46:44 +0200 | [diff] [blame] | 29 | #include <linux/mutex.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 31 | typedef enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | FL_READY, |
| 33 | FL_STATUS, |
| 34 | FL_CFI_QUERY, |
| 35 | FL_JEDEC_QUERY, |
| 36 | FL_ERASING, |
| 37 | FL_ERASE_SUSPENDING, |
| 38 | FL_ERASE_SUSPENDED, |
| 39 | FL_WRITING, |
| 40 | FL_WRITING_TO_BUFFER, |
Nicolas Pitre | f77814d | 2005-02-08 17:11:19 +0000 | [diff] [blame] | 41 | FL_OTP_WRITE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | FL_WRITE_SUSPENDING, |
| 43 | FL_WRITE_SUSPENDED, |
| 44 | FL_PM_SUSPENDED, |
| 45 | FL_SYNCING, |
| 46 | FL_UNLOADING, |
| 47 | FL_LOCKING, |
| 48 | FL_UNLOCKING, |
| 49 | FL_POINT, |
| 50 | FL_XIP_WHILE_ERASING, |
| 51 | FL_XIP_WHILE_WRITING, |
Kevin Hao | c4a9f88 | 2007-10-02 13:56:04 -0700 | [diff] [blame] | 52 | FL_SHUTDOWN, |
Alessandro Rubini | 30631cb | 2009-09-20 23:28:14 +0200 | [diff] [blame] | 53 | /* These 2 come from nand_state_t, which has been unified here */ |
| 54 | FL_READING, |
| 55 | FL_CACHEDPRG, |
Mika Korhonen | 7207302 | 2009-10-23 07:50:43 +0200 | [diff] [blame] | 56 | /* These 4 come from onenand_state_t, which has been unified here */ |
Alessandro Rubini | 30631cb | 2009-09-20 23:28:14 +0200 | [diff] [blame] | 57 | FL_RESETING, |
| 58 | FL_OTPING, |
Mika Korhonen | 7207302 | 2009-10-23 07:50:43 +0200 | [diff] [blame] | 59 | FL_PREPARING_ERASE, |
| 60 | FL_VERIFYING_ERASE, |
Alessandro Rubini | 30631cb | 2009-09-20 23:28:14 +0200 | [diff] [blame] | 61 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | FL_UNKNOWN |
| 63 | } flstate_t; |
| 64 | |
| 65 | |
| 66 | |
Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 67 | /* 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] | 68 | if they're interleaved. This can even refer to individual partitions on |
| 69 | the same physical chip when present. */ |
| 70 | |
| 71 | struct flchip { |
| 72 | unsigned long start; /* Offset within the map */ |
| 73 | // unsigned long len; |
| 74 | /* We omit len for now, because when we group them together |
| 75 | we insist that they're all of the same size, and the chip size |
| 76 | is held in the next level up. If we get more versatile later, |
| 77 | it'll make it a damn sight harder to find which chip we want from |
| 78 | a given offset, and we'll want to add the per-chip length field |
| 79 | back in. |
| 80 | */ |
| 81 | int ref_point_counter; |
| 82 | flstate_t state; |
| 83 | flstate_t oldstate; |
| 84 | |
Ben Dooks | 0514cd9 | 2005-03-14 18:27:18 +0000 | [diff] [blame] | 85 | unsigned int write_suspended:1; |
| 86 | unsigned int erase_suspended:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | unsigned long in_progress_block_addr; |
| 88 | |
Stefani Seibold | c4e7737 | 2010-04-18 22:46:44 +0200 | [diff] [blame] | 89 | struct mutex mutex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | wait_queue_head_t wq; /* Wait on here when we're waiting for the chip |
| 91 | to be ready */ |
| 92 | int word_write_time; |
| 93 | int buffer_write_time; |
| 94 | int erase_time; |
| 95 | |
Anders Grafström | e93cafe | 2008-08-05 18:37:41 +0200 | [diff] [blame] | 96 | int word_write_time_max; |
| 97 | int buffer_write_time_max; |
| 98 | int erase_time_max; |
| 99 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | void *priv; |
| 101 | }; |
| 102 | |
| 103 | /* This is used to handle contention on write/erase operations |
| 104 | between partitions of the same physical chip. */ |
| 105 | struct flchip_shared { |
Stefani Seibold | 8ae6641 | 2010-08-05 09:19:26 +0200 | [diff] [blame] | 106 | struct mutex lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | struct flchip *writing; |
| 108 | struct flchip *erasing; |
| 109 | }; |
| 110 | |
| 111 | |
| 112 | #endif /* __MTD_FLASHCHIP_H__ */ |