linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Wolfgang Grandegger <wg@grandegger.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH 6/6] [POWERPC] booting-without-of: add FHCI USB, FSL MCU, FSL UPM and GPIO LEDs bindings
Date: Wed, 30 Apr 2008 15:16:56 +0400	[thread overview]
Message-ID: <20080430111656.GA14148@polina.dev.rtsoft.ru> (raw)
In-Reply-To: <48182FA6.5010900@grandegger.com>

On Wed, Apr 30, 2008 at 10:36:54AM +0200, Wolfgang Grandegger wrote:
> Hi Anton,
[...]
> > +	upm@1,0 {
> > +		#address-cells = <0>;
> > +		#size-cells = <0>;
> > +		compatible = "fsl,upm-nand";
> > +		reg = <1 0 1>;
> > +		fsl,upm-addr-offset = <16>;
> > +		fsl,upm-cmd-offset = <8>;
> > +		gpios = <&qe_pio_e 18 0>;
> > +
> > +		flash {
> > +			#address-cells = <1>;
> > +			#size-cells = <1>;
> > +			compatible = "stmicro,NAND512W3A2BN6E";
> > +
> > +			partition@0 {
> > +				...
> > +			};
> > +		};
> > +	};
> 
> Where can I find the code for that binding? fsl_upm_nand.c from
> http://patchwork.ozlabs.org/linuxppc/patch?q=upm&id=17306 does not parse
> OF partitions. Are there any plans to push the fsl_upm_nand driver
> upstream?

David already pushed UPM NAND driver upstream, but true, it was an "old"
version, i.e. without approved bindings. I'll send the update (inlining
here) if/when these bindings will be applied to the powerpc tree.

- - - -
From: Anton Vorontsov <avorontsov@ru.mvista.com>
Subject: [NAND] update FSL UPM NAND driver for the new OF bindings

- get rid of fsl,wait-pattern and fsl,wait-write. I think this isn't
  chip-specific, and we should always do waits. I saw one board that
  didn't need fsl,wait-pattern, but I assume it was exception that
  proves general rule;
- get rid of chip-delay. Today there are no users for this, and if
  anyone really need this they should push the OF bindings beforehand;
- Now flash chips should be child nodes of the FSL UPM nand controller;
- Implement OF partition parsing.

Signed-off-by: not yet.
---
 drivers/mtd/nand/fsl_upm.c |   62 +++++++++++++++++++++++++++-----------------
 1 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
index 1ebfd87..f91c950 100644
--- a/drivers/mtd/nand/fsl_upm.c
+++ b/drivers/mtd/nand/fsl_upm.c
@@ -36,9 +36,6 @@ struct fsl_upm_nand {
 	uint8_t upm_cmd_offset;
 	void __iomem *io_base;
 	int rnb_gpio;
-	const uint32_t *wait_pattern;
-	const uint32_t *wait_write;
-	int chip_delay;
 };
 
 #define to_fsl_upm_nand(mtd) container_of(mtd, struct fsl_upm_nand, mtd)
@@ -89,8 +86,7 @@ static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 
 	fsl_upm_run_pattern(&fun->upm, fun->io_base, cmd);
 
-	if (fun->wait_pattern)
-		fun_wait_rnb(fun);
+	fun_wait_rnb(fun);
 }
 
 static uint8_t fun_read_byte(struct mtd_info *mtd)
@@ -116,14 +112,16 @@ static void fun_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
 
 	for (i = 0; i < len; i++) {
 		out_8(fun->chip.IO_ADDR_W, buf[i]);
-		if (fun->wait_write)
-			fun_wait_rnb(fun);
+		fun_wait_rnb(fun);
 	}
 }
 
-static int __devinit fun_chip_init(struct fsl_upm_nand *fun)
+static int __devinit fun_chip_init(struct fsl_upm_nand *fun,
+				   const struct device_node *upm_np,
+				   const struct resource *io_res)
 {
 	int ret;
+	struct device_node *flash_np;
 #ifdef CONFIG_MTD_PARTITIONS
 	static const char *part_types[] = { "cmdlinepart", NULL, };
 #endif
@@ -131,7 +129,7 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun)
 	fun->chip.IO_ADDR_R = fun->io_base;
 	fun->chip.IO_ADDR_W = fun->io_base;
 	fun->chip.cmd_ctrl = fun_cmd_ctrl;
-	fun->chip.chip_delay = fun->chip_delay;
+	fun->chip.chip_delay = 50;
 	fun->chip.read_byte = fun_read_byte;
 	fun->chip.read_buf = fun_read_buf;
 	fun->chip.write_buf = fun_write_buf;
@@ -143,18 +141,42 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun)
 	fun->mtd.priv = &fun->chip;
 	fun->mtd.owner = THIS_MODULE;
 
+	flash_np = of_get_next_child(upm_np, NULL);
+	if (!flash_np)
+		return -ENODEV;
+
+	fun->mtd.name = kasprintf(GFP_KERNEL, "%x.%s", io_res->start,
+				  flash_np->name);
+	if (!fun->mtd.name) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
 	ret = nand_scan(&fun->mtd, 1);
 	if (ret)
-		return ret;
-
-	fun->mtd.name = fun->dev->bus_id;
+		goto err;
 
 #ifdef CONFIG_MTD_PARTITIONS
 	ret = parse_mtd_partitions(&fun->mtd, part_types, &fun->parts, 0);
