ramips: clean up the mt7621 nand flash driver hacks, add support for the xiaomi mir3g...
[oweals/openwrt.git] / target / linux / ramips / patches-4.14 / 0040-nand-hack.patch
1 --- a/drivers/mtd/nand/nand_base.c
2 +++ b/drivers/mtd/nand/nand_base.c
3 @@ -1908,6 +1908,9 @@ static int nand_do_read_ops(struct mtd_i
4                                                  __func__, buf);
5  
6  read_retry:
7 +#ifdef CONFIG_MTK_MTD_NAND
8 +                       ret = chip->read_page(mtd, chip, bufpoi, page);
9 +#else
10                         if (nand_standard_page_accessors(&chip->ecc))
11                                 chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
12  
13 @@ -1927,6 +1930,7 @@ read_retry:
14                         else
15                                 ret = chip->ecc.read_page(mtd, chip, bufpoi,
16                                                           oob_required, page);
17 +#endif
18                         if (ret < 0) {
19                                 if (use_bufpoi)
20                                         /* Invalidate page cache */
21 @@ -2761,9 +2765,14 @@ static int nand_do_write_ops(struct mtd_
22                         memset(chip->oob_poi, 0xff, mtd->oobsize);
23                 }
24  
25 -               ret = nand_write_page(mtd, chip, column, bytes, wbuf,
26 -                                     oob_required, page,
27 -                                     (ops->mode == MTD_OPS_RAW));
28 +               if (chip->write_page)
29 +                       ret = chip->write_page(mtd, chip, column, bytes, wbuf,
30 +                                              oob_required, page,
31 +                                              (ops->mode == MTD_OPS_RAW));
32 +               else
33 +                       ret = nand_write_page(mtd, chip, column, bytes, wbuf,
34 +                                             oob_required, page,
35 +                                             (ops->mode == MTD_OPS_RAW));
36                 if (ret)
37                         break;
38  
39 --- a/include/linux/mtd/rawnand.h
40 +++ b/include/linux/mtd/rawnand.h
41 @@ -885,6 +885,9 @@ struct nand_chip {
42         int(*waitfunc)(struct mtd_info *mtd, struct nand_chip *this);
43         int (*erase)(struct mtd_info *mtd, int page);
44         int (*scan_bbt)(struct mtd_info *mtd);
45 +       int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
46 +                       uint32_t offset, int data_len, const uint8_t *buf,
47 +                       int oob_required, int page, int raw);
48         int (*onfi_set_features)(struct mtd_info *mtd, struct nand_chip *chip,
49                         int feature_addr, uint8_t *subfeature_para);
50         int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip,
51 @@ -893,6 +896,9 @@ struct nand_chip {
52         int (*setup_data_interface)(struct mtd_info *mtd, int chipnr,
53                                     const struct nand_data_interface *conf);
54  
55 +#ifdef CONFIG_MTK_MTD_NAND
56 +       int (*read_page)(struct mtd_info *mtd, struct nand_chip *chip, u8 *buf, int page);
57 +#endif /* CONFIG_MTK_MTD_NAND */
58  
59         int chip_delay;
60         unsigned int options;