devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sekhar Nori <nsekhar-l0cyMroinI0@public.gmane.org>
To: Heiko Schocher <hs-ynQEQJNshbs@public.gmane.org>
Cc: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org,
	Wolfgang Denk <wd-ynQEQJNshbs@public.gmane.org>,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	Grant Likely
	<grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Scott Wood <scottwood-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
	David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH v5 6/7] ARM: mtd: nand: davinci: add OF support for davinci nand controller
Date: Wed, 18 Jul 2012 23:15:28 +0530	[thread overview]
Message-ID: <5006F638.2000301@ti.com> (raw)
In-Reply-To: <1338373143-7467-7-git-send-email-hs-ynQEQJNshbs@public.gmane.org>

Hi Heiko,

On 5/30/2012 3:49 PM, Heiko Schocher wrote:
> add OF support for the davinci nand controller.
> 
> Signed-off-by: Heiko Schocher <hs-ynQEQJNshbs@public.gmane.org>
> Cc: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org
> Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> Cc: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> Cc: David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
> Cc: Sekhar Nori <nsekhar-l0cyMroinI0@public.gmane.org>
> Cc: Wolfgang Denk <wd-ynQEQJNshbs@public.gmane.org>
> Cc: Scott Wood <scottwood-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> 
> ---
> - changes for v2:
>   - add comments from Scott Wood:
>     - add "ti,davinci-" prefix
>     - Dashes are preferred to underscores
>     - rename "nandflash" to "nand"
>     - introduce new "ti,davinci" specific properties for setting
>       up ecc_mode, ecc_bits, options and bbt options, instead
>       using linux defines
>     - readme fixes
> - no changes for v3
> - changes for v4
>   remove "pinmux-handle" property as discussed here:
>   http://www.spinics.net/lists/arm-kernel/msg175701.html
>   with Nori Sekhar
> - no changes for v5
> 
>  .../devicetree/bindings/arm/davinci/nand.txt       |   72 ++++++++++++++++++
>  drivers/mtd/nand/davinci_nand.c                    |   80 +++++++++++++++++++-
>  2 files changed, 151 insertions(+), 1 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/arm/davinci/nand.txt
> 
> diff --git a/Documentation/devicetree/bindings/arm/davinci/nand.txt b/Documentation/devicetree/bindings/arm/davinci/nand.txt
> new file mode 100644
> index 0000000..5afe4a6
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/arm/davinci/nand.txt
> @@ -0,0 +1,72 @@
> +* Texas Instruments Davinci NAND
> +
> +This file provides information, what the device node for the
> +davinci nand interface contain.
> +
> +Required properties:
> +- compatible: "ti,davinci-nand";
> +- reg : contain 2 offset/length values:
> +        - offset and length for the access window
> +        - offset and length for accessing the aemif control registers
> +- ti,davinci-chipselect: Indicates on the davinci_nand driver which
> +                         chipselect is used for accessing the nand.
> +
> +Recommended properties :
> +- ti,davinci-mask-ale: mask for ale
> +- ti,davinci-mask-cle: mask for cle
> +- ti,davinci-mask-chipsel: mask for chipselect
> +- ti,davinci-ecc-mode: ECC mode valid values for davinci driver:
> +		- "none"
> +		- "soft"
> +		- "hw"
> +- ti,davinci-ecc-bits: used ECC bits, currently supported 1 or 4.
> +- ti,davinci-nand-buswidth: buswidth 8 or 16
> +- ti,davinci-nand-use-bbt: use flash based bad block table support.
> +
> +Optional properties:
> +- timing-handle: contains a handle to setup aemif timing.
> +
> +Example (enbw_cmc board):
> +aemif@60000000 {
> +	compatible = "ti,davinci-aemif";
> +	#address-cells = <2>;
> +	#size-cells = <1>;
> +	reg = <0x68000000 0x80000>;
> +	ranges = <2 0 0x60000000 0x02000000
> +		  3 0 0x62000000 0x02000000
> +		  4 0 0x64000000 0x02000000
> +		  5 0 0x66000000 0x02000000
> +		  6 0 0x68000000 0x02000000>;
> +	nand_cs: cs3@68000000 {
> +		compatible = "ti,davinci-cs";
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		/* all timings in nanoseconds */
> +		cs = <3>;
> +		asize = <0>;
> +		ta = <0>;
> +		rhold = <7>;
> +		rstrobe = <42>;
> +		rsetup = <7>;
> +		whold = <7>;
> +		wstrobe = <14>;
> +		wsetup = <7>;
> +		ew = <0>;
> +		ss = <0>;
> +	};
> +	nand@3,0 {
> +		compatible = "ti,davinci-nand";
> +		reg = <3 0x0 0x807ff
> +			6 0x0 0x8000>;
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		ti,davinci-chipselect = <1>;
> +		ti,davinci-mask-ale = <0>;
> +		ti,davinci-mask-cle = <0>;
> +		ti,davinci-mask-chipsel = <0>;
> +		ti,davinci-ecc-mode = "hw";
> +		ti,davinci-ecc-bits = <4>;
> +		ti,davinci-nand-use-bbt;
> +		timing-handle = <&nand_cs>;
> +	};
> +};
> diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
> index d94b03c..67bdd29 100644
> --- a/drivers/mtd/nand/davinci_nand.c
> +++ b/drivers/mtd/nand/davinci_nand.c
> @@ -33,9 +33,12 @@
>  #include <linux/mtd/nand.h>
>  #include <linux/mtd/partitions.h>
>  #include <linux/slab.h>
> +#include <linux/of_i2c.h>

