root/drivers/mtd/nand/raw/nand_esmt.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. esmt_nand_decode_id
  2. esmt_nand_init

   1 // 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 
  11 static 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->base.eccreq.step_size = 512;
  18                 switch (chip->id.data[4] & 0x3) {
  19                 case 0x0:
  20                         chip->base.eccreq.strength = 4;
  21                         break;
  22                 case 0x1:
  23                         chip->base.eccreq.strength = 2;
  24                         break;
  25                 case 0x2:
  26                         chip->base.eccreq.strength = 1;
  27                         break;
  28                 default:
  29                         WARN(1, "Could not get ECC info");
  30                         chip->base.eccreq.step_size = 0;
  31                         break;
  32                 }
  33         }
  34 }
  35 
  36 static int esmt_nand_init(struct nand_chip *chip)
  37 {
  38         if (nand_is_slc(chip))
  39                 /*
  40                  * It is known that some ESMT SLC NANDs have been shipped
  41                  * with the factory bad block markers in the first or last page
  42                  * of the block, instead of the first or second page. To be on
  43                  * the safe side, let's check all three locations.
  44                  */
  45                 chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE |
  46                                  NAND_BBM_LASTPAGE;
  47 
  48         return 0;
  49 }
  50 
  51 const struct nand_manufacturer_ops esmt_nand_manuf_ops = {
  52         .detect = esmt_nand_decode_id,
  53         .init = esmt_nand_init,
  54 };

/* [<][>][^][v][top][bottom][index][help] */