Lines Matching +full:len +full:- +full:or +full:- +full:define
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2016-2017 Micron Technology, Inc.
9 #define __LINUX_MTD_SPINAND_H
17 #include <linux/spi/spi-mem.h>
23 #define SPINAND_RESET_OP \
29 #define SPINAND_WR_EN_DIS_OP(enable) \
35 #define SPINAND_READID_OP(naddr, ndummy, buf, len) \ argument
39 SPI_MEM_OP_DATA_IN(len, buf, 1))
41 #define SPINAND_SET_FEATURE_OP(reg, valptr) \
47 #define SPINAND_GET_FEATURE_OP(reg, valptr) \
53 #define SPINAND_BLK_ERASE_OP(addr) \
59 #define SPINAND_PAGE_READ_OP(addr) \
65 #define SPINAND_PAGE_READ_FROM_CACHE_OP(addr, ndummy, buf, len, ...) \ argument
69 SPI_MEM_OP_DATA_IN(len, buf, 1), \
72 #define SPINAND_PAGE_READ_FROM_CACHE_FAST_OP(addr, ndummy, buf, len) \ argument
76 SPI_MEM_OP_DATA_IN(len, buf, 1))
78 #define SPINAND_PAGE_READ_FROM_CACHE_OP_3A(addr, ndummy, buf, len) \ argument
82 SPI_MEM_OP_DATA_IN(len, buf, 1))
84 #define SPINAND_PAGE_READ_FROM_CACHE_FAST_OP_3A(addr, ndummy, buf, len) \ argument
88 SPI_MEM_OP_DATA_IN(len, buf, 1))
90 #define SPINAND_PAGE_READ_FROM_CACHE_DTR_OP(addr, ndummy, buf, len, freq) \ argument
94 SPI_MEM_DTR_OP_DATA_IN(len, buf, 1), \
97 #define SPINAND_PAGE_READ_FROM_CACHE_X2_OP(addr, ndummy, buf, len) \ argument
101 SPI_MEM_OP_DATA_IN(len, buf, 2))
103 #define SPINAND_PAGE_READ_FROM_CACHE_X2_OP_3A(addr, ndummy, buf, len) \ argument
107 SPI_MEM_OP_DATA_IN(len, buf, 2))
109 #define SPINAND_PAGE_READ_FROM_CACHE_X2_DTR_OP(addr, ndummy, buf, len, freq) \ argument
113 SPI_MEM_DTR_OP_DATA_IN(len, buf, 2), \
116 #define SPINAND_PAGE_READ_FROM_CACHE_X4_OP(addr, ndummy, buf, len) \ argument
120 SPI_MEM_OP_DATA_IN(len, buf, 4))
122 #define SPINAND_PAGE_READ_FROM_CACHE_X4_OP_3A(addr, ndummy, buf, len) \ argument
126 SPI_MEM_OP_DATA_IN(len, buf, 4))
128 #define SPINAND_PAGE_READ_FROM_CACHE_X4_DTR_OP(addr, ndummy, buf, len, freq) \ argument
132 SPI_MEM_DTR_OP_DATA_IN(len, buf, 4), \
135 #define SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(addr, ndummy, buf, len) \ argument
139 SPI_MEM_OP_DATA_IN(len, buf, 2))
141 #define SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP_3A(addr, ndummy, buf, len) \ argument
145 SPI_MEM_OP_DATA_IN(len, buf, 2))
147 #define SPINAND_PAGE_READ_FROM_CACHE_DUALIO_DTR_OP(addr, ndummy, buf, len, freq) \ argument
151 SPI_MEM_DTR_OP_DATA_IN(len, buf, 2), \
154 #define SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(addr, ndummy, buf, len) \ argument
158 SPI_MEM_OP_DATA_IN(len, buf, 4))
160 #define SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP_3A(addr, ndummy, buf, len) \ argument
164 SPI_MEM_OP_DATA_IN(len, buf, 4))
166 #define SPINAND_PAGE_READ_FROM_CACHE_QUADIO_DTR_OP(addr, ndummy, buf, len, freq) \ argument
170 SPI_MEM_DTR_OP_DATA_IN(len, buf, 4), \
173 #define SPINAND_PROG_EXEC_OP(addr) \
179 #define SPINAND_PROG_LOAD(reset, addr, buf, len) \ argument
183 SPI_MEM_OP_DATA_OUT(len, buf, 1))
185 #define SPINAND_PROG_LOAD_X4(reset, addr, buf, len) \ argument
189 SPI_MEM_OP_DATA_OUT(len, buf, 4))
194 #define SPINAND_CMD_PROG_LOAD_X4 0x32
195 #define SPINAND_CMD_PROG_LOAD_RDM_DATA_X4 0x34
198 #define REG_BLOCK_LOCK 0xa0
199 #define BL_ALL_UNLOCKED 0x00
202 #define REG_CFG 0xb0
203 #define CFG_OTP_ENABLE BIT(6)
204 #define CFG_ECC_ENABLE BIT(4)
205 #define CFG_QUAD_ENABLE BIT(0)
208 #define REG_STATUS 0xc0
209 #define STATUS_BUSY BIT(0)
210 #define STATUS_ERASE_FAILED BIT(2)
211 #define STATUS_PROG_FAILED BIT(3)
212 #define STATUS_ECC_MASK GENMASK(5, 4)
213 #define STATUS_ECC_NO_BITFLIPS (0 << 4)
214 #define STATUS_ECC_HAS_BITFLIPS (1 << 4)
215 #define STATUS_ECC_UNCOR_ERROR (2 << 4)
220 #define SPINAND_MAX_ID_LEN 5
233 #define SPINAND_READ_INITIAL_DELAY_US 6
234 #define SPINAND_READ_POLL_DELAY_US 5
235 #define SPINAND_RESET_INITIAL_DELAY_US 5
236 #define SPINAND_RESET_POLL_DELAY_US 5
237 #define SPINAND_WRITE_INITIAL_DELAY_US 75
238 #define SPINAND_WRITE_POLL_DELAY_US 15
239 #define SPINAND_ERASE_INITIAL_DELAY_US 250
240 #define SPINAND_ERASE_POLL_DELAY_US 50
242 #define SPINAND_WAITRDY_TIMEOUT_MS 400
245 * struct spinand_id - SPI NAND id structure
248 * @len: ID length
252 int len; member
262 * struct spinand_devid - SPI NAND device id structure
264 * @len: number of bytes in device id
270 * read_id opcode + 1-byte address.
276 const u8 len; member
281 * struct manufacurer_ops - SPI NAND manufacturer specific operations
294 * struct spinand_manufacturer - SPI NAND manufacturer instance
325 * struct spinand_op_variants - SPI NAND operation variants
329 * Some operations like read-from-cache/write-to-cache have several variants
330 * depending on the number of IO lines you use to transfer data or address
340 #define SPINAND_OP_VARIANTS(name, ...) \
348 * spinand_ecc_info - description of the on-die ECC implemented by a SPI NAND
351 * the number of corrected bitflips if correction was possible or
352 * -EBADMSG if there are uncorrectable errors. I can also return
355 * @ooblayout: the OOB layout used by the on-die ECC implementation
362 #define SPINAND_HAS_QE_BIT BIT(0)
363 #define SPINAND_HAS_CR_FEAT_BIT BIT(1)
364 #define SPINAND_HAS_PROG_PLANE_SELECT_BIT BIT(2)
365 #define SPINAND_HAS_READ_PLANE_SELECT_BIT BIT(3)
366 #define SPINAND_NO_RAW_ACCESS BIT(4)
369 * struct spinand_ondie_ecc_conf - private SPI-NAND on-die ECC engine structure
371 * ->get_status() is not populated by the spinand device.
378 * struct spinand_info - Structure used to describe SPI NAND chips
381 * @flags: OR-ing of the SPINAND_XXX flags
384 * @eccinfo: on-die ECC info
386 * @op_variants.read_cache: variants of the read-cache operation
387 * @op_variants.write_cache: variants of the write-cache operation
388 * @op_variants.update_cache: variants of the update-cache operation
390 * multi-die chips
414 #define SPINAND_ID(__method, ...) \
417 .len = sizeof((u8[]){ __VA_ARGS__ }), \
421 #define SPINAND_INFO_OP_VARIANTS(__read, __write, __update) \
428 #define SPINAND_ECCINFO(__ooblayout, __get_status) \
434 #define SPINAND_SELECT_TARGET(__func) \
437 #define SPINAND_CONT_READ(__set_cont_read) \
440 #define SPINAND_INFO(__model, __id, __memorg, __eccreq, __op_variants, \
460 * struct spinand_device - SPI NAND device instance
471 * a command addressing a page or an eraseblock embedded in
474 * @eccinfo: on-die ECC information
479 * because the spi-mem interface explicitly requests that buffers
480 * passed in spi_mem_op be DMA-able, so we can't based the bufs on
485 * suitable to use or not in general with this chip/configuration.
486 * A per-transfer check must of course be done to ensure it is
525 * mtd_to_spinand() - Get the SPI NAND device attached to an MTD instance
536 * spinand_to_mtd() - Get the MTD device embedded in a SPI NAND device
543 return nanddev_to_mtd(&spinand->base); in spinand_to_mtd()
547 * nand_to_spinand() - Get the SPI NAND device embedding an NAND object
558 * spinand_to_nand() - Get the NAND device embedded in a SPI NAND object
566 return &spinand->base; in spinand_to_nand()
570 * spinand_set_of_node - Attach a DT node to a SPI NAND device
579 nanddev_set_of_node(&spinand->base, np); in spinand_set_of_node()