From: Grant Likely <grant.likely@secretlab.ca>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: linux-mtd@lists.infradead.org,
devicetree-discuss@lists.ozlabs.org,
Nicolas Ferre <nicolas.ferre@atmel.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [FOR 3.4 PATCH 4/6] of/mtd/nand: add generic bindings and helpers
Date: Sat, 28 Jan 2012 13:05:45 -0700 [thread overview]
Message-ID: <20120128200545.GH2501@ponder.secretlab.ca> (raw)
In-Reply-To: <1327727444-23908-4-git-send-email-plagnioj@jcrosoft.com>
On Sat, Jan 28, 2012 at 06:10:42AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> - nand-ecc-mode : String, operation mode of the NAND ecc mode.
> Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first",
> "soft_bch".
> - nand-bus-width : 8 or 16 bus width if not present 8
> - nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> Cc: devicetree-discuss@lists.ozlabs.org
> Cc: linux-mtd@lists.infradead.org
Fine by me.
Acked-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> Documentation/devicetree/bindings/mtd/nand.txt | 7 ++
> drivers/of/Kconfig | 4 +
> drivers/of/Makefile | 1 +
> drivers/of/of_mtd.c | 90 ++++++++++++++++++++++++
> include/linux/of_mtd.h | 19 +++++
> 5 files changed, 121 insertions(+), 0 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/mtd/nand.txt
> create mode 100644 drivers/of/of_mtd.c
> create mode 100644 include/linux/of_mtd.h
>
> diff --git a/Documentation/devicetree/bindings/mtd/nand.txt b/Documentation/devicetree/bindings/mtd/nand.txt
> new file mode 100644
> index 0000000..03855c8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mtd/nand.txt
> @@ -0,0 +1,7 @@
> +* MTD generic binding
> +
> +- nand-ecc-mode : String, operation mode of the NAND ecc mode.
> + Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first",
> + "soft_bch".
> +- nand-bus-width : 8 or 16 bus width if not present 8
> +- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
> index 268163d..fa666a9 100644
> --- a/drivers/of/Kconfig
> +++ b/drivers/of/Kconfig
> @@ -90,4 +90,8 @@ config OF_PCI_IRQ
> help
> OpenFirmware PCI IRQ routing helpers
>
> +config OF_MTD
> + depends on MTD
> + def_bool y
> +
> endmenu # OF
> diff --git a/drivers/of/Makefile b/drivers/of/Makefile
> index a73f5a5..8c4980a 100644
> --- a/drivers/of/Makefile
> +++ b/drivers/of/Makefile
> @@ -12,3 +12,4 @@ obj-$(CONFIG_OF_SELFTEST) += selftest.o
> obj-$(CONFIG_OF_MDIO) += of_mdio.o
> obj-$(CONFIG_OF_PCI) += of_pci.o
> obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o
> +obj-$(CONFIG_OF_NET) += of_mtd.o
> diff --git a/drivers/of/of_mtd.c b/drivers/of/of_mtd.c
> new file mode 100644
> index 0000000..199bf58
> --- /dev/null
> +++ b/drivers/of/of_mtd.c
> @@ -0,0 +1,90 @@
> +/*
> + * Copyright 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> + *
> + * OF helpers for mtd.
> + *
> + * This file is released under the GPLv2
> + *
> + */
> +#include <linux/kernel.h>
> +#include <linux/of_mtd.h>
> +#include <linux/mtd/nand.h>
> +#include <linux/export.h>
> +
> +/**
> + * It maps 'enum nand_ecc_modes_t' found in include/linux/mtd/nand.h
> + * into the device tree binding of 'phy-mode', so that Ethernet
> + * device driver can get phy interface from device tree.
> + */
> +static const char *nand_ecc_modes[] = {
> + [NAND_ECC_NONE] = "none",
> + [NAND_ECC_SOFT] = "soft",
> + [NAND_ECC_HW] = "hw",
> + [NAND_ECC_HW_SYNDROME] = "hw_syndrome",
> + [NAND_ECC_HW_OOB_FIRST] = "hw_oob_first",
> + [NAND_ECC_SOFT_BCH] = "soft_bch",
> +};
> +
> +/**
> + * of_get_nand_ecc_mode - Get nand ecc mode for given device_node
> + * @np: Pointer to the given device_node
> + *
> + * The function gets ecc mode string from property 'nand-ecc-mode',
> + * and return its index in nand_ecc_modes table, or errno in error case.
> + */
> +const int of_get_nand_ecc_mode(struct device_node *np)
> +{
> + const char *pm;
> + int err, i;
> +
> + err = of_property_read_string(np, "nand-ecc-mode", &pm);
> + if (err < 0)
> + return err;
> +
> + for (i = 0; i < ARRAY_SIZE(nand_ecc_modes); i++)
> + if (!strcasecmp(pm, nand_ecc_modes[i]))
> + return i;
> +
> + return -ENODEV;
> +}
> +EXPORT_SYMBOL_GPL(of_get_nand_ecc_mode);
> +
> +/**
> + * of_get_nand_bus_width - Get nand bus witdh for given device_node
> + * @np: Pointer to the given device_node
> + *
> + * return bus width option, or errno in error case.
> + */
> +int of_get_nand_bus_width(struct device_node *np)
> +{
> + u32 val;
> +
> + if (of_property_read_u32(np, "nand-bus-width", &val))
> + return 8;
> +
> + switch(val) {
> + case 8:
> + case 16:
> + return val;
> + default:
> + return -EIO;
> + }
> +}
> +EXPORT_SYMBOL_GPL(of_get_nand_bus_width);
> +
> +/**
> + * of_get_nand_on_flash_bbt - Get nand on flash bbt for given device_node
> + * @np: Pointer to the given device_node
> + *
> + * return true if 1 false other wise
> + */
> +bool of_get_nand_on_flash_bbt(struct device_node *np)
> +{
> + u32 val;
> +
> + if (of_property_read_u32(np, "nand-on-flash-bbt", &val))
> + return false;
> +
> + return val ? true : false;
> +}
> +EXPORT_SYMBOL_GPL(of_get_nand_on_flash_bbt);
> diff --git a/include/linux/of_mtd.h b/include/linux/of_mtd.h
> new file mode 100644
> index 0000000..bae1b60
> --- /dev/null
> +++ b/include/linux/of_mtd.h
> @@ -0,0 +1,19 @@
> +/*
> + * Copyright 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> + *
> + * OF helpers for mtd.
> + *
> + * This file is released under the GPLv2
> + */
> +
> +#ifndef __LINUX_OF_MTD_H
> +#define __LINUX_OF_NET_H
> +
> +#ifdef CONFIG_OF_MTD
> +#include <linux/of.h>
> +extern const int of_get_nand_ecc_mode(struct device_node *np);
> +int of_get_nand_bus_width(struct device_node *np);
> +bool of_get_nand_on_flash_bbt(struct device_node *np);
> +#endif
> +
> +#endif /* __LINUX_OF_MTD_H */
> --
> 1.7.7
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2012-01-28 20:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1327727444-23908-1-git-send-email-plagnioj@jcrosoft.com>
2012-01-28 5:10 ` [FOR 3.4 PATCH 4/6] of/mtd/nand: add generic bindings and helpers Jean-Christophe PLAGNIOL-VILLARD
2012-01-28 20:05 ` Grant Likely [this message]
2012-01-28 5:10 ` [FOR 3.4 PATCH 5/6] atmel/nand: add DT support Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <1327727444-23908-5-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
2012-01-28 20:08 ` Grant Likely
2012-01-29 18:31 ` Simon Glass
[not found] ` <CAPnjgZ0uTwFwaK2Dxdna7p6zrj9OZdV=CxT1eGsT+M5Aa+SJNA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-30 5:56 ` Jean-Christophe PLAGNIOL-VILLARD
2012-02-06 10:35 ` [PATCH 4/6 V2] of/mtd/nand: add generic bindings and helpers Jean-Christophe PLAGNIOL-VILLARD
2012-02-06 16:20 ` Stefan Roese
2012-02-07 4:16 ` Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <20120207041606.GD15647-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org>
2012-02-07 9:45 ` Stefan Roese
[not found] ` <201202071045.30128.sr-ynQEQJNshbs@public.gmane.org>
2012-02-07 10:10 ` Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <1328524512-18159-1-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
2012-02-07 16:18 ` [PATCH 4/6 v3] " Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <1328631510-11688-1-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
2012-02-08 7:16 ` Stefan Roese
2012-02-06 10:35 ` [PATCH 5/6 V2] atmel/nand: add DT support Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <1328524512-18159-2-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
2012-02-07 10:30 ` Nicolas Ferre
2012-02-07 11:53 ` Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <20120207115306.GF15647-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org>
2012-02-21 9:22 ` Nicolas Ferre
2012-02-21 9:32 ` Jean-Christophe PLAGNIOL-VILLARD
2012-02-20 17:17 ` Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <20120220171731.GA9371-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org>
2012-02-20 21:37 ` David Woodhouse
2012-02-21 9:46 ` [PATCH 5/6 V3] " Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <1329817573-6473-1-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
2012-02-21 9:59 ` Nicolas Ferre
[not found] ` <4F436AF5.5030104-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-02-21 11:00 ` Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120128200545.GH2501@ponder.secretlab.ca \
--to=grant.likely@secretlab.ca \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=nicolas.ferre@atmel.com \
--cc=plagnioj@jcrosoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).