nand_esmt.c 944 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #include <linux/mtd/rawnand.h>
  8. #include "internals.h"
  9. static void esmt_nand_decode_id(struct nand_chip *chip)
  10. {
  11. nand_decode_ext_id(chip);
  12. /* Extract ECC requirements from 5th id byte. */
  13. if (chip->id.len >= 5 && nand_is_slc(chip)) {
  14. chip->ecc_step_ds = 512;
  15. switch (chip->id.data[4] & 0x3) {
  16. case 0x0:
  17. chip->ecc_strength_ds = 4;
  18. break;
  19. case 0x1:
  20. chip->ecc_strength_ds = 2;
  21. break;
  22. case 0x2:
  23. chip->ecc_strength_ds = 1;
  24. break;
  25. default:
  26. WARN(1, "Could not get ECC info");
  27. chip->ecc_step_ds = 0;
  28. break;
  29. }
  30. }
  31. }
  32. static int esmt_nand_init(struct nand_chip *chip)
  33. {
  34. if (nand_is_slc(chip))
  35. chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
  36. return 0;
  37. }
  38. const struct nand_manufacturer_ops esmt_nand_manuf_ops = {
  39. .detect = esmt_nand_decode_id,
  40. .init = esmt_nand_init,
  41. };