]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/linux/mtd/onenand.h
c557caa24a6c80b18c379da5e8309fdcafad177a
[linux-2.6-omap-h63xx.git] / include / linux / mtd / onenand.h
1 /*
2  *  linux/include/linux/mtd/onenand.h
3  *
4  *  Copyright (C) 2005 Samsung Electronics
5  *  Kyungmin Park <kyungmin.park@samsung.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  */
11
12 #ifndef __LINUX_MTD_ONENAND_H
13 #define __LINUX_MTD_ONENAND_H
14
15 #include <linux/spinlock.h>
16 #include <linux/mtd/onenand_regs.h>
17
18 #define MAX_BUFFERRAM           2
19
20 /* Scan and identify a OneNAND device */
21 extern int onenand_scan(struct mtd_info *mtd, int max_chips);
22 /* Free resources held by the OneNAND device */
23 extern void onenand_release(struct mtd_info *mtd);
24
25 /**
26  * onenand_state_t - chip states
27  * Enumeration for OneNAND flash chip state
28  */
29 typedef enum {
30         FL_READY,
31         FL_READING,
32         FL_WRITING,
33         FL_ERASING,
34         FL_SYNCING,
35         FL_UNLOCKING,
36         FL_LOCKING,
37 } onenand_state_t;
38
39 /**
40  * struct onenand_bufferram - OneNAND BufferRAM Data
41  * @param block         block address in BufferRAM
42  * @param page          page address in BufferRAM
43  * @param valid         valid flag
44  */
45 struct onenand_bufferram {
46         int block;
47         int page;
48         int valid;
49 };
50
51 /**
52  * struct onenand_chip - OneNAND Private Flash Chip Data
53  * @param base          [BOARDSPECIFIC] address to access OneNAND
54  * @param chipsize      [INTERN] the size of one chip for multichip arrays
55  * @param device_id     [INTERN] device ID
56  * @param verstion_id   [INTERN] version ID
57  * @param options       [BOARDSPECIFIC] various chip options. They can partly be set to inform onenand_scan about
58  * @param erase_shift   [INTERN] number of address bits in a block
59  * @param page_shift    [INTERN] number of address bits in a page
60  * @param ppb_shift     [INTERN] number of address bits in a pages per block
61  * @param page_mask     [INTERN] a page per block mask
62  * @param bufferam_index        [INTERN] BufferRAM index
63  * @param bufferam      [INTERN] BufferRAM info
64  * @param readw         [REPLACEABLE] hardware specific function for read short
65  * @param writew        [REPLACEABLE] hardware specific function for write short
66  * @param command       [REPLACEABLE] hardware specific function for writing commands to the chip
67  * @param wait          [REPLACEABLE] hardware specific function for wait on ready
68  * @param read_bufferram        [REPLACEABLE] hardware specific function for BufferRAM Area
69  * @param write_bufferram       [REPLACEABLE] hardware specific function for BufferRAM Area
70  * @param chip_lock     [INTERN] spinlock used to protect access to this structure and the chip
71  * @param wq            [INTERN] wait queue to sleep on if a OneNAND operation is in progress
72  * @param state         [INTERN] the current state of the OneNAND device
73  * @param autooob       [REPLACEABLE] the default (auto)placement scheme
74  * @param priv          [OPTIONAL] pointer to private chip date
75  */
76 struct onenand_chip {
77         void __iomem            *base;
78         unsigned int            chipsize;
79         unsigned int            device_id;
80         unsigned int            options;
81
82         unsigned int            erase_shift;
83         unsigned int            page_shift;
84         unsigned int            ppb_shift;      /* Pages per block shift */
85         unsigned int            page_mask;
86
87         unsigned int            bufferram_index;
88         struct onenand_bufferram        bufferram[MAX_BUFFERRAM];
89
90         int (*command)(struct mtd_info *mtd, int cmd, loff_t address, size_t len);
91         int (*wait)(struct mtd_info *mtd, int state);
92         int (*read_bufferram)(struct mtd_info *mtd, int area,
93                         unsigned char *buffer, int offset, size_t count);
94         int (*write_bufferram)(struct mtd_info *mtd, int area,
95                         const unsigned char *buffer, int offset, size_t count);
96         unsigned short (*read_word)(void __iomem *addr);
97         void (*write_word)(unsigned short value, void __iomem *addr);
98         void (*mmcontrol)(struct mtd_info *mtd, int sync_read);
99
100         spinlock_t              chip_lock;
101         wait_queue_head_t       wq;
102         onenand_state_t         state;
103
104         struct nand_oobinfo     *autooob;
105
106         void                    *priv;
107 };
108
109 #define ONENAND_CURRENT_BUFFERRAM(this)         (this->bufferram_index)
110 #define ONENAND_NEXT_BUFFERRAM(this)            (this->bufferram_index ^ 1)
111 #define ONENAND_SET_NEXT_BUFFERRAM(this)        (this->bufferram_index ^= 1)
112
113 /*
114  * Options bits
115  */
116 #define ONENAND_CONT_LOCK               (0x0001)
117
118
119 /*
120  * OneNAND Flash Manufacturer ID Codes
121  */
122 #define ONENAND_MFR_SAMSUNG     0xec
123 #define ONENAND_MFR_UNKNOWN     0x00
124
125 /**
126  * struct nand_manufacturers - NAND Flash Manufacturer ID Structure
127  * @param name:         Manufacturer name
128  * @param id:           manufacturer ID code of device.
129 */
130 struct onenand_manufacturers {
131         int id;
132         char *name;
133 };
134
135 #endif  /* __LINUX_MTD_ONENAND_H */