aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel.garcia@free-electrons.com>2014-02-24 17:24:48 -0500
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:57:49 -0400
commitf2bc306ee314bb5f8660367b5ffe43488c764639 (patch)
treef1cf6fd5267cdd0cc3642ed77cd16e0bc8139256
parentfbdf78d53275cf017b263945abfe00ce06881b4b (diff)
of_mtd: Add helpers to get ECC strength and ECC step size
This commit adds simple helpers to obtain the devicetree properties that specify the ECC strength and ECC step size to use on a given NAND controller. Acked-by: Boris BREZILLON <b.brezillon.dev@gmail.com> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Huang Shijie <b32955@freescale.com>
-rw-r--r--drivers/of/of_mtd.c34
-rw-r--r--include/linux/of_mtd.h12
2 files changed, 46 insertions, 0 deletions
diff --git a/drivers/of/of_mtd.c b/drivers/of/of_mtd.c
index a27ec94877e4..b7361ed70537 100644
--- a/drivers/of/of_mtd.c
+++ b/drivers/of/of_mtd.c
@@ -50,6 +50,40 @@ int of_get_nand_ecc_mode(struct device_node *np)
50EXPORT_SYMBOL_GPL(of_get_nand_ecc_mode); 50EXPORT_SYMBOL_GPL(of_get_nand_ecc_mode);
51 51
52/** 52/**
53 * of_get_nand_ecc_step_size - Get ECC step size associated to
54 * the required ECC strength (see below).
55 * @np: Pointer to the given device_node
56 *
57 * return the ECC step size, or errno in error case.
58 */
59int of_get_nand_ecc_step_size(struct device_node *np)
60{
61 int ret;
62 u32 val;
63
64 ret = of_property_read_u32(np, "nand-ecc-step-size", &val);
65 return ret ? ret : val;
66}
67EXPORT_SYMBOL_GPL(of_get_nand_ecc_step_size);
68
69/**
70 * of_get_nand_ecc_strength - Get required ECC strength over the
71 * correspnding step size as defined by 'nand-ecc-size'
72 * @np: Pointer to the given device_node
73 *
74 * return the ECC strength, or errno in error case.
75 */
76int of_get_nand_ecc_strength(struct device_node *np)
77{
78 int ret;
79 u32 val;
80
81 ret = of_property_read_u32(np, "nand-ecc-strength", &val);
82 return ret ? ret : val;
83}
84EXPORT_SYMBOL_GPL(of_get_nand_ecc_strength);
85
86/**
53 * of_get_nand_bus_width - Get nand bus witdh for given device_node 87 * of_get_nand_bus_width - Get nand bus witdh for given device_node
54 * @np: Pointer to the given device_node 88 * @np: Pointer to the given device_node
55 * 89 *
diff --git a/include/linux/of_mtd.h b/include/linux/of_mtd.h
index cb32d9c1e8dc..e266caa36402 100644
--- a/include/linux/of_mtd.h
+++ b/include/linux/of_mtd.h
@@ -13,6 +13,8 @@
13 13
14#include <linux/of.h> 14#include <linux/of.h>
15int of_get_nand_ecc_mode(struct device_node *np); 15int of_get_nand_ecc_mode(struct device_node *np);
16int of_get_nand_ecc_step_size(struct device_node *np);
17int of_get_nand_ecc_strength(struct device_node *np);
16int of_get_nand_bus_width(struct device_node *np); 18int of_get_nand_bus_width(struct device_node *np);
17bool of_get_nand_on_flash_bbt(struct device_node *np); 19bool of_get_nand_on_flash_bbt(struct device_node *np);
18 20
@@ -23,6 +25,16 @@ static inline int of_get_nand_ecc_mode(struct device_node *np)
23 return -ENOSYS; 25 return -ENOSYS;
24} 26}
25 27
28static inline int of_get_nand_ecc_step_size(struct device_node *np)
29{
30 return -ENOSYS;
31}
32
33static inline int of_get_nand_ecc_strength(struct device_node *np)
34{
35 return -ENOSYS;
36}
37
26static inline int of_get_nand_bus_width(struct device_node *np) 38static inline int of_get_nand_bus_width(struct device_node *np)
27{ 39{
28 return -ENOSYS; 40 return -ENOSYS;