Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright © 2000      Red Hat UK Limited
0004  * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org>
0005  */
0006 
0007 #ifndef __MTD_FLASHCHIP_H__
0008 #define __MTD_FLASHCHIP_H__
0009 
0010 /* For spinlocks. sched.h includes spinlock.h from whichever directory it
0011  * happens to be in - so we don't have to care whether we're on 2.2, which
0012  * has asm/spinlock.h, or 2.4, which has linux/spinlock.h
0013  */
0014 #include <linux/sched.h>
0015 #include <linux/mutex.h>
0016 
0017 typedef enum {
0018     FL_READY,
0019     FL_STATUS,
0020     FL_CFI_QUERY,
0021     FL_JEDEC_QUERY,
0022     FL_ERASING,
0023     FL_ERASE_SUSPENDING,
0024     FL_ERASE_SUSPENDED,
0025     FL_WRITING,
0026     FL_WRITING_TO_BUFFER,
0027     FL_OTP_WRITE,
0028     FL_WRITE_SUSPENDING,
0029     FL_WRITE_SUSPENDED,
0030     FL_PM_SUSPENDED,
0031     FL_SYNCING,
0032     FL_UNLOADING,
0033     FL_LOCKING,
0034     FL_UNLOCKING,
0035     FL_POINT,
0036     FL_XIP_WHILE_ERASING,
0037     FL_XIP_WHILE_WRITING,
0038     FL_SHUTDOWN,
0039     /* These 2 come from nand_state_t, which has been unified here */
0040     FL_READING,
0041     FL_CACHEDPRG,
0042     /* These 4 come from onenand_state_t, which has been unified here */
0043     FL_RESETTING,
0044     FL_OTPING,
0045     FL_PREPARING_ERASE,
0046     FL_VERIFYING_ERASE,
0047 
0048     FL_UNKNOWN
0049 } flstate_t;
0050 
0051 
0052 
0053 /* NOTE: confusingly, this can be used to refer to more than one chip at a time,
0054    if they're interleaved.  This can even refer to individual partitions on
0055    the same physical chip when present. */
0056 
0057 struct flchip {
0058     unsigned long start; /* Offset within the map */
0059     //  unsigned long len;
0060     /* We omit len for now, because when we group them together
0061        we insist that they're all of the same size, and the chip size
0062        is held in the next level up. If we get more versatile later,
0063        it'll make it a damn sight harder to find which chip we want from
0064        a given offset, and we'll want to add the per-chip length field
0065        back in.
0066     */
0067     int ref_point_counter;
0068     flstate_t state;
0069     flstate_t oldstate;
0070 
0071     unsigned int write_suspended:1;
0072     unsigned int erase_suspended:1;
0073     unsigned long in_progress_block_addr;
0074     unsigned long in_progress_block_mask;
0075 
0076     struct mutex mutex;
0077     wait_queue_head_t wq; /* Wait on here when we're waiting for the chip
0078                  to be ready */
0079     int word_write_time;
0080     int buffer_write_time;
0081     int erase_time;
0082 
0083     int word_write_time_max;
0084     int buffer_write_time_max;
0085     int erase_time_max;
0086 
0087     void *priv;
0088 };
0089 
0090 /* This is used to handle contention on write/erase operations
0091    between partitions of the same physical chip. */
0092 struct flchip_shared {
0093     struct mutex lock;
0094     struct flchip *writing;
0095     struct flchip *erasing;
0096 };
0097 
0098 
0099 #endif /* __MTD_FLASHCHIP_H__ */