bmips: move to kernel 6.1 by default
[openwrt/staging/dangole.git] / target / linux / bmips / patches-5.15 / 210-macronix_nand_block_protection_support.patch
1 From 5a37811de679bff03e9c5a746f75574910ede964 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
3 Date: Wed, 22 Mar 2023 20:52:13 +0100
4 Subject: [PATCH] Revert "mtd: rawnand: Macronix: Add support for block
5 protection"
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 This reverts commit 03a539c7a118427a6609a26461358c56ac8f3a06.
11
12 Macronix block protection doesn't seem to be supported on Sercomm H-500s
13 devices since it hangs the device.
14
15 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
16 ---
17 drivers/mtd/nand/raw/nand_macronix.c | 72 ----------------------------
18 1 file changed, 72 deletions(-)
19
20 --- a/drivers/mtd/nand/raw/nand_macronix.c
21 +++ b/drivers/mtd/nand/raw/nand_macronix.c
22 @@ -12,10 +12,6 @@
23 #define MACRONIX_READ_RETRY_BIT BIT(0)
24 #define MACRONIX_NUM_READ_RETRY_MODES 6
25
26 -#define ONFI_FEATURE_ADDR_MXIC_PROTECTION 0xA0
27 -#define MXIC_BLOCK_PROTECTION_ALL_LOCK 0x38
28 -#define MXIC_BLOCK_PROTECTION_ALL_UNLOCK 0x0
29 -
30 #define ONFI_FEATURE_ADDR_MXIC_RANDOMIZER 0xB0
31 #define MACRONIX_RANDOMIZER_BIT BIT(1)
32 #define MACRONIX_RANDOMIZER_ENPGM BIT(0)
33 @@ -179,73 +175,6 @@ static void macronix_nand_fix_broken_get
34 ONFI_FEATURE_ADDR_TIMING_MODE, 1);
35 }
36
37 -/*
38 - * Macronix NAND supports Block Protection by Protectoin(PT) pin;
39 - * active high at power-on which protects the entire chip even the #WP is
40 - * disabled. Lock/unlock protection area can be partition according to
41 - * protection bits, i.e. upper 1/2 locked, upper 1/4 locked and so on.
42 - */
43 -static int mxic_nand_lock(struct nand_chip *chip, loff_t ofs, uint64_t len)
44 -{
45 - u8 feature[ONFI_SUBFEATURE_PARAM_LEN];
46 - int ret;
47 -
48 - feature[0] = MXIC_BLOCK_PROTECTION_ALL_LOCK;
49 - nand_select_target(chip, 0);
50 - ret = nand_set_features(chip, ONFI_FEATURE_ADDR_MXIC_PROTECTION,
51 - feature);
52 - nand_deselect_target(chip);
53 - if (ret)
54 - pr_err("%s all blocks failed\n", __func__);
55 -
56 - return ret;
57 -}
58 -
59 -static int mxic_nand_unlock(struct nand_chip *chip, loff_t ofs, uint64_t len)
60 -{
61 - u8 feature[ONFI_SUBFEATURE_PARAM_LEN];
62 - int ret;
63 -
64 - feature[0] = MXIC_BLOCK_PROTECTION_ALL_UNLOCK;
65 - nand_select_target(chip, 0);
66 - ret = nand_set_features(chip, ONFI_FEATURE_ADDR_MXIC_PROTECTION,
67 - feature);
68 - nand_deselect_target(chip);
69 - if (ret)
70 - pr_err("%s all blocks failed\n", __func__);
71 -
72 - return ret;
73 -}
74 -
75 -static void macronix_nand_block_protection_support(struct nand_chip *chip)
76 -{
77 - u8 feature[ONFI_SUBFEATURE_PARAM_LEN];
78 - int ret;
79 -
80 - bitmap_set(chip->parameters.get_feature_list,
81 - ONFI_FEATURE_ADDR_MXIC_PROTECTION, 1);
82 -
83 - feature[0] = MXIC_BLOCK_PROTECTION_ALL_UNLOCK;
84 - nand_select_target(chip, 0);
85 - ret = nand_get_features(chip, ONFI_FEATURE_ADDR_MXIC_PROTECTION,
86 - feature);
87 - nand_deselect_target(chip);
88 - if (ret || feature[0] != MXIC_BLOCK_PROTECTION_ALL_LOCK) {
89 - if (ret)
90 - pr_err("Block protection check failed\n");
91 -
92 - bitmap_clear(chip->parameters.get_feature_list,
93 - ONFI_FEATURE_ADDR_MXIC_PROTECTION, 1);
94 - return;
95 - }
96 -
97 - bitmap_set(chip->parameters.set_feature_list,
98 - ONFI_FEATURE_ADDR_MXIC_PROTECTION, 1);
99 -
100 - chip->ops.lock_area = mxic_nand_lock;
101 - chip->ops.unlock_area = mxic_nand_unlock;
102 -}
103 -
104 static int nand_power_down_op(struct nand_chip *chip)
105 {
106 int ret;
107 @@ -323,7 +252,6 @@ static int macronix_nand_init(struct nan
108
109 macronix_nand_fix_broken_get_timings(chip);
110 macronix_nand_onfi_init(chip);
111 - macronix_nand_block_protection_support(chip);
112 macronix_nand_deep_power_down_support(chip);
113
114 return 0;