mvebu: Add MTD split framework support
[openwrt/svn-archive/archive.git] / target / linux / mvebu / patches-3.14 / 009-add_of_mtd_ecc_helpers.patch
1 From 6d9434ebb76157071164b32ad03fbed165c74382 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Mon, 24 Feb 2014 19:24:48 -0300
4 Subject: of_mtd: Add helpers to get ECC strength and ECC step size
5
6 This commit adds simple helpers to obtain the devicetree properties
7 that specify the ECC strength and ECC step size to use on a given
8 NAND controller.
9
10 Acked-by: Boris BREZILLON <b.brezillon.dev@gmail.com>
11 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
12 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
13
14 --- a/drivers/of/of_mtd.c
15 +++ b/drivers/of/of_mtd.c
16 @@ -50,6 +50,40 @@ int of_get_nand_ecc_mode(struct device_n
17 EXPORT_SYMBOL_GPL(of_get_nand_ecc_mode);
18
19 /**
20 + * of_get_nand_ecc_step_size - Get ECC step size associated to
21 + * the required ECC strength (see below).
22 + * @np: Pointer to the given device_node
23 + *
24 + * return the ECC step size, or errno in error case.
25 + */
26 +int of_get_nand_ecc_step_size(struct device_node *np)
27 +{
28 + int ret;
29 + u32 val;
30 +
31 + ret = of_property_read_u32(np, "nand-ecc-step-size", &val);
32 + return ret ? ret : val;
33 +}
34 +EXPORT_SYMBOL_GPL(of_get_nand_ecc_step_size);
35 +
36 +/**
37 + * of_get_nand_ecc_strength - Get required ECC strength over the
38 + * correspnding step size as defined by 'nand-ecc-size'
39 + * @np: Pointer to the given device_node
40 + *
41 + * return the ECC strength, or errno in error case.
42 + */
43 +int of_get_nand_ecc_strength(struct device_node *np)
44 +{
45 + int ret;
46 + u32 val;
47 +
48 + ret = of_property_read_u32(np, "nand-ecc-strength", &val);
49 + return ret ? ret : val;
50 +}
51 +EXPORT_SYMBOL_GPL(of_get_nand_ecc_strength);
52 +
53 +/**
54 * of_get_nand_bus_width - Get nand bus witdh for given device_node
55 * @np: Pointer to the given device_node
56 *
57 --- a/include/linux/of_mtd.h
58 +++ b/include/linux/of_mtd.h
59 @@ -13,6 +13,8 @@
60
61 #include <linux/of.h>
62 int of_get_nand_ecc_mode(struct device_node *np);
63 +int of_get_nand_ecc_step_size(struct device_node *np);
64 +int of_get_nand_ecc_strength(struct device_node *np);
65 int of_get_nand_bus_width(struct device_node *np);
66 bool of_get_nand_on_flash_bbt(struct device_node *np);
67
68 @@ -23,6 +25,16 @@ static inline int of_get_nand_ecc_mode(s
69 return -ENOSYS;
70 }
71
72 +static inline int of_get_nand_ecc_step_size(struct device_node *np)
73 +{
74 + return -ENOSYS;
75 +}
76 +
77 +static inline int of_get_nand_ecc_strength(struct device_node *np)
78 +{
79 + return -ENOSYS;
80 +}
81 +
82 static inline int of_get_nand_bus_width(struct device_node *np)
83 {
84 return -ENOSYS;