nand_macronix.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (C) 2017 Free Electrons
  3. * Copyright (C) 2017 NextThing Co
  4. *
  5. * Author: Boris Brezillon <boris.brezillon@free-electrons.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17. #include <linux/mtd/rawnand.h>
  18. /*
  19. * Macronix AC series does not support using SET/GET_FEATURES to change
  20. * the timings unlike what is declared in the parameter page. Unflag
  21. * this feature to avoid unnecessary downturns.
  22. */
  23. static void macronix_nand_fix_broken_get_timings(struct nand_chip *chip)
  24. {
  25. unsigned int i;
  26. static const char * const broken_get_timings[] = {
  27. "MX30LF1G18AC",
  28. "MX30LF1G28AC",
  29. "MX30LF2G18AC",
  30. "MX30LF2G28AC",
  31. "MX30LF4G18AC",
  32. "MX30LF4G28AC",
  33. "MX60LF8G18AC",
  34. };
  35. if (!chip->parameters.supports_set_get_features)
  36. return;
  37. for (i = 0; i < ARRAY_SIZE(broken_get_timings); i++) {
  38. if (!strcmp(broken_get_timings[i], chip->parameters.model))
  39. break;
  40. }
  41. if (i == ARRAY_SIZE(broken_get_timings))
  42. return;
  43. bitmap_clear(chip->parameters.get_feature_list,
  44. ONFI_FEATURE_ADDR_TIMING_MODE, 1);
  45. bitmap_clear(chip->parameters.set_feature_list,
  46. ONFI_FEATURE_ADDR_TIMING_MODE, 1);
  47. }
  48. static int macronix_nand_init(struct nand_chip *chip)
  49. {
  50. if (nand_is_slc(chip))
  51. chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
  52. macronix_nand_fix_broken_get_timings(chip);
  53. return 0;
  54. }
  55. const struct nand_manufacturer_ops macronix_nand_manuf_ops = {
  56. .init = macronix_nand_init,
  57. };