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>
14 #include <linux/bitfield.h>
16 /* ONFI version bits */
17 #define ONFI_VERSION_1_0 BIT(1)
18 #define ONFI_VERSION_2_0 BIT(2)
19 #define ONFI_VERSION_2_1 BIT(3)
20 #define ONFI_VERSION_2_2 BIT(4)
21 #define ONFI_VERSION_2_3 BIT(5)
22 #define ONFI_VERSION_3_0 BIT(6)
23 #define ONFI_VERSION_3_1 BIT(7)
24 #define ONFI_VERSION_3_2 BIT(8)
25 #define ONFI_VERSION_4_0 BIT(9)
28 #define ONFI_FEATURE_16_BIT_BUS BIT(0)
29 #define ONFI_FEATURE_NV_DDR BIT(5)
30 #define ONFI_FEATURE_EXT_PARAM_PAGE BIT(7)
32 /* ONFI timing mode, used in both asynchronous and synchronous mode */
33 #define ONFI_DATA_INTERFACE_SDR 0
34 #define ONFI_DATA_INTERFACE_NVDDR BIT(4)
35 #define ONFI_DATA_INTERFACE_NVDDR2 BIT(5)
36 #define ONFI_TIMING_MODE_0 BIT(0)
37 #define ONFI_TIMING_MODE_1 BIT(1)
38 #define ONFI_TIMING_MODE_2 BIT(2)
39 #define ONFI_TIMING_MODE_3 BIT(3)
40 #define ONFI_TIMING_MODE_4 BIT(4)
41 #define ONFI_TIMING_MODE_5 BIT(5)
42 #define ONFI_TIMING_MODE_UNKNOWN BIT(6)
43 #define ONFI_TIMING_MODE_PARAM(x) FIELD_GET(GENMASK(3, 0), (x))
45 /* ONFI feature number/address */
46 #define ONFI_FEATURE_NUMBER 256
47 #define ONFI_FEATURE_ADDR_TIMING_MODE 0x1
49 /* Vendor-specific feature address (Micron) */
50 #define ONFI_FEATURE_ADDR_READ_RETRY 0x89
51 #define ONFI_FEATURE_ON_DIE_ECC 0x90
52 #define ONFI_FEATURE_ON_DIE_ECC_EN BIT(3)
54 /* ONFI subfeature parameters length */
55 #define ONFI_SUBFEATURE_PARAM_LEN 4
57 /* ONFI optional commands SET/GET FEATURES supported? */
58 #define ONFI_OPT_CMD_READ_CACHE BIT(1)
59 #define ONFI_OPT_CMD_SET_GET_FEATURES BIT(2)
61 struct nand_onfi_params
{
62 /* rev info and features block */
69 __le16 ext_param_page_length
; /* since ONFI 2.1 */
70 u8 num_of_param_pages
; /* since ONFI 2.1 */
73 /* manufacturer information block */
74 char manufacturer
[12];
80 /* memory organization block */
82 __le16 spare_bytes_per_page
;
83 __le32 data_bytes_per_ppage
;
84 __le16 spare_bytes_per_ppage
;
85 __le32 pages_per_block
;
86 __le32 blocks_per_lun
;
91 __le16 block_endurance
;
92 u8 guaranteed_good_blocks
;
93 __le16 guaranteed_block_endurance
;
101 /* electrical parameter block */
102 u8 io_pin_capacitance_max
;
103 __le16 sdr_timing_modes
;
104 __le16 program_cache_timing_mode
;
109 u8 nvddr_timing_modes
;
110 u8 nvddr2_timing_modes
;
111 u8 nvddr_nvddr2_features
;
112 __le16 clk_pin_capacitance_typ
;
113 __le16 io_pin_capacitance_typ
;
114 __le16 input_pin_capacitance_typ
;
115 u8 input_pin_capacitance_max
;
116 u8 driver_strength_support
;
122 __le16 vendor_revision
;
128 #define ONFI_CRC_BASE 0x4F4E
130 /* Extended ECC information Block Definition (since ONFI 2.1) */
131 struct onfi_ext_ecc_info
{
135 __le16 block_endurance
;
139 #define ONFI_SECTION_TYPE_0 0 /* Unused section. */
140 #define ONFI_SECTION_TYPE_1 1 /* for additional sections. */
141 #define ONFI_SECTION_TYPE_2 2 /* for ECC information. */
142 struct onfi_ext_section
{
147 #define ONFI_EXT_SECTION_MAX 8
149 /* Extended Parameter Page Definition (since ONFI 2.1) */
150 struct onfi_ext_param_page
{
152 u8 sig
[4]; /* 'E' 'P' 'P' 'S' */
154 struct onfi_ext_section sections
[ONFI_EXT_SECTION_MAX
];
157 * The actual size of the Extended Parameter Page is in
158 * @ext_param_page_length of nand_onfi_params{}.
159 * The following are the variable length sections.
160 * So we do not add any fields below. Please see the ONFI spec.
165 * struct onfi_params - ONFI specific parameters that will be reused
166 * @version: ONFI version (BCD encoded), 0 if ONFI is not supported
167 * @tPROG: Page program time
168 * @tBERS: Block erase time
169 * @tR: Page read time
170 * @tCCS: Change column setup time
171 * @fast_tCAD: Command/Address/Data slow or fast delay (NV-DDR only)
172 * @sdr_timing_modes: Supported asynchronous/SDR timing modes
173 * @nvddr_timing_modes: Supported source synchronous/NV-DDR timing modes
174 * @vendor_revision: Vendor specific revision number
175 * @vendor: Vendor specific data
184 u16 sdr_timing_modes
;
185 u16 nvddr_timing_modes
;
190 #endif /* __LINUX_MTD_ONFI_H */