+
+#ifdef CONFIG_MTD_OF_PARTS
+	if (ret <= 0) {
+		ret = of_mtd_parse_partitions(fun->dev, &fun->mtd,
+					flash_np, &fun->parts);
+		if (ret < 0) {
+			ret = -EINVAL;
+			goto err;
+		}
+	}
+#endif
 	if (ret > 0)
-		return add_mtd_partitions(&fun->mtd, fun->parts, ret);
+		ret = add_mtd_partitions(&fun->mtd, fun->parts, ret);
+	else
 #endif
-	return add_mtd_device(&fun->mtd);
+		ret = add_mtd_device(&fun->mtd);
+err:
+	of_node_put(flash_np);
+	return ret;
 }
 
 static int __devinit fun_probe(struct of_device *ofdev,
@@ -220,17 +242,8 @@ static int __devinit fun_probe(struct of_device *ofdev,
 
 	fun->dev = &ofdev->dev;
 	fun->last_ctrl = NAND_CLE;
-	fun->wait_pattern = of_get_property(ofdev->node, "fsl,wait-pattern",
-					    NULL);
-	fun->wait_write = of_get_property(ofdev->node, "fsl,wait-write", NULL);
-
-	prop = of_get_property(ofdev->node, "chip-delay", NULL);
-	if (prop)
-		fun->chip_delay = *prop;
-	else
-		fun->chip_delay = 50;
 
-	ret = fun_chip_init(fun);
+	ret = fun_chip_init(fun, ofdev->node, &io_res);
 	if (ret)
 		goto err2;
 
@@ -251,6 +264,7 @@ static int __devexit fun_remove(struct of_device *ofdev)
 	struct fsl_upm_nand *fun = dev_get_drvdata(&ofdev->dev);
 
 	nand_release(&fun->mtd);
+	kfree(fun->mtd.name);
 
 	if (fun->rnb_gpio >= 0)
 		gpio_free(fun->rnb_gpio);
-- 
1.5.5.1

  reply	other threads:[~2008-04-30 11:16 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-29 18:59 [PATCH 0/6 v4] Few more patches for Kumar's powerpc.git Anton Vorontsov
2008-04-29 19:00 ` [PATCH 1/6] [POWERPC] sysdev: implement FSL GTM support Anton Vorontsov
2008-05-01  4:00   ` Kumar Gala
2008-05-01 11:43     ` Anton Vorontsov
2008-04-29 19:00 ` [PATCH 2/6] [POWERPC] QE: add support for QE USB clocks routing Anton Vorontsov
2008-04-29 19:57   ` Timur Tabi
2008-04-29 21:22     ` Anton Vorontsov
2008-04-29 19:00 ` [PATCH 3/6] [POWERPC] QE: prepare QE PIO code for GPIO LIB support Anton Vorontsov
2008-04-29 20:10   ` Timur Tabi
2008-04-29 19:00 ` [PATCH 4/6] [POWERPC] QE: implement support for the GPIO LIB API Anton Vorontsov
2008-04-29 20:29   ` Timur Tabi
2008-04-29 21:23     ` Anton Vorontsov
2008-04-29 21:29       ` Timur Tabi
2008-04-30 19:30   ` [PATCH v2 " Anton Vorontsov
2008-04-30 19:42     ` Timur Tabi
2008-04-30 22:47       ` Anton Vorontsov
2008-04-30 22:50         ` Timur Tabi
2008-04-30 22:59           ` Anton Vorontsov
2008-04-30 23:03             ` Timur Tabi
2008-04-30 23:24               ` Anton Vorontsov
2008-05-01 14:33                 ` Timur Tabi
2008-05-01 14:33     ` Timur Tabi
2008-04-29 19:00 ` [PATCH 5/6] [POWERPC] 83xx: new board support: MPC8360E-RDK Anton Vorontsov
2008-06-10 15:55   ` Kumar Gala
2008-06-10 19:32     ` [PATCH] powerpc: 83xx: update mpc83xx_defconfig to support MPC8360E-RDK Anton Vorontsov
2008-06-10 22:01       ` Kumar Gala
2008-06-10 23:16         ` [PATCH v2] powerpc/83xx: " Anton Vorontsov
2008-06-11 12:47           ` [PATCH v3] " Anton Vorontsov
2008-04-29 19:00 ` [PATCH 6/6] [POWERPC] booting-without-of: add FHCI USB, FSL MCU, FSL UPM and GPIO LEDs bindings Anton Vorontsov
2008-04-30  8:36   ` Wolfgang Grandegger
2008-04-30 11:16     ` Anton Vorontsov [this message]
2008-04-30 13:19       ` Wolfgang Grandegger
2008-04-30 14:07         ` Anton Vorontsov
2008-04-30 17:26           ` Wolfgang Grandegger
  -- strict thread matches above, loose matches on Subject: below --
2008-04-25 17:00 [PATCH 0/6 v3] Few more patches for Kumar's powerpc.git Anton Vorontsov
2008-04-25 17:01 ` [PATCH 6/6] [POWERPC] booting-without-of: add FHCI USB, FSL MCU, FSL UPM and GPIO LEDs bindings Anton Vorontsov

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=20080430111656.GA14148@polina.dev.rtsoft.ru \
    --to=avorontsov@ru.mvista.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=wg@grandegger.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).