sunxi: add support for 4.1
[openwrt.git] / target / linux / sunxi / patches-4.1 / 116-mtd-add-vendor-specific-initcode-infra.patch
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
6 Add new fields in nand_manufacturers and nand_chip struct to provide
7 manufacturer specific handling like read retries.
8
9 Signed-off-by: Boris BREZILLON <b.brezillon.dev@gmail.com>
10 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 ---
12  drivers/mtd/nand/nand_base.c | 7 +++++++
13  include/linux/mtd/nand.h     | 4 ++++
14  2 files changed, 11 insertions(+)
15
16 diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
17 index 577cb9e..51642c6 100644
18 --- a/drivers/mtd/nand/nand_base.c
19 +++ b/drivers/mtd/nand/nand_base.c
20 @@ -4382,6 +4382,13 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
21         if (mtd->writesize > 512 && chip->cmdfunc == nand_command)
22                 chip->cmdfunc = nand_command_lp;
23  
24 +       if (nand_manuf_ids[maf_idx].init) {
25 +               int err;
26 +               err = nand_manuf_ids[maf_idx].init(mtd, id_data);
27 +               if (err)
28 +                       return ERR_PTR(err);
29 +       }
30 +
31         pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n",
32                 *maf_id, *dev_id);
33  
34 diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
35 index 6cbd06a3..5844d6f 100644
36 --- a/include/linux/mtd/nand.h
37 +++ b/include/linux/mtd/nand.h
38 @@ -748,6 +748,9 @@ struct nand_chip {
39         int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip,
40                         int feature_addr, uint8_t *subfeature_para);
41         int (*setup_read_retry)(struct mtd_info *mtd, int retry_mode);
42 +       void (*manuf_cleanup)(struct mtd_info *mtd);
43 +
44 +       void *manuf_priv;
45  
46         int chip_delay;
47         unsigned int options;
48 @@ -950,6 +953,7 @@ struct nand_flash_dev {
49  struct nand_manufacturers {
50         int id;
51         char *name;
52 +       int (*init)(struct mtd_info *mtd, const uint8_t *id);
53  };
54  
55  extern struct nand_flash_dev nand_flash_ids[];