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(fast, addr, ndummy, buf, len) \ argument
69 SPI_MEM_OP_DATA_IN(len, buf, 1))
71 #define SPINAND_PAGE_READ_FROM_CACHE_OP_3A(fast, addr, ndummy, buf, len) \ argument
75 SPI_MEM_OP_DATA_IN(len, buf, 1))
77 #define SPINAND_PAGE_READ_FROM_CACHE_X2_OP(addr, ndummy, buf, len) \ argument
81 SPI_MEM_OP_DATA_IN(len, buf, 2))
83 #define SPINAND_PAGE_READ_FROM_CACHE_X2_OP_3A(addr, ndummy, buf, len) \ argument
87 SPI_MEM_OP_DATA_IN(len, buf, 2))
89 #define SPINAND_PAGE_READ_FROM_CACHE_X4_OP(addr, ndummy, buf, len) \ argument
93 SPI_MEM_OP_DATA_IN(len, buf, 4))
95 #define SPINAND_PAGE_READ_FROM_CACHE_X4_OP_3A(addr, ndummy, buf, len) \ argument
99 SPI_MEM_OP_DATA_IN(len, buf, 4))
101 #define SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(addr, ndummy, buf, len) \ argument
105 SPI_MEM_OP_DATA_IN(len, buf, 2))
107 #define SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP_3A(addr, ndummy, buf, len) \ argument
111 SPI_MEM_OP_DATA_IN(len, buf, 2))
113 #define SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(addr, ndummy, buf, len) \ argument
117 SPI_MEM_OP_DATA_IN(len, buf, 4))
119 #define SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP_3A(addr, ndummy, buf, len) \ argument
123 SPI_MEM_OP_DATA_IN(len, buf, 4))
125 #define SPINAND_PROG_EXEC_OP(addr) \
131 #define SPINAND_PROG_LOAD(reset, addr, buf, len) \ argument
135 SPI_MEM_OP_DATA_OUT(len, buf, 1))
137 #define SPINAND_PROG_LOAD_X4(reset, addr, buf, len) \ argument
141 SPI_MEM_OP_DATA_OUT(len, buf, 4))
146 #define SPINAND_CMD_PROG_LOAD_X4 0x32
147 #define SPINAND_CMD_PROG_LOAD_RDM_DATA_X4 0x34
150 #define REG_BLOCK_LOCK 0xa0
151 #define BL_ALL_UNLOCKED 0x00
154 #define REG_CFG 0xb0
155 #define CFG_OTP_ENABLE BIT(6)
156 #define CFG_ECC_ENABLE BIT(4)
157 #define CFG_QUAD_ENABLE BIT(0)
160 #define REG_STATUS 0xc0
161 #define STATUS_BUSY BIT(0)
162 #define STATUS_ERASE_FAILED BIT(2)
163 #define STATUS_PROG_FAILED BIT(3)
164 #define STATUS_ECC_MASK GENMASK(5, 4)
165 #define STATUS_ECC_NO_BITFLIPS (0 << 4)
166 #define STATUS_ECC_HAS_BITFLIPS (1 << 4)
167 #define STATUS_ECC_UNCOR_ERROR (2 << 4)
172 #define SPINAND_MAX_ID_LEN 5
185 #define SPINAND_READ_INITIAL_DELAY_US 6
186 #define SPINAND_READ_POLL_DELAY_US 5
187 #define SPINAND_RESET_INITIAL_DELAY_US 5
188 #define SPINAND_RESET_POLL_DELAY_US 5
189 #define SPINAND_WRITE_INITIAL_DELAY_US 75
190 #define SPINAND_WRITE_POLL_DELAY_US 15
191 #define SPINAND_ERASE_INITIAL_DELAY_US 250
192 #define SPINAND_ERASE_POLL_DELAY_US 50
194 #define SPINAND_WAITRDY_TIMEOUT_MS 400
197 * struct spinand_id - SPI NAND id structure
200 * @len: ID length
204 int len; member
214 * struct spinand_devid - SPI NAND device id structure
216 * @len: number of bytes in device id
222 * read_id opcode + 1-byte address.
228 const u8 len; member
233 * struct manufacurer_ops - SPI NAND manufacturer specific operations
246 * struct spinand_manufacturer - SPI NAND manufacturer instance
276 * struct spinand_op_variants - SPI NAND operation variants
280 * Some operations like read-from-cache/write-to-cache have several variants
281 * depending on the number of IO lines you use to transfer data or address
291 #define SPINAND_OP_VARIANTS(name, ...) \
299 * spinand_ecc_info - description of the on-die ECC implemented by a SPI NAND
302 * the number of corrected bitflips if correction was possible or
303 * -EBADMSG if there are uncorrectable errors. I can also return
306 * @ooblayout: the OOB layout used by the on-die ECC implementation
313 #define SPINAND_HAS_QE_BIT BIT(0)
314 #define SPINAND_HAS_CR_FEAT_BIT BIT(1)
315 #define SPINAND_HAS_PROG_PLANE_SELECT_BIT BIT(2)
316 #define SPINAND_HAS_READ_PLANE_SELECT_BIT BIT(3)
319 * struct spinand_ondie_ecc_conf - private SPI-NAND on-die ECC engine structure
321 * ->get_status() is not populated by the spinand device.
328 * struct spinand_info - Structure used to describe SPI NAND chips
331 * @flags: OR-ing of the SPINAND_XXX flags
334 * @eccinfo: on-die ECC info
336 * @op_variants.read_cache: variants of the read-cache operation
337 * @op_variants.write_cache: variants of the write-cache operation
338 * @op_variants.update_cache: variants of the update-cache operation
340 * multi-die chips
364 #define SPINAND_ID(__method, ...) \
367 .len = sizeof((u8[]){ __VA_ARGS__ }), \
371 #define SPINAND_INFO_OP_VARIANTS(__read, __write, __update) \
378 #define SPINAND_ECCINFO(__ooblayout, __get_status) \
384 #define SPINAND_SELECT_TARGET(__func) \
387 #define SPINAND_CONT_READ(__set_cont_read) \
390 #define SPINAND_INFO(__model, __id, __memorg, __eccreq, __op_variants, \
410 * struct spinand_device - SPI NAND device instance
421 * a command addressing a page or an eraseblock embedded in
424 * @eccinfo: on-die ECC information
429 * because the spi-mem interface explicitly requests that buffers
430 * passed in spi_mem_op be DMA-able, so we can't based the bufs on
435 * suitable to use or not in general with this chip/configuration.
436 * A per-transfer check must of course be done to ensure it is
475 * mtd_to_spinand() - Get the SPI NAND device attached to an MTD instance
486 * spinand_to_mtd() - Get the MTD device embedded in a SPI NAND device
493 return nanddev_to_mtd(&spinand->base); in spinand_to_mtd()
497 * nand_to_spinand() - Get the SPI NAND device embedding an NAND object
508 * spinand_to_nand() - Get the NAND device embedded in a SPI NAND object
516 return &spinand->base; in spinand_to_nand()
520 * spinand_set_of_node - Attach a DT node to a SPI NAND device
529 nanddev_set_of_node(&spinand->base, np); in spinand_set_of_node()