linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mtd: sh_flctl: Probe SNAND_E flag from NAND chip
@ 2012-09-26  9:05 Bastian Hecht
  2012-09-26  9:05 ` [PATCH 2/3] mtd: sh_flctl: Add device tree support Bastian Hecht
  2012-09-26  9:05 ` [PATCH 3/3] mtd: sh_flctl: Add sh7372 device tree config Bastian Hecht
  0 siblings, 2 replies; 3+ messages in thread
From: Bastian Hecht @ 2012-09-26  9:05 UTC (permalink / raw)
  To: linux-mtd; +Cc: Magnus Damm, linux-sh

SNAND_E indicates whether we deal with 512kB or 2048kB page sizes. We
can probe this from the NAND chip itself and don't need to specify it in
the platform data anymore.

Signed-off-by: Bastian Hecht <hechtb@gmail.com>
---
Based on l2-mtd with reverted commit e26c113b4130aefa1d8446602bb5b05cfd646bfe
and the 2 patches posted 3 days ago (09/23)
mtd: sh_flctl: Setup and release DMA channels
and
mtd: sh_flctl: Use DMA for data fifo FLTDFIFO when available

 drivers/mtd/nand/sh_flctl.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index 0d90af8..8f0bed1 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -970,6 +970,7 @@ static int flctl_chip_init_tail(struct mtd_info *mtd)
 		}
 	} else {
 		flctl->page_size = 1;
+		flctl->flcmncr_base |= SNAND_E;
 		if (chip->chipsize > (128 << 20)) {
 			/* big than 128MB */
 			flctl->rw_ADRCNT = ADRCNT2_E;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] mtd: sh_flctl: Add device tree support
  2012-09-26  9:05 [PATCH 1/3] mtd: sh_flctl: Probe SNAND_E flag from NAND chip Bastian Hecht
@ 2012-09-26  9:05 ` Bastian Hecht
  2012-09-26  9:05 ` [PATCH 3/3] mtd: sh_flctl: Add sh7372 device tree config Bastian Hecht
  1 sibling, 0 replies; 3+ messages in thread
From: Bastian Hecht @ 2012-09-26  9:05 UTC (permalink / raw)
  To: linux-mtd; +Cc: Magnus Damm, linux-sh

The flctl can now be probed via device tree setup in addition to the
existing platform data way.

SoC specific setup data is set in the .data member of the OF match, so
kept within the driver itself, while board/user specific setup - like
partitioning - is taken from the device tree.

Signed-off-by: Bastian Hecht <hechtb@gmail.com>
---
 drivers/mtd/nand/sh_flctl.c |   84 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 77 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index 8f0bed1..472c27e 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -28,6 +28,9 @@
 #include <linux/dma-mapping.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_mtd.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
@@ -1020,6 +1023,65 @@ static irqreturn_t flctl_handle_flste(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+#ifdef CONFIG_OF
+struct flctl_soc_config {
+	unsigned long flcmncr_val;
+	unsigned has_hwecc:1;
+	unsigned use_holden:1;
+};
+
+static const struct of_device_id of_flctl_match[] = {
+	{},
+};
+MODULE_DEVICE_TABLE(of, of_flctl_match);
+
+static struct sh_flctl_platform_data *flctl_parse_dt(struct device *dev)
+{
+	const struct of_device_id *match;
+	struct flctl_soc_config *config;
+	struct sh_flctl_platform_data *pdata;
+	struct device_node *dn = dev->of_node;
+	int ret;
+
+	match = of_match_device(of_flctl_match, dev);
+	if (match)
+		config = (struct flctl_soc_config *)match->data;
+	else {
+		dev_err(dev, "%s: no OF configuration attached\n", __func__);
+		return NULL;
+	}
+
+	pdata = devm_kzalloc(dev, sizeof(struct sh_flctl_platform_data),
+								GFP_KERNEL);
+	if (!pdata) {
+		dev_err(dev, "%s: failed to allocate config data\n", __func__);
+		return NULL;
+	}
+
+	/* set SoC specific options */
+	pdata->flcmncr_val = config->flcmncr_val;
+	pdata->has_hwecc = config->has_hwecc;
+	pdata->use_holden = config->use_holden;
+
+	/* parse user defined options */
+	ret = of_get_nand_bus_width(dn);
+	if (ret = 16)
+		pdata->flcmncr_val |= SEL_16BIT;
+	else if (ret != 8) {
+		dev_err(dev, "%s: invalid bus width\n", __func__);
+		return NULL;
+	}
+
+	return pdata;
+}
+#else /* CONFIG_OF */
+#define of_flctl_match NULL
+static struct sh_flctl_platform_data *flctl_parse_dt(struct device *dev)
+{
+	return NULL;
+}
+#endif /* CONFIG_OF */
+
 static int __devinit flctl_probe(struct platform_device *pdev)
 {
 	struct resource *res;
@@ -1029,12 +1091,7 @@ static int __devinit flctl_probe(struct platform_device *pdev)
 	struct sh_flctl_platform_data *pdata;
 	int ret = -ENXIO;
 	int irq;
-
-	pdata = pdev->dev.platform_data;
-	if (pdata = NULL) {
-		dev_err(&pdev->dev, "no platform data defined\n");
-		return -EINVAL;
-	}
+	struct mtd_part_parser_data ppdata = {};
 
 	flctl = kzalloc(sizeof(struct sh_flctl), GFP_KERNEL);
 	if (!flctl) {
@@ -1066,6 +1123,16 @@ static int __devinit flctl_probe(struct platform_device *pdev)
 		goto err_flste;
 	}
 
+	if (pdev->dev.of_node)
+		pdata = flctl_parse_dt(&pdev->dev);
+	else
+		pdata = pdev->dev.platform_data;
+
+	if (!pdata) {
+		dev_err(&pdev->dev, "no setup data defined\n");
+		return -EINVAL;
+	}
+
 	platform_set_drvdata(pdev, flctl);
 	flctl_mtd = &flctl->mtd;
 	nand = &flctl->chip;
@@ -1108,7 +1175,9 @@ static int __devinit flctl_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_chip;
 
-	mtd_device_register(flctl_mtd, pdata->parts, pdata->nr_parts);
+	ppdata.of_node = pdev->dev.of_node;
+	ret = mtd_device_parse_register(flctl_mtd, NULL, &ppdata, pdata->parts,
+			pdata->nr_parts);
 
 	return 0;
 
@@ -1142,6 +1211,7 @@ static struct platform_driver flctl_driver = {
 	.driver = {
 		.name	= "sh_flctl",
 		.owner	= THIS_MODULE,
+		.of_match_table = of_flctl_match,
 	},
 };
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] mtd: sh_flctl: Add sh7372 device tree config
  2012-09-26  9:05 [PATCH 1/3] mtd: sh_flctl: Probe SNAND_E flag from NAND chip Bastian Hecht
  2012-09-26  9:05 ` [PATCH 2/3] mtd: sh_flctl: Add device tree support Bastian Hecht
@ 2012-09-26  9:05 ` Bastian Hecht
  1 sibling, 0 replies; 3+ messages in thread
From: Bastian Hecht @ 2012-09-26  9:05 UTC (permalink / raw)
  To: linux-mtd; +Cc: Magnus Damm, linux-sh

Include the configuration data to set up FLCTL via device tree probing
for the SoC sh7372.

Signed-off-by: Bastian Hecht <hechtb@gmail.com>
---
 drivers/mtd/nand/sh_flctl.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index 472c27e..b8b1d52 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -1030,7 +1030,15 @@ struct flctl_soc_config {
 	unsigned use_holden:1;
 };
 
+static struct flctl_soc_config flctl_sh7372_config = {
+	.flcmncr_val = CLK_16B_12L_4H | TYPESEL_SET | SHBUSSEL,
+	.has_hwecc = 1,
+	.use_holden = 1,
+};
+
 static const struct of_device_id of_flctl_match[] = {
+	{ .compatible = "renesas,shmobile-flctl-sh7372",
+				.data = &flctl_sh7372_config },
 	{},
 };
 MODULE_DEVICE_TABLE(of, of_flctl_match);
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-26  9:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-26  9:05 [PATCH 1/3] mtd: sh_flctl: Probe SNAND_E flag from NAND chip Bastian Hecht
2012-09-26  9:05 ` [PATCH 2/3] mtd: sh_flctl: Add device tree support Bastian Hecht
2012-09-26  9:05 ` [PATCH 3/3] mtd: sh_flctl: Add sh7372 device tree config Bastian Hecht

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).