internals.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2018 - Bootlin
  4. *
  5. * Author: Boris Brezillon <boris.brezillon@bootlin.com>
  6. *
  7. * Header containing internal definitions to be used only by core files.
  8. * NAND controller drivers should not include this file.
  9. */
  10. #ifndef __LINUX_RAWNAND_INTERNALS
  11. #define __LINUX_RAWNAND_INTERNALS
  12. #include <linux/mtd/rawnand.h>
  13. /*
  14. * NAND Flash Manufacturer ID Codes
  15. */
  16. #define NAND_MFR_TOSHIBA 0x98
  17. #define NAND_MFR_ESMT 0xc8
  18. #define NAND_MFR_SAMSUNG 0xec
  19. #define NAND_MFR_FUJITSU 0x04
  20. #define NAND_MFR_NATIONAL 0x8f
  21. #define NAND_MFR_RENESAS 0x07
  22. #define NAND_MFR_STMICRO 0x20
  23. #define NAND_MFR_HYNIX 0xad
  24. #define NAND_MFR_MICRON 0x2c
  25. #define NAND_MFR_AMD 0x01
  26. #define NAND_MFR_MACRONIX 0xc2
  27. #define NAND_MFR_EON 0x92
  28. #define NAND_MFR_SANDISK 0x45
  29. #define NAND_MFR_INTEL 0x89
  30. #define NAND_MFR_ATO 0x9b
  31. #define NAND_MFR_WINBOND 0xef
  32. /**
  33. * struct nand_manufacturer_ops - NAND Manufacturer operations
  34. * @detect: detect the NAND memory organization and capabilities
  35. * @init: initialize all vendor specific fields (like the ->read_retry()
  36. * implementation) if any.
  37. * @cleanup: the ->init() function may have allocated resources, ->cleanup()
  38. * is here to let vendor specific code release those resources.
  39. * @fixup_onfi_param_page: apply vendor specific fixups to the ONFI parameter
  40. * page. This is called after the checksum is verified.
  41. */
  42. struct nand_manufacturer_ops {
  43. void (*detect)(struct nand_chip *chip);
  44. int (*init)(struct nand_chip *chip);
  45. void (*cleanup)(struct nand_chip *chip);
  46. void (*fixup_onfi_param_page)(struct nand_chip *chip,
  47. struct nand_onfi_params *p);
  48. };
  49. /**
  50. * struct nand_manufacturer - NAND Flash Manufacturer structure
  51. * @name: Manufacturer name
  52. * @id: manufacturer ID code of device.
  53. * @ops: manufacturer operations
  54. */
  55. struct nand_manufacturer {
  56. int id;
  57. char *name;
  58. const struct nand_manufacturer_ops *ops;
  59. };
  60. extern struct nand_flash_dev nand_flash_ids[];
  61. extern const struct nand_manufacturer_ops toshiba_nand_manuf_ops;
  62. extern const struct nand_manufacturer_ops samsung_nand_manuf_ops;
  63. extern const struct nand_manufacturer_ops hynix_nand_manuf_ops;
  64. extern const struct nand_manufacturer_ops micron_nand_manuf_ops;
  65. extern const struct nand_manufacturer_ops amd_nand_manuf_ops;
  66. extern const struct nand_manufacturer_ops macronix_nand_manuf_ops;
  67. /* Core functions */
  68. const struct nand_manufacturer *nand_get_manufacturer(u8 id);
  69. int nand_markbad_bbm(struct nand_chip *chip, loff_t ofs);
  70. int nand_erase_nand(struct nand_chip *chip, struct erase_info *instr,
  71. int allowbbt);
  72. int onfi_fill_data_interface(struct nand_chip *chip,
  73. enum nand_data_interface_type type,
  74. int timing_mode);
  75. int nand_get_features(struct nand_chip *chip, int addr, u8 *subfeature_param);
  76. int nand_set_features(struct nand_chip *chip, int addr, u8 *subfeature_param);
  77. int nand_read_page_raw_notsupp(struct nand_chip *chip, u8 *buf,
  78. int oob_required, int page);
  79. int nand_write_page_raw_notsupp(struct nand_chip *chip, const u8 *buf,
  80. int oob_required, int page);
  81. int nand_exit_status_op(struct nand_chip *chip);
  82. int nand_read_param_page_op(struct nand_chip *chip, u8 page, void *buf,
  83. unsigned int len);
  84. void nand_decode_ext_id(struct nand_chip *chip);
  85. void panic_nand_wait(struct nand_chip *chip, unsigned long timeo);
  86. void sanitize_string(uint8_t *s, size_t len);
  87. /* BBT functions */
  88. int nand_markbad_bbt(struct nand_chip *chip, loff_t offs);
  89. int nand_isreserved_bbt(struct nand_chip *chip, loff_t offs);
  90. int nand_isbad_bbt(struct nand_chip *chip, loff_t offs, int allowbbt);
  91. /* Legacy */
  92. void nand_legacy_set_defaults(struct nand_chip *chip);
  93. void nand_legacy_adjust_cmdfunc(struct nand_chip *chip);
  94. int nand_legacy_check_hooks(struct nand_chip *chip);
  95. /* ONFI functions */
  96. u16 onfi_crc16(u16 crc, u8 const *p, size_t len);
  97. int nand_onfi_detect(struct nand_chip *chip);
  98. #endif /* __LINUX_RAWNAND_INTERNALS */