]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - include/linux/mtd/nand.h
mtd: nand: Move AMD/Spansion specific init/detection logic in nand_amd.c
[karo-tx-linux.git] / include / linux / mtd / nand.h
index 9591e0fbe5bd76a1c47e2deb4292469e0a2cf8e6..97dce42778e99c4e8e67ba259b45ee0555f55df8 100644 (file)
@@ -366,26 +366,6 @@ struct onfi_ext_param_page {
         */
 } __packed;
 
-struct nand_onfi_vendor_micron {
-       u8 two_plane_read;
-       u8 read_cache;
-       u8 read_unique_id;
-       u8 dq_imped;
-       u8 dq_imped_num_settings;
-       u8 dq_imped_feat_addr;
-       u8 rb_pulldown_strength;
-       u8 rb_pulldown_strength_feat_addr;
-       u8 rb_pulldown_strength_num_settings;
-       u8 otp_mode;
-       u8 otp_page_start;
-       u8 otp_data_prot_addr;
-       u8 otp_num_pages;
-       u8 otp_feat_addr;
-       u8 read_retry_options;
-       u8 reserved[72];
-       u8 param_revision;
-} __packed;
-
 struct jedec_ecc_info {
        u8 ecc_bits;
        u8 codeword_size;
@@ -464,6 +444,17 @@ struct nand_jedec_params {
        __le16 crc;
 } __packed;
 
+/**
+ * struct nand_id - NAND id structure
+ * @data: buffer containing the id bytes. Currently 8 bytes large, but can
+ *       be extended if required.
+ * @len: ID length.
+ */
+struct nand_id {
+       u8 data[8];
+       int len;
+};
+
 /**
  * struct nand_hw_control - Control structure for hardware controller (e.g ECC generator) shared among independent devices
  * @lock:               protection lock
@@ -720,6 +711,20 @@ nand_get_sdr_timings(const struct nand_data_interface *conf)
        return &conf->timings.sdr;
 }
 
+/**
+ * struct nand_manufacturer_ops - NAND Manufacturer operations
+ * @detect: detect the NAND memory organization and capabilities
+ * @init: initialize all vendor specific fields (like the ->read_retry()
+ *       implementation) if any.
+ * @cleanup: the ->init() function may have allocated resources, ->cleanup()
+ *          is here to let vendor specific code release those resources.
+ */
+struct nand_manufacturer_ops {
+       void (*detect)(struct nand_chip *chip);
+       int (*init)(struct nand_chip *chip);
+       void (*cleanup)(struct nand_chip *chip);
+};
+
 /**
  * struct nand_chip - NAND Private Flash Chip Data
  * @mtd:               MTD device registered to the MTD framework
@@ -793,6 +798,7 @@ nand_get_sdr_timings(const struct nand_data_interface *conf)
  * @pagebuf_bitflips:  [INTERN] holds the bitflip count for the page which is
  *                     currently in data_buf.
  * @subpagesize:       [INTERN] holds the subpagesize
+ * @id:                        [INTERN] holds NAND ID
  * @onfi_version:      [INTERN] holds the chip ONFI version (BCD encoded),
  *                     non 0 if ONFI supported.
  * @jedec_version:     [INTERN] holds the chip JEDEC version (BCD encoded),
@@ -823,6 +829,7 @@ nand_get_sdr_timings(const struct nand_data_interface *conf)
  *                     additional error status checks (determine if errors are
  *                     correctable).
  * @write_page:                [REPLACEABLE] High-level page write function
+ * @manufacturer:      [INTERN] Contains manufacturer information
  */
 
 struct nand_chip {
@@ -881,6 +888,7 @@ struct nand_chip {
        int badblockpos;
        int badblockbits;
 
+       struct nand_id id;
        int onfi_version;
        int jedec_version;
        union {
@@ -910,6 +918,11 @@ struct nand_chip {
        struct nand_bbt_descr *badblock_pattern;
 
        void *priv;
+
+       struct {
+               const struct nand_manufacturer *desc;
+               void *priv;
+       } manufacturer;
 };
 
 extern const struct mtd_ooblayout_ops nand_ooblayout_sp_ops;
@@ -946,6 +959,17 @@ static inline void nand_set_controller_data(struct nand_chip *chip, void *priv)
        chip->priv = priv;
 }
 
+static inline void nand_set_manufacturer_data(struct nand_chip *chip,
+                                             void *priv)
+{
+       chip->manufacturer.priv = priv;
+}
+
+static inline void *nand_get_manufacturer_data(struct nand_chip *chip)
+{
+       return chip->manufacturer.priv;
+}
+
 /*
  * NAND Flash Manufacturer ID Codes
  */
@@ -1049,17 +1073,32 @@ struct nand_flash_dev {
 };
 
 /**
- * struct nand_manufacturers - NAND Flash Manufacturer ID Structure
+ * struct nand_manufacturer - NAND Flash Manufacturer structure
  * @name:      Manufacturer name
  * @id:                manufacturer ID code of device.
+ * @ops:       manufacturer operations
 */
-struct nand_manufacturers {
+struct nand_manufacturer {
        int id;
        char *name;
+       const struct nand_manufacturer_ops *ops;
 };
 
+const struct nand_manufacturer *nand_get_manufacturer(u8 id);
+
+static inline const char *
+nand_manufacturer_name(const struct nand_manufacturer *manufacturer)
+{
+       return manufacturer ? manufacturer->name : "Unknown";
+}
+
 extern struct nand_flash_dev nand_flash_ids[];
-extern struct nand_manufacturers nand_manuf_ids[];
+
+extern const struct nand_manufacturer_ops toshiba_nand_manuf_ops;
+extern const struct nand_manufacturer_ops samsung_nand_manuf_ops;
+extern const struct nand_manufacturer_ops hynix_nand_manuf_ops;
+extern const struct nand_manufacturer_ops micron_nand_manuf_ops;
+extern const struct nand_manufacturer_ops amd_nand_manuf_ops;
 
 int nand_default_bbt(struct mtd_info *mtd);
 int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs);
@@ -1226,4 +1265,6 @@ int nand_reset(struct nand_chip *chip, int chipnr);
 /* Free resources held by the NAND device */
 void nand_cleanup(struct nand_chip *chip);
 
+/* Default extended ID decoding function */
+void nand_decode_ext_id(struct nand_chip *chip);
 #endif /* __LINUX_MTD_NAND_H */