1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org>
4 * Steven J. Hill <sjhill@realitydiluted.com>
5 * Thomas Gleixner <tglx@linutronix.de>
7 * Contains all ONFI related definitions
10 #ifndef __LINUX_MTD_ONFI_H
11 #define __LINUX_MTD_ONFI_H
13 #include <linux/types.h>
15 /* ONFI version bits */
16 #define ONFI_VERSION_1_0 BIT(1)
17 #define ONFI_VERSION_2_0 BIT(2)
18 #define ONFI_VERSION_2_1 BIT(3)
19 #define ONFI_VERSION_2_2 BIT(4)
20 #define ONFI_VERSION_2_3 BIT(5)
21 #define ONFI_VERSION_3_0 BIT(6)
22 #define ONFI_VERSION_3_1 BIT(7)
23 #define ONFI_VERSION_3_2 BIT(8)
24 #define ONFI_VERSION_4_0 BIT(9)
27 #define ONFI_FEATURE_16_BIT_BUS (1 << 0)
28 #define ONFI_FEATURE_EXT_PARAM_PAGE (1 << 7)
30 /* ONFI timing mode, used in both asynchronous and synchronous mode */
31 #define ONFI_TIMING_MODE_0 (1 << 0)
32 #define ONFI_TIMING_MODE_1 (1 << 1)
33 #define ONFI_TIMING_MODE_2 (1 << 2)
34 #define ONFI_TIMING_MODE_3 (1 << 3)
35 #define ONFI_TIMING_MODE_4 (1 << 4)
36 #define ONFI_TIMING_MODE_5 (1 << 5)
37 #define ONFI_TIMING_MODE_UNKNOWN (1 << 6)
39 /* ONFI feature number/address */
40 #define ONFI_FEATURE_NUMBER 256
41 #define ONFI_FEATURE_ADDR_TIMING_MODE 0x1
43 /* Vendor-specific feature address (Micron) */
44 #define ONFI_FEATURE_ADDR_READ_RETRY 0x89
45 #define ONFI_FEATURE_ON_DIE_ECC 0x90
46 #define ONFI_FEATURE_ON_DIE_ECC_EN BIT(3)
48 /* ONFI subfeature parameters length */
49 #define ONFI_SUBFEATURE_PARAM_LEN 4
51 /* ONFI optional commands SET/GET FEATURES supported? */
52 #define ONFI_OPT_CMD_SET_GET_FEATURES (1 << 2)
54 struct nand_onfi_params {
55 /* rev info and features block */
62 __le16 ext_param_page_length; /* since ONFI 2.1 */
63 u8 num_of_param_pages; /* since ONFI 2.1 */
66 /* manufacturer information block */
67 char manufacturer[12];
73 /* memory organization block */
75 __le16 spare_bytes_per_page;
76 __le32 data_bytes_per_ppage;
77 __le16 spare_bytes_per_ppage;
78 __le32 pages_per_block;
79 __le32 blocks_per_lun;
84 __le16 block_endurance;
85 u8 guaranteed_good_blocks;
86 __le16 guaranteed_block_endurance;
94 /* electrical parameter block */
95 u8 io_pin_capacitance_max;
96 __le16 async_timing_mode;
97 __le16 program_cache_timing_mode;
102 __le16 src_sync_timing_mode;
103 u8 src_ssync_features;
104 __le16 clk_pin_capacitance_typ;
105 __le16 io_pin_capacitance_typ;
106 __le16 input_pin_capacitance_typ;
107 u8 input_pin_capacitance_max;
108 u8 driver_strength_support;
114 __le16 vendor_revision;
120 #define ONFI_CRC_BASE 0x4F4E
122 /* Extended ECC information Block Definition (since ONFI 2.1) */
123 struct onfi_ext_ecc_info {
127 __le16 block_endurance;
131 #define ONFI_SECTION_TYPE_0 0 /* Unused section. */
132 #define ONFI_SECTION_TYPE_1 1 /* for additional sections. */
133 #define ONFI_SECTION_TYPE_2 2 /* for ECC information. */
134 struct onfi_ext_section {
139 #define ONFI_EXT_SECTION_MAX 8
141 /* Extended Parameter Page Definition (since ONFI 2.1) */
142 struct onfi_ext_param_page {
144 u8 sig[4]; /* 'E' 'P' 'P' 'S' */
146 struct onfi_ext_section sections[ONFI_EXT_SECTION_MAX];
149 * The actual size of the Extended Parameter Page is in
150 * @ext_param_page_length of nand_onfi_params{}.
151 * The following are the variable length sections.
152 * So we do not add any fields below. Please see the ONFI spec.
157 * struct onfi_params - ONFI specific parameters that will be reused
158 * @version: ONFI version (BCD encoded), 0 if ONFI is not supported
159 * @tPROG: Page program time
160 * @tBERS: Block erase time
161 * @tR: Page read time
162 * @tCCS: Change column setup time
163 * @async_timing_mode: Supported asynchronous timing mode
164 * @vendor_revision: Vendor specific revision number
165 * @vendor: Vendor specific data
173 u16 async_timing_mode;
178 #endif /* __LINUX_MTD_ONFI_H */