1 From eb7f9115409710732ebc4dfe1be629252280910e Mon Sep 17 00:00:00 2001
2 From: Boris BREZILLON <boris.brezillon@free-electrons.com>
3 Date: Mon, 28 Jul 2014 14:47:04 +0200
4 Subject: [PATCH] of: mtd: Add NAND randomizer mode retrieval
6 Add a of_get_nand_rnd_mode() helper function.
8 Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
9 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 drivers/of/of_mtd.c | 35 +++++++++++++++++++++++++++++++++++
12 include/linux/of_mtd.h | 6 ++++++
13 2 files changed, 41 insertions(+)
15 --- a/drivers/of/of_mtd.c
16 +++ b/drivers/of/of_mtd.c
17 @@ -84,6 +84,41 @@ int of_get_nand_ecc_strength(struct devi
18 EXPORT_SYMBOL_GPL(of_get_nand_ecc_strength);
21 + * It maps 'enum nand_rnd_modes_t' found in include/linux/mtd/nand.h
22 + * into the device tree binding of 'nand-rnd', so that MTD
23 + * device driver can get nand rnd from device tree.
25 +static const char *nand_rnd_modes[] = {
26 + [NAND_RND_NONE] = "none",
27 + [NAND_RND_SOFT] = "soft",
28 + [NAND_RND_HW] = "hw",
32 + * of_get_nand_rnd_mode - Get nand randomizer mode for given device_node
33 + * @np: Pointer to the given device_node
35 + * The function gets randomizer mode string from property 'nand-rnd-mode',
36 + * and return its index in nand_rnd_modes table, or errno in error case.
38 +int of_get_nand_rnd_mode(struct device_node *np)
43 + err = of_property_read_string(np, "nand-rnd-mode", &pm);
47 + for (i = 0; i < ARRAY_SIZE(nand_rnd_modes); i++)
48 + if (!strcasecmp(pm, nand_rnd_modes[i]))
53 +EXPORT_SYMBOL_GPL(of_get_nand_rnd_mode);
56 * of_get_nand_bus_width - Get nand bus witdh for given device_node
57 * @np: Pointer to the given device_node
59 --- a/include/linux/of_mtd.h
60 +++ b/include/linux/of_mtd.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_rnd_mode(struct device_node *np);
66 int of_get_nand_bus_width(struct device_node *np);
67 bool of_get_nand_on_flash_bbt(struct device_node *np);
69 @@ -34,6 +35,11 @@ static inline int of_get_nand_ecc_streng
74 +static inline int of_get_nand_rnd_mode(struct device_node *np)
79 static inline int of_get_nand_bus_width(struct device_node *np)