| 1 |
// SPDX-License-Identifier: GPL-2.0 |
| 2 |
/* |
| 3 |
* Copyright (c) 2018 Macronix |
| 4 |
* |
| 5 |
* Author: Boris Brezillon <[email protected]> |
| 6 |
*/ |
| 7 |
|
| 8 |
#include <linux/bitfield.h> |
| 9 |
#include <linux/device.h> |
| 10 |
#include <linux/kernel.h> |
| 11 |
#include <linux/mtd/spinand.h> |
| 12 |
|
| 13 |
#define SPINAND_MFR_MACRONIX 0xC2 |
| 14 |
#define MACRONIX_ECCSR_BF_LAST_PAGE(eccsr) FIELD_GET(GENMASK(3, 0), eccsr) |
| 15 |
#define MACRONIX_ECCSR_BF_ACCUMULATED_PAGES(eccsr) FIELD_GET(GENMASK(7, 4), eccsr) |
| 16 |
#define MACRONIX_CFG_CONT_READ BIT(2) |
| 17 |
#define MACRONIX_FEATURE_ADDR_READ_RETRY 0x70 |
| 18 |
#define MACRONIX_NUM_READ_RETRY_MODES 5 |
| 19 |
|
| 20 |
#define STATUS_ECC_HAS_BITFLIPS_THRESHOLD (3 << 4) |
| 21 |
|
| 22 |
/* Bitflip theshold configuration register */ |
| 23 |
#define REG_CFG_BFT 0x10 |
| 24 |
#define CFG_BFT(x) FIELD_PREP(GENMASK(7, 4), (x)) |
| 25 |
|
| 26 |
struct macronix_priv { |
| 27 |
bool cont_read; |
| 28 |
}; |
| 29 |
|
| 30 |
static SPINAND_OP_VARIANTS(read_cache_variants, |
| 31 |
SPINAND_PAGE_READ_FROM_CACHE_1S_1S_4S_OP(0, 1, NULL, 0, 0), |
| 32 |
SPINAND_PAGE_READ_FROM_CACHE_1S_1S_2S_OP(0, 1, NULL, 0, 0), |
| 33 |
SPINAND_PAGE_READ_FROM_CACHE_FAST_1S_1S_1S_OP(0, 1, NULL, 0, 0), |
| 34 |
SPINAND_PAGE_READ_FROM_CACHE_1S_1S_1S_OP(0, 1, NULL, 0, 0)); |
| 35 |
|
| 36 |
static SPINAND_OP_VARIANTS(write_cache_variants, |
| 37 |
SPINAND_PROG_LOAD_1S_1S_4S_OP(true, 0, NULL, 0), |
| 38 |
SPINAND_PROG_LOAD_1S_1S_1S_OP(false, 0, NULL, 0)); |
| 39 |
|
| 40 |
static SPINAND_OP_VARIANTS(update_cache_variants, |
| 41 |
SPINAND_PROG_LOAD_1S_1S_4S_OP(false, 0, NULL, 0), |
| 42 |
SPINAND_PROG_LOAD_1S_1S_1S_OP(false, 0, NULL, 0)); |
| 43 |
|
| 44 |
#define SPINAND_MACRONIX_READ_ECCSR_1S_0_1S(buf) \ |
| 45 |
SPI_MEM_OP(SPI_MEM_OP_CMD(0x7c, 1), \ |
| 46 |
SPI_MEM_OP_NO_ADDR, \ |
| 47 |
SPI_MEM_OP_DUMMY(1, 1), \ |
| 48 |
SPI_MEM_OP_DATA_IN(1, buf, 1)) |
| 49 |
|
| 50 |
static SPINAND_OP_VARIANTS(macronix_ops, |
| 51 |
SPINAND_MACRONIX_READ_ECCSR_1S_0_1S(NULL)); |
| 52 |
|
| 53 |
static struct spi_mem_op |
| 54 |
spinand_fill_macronix_read_eccsr_op(struct spinand_device *spinand, void *valptr) |
| 55 |
{ |
| 56 |
WARN_ON_ONCE(spinand->bus_iface != SSDR); |
| 57 |
|
| 58 |
return (struct spi_mem_op)SPINAND_MACRONIX_READ_ECCSR_1S_0_1S(valptr); |
| 59 |
} |
| 60 |
|
| 61 |
static int mx35lfxge4ab_ooblayout_ecc(struct mtd_info *mtd, int section, |
| 62 |
struct mtd_oob_region *region) |
| 63 |
{ |
| 64 |
return -ERANGE; |
| 65 |
} |
| 66 |
|
| 67 |
static int mx35lfxge4ab_ooblayout_free(struct mtd_info *mtd, int section, |
| 68 |
struct mtd_oob_region *region) |
| 69 |
{ |
| 70 |
if (section) |
| 71 |
return -ERANGE; |
| 72 |
|
| 73 |
region->offset = 2; |
| 74 |
region->length = mtd->oobsize - 2; |
| 75 |
|
| 76 |
return 0; |
| 77 |
} |
| 78 |
|
| 79 |
static const struct mtd_ooblayout_ops mx35lfxge4ab_ooblayout = { |
| 80 |
.ecc = mx35lfxge4ab_ooblayout_ecc, |
| 81 |
.free = mx35lfxge4ab_ooblayout_free, |
| 82 |
}; |
| 83 |
|
| 84 |
static int macronix_get_eccsr(struct spinand_device *spinand, u8 *eccsr) |
| 85 |
{ |
| 86 |
struct macronix_priv *priv = spinand->priv; |
| 87 |
struct spi_mem_op op = SPINAND_OP(spinand, macronix_read_eccsr, eccsr); |
| 88 |
int ret; |
| 89 |
|
| 90 |
ret = spi_mem_exec_op(spinand->spimem, &op); |
| 91 |
if (ret) |
| 92 |
return ret; |
| 93 |
|
| 94 |
/* |
| 95 |
* ECCSR exposes the number of bitflips for the last read page in bits [3:0]. |
| 96 |
* Continuous read compatible chips also expose the maximum number of |
| 97 |
* bitflips for the whole (continuous) read operation in bits [7:4]. |
| 98 |
*/ |
| 99 |
if (!priv->cont_read) |
| 100 |
*eccsr = MACRONIX_ECCSR_BF_LAST_PAGE(*eccsr); |
| 101 |
else |
| 102 |
*eccsr = MACRONIX_ECCSR_BF_ACCUMULATED_PAGES(*eccsr); |
| 103 |
|
| 104 |
return 0; |
| 105 |
} |
| 106 |
|
| 107 |
static int macronix_ecc_get_status(struct spinand_device *spinand, |
| 108 |
u8 status) |
| 109 |
{ |
| 110 |
struct nand_device *nand = spinand_to_nand(spinand); |
| 111 |
u8 eccsr; |
| 112 |
|
| 113 |
switch (status & STATUS_ECC_MASK) { |
| 114 |
case STATUS_ECC_NO_BITFLIPS: |
| 115 |
return 0; |
| 116 |
|
| 117 |
case STATUS_ECC_UNCOR_ERROR: |
| 118 |
return -EBADMSG; |
| 119 |
|
| 120 |
case STATUS_ECC_HAS_BITFLIPS: |
| 121 |
/* |
| 122 |
* Let's try to retrieve the real maximum number of bitflips |
| 123 |
* in order to avoid forcing the wear-leveling layer to move |
| 124 |
* data around if it's not necessary. |
| 125 |
*/ |
| 126 |
if (macronix_get_eccsr(spinand, spinand->scratchbuf)) |
| 127 |
return nanddev_get_ecc_conf(nand)->strength; |
| 128 |
|
| 129 |
eccsr = *spinand->scratchbuf; |
| 130 |
if (WARN_ON(eccsr > nanddev_get_ecc_conf(nand)->strength || !eccsr)) |
| 131 |
return nanddev_get_ecc_conf(nand)->strength; |
| 132 |
|
| 133 |
return eccsr; |
| 134 |
default: |
| 135 |
break; |
| 136 |
} |
| 137 |
|
| 138 |
return -EINVAL; |
| 139 |
} |
| 140 |
|
| 141 |
static int macronix_set_cont_read(struct spinand_device *spinand, bool enable) |
| 142 |
{ |
| 143 |
struct macronix_priv *priv = spinand->priv; |
| 144 |
int ret; |
| 145 |
|
| 146 |
ret = spinand_upd_cfg(spinand, MACRONIX_CFG_CONT_READ, |
| 147 |
enable ? MACRONIX_CFG_CONT_READ : 0); |
| 148 |
if (ret) |
| 149 |
return ret; |
| 150 |
|
| 151 |
priv->cont_read = enable; |
| 152 |
|
| 153 |
return 0; |
| 154 |
} |
| 155 |
|
| 156 |
/** |
| 157 |
* macronix_set_read_retry - Set the retry mode |
| 158 |
* @spinand: SPI NAND device |
| 159 |
* @retry_mode: Specify which retry mode to set |
| 160 |
* |
| 161 |
* Return: 0 on success, a negative error code otherwise. |
| 162 |
*/ |
| 163 |
static int macronix_set_read_retry(struct spinand_device *spinand, |
| 164 |
unsigned int retry_mode) |
| 165 |
{ |
| 166 |
struct spi_mem_op op = SPINAND_OP(spinand, set_feature, |
| 167 |
MACRONIX_FEATURE_ADDR_READ_RETRY, spinand->scratchbuf); |
| 168 |
|
| 169 |
*spinand->scratchbuf = retry_mode; |
| 170 |
return spi_mem_exec_op(spinand->spimem, &op); |
| 171 |
} |
| 172 |
|
| 173 |
static const struct spinand_info macronix_spinand_table[] = { |
| 174 |
SPINAND_INFO("MX35LF1GE4AB", |
| 175 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x12), |
| 176 |
NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), |
| 177 |
NAND_ECCREQ(4, 512), |
| 178 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 179 |
&write_cache_variants, |
| 180 |
&update_cache_variants), |
| 181 |
SPINAND_HAS_QE_BIT, |
| 182 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 183 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 184 |
macronix_ecc_get_status)), |
| 185 |
SPINAND_INFO("MX35LF2GE4AB", |
| 186 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x22), |
| 187 |
NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 2, 1, 1), |
| 188 |
NAND_ECCREQ(4, 512), |
| 189 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 190 |
&write_cache_variants, |
| 191 |
&update_cache_variants), |
| 192 |
SPINAND_HAS_QE_BIT | |
| 193 |
SPINAND_HAS_PROG_PLANE_SELECT_BIT | |
| 194 |
SPINAND_HAS_READ_PLANE_SELECT_BIT, |
| 195 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), |
| 196 |
SPINAND_INFO("MX35LF2GE4AD", |
| 197 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x26, 0x03), |
| 198 |
NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 1, 1, 1), |
| 199 |
NAND_ECCREQ(8, 512), |
| 200 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 201 |
&write_cache_variants, |
| 202 |
&update_cache_variants), |
| 203 |
SPINAND_HAS_QE_BIT, |
| 204 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 205 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 206 |
macronix_ecc_get_status), |
| 207 |
SPINAND_CONT_READ(macronix_set_cont_read), |
| 208 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 209 |
macronix_set_read_retry)), |
| 210 |
SPINAND_INFO("MX35LF4GE4AD", |
| 211 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x37, 0x03), |
| 212 |
NAND_MEMORG(1, 4096, 128, 64, 2048, 40, 1, 1, 1), |
| 213 |
NAND_ECCREQ(8, 512), |
| 214 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 215 |
&write_cache_variants, |
| 216 |
&update_cache_variants), |
| 217 |
SPINAND_HAS_QE_BIT, |
| 218 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 219 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 220 |
macronix_ecc_get_status), |
| 221 |
SPINAND_CONT_READ(macronix_set_cont_read), |
| 222 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 223 |
macronix_set_read_retry)), |
| 224 |
SPINAND_INFO("MX35LF1G24AD", |
| 225 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14, 0x03), |
| 226 |
NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1), |
| 227 |
NAND_ECCREQ(8, 512), |
| 228 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 229 |
&write_cache_variants, |
| 230 |
&update_cache_variants), |
| 231 |
SPINAND_HAS_QE_BIT, |
| 232 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL), |
| 233 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 234 |
macronix_set_read_retry)), |
| 235 |
SPINAND_INFO("MX35LF2G24AD", |
| 236 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x24, 0x03), |
| 237 |
NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1), |
| 238 |
NAND_ECCREQ(8, 512), |
| 239 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 240 |
&write_cache_variants, |
| 241 |
&update_cache_variants), |
| 242 |
SPINAND_HAS_QE_BIT | |
| 243 |
SPINAND_HAS_PROG_PLANE_SELECT_BIT, |
| 244 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL), |
| 245 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 246 |
macronix_set_read_retry)), |
| 247 |
SPINAND_INFO("MX35LF2G24AD-Z4I8", |
| 248 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x64, 0x03), |
| 249 |
NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1), |
| 250 |
NAND_ECCREQ(8, 512), |
| 251 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 252 |
&write_cache_variants, |
| 253 |
&update_cache_variants), |
| 254 |
SPINAND_HAS_QE_BIT, |
| 255 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL), |
| 256 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 257 |
macronix_set_read_retry)), |
| 258 |
SPINAND_INFO("MX35LF4G24AD", |
| 259 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35, 0x03), |
| 260 |
NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 2, 1, 1), |
| 261 |
NAND_ECCREQ(8, 512), |
| 262 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 263 |
&write_cache_variants, |
| 264 |
&update_cache_variants), |
| 265 |
SPINAND_HAS_QE_BIT | |
| 266 |
SPINAND_HAS_PROG_PLANE_SELECT_BIT, |
| 267 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL), |
| 268 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 269 |
macronix_set_read_retry)), |
| 270 |
SPINAND_INFO("MX35LF4G24AD-Z4I8", |
| 271 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x75, 0x03), |
| 272 |
NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1), |
| 273 |
NAND_ECCREQ(8, 512), |
| 274 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 275 |
&write_cache_variants, |
| 276 |
&update_cache_variants), |
| 277 |
SPINAND_HAS_QE_BIT, |
| 278 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL), |
| 279 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 280 |
macronix_set_read_retry)), |
| 281 |
SPINAND_INFO("MX31LF1GE4BC", |
| 282 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x1e), |
| 283 |
NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), |
| 284 |
NAND_ECCREQ(8, 512), |
| 285 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 286 |
&write_cache_variants, |
| 287 |
&update_cache_variants), |
| 288 |
SPINAND_HAS_QE_BIT, |
| 289 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 290 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 291 |
macronix_ecc_get_status)), |
| 292 |
SPINAND_INFO("MX31UF1GE4BC", |
| 293 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x9e), |
| 294 |
NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), |
| 295 |
NAND_ECCREQ(8, 512), |
| 296 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 297 |
&write_cache_variants, |
| 298 |
&update_cache_variants), |
| 299 |
SPINAND_HAS_QE_BIT, |
| 300 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 301 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 302 |
macronix_ecc_get_status)), |
| 303 |
|
| 304 |
SPINAND_INFO("MX35LF2G14AC", |
| 305 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x20), |
| 306 |
NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 2, 1, 1), |
| 307 |
NAND_ECCREQ(4, 512), |
| 308 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 309 |
&write_cache_variants, |
| 310 |
&update_cache_variants), |
| 311 |
SPINAND_HAS_QE_BIT | |
| 312 |
SPINAND_HAS_PROG_PLANE_SELECT_BIT | |
| 313 |
SPINAND_HAS_READ_PLANE_SELECT_BIT, |
| 314 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 315 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 316 |
macronix_ecc_get_status)), |
| 317 |
SPINAND_INFO("MX35UF4G24AD", |
| 318 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xb5, 0x03), |
| 319 |
NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 2, 1, 1), |
| 320 |
NAND_ECCREQ(8, 512), |
| 321 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 322 |
&write_cache_variants, |
| 323 |
&update_cache_variants), |
| 324 |
SPINAND_HAS_QE_BIT | |
| 325 |
SPINAND_HAS_PROG_PLANE_SELECT_BIT, |
| 326 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 327 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 328 |
macronix_ecc_get_status), |
| 329 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 330 |
macronix_set_read_retry)), |
| 331 |
SPINAND_INFO("MX35UF4G24AD-Z4I8", |
| 332 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xf5, 0x03), |
| 333 |
NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1), |
| 334 |
NAND_ECCREQ(8, 512), |
| 335 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 336 |
&write_cache_variants, |
| 337 |
&update_cache_variants), |
| 338 |
SPINAND_HAS_QE_BIT, |
| 339 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 340 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 341 |
macronix_ecc_get_status), |
| 342 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 343 |
macronix_set_read_retry)), |
| 344 |
SPINAND_INFO("MX35UF4GE4AD", |
| 345 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xb7, 0x03), |
| 346 |
NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1), |
| 347 |
NAND_ECCREQ(8, 512), |
| 348 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 349 |
&write_cache_variants, |
| 350 |
&update_cache_variants), |
| 351 |
SPINAND_HAS_QE_BIT, |
| 352 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 353 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 354 |
macronix_ecc_get_status), |
| 355 |
SPINAND_CONT_READ(macronix_set_cont_read), |
| 356 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 357 |
macronix_set_read_retry)), |
| 358 |
SPINAND_INFO("MX35UF2G14AC", |
| 359 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa0), |
| 360 |
NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 2, 1, 1), |
| 361 |
NAND_ECCREQ(4, 512), |
| 362 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 363 |
&write_cache_variants, |
| 364 |
&update_cache_variants), |
| 365 |
SPINAND_HAS_QE_BIT | |
| 366 |
SPINAND_HAS_PROG_PLANE_SELECT_BIT | |
| 367 |
SPINAND_HAS_READ_PLANE_SELECT_BIT, |
| 368 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 369 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 370 |
macronix_ecc_get_status)), |
| 371 |
SPINAND_INFO("MX35UF2G24AD", |
| 372 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa4, 0x03), |
| 373 |
NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1), |
| 374 |
NAND_ECCREQ(8, 512), |
| 375 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 376 |
&write_cache_variants, |
| 377 |
&update_cache_variants), |
| 378 |
SPINAND_HAS_QE_BIT | |
| 379 |
SPINAND_HAS_PROG_PLANE_SELECT_BIT, |
| 380 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 381 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 382 |
macronix_ecc_get_status), |
| 383 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 384 |
macronix_set_read_retry)), |
| 385 |
SPINAND_INFO("MX35UF2G24AD-Z4I8", |
| 386 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xe4, 0x03), |
| 387 |
NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1), |
| 388 |
NAND_ECCREQ(8, 512), |
| 389 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 390 |
&write_cache_variants, |
| 391 |
&update_cache_variants), |
| 392 |
SPINAND_HAS_QE_BIT, |
| 393 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 394 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 395 |
macronix_ecc_get_status), |
| 396 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 397 |
macronix_set_read_retry)), |
| 398 |
SPINAND_INFO("MX35UF2GE4AD", |
| 399 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa6, 0x03), |
| 400 |
NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1), |
| 401 |
NAND_ECCREQ(8, 512), |
| 402 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 403 |
&write_cache_variants, |
| 404 |
&update_cache_variants), |
| 405 |
SPINAND_HAS_QE_BIT, |
| 406 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 407 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 408 |
macronix_ecc_get_status), |
| 409 |
SPINAND_CONT_READ(macronix_set_cont_read), |
| 410 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 411 |
macronix_set_read_retry)), |
| 412 |
SPINAND_INFO("MX35UF2GE4AC", |
| 413 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa2, 0x01), |
| 414 |
NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 1, 1, 1), |
| 415 |
NAND_ECCREQ(4, 512), |
| 416 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 417 |
&write_cache_variants, |
| 418 |
&update_cache_variants), |
| 419 |
SPINAND_HAS_QE_BIT, |
| 420 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 421 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 422 |
macronix_ecc_get_status), |
| 423 |
SPINAND_CONT_READ(macronix_set_cont_read)), |
| 424 |
SPINAND_INFO("MX35UF1G14AC", |
| 425 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x90), |
| 426 |
NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), |
| 427 |
NAND_ECCREQ(4, 512), |
| 428 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 429 |
&write_cache_variants, |
| 430 |
&update_cache_variants), |
| 431 |
SPINAND_HAS_QE_BIT, |
| 432 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 433 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 434 |
macronix_ecc_get_status)), |
| 435 |
SPINAND_INFO("MX35UF1G24AD", |
| 436 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x94, 0x03), |
| 437 |
NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1), |
| 438 |
NAND_ECCREQ(8, 512), |
| 439 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 440 |
&write_cache_variants, |
| 441 |
&update_cache_variants), |
| 442 |
SPINAND_HAS_QE_BIT, |
| 443 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 444 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 445 |
macronix_ecc_get_status), |
| 446 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 447 |
macronix_set_read_retry)), |
| 448 |
SPINAND_INFO("MX35UF1GE4AD", |
| 449 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x96, 0x03), |
| 450 |
NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1), |
| 451 |
NAND_ECCREQ(8, 512), |
| 452 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 453 |
&write_cache_variants, |
| 454 |
&update_cache_variants), |
| 455 |
SPINAND_HAS_QE_BIT, |
| 456 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 457 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 458 |
macronix_ecc_get_status), |
| 459 |
SPINAND_CONT_READ(macronix_set_cont_read), |
| 460 |
SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES, |
| 461 |
macronix_set_read_retry)), |
| 462 |
SPINAND_INFO("MX35UF1GE4AC", |
| 463 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x92, 0x01), |
| 464 |
NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), |
| 465 |
NAND_ECCREQ(4, 512), |
| 466 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 467 |
&write_cache_variants, |
| 468 |
&update_cache_variants), |
| 469 |
SPINAND_HAS_QE_BIT, |
| 470 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 471 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 472 |
macronix_ecc_get_status), |
| 473 |
SPINAND_CONT_READ(macronix_set_cont_read)), |
| 474 |
SPINAND_INFO("MX31LF2GE4BC", |
| 475 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x2e), |
| 476 |
NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 1, 1, 1), |
| 477 |
NAND_ECCREQ(8, 512), |
| 478 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 479 |
&write_cache_variants, |
| 480 |
&update_cache_variants), |
| 481 |
SPINAND_HAS_QE_BIT, |
| 482 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 483 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 484 |
macronix_ecc_get_status)), |
| 485 |
SPINAND_INFO("MX3UF2GE4BC", |
| 486 |
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xae), |
| 487 |
NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 1, 1, 1), |
| 488 |
NAND_ECCREQ(8, 512), |
| 489 |
SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
| 490 |
&write_cache_variants, |
| 491 |
&update_cache_variants), |
| 492 |
SPINAND_HAS_QE_BIT, |
| 493 |
SPINAND_INFO_VENDOR_OPS(¯onix_ops), |
| 494 |
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
| 495 |
macronix_ecc_get_status)), |
| 496 |
}; |
| 497 |
|
| 498 |
static int macronix_spinand_init(struct spinand_device *spinand) |
| 499 |
{ |
| 500 |
struct macronix_priv *priv; |
| 501 |
|
| 502 |
priv = kzalloc_obj(*priv); |
| 503 |
if (!priv) |
| 504 |
return -ENOMEM; |
| 505 |
|
| 506 |
spinand->priv = priv; |
| 507 |
|
| 508 |
return 0; |
| 509 |
} |
| 510 |
|
| 511 |
static void macronix_spinand_cleanup(struct spinand_device *spinand) |
| 512 |
{ |
| 513 |
kfree(spinand->priv); |
| 514 |
} |
| 515 |
|
| 516 |
static const struct spinand_manufacturer_ops macronix_spinand_manuf_ops = { |
| 517 |
.init = macronix_spinand_init, |
| 518 |
.cleanup = macronix_spinand_cleanup, |
| 519 |
}; |
| 520 |
|
| 521 |
const struct spinand_manufacturer macronix_spinand_manufacturer = { |
| 522 |
.id = SPINAND_MFR_MACRONIX, |
| 523 |
.name = "Macronix", |
| 524 |
.chips = macronix_spinand_table, |
| 525 |
.nchips = ARRAY_SIZE(macronix_spinand_table), |
| 526 |
.ops = ¯onix_spinand_manuf_ops, |
| 527 |
}; |