blob: 96f039a83bc82ec72021ce25efec2d948933e2f9 [file] [log] [blame]
Marcel Ziswilera68642a2018-09-19 13:40:49 +02001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2018 Toradex AG
4 *
5 * Author: Marcel Ziswiler <marcel.ziswiler@toradex.com>
6 */
7
8#include <linux/mtd/rawnand.h>
9#include "internals.h"
10
11static void esmt_nand_decode_id(struct nand_chip *chip)
12{
13 nand_decode_ext_id(chip);
14
15 /* Extract ECC requirements from 5th id byte. */
16 if (chip->id.len >= 5 && nand_is_slc(chip)) {
17 chip->ecc_step_ds = 512;
18 switch (chip->id.data[4] & 0x3) {
19 case 0x0:
20 chip->ecc_strength_ds = 4;
21 break;
22 case 0x1:
23 chip->ecc_strength_ds = 2;
24 break;
25 case 0x2:
26 chip->ecc_strength_ds = 1;
27 break;
28 default:
29 WARN(1, "Could not get ECC info");
30 chip->ecc_step_ds = 0;
31 break;
32 }
33 }
34}
35
36static int esmt_nand_init(struct nand_chip *chip)
37{
38 if (nand_is_slc(chip))
39 chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
40
41 return 0;
42}
43
44const struct nand_manufacturer_ops esmt_nand_manuf_ops = {
45 .detect = esmt_nand_decode_id,
46 .init = esmt_nand_init,
47};