d0bc250f4519b98f7161dcf673f0b9fa9169f2ec
[openwrt/staging/lynxis.git] / target / linux / mediatek / patches-4.4 / 0076-mtd-nand-add-power-domains-to-the-mediatek-driver.patch
1 From 5dc0d474396e04e6c140d71f0e113eb1c03501c5 Mon Sep 17 00:00:00 2001
2 From: John Crispin <john@phrozen.org>
3 Date: Tue, 17 May 2016 05:44:10 +0200
4 Subject: [PATCH 076/102] mtd: nand: add power domains to the mediatek driver
5
6 Signed-off-by: John Crispin <john@phrozen.org>
7 ---
8 drivers/mtd/nand/mtk_nand.c | 13 ++++++++++++-
9 1 file changed, 12 insertions(+), 1 deletion(-)
10
11 diff --git a/drivers/mtd/nand/mtk_nand.c b/drivers/mtd/nand/mtk_nand.c
12 index 907b90c..bde1a1d 100644
13 --- a/drivers/mtd/nand/mtk_nand.c
14 +++ b/drivers/mtd/nand/mtk_nand.c
15 @@ -16,6 +16,7 @@
16
17 #include <linux/platform_device.h>
18 #include <linux/dma-mapping.h>
19 +#include <linux/pm_runtime.h>
20 #include <linux/interrupt.h>
21 #include <linux/delay.h>
22 #include <linux/clk.h>
23 @@ -102,6 +103,7 @@
24 #define NFI_MASTER_STA (0x224)
25 #define MASTER_STA_MASK (0x0FFF)
26 #define NFI_EMPTY_THRESH (0x23C)
27 +#define NFI_ACCCON1 (0x244)
28
29 #define MTK_NAME "mtk-nand"
30 #define KB(x) ((x) * 1024UL)
31 @@ -539,6 +541,8 @@ static void mtk_nfc_bad_mark_swap(struct mtd_info *mtd, uint8_t *buf, int raw)
32 struct mtk_nfc_nand_chip *nand = to_mtk_nand(chip);
33 u32 bad_pos = nand->bad_mark.pos;
34
35 + return;
36 +
37 if (raw)
38 bad_pos += nand->bad_mark.sec * mtk_data_len(chip);
39 else
40 @@ -946,7 +950,8 @@ static int mtk_nfc_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
41
42 static inline void mtk_nfc_hw_init(struct mtk_nfc *nfc)
43 {
44 - nfi_writel(nfc, 0x10804211, NFI_ACCCON);
45 + nfi_writel(nfc, 0x30c77fff, NFI_ACCCON);
46 + nfi_writel(nfc, 0xC03222, NFI_ACCCON1);
47 nfi_writew(nfc, 0xf1, NFI_CNRNB);
48 nfi_writew(nfc, PAGEFMT_8K_16K, NFI_PAGEFMT);
49
50 @@ -1328,6 +1333,9 @@ static int mtk_nfc_probe(struct platform_device *pdev)
51 goto clk_disable;
52 }
53
54 + pm_runtime_enable(dev);
55 + pm_runtime_get_sync(dev);
56 +
57 platform_set_drvdata(pdev, nfc);
58
59 ret = mtk_nfc_nand_chips_init(dev, nfc);
60 @@ -1362,6 +1370,9 @@ static int mtk_nfc_remove(struct platform_device *pdev)
61 mtk_ecc_release(nfc->ecc);
62 mtk_nfc_disable_clk(&nfc->clk);
63
64 + pm_runtime_put_sync(&pdev->dev);
65 + pm_runtime_disable(&pdev->dev);
66 +
67 return 0;
68 }
69
70 --
71 1.7.10.4
72