This include is not required.

> +#include <linux/of_device.h>
>  
>  #include <mach/nand.h>
>  #include <mach/aemif.h>
> +#include <mach/mux.h>

This too.

>  
>  /*
>   * This is a device driver for the NAND flash controller found on the
> @@ -518,9 +521,81 @@ static struct nand_ecclayout hwecc4_2048 __initconst = {
>  	},
>  };
>  
> +#if defined(CONFIG_OF)
> +static const struct of_device_id davinci_nand_of_match[] = {
> +	{.compatible = "ti,davinci-nand", },
> +	{},
> +}
> +MODULE_DEVICE_TABLE(of, davinci_nand_of_match);
> +
> +static struct davinci_nand_pdata
> +	*nand_davinci_get_pdata(struct platform_device *pdev)
> +{
> +	if ((pdev->dev.platform_data == NULL) &&
> +		(pdev->dev.of_node)) {

You can simplify this and also avoid breaking the statement.

	if (!pdev->dev.platform_data && pdev->dev.of_node) {


> +		struct device_node *tmp_np;
> +		struct davinci_nand_pdata *pdata;
> +		const char *mode;
> +		u32 prop;
> +		int len;
> +
> +		pdata =  kzalloc(sizeof(struct davinci_nand_pdata),
> +				GFP_KERNEL);

I don't see this getting freed anywhere. You wanted to use devm_kzalloc()?

> +		pdev->dev.platform_data = pdata;
> +		if (!pdata)
> +			return NULL;
> +		if (!of_property_read_u32(pdev->dev.of_node,
> +			"ti,davinci-chipselect", &prop))
> +			pdev->id = prop;
> +		if (!of_property_read_u32(pdev->dev.of_node,
> +			"ti,davinci-mask-ale", &prop))
> +			pdata->mask_ale = prop;
> +		if (!of_property_read_u32(pdev->dev.of_node,
> +			"ti,davinci-mask-cle", &prop))
> +			pdata->mask_cle = prop;
> +		if (!of_property_read_u32(pdev->dev.of_node,
> +			"ti,davinci-mask-chipsel", &prop))
> +			pdata->mask_chipsel = prop;
> +		if (!of_property_read_string(pdev->dev.of_node,
> +			"ti,davinci-ecc-mode", &mode)) {
> +			if (!strncmp("none", mode, 4))
> +				pdata->ecc_mode = NAND_ECC_NONE;
> +			if (!strncmp("soft", mode, 4))
> +				pdata->ecc_mode = NAND_ECC_SOFT;
> +			if (!strncmp("hw", mode, 2))
> +				pdata->ecc_mode = NAND_ECC_HW;
> +		}
> +		if (!of_property_read_u32(pdev->dev.of_node,
> +			"ti,davinci-ecc-bits", &prop))
> +			pdata->ecc_bits = prop;
> +		if (!of_property_read_u32(pdev->dev.of_node,
> +			"ti,davinci-nand-buswidth", &prop))
> +			if (prop == 16)
> +				pdata->options |= NAND_BUSWIDTH_16;
> +		if (of_find_property(pdev->dev.of_node,
> +			"ti,davinci-nand-use-bbt", &len))
> +			pdata->bbt_options = NAND_BBT_USE_FLASH;
> +

> +		tmp_np = of_parse_phandle(pdev->dev.of_node,
> +				"timing-handle", 0);
> +		if (tmp_np)
> +			davinci_aemif_setup_timing_of(tmp_np);

Since the aemif driver conversion to DT needs to be looked at along with
its movement to drivers/ folder, is it possible to drop the AEMIF timing
specific bindings from the patch and only keep the NAND specific ones?

Thanks,
Sekhar

  parent reply	other threads:[~2012-07-18 17:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-30 10:18 [PATCH v5 0/7] ARM: davinci: add support for the am1808 based enbw_cmc board Heiko Schocher
     [not found] ` <1338373143-7467-1-git-send-email-hs-ynQEQJNshbs@public.gmane.org>
2012-05-30 10:18   ` [PATCH v5 1/7] ARM: davinci, cp_intc: Add irq domain support Heiko Schocher
     [not found]     ` <1338373143-7467-2-git-send-email-hs-ynQEQJNshbs@public.gmane.org>
2012-06-01 19:36       ` Sekhar Nori
     [not found]         ` <4FC919C9.6070107-l0cyMroinI0@public.gmane.org>
2012-06-12 17:36           ` Sekhar Nori
     [not found]             ` <4FD77E0F.8050907-l0cyMroinI0@public.gmane.org>
2012-06-13  9:50               ` Heiko Schocher
2012-06-25 17:15       ` Sekhar Nori
     [not found]         ` <4FE89CCB.4090609-l0cyMroinI0@public.gmane.org>
2012-06-26  6:54           ` Heiko Schocher
2012-05-30 10:18   ` [PATCH v5 2/7] ARM: davinci, cp_intc: Add OF support for TI interrupt controller Heiko Schocher
     [not found]     ` <1338373143-7467-3-git-send-email-hs-ynQEQJNshbs@public.gmane.org>
2012-07-03 19:09       ` Sekhar Nori
     [not found]         ` <4FF34360.6030501-l0cyMroinI0@public.gmane.org>
2012-07-03 19:16           ` [PATCH] ARM: davinci: " Sekhar Nori
     [not found]             ` <1341342970-27535-1-git-send-email-nsekhar-l0cyMroinI0@public.gmane.org>
2012-07-05 12:43               ` Heiko Schocher
     [not found]                 ` <4FF58BDC.6060802-ynQEQJNshbs@public.gmane.org>
2012-07-06 16:53                   ` Sekhar Nori
     [not found]                     ` <4FF71822.2070908-l0cyMroinI0@public.gmane.org>
2012-07-10  8:43                       ` Sekhar Nori
2012-05-30 10:18   ` [PATCH v5 3/7] ARM: davinci: configure davinci aemif chipselects through OF Heiko Schocher
2012-05-30 10:19   ` [PATCH v5 5/7] ARM: davinci: i2c: add OF support Heiko Schocher
     [not found]     ` <1338373143-7467-6-git-send-email-hs-ynQEQJNshbs@public.gmane.org>
2012-07-13 13:57       ` Sekhar Nori
     [not found]         ` <5000294C.5070606-l0cyMroinI0@public.gmane.org>
2012-07-14  4:15           ` Heiko Schocher
     [not found]             ` <5000F276.3080301-ynQEQJNshbs@public.gmane.org>
2012-07-16 16:16               ` Sekhar Nori
2012-05-30 10:19   ` [PATCH v5 6/7] ARM: mtd: nand: davinci: add OF support for davinci nand controller Heiko Schocher
     [not found]     ` <1338373143-7467-7-git-send-email-hs-ynQEQJNshbs@public.gmane.org>
2012-07-18 17:45       ` Sekhar Nori [this message]
2012-05-30 10:19   ` [PATCH v5 7/7] ARM: davinci: add support for the am1808 based enbw_cmc board Heiko Schocher
2012-05-30 10:19 ` [PATCH v5 4/7] ARM: davinci: net: davinci_emac: add OF support Heiko Schocher
     [not found]   ` <1338373143-7467-5-git-send-email-hs-ynQEQJNshbs@public.gmane.org>
2012-07-08 14:26     ` Sekhar Nori
     [not found]       ` <4FF998A7.50309-l0cyMroinI0@public.gmane.org>
2012-07-09  8:25         ` Heiko Schocher

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=5006F638.2000301@ti.com \
    --to=nsekhar-l0cymroini0@public.gmane.org \
    --cc=davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=hs-ynQEQJNshbs@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=scottwood-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=wd-ynQEQJNshbs@public.gmane.org \
    /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).