1 From 410a91f6efa1c4c3c4369d1dd2c31286749dff33 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Wed, 23 Mar 2016 11:19:01 +0100
4 Subject: [PATCH 073/102] of: mtd: prepare helper reading NAND ECC algo from
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 NAND subsystem is being slightly reworked to store ECC details in
11 separated fields. In future we'll want to add support for more DT
12 properties as specifying every possible setup with a single
13 "nand-ecc-mode" is a pretty bad idea.
14 To allow this let's add a helper that will support something like
15 "nand-ecc-algo" in future. Right now we use it for keeping backward
18 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
19 Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
21 drivers/of/of_mtd.c | 36 ++++++++++++++++++++++++++++++++++++
22 include/linux/of_mtd.h | 6 ++++++
23 2 files changed, 42 insertions(+)
25 --- a/drivers/of/of_mtd.c
26 +++ b/drivers/of/of_mtd.c
27 @@ -50,6 +50,42 @@ int of_get_nand_ecc_mode(struct device_n
28 EXPORT_SYMBOL_GPL(of_get_nand_ecc_mode);
31 + * of_get_nand_ecc_algo - Get nand ecc algorithm for given device_node
32 + * @np: Pointer to the given device_node
34 + * The function gets ecc algorithm and returns its enum value, or errno in error
37 +int of_get_nand_ecc_algo(struct device_node *np)
43 + * TODO: Read ECC algo OF property and map it to enum nand_ecc_algo.
44 + * It's not implemented yet as currently NAND subsystem ignores
45 + * algorithm explicitly set this way. Once it's handled we should
46 + * document & support new property.
50 + * For backward compatibility we also read "nand-ecc-mode" checking
51 + * for some obsoleted values that were specifying ECC algorithm.
53 + err = of_property_read_string(np, "nand-ecc-mode", &pm);
57 + if (!strcasecmp(pm, "soft"))
58 + return NAND_ECC_HAMMING;
59 + else if (!strcasecmp(pm, "soft_bch"))
60 + return NAND_ECC_BCH;
64 +EXPORT_SYMBOL_GPL(of_get_nand_ecc_algo);
67 * of_get_nand_ecc_step_size - Get ECC step size associated to
68 * the required ECC strength (see below).
69 * @np: Pointer to the given device_node
70 --- a/include/linux/of_mtd.h
71 +++ b/include/linux/of_mtd.h
75 int of_get_nand_ecc_mode(struct device_node *np);
76 +int of_get_nand_ecc_algo(struct device_node *np);
77 int of_get_nand_ecc_step_size(struct device_node *np);
78 int of_get_nand_ecc_strength(struct device_node *np);
79 int of_get_nand_bus_width(struct device_node *np);
80 @@ -24,6 +25,11 @@ static inline int of_get_nand_ecc_mode(s
85 +static inline int of_get_nand_ecc_algo(struct device_node *np)
90 static inline int of_get_nand_ecc_step_size(struct device_node *np)