aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKyungmin Park <kyungmin.park@samsung.com>2005-07-11 06:41:53 -0400
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-11-06 15:17:24 -0500
commitcd5f6346bc28a41375412b49b290d22ee4e4bbe8 (patch)
treee90e028e7319f2787fd8660d10d8455aba95ddc5 /include
parent4ce1f562189696605a84813cf71847c0cc698414 (diff)
[MTD] Add initial support for OneNAND flash chips
OneNAND is a new flash technology from Samsung with integrated SRAM buffers and logic interface. Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/linux/mtd/onenand.h134
-rw-r--r--include/linux/mtd/onenand_regs.h167
2 files changed, 301 insertions, 0 deletions
diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h
new file mode 100644
index 000000000000..b9a64117d646
--- /dev/null
+++ b/include/linux/mtd/onenand.h
@@ -0,0 +1,134 @@
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 */
21extern int onenand_scan(struct mtd_info *mtd, int max_chips);
22/* Free resources held by the OneNAND device */
23extern void onenand_release(struct mtd_info *mtd);
24
25/**
26 * onenand_state_t - chip states
27 * Enumeration for OneNAND flash chip state
28 */
29typedef 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 */
45struct 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 */
76struct 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
99 spinlock_t chip_lock;
100 wait_queue_head_t wq;
101 onenand_state_t state;
102
103 struct nand_oobinfo *autooob;
104
105 void *priv;
106};
107
108#define ONENAND_CURRENT_BUFFERRAM(this) (this->bufferram_index)
109#define ONENAND_NEXT_BUFFERRAM(this) (this->bufferram_index ^ 1)
110#define ONENAND_SET_NEXT_BUFFERRAM(this) (this->bufferram_index ^= 1)
111
112/*
113 * Options bits
114 */
115#define ONENAND_CONT_LOCK (0x0001)
116
117
118/*
119 * OneNAND Flash Manufacturer ID Codes
120 */
121#define ONENAND_MFR_SAMSUNG 0xec
122#define ONENAND_MFR_UNKNOWN 0x00
123
124/**
125 * struct nand_manufacturers - NAND Flash Manufacturer ID Structure
126 * @param name: Manufacturer name
127 * @param id: manufacturer ID code of device.
128*/
129struct onenand_manufacturers {
130 int id;
131 char *name;
132};
133
134#endif /* __LINUX_MTD_ONENAND_H */
diff --git a/include/linux/mtd/onenand_regs.h b/include/linux/mtd/onenand_regs.h
new file mode 100644
index 000000000000..4a2daad7d738
--- /dev/null
+++ b/include/linux/mtd/onenand_regs.h
@@ -0,0 +1,167 @@
1/*
2 * linux/include/linux/mtd/onenand_regs.h
3 *
4 * OneNAND Register header file
5 *
6 * Copyright (C) 2005 Samsung Electronics
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef __ONENAND_REG_H
14#define __ONENAND_REG_H
15
16/* Memory Address Map Translation (Word order) */
17#define ONENAND_MEMORY_MAP(x) ((x) << 1)
18
19/*
20 * External BufferRAM area
21 */
22#define ONENAND_BOOTRAM ONENAND_MEMORY_MAP(0x0000)
23#define ONENAND_DATARAM ONENAND_MEMORY_MAP(0x0200)
24#define ONENAND_SPARERAM ONENAND_MEMORY_MAP(0x8010)
25
26/*
27 * OneNAND Registers
28 */
29#define ONENAND_REG_MANUFACTURER_ID ONENAND_MEMORY_MAP(0xF000)
30#define ONENAND_REG_DEVICE_ID ONENAND_MEMORY_MAP(0xF001)
31#define ONENAND_REG_VERSION_ID ONENAND_MEMORY_MAP(0xF002)
32#define ONENAND_REG_DATA_BUFFER_SIZE ONENAND_MEMORY_MAP(0xF003)
33#define ONENAND_REG_BOOT_BUFFER_SIZE ONENAND_MEMORY_MAP(0xF004)
34#define ONENAND_REG_NUM_BUFFERS ONENAND_MEMORY_MAP(0xF005)
35#define ONENAND_REG_TECHNOLOGY ONENAND_MEMORY_MAP(0xF006)
36
37#define ONENAND_REG_START_ADDRESS1 ONENAND_MEMORY_MAP(0xF100)
38#define ONENAND_REG_START_ADDRESS2 ONENAND_MEMORY_MAP(0xF101)
39#define ONENAND_REG_START_ADDRESS3 ONENAND_MEMORY_MAP(0xF102)
40#define ONENAND_REG_START_ADDRESS4 ONENAND_MEMORY_MAP(0xF103)
41#define ONENAND_REG_START_ADDRESS5 ONENAND_MEMORY_MAP(0xF104)
42#define ONENAND_REG_START_ADDRESS6 ONENAND_MEMORY_MAP(0xF105)
43#define ONENAND_REG_START_ADDRESS7 ONENAND_MEMORY_MAP(0xF106)
44#define ONENAND_REG_START_ADDRESS8 ONENAND_MEMORY_MAP(0xF107)
45
46#define ONENAND_REG_START_BUFFER ONENAND_MEMORY_MAP(0xF200)
47#define ONENAND_REG_COMMAND ONENAND_MEMORY_MAP(0xF220)
48#define ONENAND_REG_SYS_CFG1 ONENAND_MEMORY_MAP(0xF221)
49#define ONENAND_REG_SYS_CFG2 ONENAND_MEMORY_MAP(0xF222)
50#define ONENAND_REG_CTRL_STATUS ONENAND_MEMORY_MAP(0xF240)
51#define ONENAND_REG_INTERRUPT ONENAND_MEMORY_MAP(0xF241)
52#define ONENAND_REG_START_BLOCK_ADDRESS ONENAND_MEMORY_MAP(0xF24C)
53#define ONENAND_REG_END_BLOCK_ADDRESS ONENAND_MEMORY_MAP(0xF24D)
54#define ONENAND_REG_WP_STATUS ONENAND_MEMORY_MAP(0xF24E)
55
56#define ONENAND_REG_ECC_STATUS ONENAND_MEMORY_MAP(0xFF00)
57#define ONENAND_REG_ECC_M0 ONENAND_MEMORY_MAP(0xFF01)
58#define ONENAND_REG_ECC_S0 ONENAND_MEMORY_MAP(0xFF02)
59#define ONENAND_REG_ECC_M1 ONENAND_MEMORY_MAP(0xFF03)
60#define ONENAND_REG_ECC_S1 ONENAND_MEMORY_MAP(0xFF04)
61#define ONENAND_REG_ECC_M2 ONENAND_MEMORY_MAP(0xFF05)
62#define ONENAND_REG_ECC_S2 ONENAND_MEMORY_MAP(0xFF06)
63#define ONENAND_REG_ECC_M3 ONENAND_MEMORY_MAP(0xFF07)
64#define ONENAND_REG_ECC_S3 ONENAND_MEMORY_MAP(0xFF08)
65
66/*
67 * Device ID Register F001h (R)
68 */
69#define ONENAND_DEVICE_DENSITY_SHIFT (4)
70#define ONENAND_DEVICE_IS_DDP (1 << 3)
71#define ONENAND_DEVICE_IS_DEMUX (1 << 2)
72#define ONENAND_DEVICE_VCC_MASK (0x3)
73
74#define ONENAND_DEVICE_DENSITY_512Mb (0x002)
75
76/*
77 * Version ID Register F002h (R)
78 */
79#define ONENAND_VERSION_PROCESS_SHIFT (8)
80
81/*
82 * Start Address 1 F100h (R/W)
83 */
84#define ONENAND_DDP_SHIFT (15)
85
86/*
87 * Start Address 8 F107h (R/W)
88 */
89#define ONENAND_FPA_MASK (0x3f)
90#define ONENAND_FPA_SHIFT (2)
91#define ONENAND_FSA_MASK (0x03)
92
93/*
94 * Start Buffer Register F200h (R/W)
95 */
96#define ONENAND_BSA_MASK (0x03)
97#define ONENAND_BSA_SHIFT (8)
98#define ONENAND_BSA_BOOTRAM (0 << 2)
99#define ONENAND_BSA_DATARAM0 (2 << 2)
100#define ONENAND_BSA_DATARAM1 (3 << 2)
101#define ONENAND_BSC_MASK (0x03)
102
103/*
104 * Command Register F220h (R/W)
105 */
106#define ONENAND_CMD_READ (0x00)
107#define ONENAND_CMD_READOOB (0x13)
108#define ONENAND_CMD_PROG (0x80)
109#define ONENAND_CMD_PROGOOB (0x1A)
110#define ONENAND_CMD_UNLOCK (0x23)
111#define ONENAND_CMD_LOCK (0x2A)
112#define ONENAND_CMD_LOCK_TIGHT (0x2C)
113#define ONENAND_CMD_ERASE (0x94)
114#define ONENAND_CMD_RESET (0xF0)
115#define ONENAND_CMD_READID (0x90)
116
117/* NOTE: Those are not *REAL* commands */
118#define ONENAND_CMD_BUFFERRAM (0x1978)
119
120/*
121 * System Configuration 1 Register F221h (R, R/W)
122 */
123#define ONENAND_SYS_CFG1_SYNC_READ (1 << 15)
124#define ONENAND_SYS_CFG1_BRL (1 << 12)
125#define ONENAND_SYS_CFG1_BL (1 << 9)
126#define ONENAND_SYS_CFG1_NO_ECC (1 << 8)
127#define ONENAND_SYS_CFG1_RDY (1 << 7)
128#define ONENAND_SYS_CFG1_INT (1 << 6)
129#define ONENAND_SYS_CFG1_IOBE (1 << 5)
130#define ONENAND_SYS_CFG1_RDY_CONF (1 << 4)
131
132/*
133 * Controller Status Register F240h (R)
134 */
135#define ONENAND_CTRL_ONGO (1 << 15)
136#define ONENAND_CTRL_LOCK (1 << 14)
137#define ONENAND_CTRL_LOAD (1 << 13)
138#define ONENAND_CTRL_PROGRAM (1 << 12)
139#define ONENAND_CTRL_ERASE (1 << 11)
140#define ONENAND_CTRL_ERROR (1 << 10)
141#define ONENAND_CTRL_RSTB (1 << 7)
142
143/*
144 * Interrupt Status Register F241h (R)
145 */
146#define ONENAND_INT_MASTER (1 << 15)
147#define ONENAND_INT_READ (1 << 7)
148#define ONENAND_INT_WRITE (1 << 6)
149#define ONENAND_INT_ERASE (1 << 5)
150#define ONENAND_INT_RESET (1 << 4)
151#define ONENAND_INT_CLEAR (0 << 0)
152
153/*
154 * NAND Flash Write Protection Status Register F24Eh (R)
155 */
156#define ONENAND_WP_US (1 << 2)
157#define ONENAND_WP_LS (1 << 1)
158#define ONENAND_WP_LTS (1 << 0)
159
160/*
161 * ECC Status Reigser FF00h (R)
162 */
163#define ONENAND_ECC_1BIT (1 << 0)
164#define ONENAND_ECC_2BIT (1 << 1)
165#define ONENAND_ECC_2BIT_ALL (0xAAAA)
166
167#endif /* __ONENAND_REG_H */