| .. | .. |
|---|
| 49 | 49 | .free = mx35lfxge4ab_ooblayout_free, |
|---|
| 50 | 50 | }; |
|---|
| 51 | 51 | |
|---|
| 52 | +static int mx35ufxge4ad_ooblayout_ecc(struct mtd_info *mtd, int section, |
|---|
| 53 | + struct mtd_oob_region *region) |
|---|
| 54 | +{ |
|---|
| 55 | + if (section) |
|---|
| 56 | + return -ERANGE; |
|---|
| 57 | + |
|---|
| 58 | + region->offset = mtd->oobsize / 2; |
|---|
| 59 | + region->length = mtd->oobsize / 2; |
|---|
| 60 | + |
|---|
| 61 | + return 0; |
|---|
| 62 | +} |
|---|
| 63 | + |
|---|
| 64 | +static int mx35ufxge4ad_ooblayout_free(struct mtd_info *mtd, int section, |
|---|
| 65 | + struct mtd_oob_region *region) |
|---|
| 66 | +{ |
|---|
| 67 | + if (section) |
|---|
| 68 | + return -ERANGE; |
|---|
| 69 | + |
|---|
| 70 | + region->offset = 2; |
|---|
| 71 | + region->length = mtd->oobsize / 2 - 2; |
|---|
| 72 | + |
|---|
| 73 | + return 0; |
|---|
| 74 | +} |
|---|
| 75 | + |
|---|
| 76 | +static const struct mtd_ooblayout_ops mx35ufxge4ad_ooblayout = { |
|---|
| 77 | + .ecc = mx35ufxge4ad_ooblayout_ecc, |
|---|
| 78 | + .free = mx35ufxge4ad_ooblayout_free, |
|---|
| 79 | +}; |
|---|
| 80 | + |
|---|
| 52 | 81 | static int mx35lf1ge4ab_get_eccsr(struct spinand_device *spinand, u8 *eccsr) |
|---|
| 53 | 82 | { |
|---|
| 54 | 83 | struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(0x7c, 1), |
|---|
| .. | .. |
|---|
| 84 | 113 | * data around if it's not necessary. |
|---|
| 85 | 114 | */ |
|---|
| 86 | 115 | if (mx35lf1ge4ab_get_eccsr(spinand, &eccsr)) |
|---|
| 87 | | - return nand->eccreq.strength; |
|---|
| 116 | + return nanddev_get_ecc_requirements(nand)->strength; |
|---|
| 88 | 117 | |
|---|
| 89 | | - if (WARN_ON(eccsr > nand->eccreq.strength || !eccsr)) |
|---|
| 90 | | - return nand->eccreq.strength; |
|---|
| 118 | + if (WARN_ON(eccsr > nanddev_get_ecc_requirements(nand)->strength || |
|---|
| 119 | + !eccsr)) |
|---|
| 120 | + return nanddev_get_ecc_requirements(nand)->strength; |
|---|
| 91 | 121 | |
|---|
| 92 | 122 | return eccsr; |
|---|
| 93 | 123 | |
|---|
| .. | .. |
|---|
| 99 | 129 | } |
|---|
| 100 | 130 | |
|---|
| 101 | 131 | static const struct spinand_info macronix_spinand_table[] = { |
|---|
| 102 | | - SPINAND_INFO("MX35LF1GE4AB", 0x12, |
|---|
| 103 | | - NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), |
|---|
| 132 | + SPINAND_INFO("MX35LF1GE4AB", |
|---|
| 133 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x12), |
|---|
| 134 | + NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), |
|---|
| 104 | 135 | NAND_ECCREQ(4, 512), |
|---|
| 105 | 136 | SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 106 | 137 | &write_cache_variants, |
|---|
| .. | .. |
|---|
| 108 | 139 | SPINAND_HAS_QE_BIT, |
|---|
| 109 | 140 | SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
|---|
| 110 | 141 | mx35lf1ge4ab_ecc_get_status)), |
|---|
| 111 | | - SPINAND_INFO("MX35LF2GE4AB", 0x22, |
|---|
| 112 | | - NAND_MEMORG(1, 2048, 64, 64, 2048, 2, 1, 1), |
|---|
| 142 | + SPINAND_INFO("MX35LF2GE4AB", |
|---|
| 143 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x22), |
|---|
| 144 | + NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 2, 1, 1), |
|---|
| 113 | 145 | NAND_ECCREQ(4, 512), |
|---|
| 114 | 146 | SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 115 | 147 | &write_cache_variants, |
|---|
| 116 | 148 | &update_cache_variants), |
|---|
| 117 | 149 | SPINAND_HAS_QE_BIT, |
|---|
| 118 | 150 | SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), |
|---|
| 151 | + SPINAND_INFO("MX35LF2GE4AD", |
|---|
| 152 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x26), |
|---|
| 153 | + NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 1, 1, 1), |
|---|
| 154 | + NAND_ECCREQ(8, 512), |
|---|
| 155 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 156 | + &write_cache_variants, |
|---|
| 157 | + &update_cache_variants), |
|---|
| 158 | + SPINAND_HAS_QE_BIT, |
|---|
| 159 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
|---|
| 160 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 161 | + SPINAND_INFO("MX35LF4GE4AD", |
|---|
| 162 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x37), |
|---|
| 163 | + NAND_MEMORG(1, 4096, 128, 64, 2048, 40, 1, 1, 1), |
|---|
| 164 | + NAND_ECCREQ(8, 512), |
|---|
| 165 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 166 | + &write_cache_variants, |
|---|
| 167 | + &update_cache_variants), |
|---|
| 168 | + SPINAND_HAS_QE_BIT, |
|---|
| 169 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
|---|
| 170 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 171 | + SPINAND_INFO("MX35LF1G24AD", |
|---|
| 172 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14), |
|---|
| 173 | + NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1), |
|---|
| 174 | + NAND_ECCREQ(8, 512), |
|---|
| 175 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 176 | + &write_cache_variants, |
|---|
| 177 | + &update_cache_variants), |
|---|
| 178 | + SPINAND_HAS_QE_BIT, |
|---|
| 179 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), |
|---|
| 180 | + SPINAND_INFO("MX35LF2G24AD", |
|---|
| 181 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x24), |
|---|
| 182 | + NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1), |
|---|
| 183 | + NAND_ECCREQ(8, 512), |
|---|
| 184 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 185 | + &write_cache_variants, |
|---|
| 186 | + &update_cache_variants), |
|---|
| 187 | + SPINAND_HAS_QE_BIT, |
|---|
| 188 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), |
|---|
| 189 | + SPINAND_INFO("MX35LF4G24AD", |
|---|
| 190 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35), |
|---|
| 191 | + NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 2, 1, 1), |
|---|
| 192 | + NAND_ECCREQ(8, 512), |
|---|
| 193 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 194 | + &write_cache_variants, |
|---|
| 195 | + &update_cache_variants), |
|---|
| 196 | + SPINAND_HAS_QE_BIT, |
|---|
| 197 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), |
|---|
| 198 | + SPINAND_INFO("MX31LF1GE4BC", |
|---|
| 199 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x1e), |
|---|
| 200 | + NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), |
|---|
| 201 | + NAND_ECCREQ(8, 512), |
|---|
| 202 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 203 | + &write_cache_variants, |
|---|
| 204 | + &update_cache_variants), |
|---|
| 205 | + SPINAND_HAS_QE_BIT, |
|---|
| 206 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
|---|
| 207 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 208 | + SPINAND_INFO("MX31UF1GE4BC", |
|---|
| 209 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x9e), |
|---|
| 210 | + NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), |
|---|
| 211 | + NAND_ECCREQ(8, 512), |
|---|
| 212 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 213 | + &write_cache_variants, |
|---|
| 214 | + &update_cache_variants), |
|---|
| 215 | + SPINAND_HAS_QE_BIT, |
|---|
| 216 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
|---|
| 217 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 218 | + |
|---|
| 219 | + SPINAND_INFO("MX35LF2G14AC", |
|---|
| 220 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x20), |
|---|
| 221 | + NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 2, 1, 1), |
|---|
| 222 | + NAND_ECCREQ(4, 512), |
|---|
| 223 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 224 | + &write_cache_variants, |
|---|
| 225 | + &update_cache_variants), |
|---|
| 226 | + SPINAND_HAS_QE_BIT, |
|---|
| 227 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
|---|
| 228 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 229 | + SPINAND_INFO("MX35UF4G24AD", |
|---|
| 230 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xb5), |
|---|
| 231 | + NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 2, 1, 1), |
|---|
| 232 | + NAND_ECCREQ(8, 512), |
|---|
| 233 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 234 | + &write_cache_variants, |
|---|
| 235 | + &update_cache_variants), |
|---|
| 236 | + SPINAND_HAS_QE_BIT, |
|---|
| 237 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
|---|
| 238 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 239 | + SPINAND_INFO("MX35UF4GE4AD", |
|---|
| 240 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xb7), |
|---|
| 241 | + NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1), |
|---|
| 242 | + NAND_ECCREQ(8, 512), |
|---|
| 243 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 244 | + &write_cache_variants, |
|---|
| 245 | + &update_cache_variants), |
|---|
| 246 | + SPINAND_HAS_QE_BIT, |
|---|
| 247 | + SPINAND_ECCINFO(&mx35ufxge4ad_ooblayout, |
|---|
| 248 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 249 | + SPINAND_INFO("MX35UF2G14AC", |
|---|
| 250 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa0), |
|---|
| 251 | + NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 2, 1, 1), |
|---|
| 252 | + NAND_ECCREQ(4, 512), |
|---|
| 253 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 254 | + &write_cache_variants, |
|---|
| 255 | + &update_cache_variants), |
|---|
| 256 | + SPINAND_HAS_QE_BIT, |
|---|
| 257 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
|---|
| 258 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 259 | + SPINAND_INFO("MX35UF2G24AD", |
|---|
| 260 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa4), |
|---|
| 261 | + NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1), |
|---|
| 262 | + NAND_ECCREQ(8, 512), |
|---|
| 263 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 264 | + &write_cache_variants, |
|---|
| 265 | + &update_cache_variants), |
|---|
| 266 | + SPINAND_HAS_QE_BIT, |
|---|
| 267 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
|---|
| 268 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 269 | + SPINAND_INFO("MX35UF2GE4AD", |
|---|
| 270 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa6), |
|---|
| 271 | + NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1), |
|---|
| 272 | + NAND_ECCREQ(8, 512), |
|---|
| 273 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 274 | + &write_cache_variants, |
|---|
| 275 | + &update_cache_variants), |
|---|
| 276 | + SPINAND_HAS_QE_BIT, |
|---|
| 277 | + SPINAND_ECCINFO(&mx35ufxge4ad_ooblayout, |
|---|
| 278 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 279 | + SPINAND_INFO("MX35UF2GE4AC", |
|---|
| 280 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa2), |
|---|
| 281 | + NAND_MEMORG(1, 2048, 64, 64, 2048, 40, 1, 1, 1), |
|---|
| 282 | + NAND_ECCREQ(4, 512), |
|---|
| 283 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 284 | + &write_cache_variants, |
|---|
| 285 | + &update_cache_variants), |
|---|
| 286 | + SPINAND_HAS_QE_BIT, |
|---|
| 287 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
|---|
| 288 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 289 | + SPINAND_INFO("MX35UF1G14AC", |
|---|
| 290 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x90), |
|---|
| 291 | + NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), |
|---|
| 292 | + NAND_ECCREQ(4, 512), |
|---|
| 293 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 294 | + &write_cache_variants, |
|---|
| 295 | + &update_cache_variants), |
|---|
| 296 | + SPINAND_HAS_QE_BIT, |
|---|
| 297 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
|---|
| 298 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 299 | + SPINAND_INFO("MX35UF1G24AD", |
|---|
| 300 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x94), |
|---|
| 301 | + NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1), |
|---|
| 302 | + NAND_ECCREQ(8, 512), |
|---|
| 303 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 304 | + &write_cache_variants, |
|---|
| 305 | + &update_cache_variants), |
|---|
| 306 | + SPINAND_HAS_QE_BIT, |
|---|
| 307 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
|---|
| 308 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 309 | + SPINAND_INFO("MX35UF1GE4AD", |
|---|
| 310 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x96), |
|---|
| 311 | + NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1), |
|---|
| 312 | + NAND_ECCREQ(8, 512), |
|---|
| 313 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 314 | + &write_cache_variants, |
|---|
| 315 | + &update_cache_variants), |
|---|
| 316 | + SPINAND_HAS_QE_BIT, |
|---|
| 317 | + SPINAND_ECCINFO(&mx35ufxge4ad_ooblayout, |
|---|
| 318 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 319 | + SPINAND_INFO("MX35UF1GE4AC", |
|---|
| 320 | + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x92), |
|---|
| 321 | + NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), |
|---|
| 322 | + NAND_ECCREQ(4, 512), |
|---|
| 323 | + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, |
|---|
| 324 | + &write_cache_variants, |
|---|
| 325 | + &update_cache_variants), |
|---|
| 326 | + SPINAND_HAS_QE_BIT, |
|---|
| 327 | + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, |
|---|
| 328 | + mx35lf1ge4ab_ecc_get_status)), |
|---|
| 119 | 329 | }; |
|---|
| 120 | 330 | |
|---|
| 121 | | -static int macronix_spinand_detect(struct spinand_device *spinand) |
|---|
| 122 | | -{ |
|---|
| 123 | | - u8 *id = spinand->id.data; |
|---|
| 124 | | - int ret; |
|---|
| 125 | | - |
|---|
| 126 | | - /* |
|---|
| 127 | | - * Macronix SPI NAND read ID needs a dummy byte, so the first byte in |
|---|
| 128 | | - * raw_id is garbage. |
|---|
| 129 | | - */ |
|---|
| 130 | | - if (id[1] != SPINAND_MFR_MACRONIX) |
|---|
| 131 | | - return 0; |
|---|
| 132 | | - |
|---|
| 133 | | - ret = spinand_match_and_init(spinand, macronix_spinand_table, |
|---|
| 134 | | - ARRAY_SIZE(macronix_spinand_table), |
|---|
| 135 | | - id[2]); |
|---|
| 136 | | - if (ret) |
|---|
| 137 | | - return ret; |
|---|
| 138 | | - |
|---|
| 139 | | - return 1; |
|---|
| 140 | | -} |
|---|
| 141 | | - |
|---|
| 142 | 331 | static const struct spinand_manufacturer_ops macronix_spinand_manuf_ops = { |
|---|
| 143 | | - .detect = macronix_spinand_detect, |
|---|
| 144 | 332 | }; |
|---|
| 145 | 333 | |
|---|
| 146 | 334 | const struct spinand_manufacturer macronix_spinand_manufacturer = { |
|---|
| 147 | 335 | .id = SPINAND_MFR_MACRONIX, |
|---|
| 148 | 336 | .name = "Macronix", |
|---|
| 337 | + .chips = macronix_spinand_table, |
|---|
| 338 | + .nchips = ARRAY_SIZE(macronix_spinand_table), |
|---|
| 149 | 339 | .ops = ¯onix_spinand_manuf_ops, |
|---|
| 150 | 340 | }; |
|---|