2 * linux/include/linux/mtd/onenand.h
4 * Copyright (C) 2005 Samsung Electronics
5 * Kyungmin Park <kyungmin.park@samsung.com>
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.
12 #ifndef __LINUX_MTD_ONENAND_H
13 #define __LINUX_MTD_ONENAND_H
15 #include <linux/spinlock.h>
16 #include <linux/mtd/onenand_regs.h>
17 #include <linux/mtd/bbm.h>
19 #define MAX_BUFFERRAM 2
21 /* Scan and identify a OneNAND device */
22 extern int onenand_scan(struct mtd_info
*mtd
, int max_chips
);
23 /* Free resources held by the OneNAND device */
24 extern void onenand_release(struct mtd_info
*mtd
);
27 * onenand_state_t - chip states
28 * Enumeration for OneNAND flash chip state
41 * struct onenand_bufferram - OneNAND BufferRAM Data
42 * @param block block address in BufferRAM
43 * @param page page address in BufferRAM
44 * @param valid valid flag
46 struct onenand_bufferram
{
53 * struct onenand_chip - OneNAND Private Flash Chip Data
54 * @param base [BOARDSPECIFIC] address to access OneNAND
55 * @param chipsize [INTERN] the size of one chip for multichip arrays
56 * @param device_id [INTERN] device ID
57 * @param verstion_id [INTERN] version ID
58 * @param options [BOARDSPECIFIC] various chip options. They can partly be set to inform onenand_scan about
59 * @param erase_shift [INTERN] number of address bits in a block
60 * @param page_shift [INTERN] number of address bits in a page
61 * @param ppb_shift [INTERN] number of address bits in a pages per block
62 * @param page_mask [INTERN] a page per block mask
63 * @param bufferam_index [INTERN] BufferRAM index
64 * @param bufferam [INTERN] BufferRAM info
65 * @param readw [REPLACEABLE] hardware specific function for read short
66 * @param writew [REPLACEABLE] hardware specific function for write short
67 * @param command [REPLACEABLE] hardware specific function for writing commands to the chip
68 * @param wait [REPLACEABLE] hardware specific function for wait on ready
69 * @param read_bufferram [REPLACEABLE] hardware specific function for BufferRAM Area
70 * @param write_bufferram [REPLACEABLE] hardware specific function for BufferRAM Area
71 * @param read_word [REPLACEABLE] hardware specific function for read register of OneNAND
72 * @param write_word [REPLACEABLE] hardware specific function for write register of OneNAND
73 * @param scan_bbt [REPLACEALBE] hardware specific function for scaning Bad block Table
74 * @param chip_lock [INTERN] spinlock used to protect access to this structure and the chip
75 * @param wq [INTERN] wait queue to sleep on if a OneNAND operation is in progress
76 * @param state [INTERN] the current state of the OneNAND device
77 * @param autooob [REPLACEABLE] the default (auto)placement scheme
78 * @param bbm [REPLACEABLE] pointer to Bad Block Management
79 * @param priv [OPTIONAL] pointer to private chip date
83 unsigned int chipsize
;
84 unsigned int device_id
;
87 unsigned int erase_shift
;
88 unsigned int page_shift
;
89 unsigned int ppb_shift
; /* Pages per block shift */
90 unsigned int page_mask
;
92 unsigned int bufferram_index
;
93 struct onenand_bufferram bufferram
[MAX_BUFFERRAM
];
95 int (*command
)(struct mtd_info
*mtd
, int cmd
, loff_t address
, size_t len
);
96 int (*wait
)(struct mtd_info
*mtd
, int state
);
97 int (*read_bufferram
)(struct mtd_info
*mtd
, int area
,
98 unsigned char *buffer
, int offset
, size_t count
);
99 int (*write_bufferram
)(struct mtd_info
*mtd
, int area
,
100 const unsigned char *buffer
, int offset
, size_t count
);
101 unsigned short (*read_word
)(void __iomem
*addr
);
102 void (*write_word
)(unsigned short value
, void __iomem
*addr
);
103 void (*mmcontrol
)(struct mtd_info
*mtd
, int sync_read
);
104 int (*block_markbad
)(struct mtd_info
*mtd
, loff_t ofs
);
105 int (*scan_bbt
)(struct mtd_info
*mtd
);
107 spinlock_t chip_lock
;
108 wait_queue_head_t wq
;
109 onenand_state_t state
;
111 struct nand_oobinfo
*autooob
;
121 #define ONENAND_CURRENT_BUFFERRAM(this) (this->bufferram_index)
122 #define ONENAND_NEXT_BUFFERRAM(this) (this->bufferram_index ^ 1)
123 #define ONENAND_SET_NEXT_BUFFERRAM(this) (this->bufferram_index ^= 1)
125 #define ONENAND_GET_SYS_CFG1(this) \
126 (this->read_word(this->base + ONENAND_REG_SYS_CFG1))
127 #define ONENAND_SET_SYS_CFG1(v, this) \
128 (this->write_word(v, this->base + ONENAND_REG_SYS_CFG1))
133 #define ONENAND_CONT_LOCK (0x0001)
137 * OneNAND Flash Manufacturer ID Codes
139 #define ONENAND_MFR_SAMSUNG 0xec
140 #define ONENAND_MFR_UNKNOWN 0x00
143 * struct nand_manufacturers - NAND Flash Manufacturer ID Structure
144 * @param name: Manufacturer name
145 * @param id: manufacturer ID code of device.
147 struct onenand_manufacturers
{
152 #endif /* __LINUX_MTD_ONENAND_H */