116-mtd-add-vendor-specific-initcode-infra.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From 95430662a26332474f4a03a7f8f44fd8d80890b3 Mon Sep 17 00:00:00 2001
  2. From: Boris BREZILLON <b.brezillon.dev@gmail.com>
  3. Date: Mon, 24 Feb 2014 16:28:32 +0100
  4. Subject: [PATCH] mtd: nand: Add manufacturer specific init code infrastructure
  5. Add new fields in nand_manufacturers and nand_chip struct to provide
  6. manufacturer specific handling like read retries.
  7. Signed-off-by: Boris BREZILLON <b.brezillon.dev@gmail.com>
  8. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  9. ---
  10. drivers/mtd/nand/nand_base.c | 7 +++++++
  11. include/linux/mtd/nand.h | 4 ++++
  12. 2 files changed, 11 insertions(+)
  13. --- a/drivers/mtd/nand/nand_base.c
  14. +++ b/drivers/mtd/nand/nand_base.c
  15. @@ -4382,6 +4382,13 @@ ident_done:
  16. if (mtd->writesize > 512 && chip->cmdfunc == nand_command)
  17. chip->cmdfunc = nand_command_lp;
  18. + if (nand_manuf_ids[maf_idx].init) {
  19. + int err;
  20. + err = nand_manuf_ids[maf_idx].init(mtd, id_data);
  21. + if (err)
  22. + return ERR_PTR(err);
  23. + }
  24. +
  25. pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n",
  26. *maf_id, *dev_id);
  27. --- a/include/linux/mtd/nand.h
  28. +++ b/include/linux/mtd/nand.h
  29. @@ -748,6 +748,9 @@ struct nand_chip {
  30. int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip,
  31. int feature_addr, uint8_t *subfeature_para);
  32. int (*setup_read_retry)(struct mtd_info *mtd, int retry_mode);
  33. + void (*manuf_cleanup)(struct mtd_info *mtd);
  34. +
  35. + void *manuf_priv;
  36. int chip_delay;
  37. unsigned int options;
  38. @@ -950,6 +953,7 @@ struct nand_flash_dev {
  39. struct nand_manufacturers {
  40. int id;
  41. char *name;
  42. + int (*init)(struct mtd_info *mtd, const uint8_t *id);
  43. };
  44. extern struct nand_flash_dev nand_flash_ids[];