mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] allow to use named resources
@ 2012-10-17 13:03 Jean-Christophe PLAGNIOL-VILLARD
  2012-10-17 13:05 ` [PATCH 1/2] driver: add support for requesting resource by name Jean-Christophe PLAGNIOL-VILLARD
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-17 13:03 UTC (permalink / raw)
  To: barebox

Hi,

	add helper to use named resources and use it on nomadik

The following changes since commit f99ea5c9d8cfddf3a1d6b181d0dbb26e06a86d2b:

  ARM samsung S5P: Enable board support (2012-10-15 19:47:01 +0200)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/nomadik

for you to fetch changes up to 0bcfbe7caab23ba5c78c964e91c43456e66cd9aa:

  nomadik_nand: switch to named resource (2012-10-17 12:09:16 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (2):
      driver: add support for requesting resource by name
      nomadik_nand: switch to named resource

 arch/arm/boards/nhk8815/setup.c |    3 +++
 drivers/base/driver.c           |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/nomadik_nand.c |    6 +++---
 include/driver.h                |   15 +++++++++++++++
 4 files changed, 67 insertions(+), 3 deletions(-)

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 1/2] driver: add support for requesting resource by name
  2012-10-17 13:03 [PATCH 0/2] allow to use named resources Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-17 13:05 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-10-17 13:05   ` [PATCH 2/2] nomadik_nand: switch to named resource Jean-Christophe PLAGNIOL-VILLARD
  2012-10-23  8:44 ` [PATCH 0/2] allow to use named resources Sascha Hauer
  2012-10-27 12:38 ` Sascha Hauer
  2 siblings, 1 reply; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-17 13:05 UTC (permalink / raw)
  To: barebox

this will allow to avoid issue with resource order

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/base/driver.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 include/driver.h      |   15 +++++++++++++++
 2 files changed, 61 insertions(+)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 64fe289..d0d20ce 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -247,6 +247,52 @@ void *dev_get_mem_region(struct device_d *dev, int num)
 }
 EXPORT_SYMBOL(dev_get_mem_region);
 
+struct resource *dev_get_resource_by_name(struct device_d *dev,
+					  const char *name)
+{
+	int i;
+
+	for (i = 0; i < dev->num_resources; i++) {
+		struct resource *res = &dev->resource[i];
+		if (resource_type(res) != IORESOURCE_MEM)
+			continue;
+		if (!res->name)
+			continue;
+		if (!strcmp(name, res->name))
+			return res;
+	}
+
+	return NULL;
+}
+
+void *dev_get_mem_region_by_name(struct device_d *dev, const char *name)
+{
+	struct resource *res;
+
+	res = dev_get_resource_by_name(dev, name);
+	if (!res)
+		return NULL;
+
+	return (void __force *)res->start;
+}
+EXPORT_SYMBOL(dev_get_mem_region_by_name);
+
+void __iomem *dev_request_mem_region_by_name(struct device_d *dev, const char *name)
+{
+	struct resource *res;
+
+	res = dev_get_resource_by_name(dev, name);
+	if (!res)
+		return NULL;
+
+	res = request_iomem_region(dev_name(dev), res->start, res->end);
+	if (!res)
+		return NULL;
+
+	return (void __force __iomem *)res->start;
+}
+EXPORT_SYMBOL(dev_request_mem_region_by_name);
+
 void __iomem *dev_request_mem_region(struct device_d *dev, int num)
 {
 	struct resource *res;
diff --git a/include/driver.h b/include/driver.h
index 4918054..f8d815c 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -193,6 +193,21 @@ static inline const char *dev_name(const struct device_d *dev)
 }
 
 /*
+ * get resource base 'name' for a device
+ */
+struct resource *dev_get_resource_by_name(struct device_d *dev,
+					  const char *name);
+/*
+ * get register base 'name' for a device
+ */
+void *dev_get_mem_region_by_name(struct device_d *dev, const char *name);
+
+/*
+ * exlusively request register base 'name' for a device
+ */
+void __iomem *dev_request_mem_region_by_name(struct device_d *dev,
+					     const char *name);
+/*
  * get register base 'num' for a device
  */
 void *dev_get_mem_region(struct device_d *dev, int num);
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/2] nomadik_nand: switch to named resource
  2012-10-17 13:05 ` [PATCH 1/2] driver: add support for requesting resource by name Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-17 13:05   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-17 13:05 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/nhk8815/setup.c |    3 +++
 drivers/mtd/nand/nomadik_nand.c |    6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boards/nhk8815/setup.c b/arch/arm/boards/nhk8815/setup.c
index 7f93ecb..0c85b25 100644
--- a/arch/arm/boards/nhk8815/setup.c
+++ b/arch/arm/boards/nhk8815/setup.c
@@ -50,14 +50,17 @@ static struct nomadik_nand_platform_data nhk8815_nand_data = {
 
 static struct resource nhk8815_nand_resources[] = {
 	{
+		.name	= "nand_addr",
 		.start	= NAND_IO_ADDR,
 		.end	= NAND_IO_ADDR + 0xfff,
 		.flags	= IORESOURCE_MEM,
 	}, {
+		.name	= "nand_cmd",
 		.start	= NAND_IO_CMD,
 		.end	= NAND_IO_CMD + 0xfff,
 		.flags	= IORESOURCE_MEM,
 	}, {
+		.name	= "nand_data",
 		.start	= NAND_IO_DATA,
 		.end	= NAND_IO_DATA + 0xfff,
 		.flags	= IORESOURCE_MEM,
diff --git a/drivers/mtd/nand/nomadik_nand.c b/drivers/mtd/nand/nomadik_nand.c
index 6fc9398..b19d6c6 100644
--- a/drivers/mtd/nand/nomadik_nand.c
+++ b/drivers/mtd/nand/nomadik_nand.c
@@ -189,8 +189,8 @@ static int nomadik_nand_probe(struct device_d *dev)
 		goto err;
 	}
 
-	host->cmd_va = dev_request_mem_region(dev, 1);
-	host->addr_va = dev_request_mem_region(dev, 0);
+	host->cmd_va = dev_request_mem_region_by_name(dev, "nand_cmd");
+	host->addr_va = dev_request_mem_region_by_name(dev, "nand_addr");
 
 	/* Link all private pointers */
 	mtd = &host->mtd;
@@ -198,7 +198,7 @@ static int nomadik_nand_probe(struct device_d *dev)
 	mtd->priv = nand;
 	nand->priv = host;
 
-	nand->IO_ADDR_W = nand->IO_ADDR_R = dev_request_mem_region(dev, 2);
+	nand->IO_ADDR_W = nand->IO_ADDR_R = dev_request_mem_region_by_name(dev, "nand_data");
 	nand->cmd_ctrl = nomadik_cmd_ctrl;
 
 	nand->ecc.mode = NAND_ECC_HW;
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 0/2] allow to use named resources
  2012-10-17 13:03 [PATCH 0/2] allow to use named resources Jean-Christophe PLAGNIOL-VILLARD
  2012-10-17 13:05 ` [PATCH 1/2] driver: add support for requesting resource by name Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-23  8:44 ` Sascha Hauer
  2012-10-23 10:22   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-10-27 12:38 ` Sascha Hauer
  2 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2012-10-23  8:44 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Wed, Oct 17, 2012 at 03:03:20PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Hi,
> 
> 	add helper to use named resources and use it on nomadik

Do we need this? devicetree does not have named resources, so with
devicetree support we are back to some arbitrary numbered resource
anyway.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 0/2] allow to use named resources
  2012-10-23  8:44 ` [PATCH 0/2] allow to use named resources Sascha Hauer
@ 2012-10-23 10:22   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-23 10:22 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 10:44 Tue 23 Oct     , Sascha Hauer wrote:
> On Wed, Oct 17, 2012 at 03:03:20PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Hi,
> > 
> > 	add helper to use named resources and use it on nomadik
> 
> Do we need this? devicetree does not have named resources, so with
> devicetree support we are back to some arbitrary numbered resource
> anyway.
> 
devicetree does have it I use on spear and I'm going to ues on at91 too

for spear13xx.dtsi

                fsmc: flash@b0000000 {
                        compatible = "st,spear600-fsmc-nand";
                        #address-cells = <1>;
                        #size-cells = <1>;
                        reg = <0xb0000000 0x1000        /* FSMC Register */
                               0xb0800000 0x0010>;      /* NAND Base */
                        reg-names = "fsmc_regs", "nand_data";
                        interrupts = <0 20 0x4
                                      0 21 0x4
                                      0 22 0x4
                                      0 23 0x4>;
                        st,ale-off = <0x20000>;
                        st,cle-off = <0x10000>;
                        status = "disabled";
                };

Best Regards,
J.
> Sascha
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 0/2] allow to use named resources
  2012-10-17 13:03 [PATCH 0/2] allow to use named resources Jean-Christophe PLAGNIOL-VILLARD
  2012-10-17 13:05 ` [PATCH 1/2] driver: add support for requesting resource by name Jean-Christophe PLAGNIOL-VILLARD
  2012-10-23  8:44 ` [PATCH 0/2] allow to use named resources Sascha Hauer
@ 2012-10-27 12:38 ` Sascha Hauer
  2 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2012-10-27 12:38 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Wed, Oct 17, 2012 at 03:03:20PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Hi,
> 
> 	add helper to use named resources and use it on nomadik
> 
> The following changes since commit f99ea5c9d8cfddf3a1d6b181d0dbb26e06a86d2b:
> 
>   ARM samsung S5P: Enable board support (2012-10-15 19:47:01 +0200)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/nomadik
> 
> for you to fetch changes up to 0bcfbe7caab23ba5c78c964e91c43456e66cd9aa:
> 
>   nomadik_nand: switch to named resource (2012-10-17 12:09:16 +0800)

Applied, thanks

Sascha

> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (2):
>       driver: add support for requesting resource by name
>       nomadik_nand: switch to named resource
> 
>  arch/arm/boards/nhk8815/setup.c |    3 +++
>  drivers/base/driver.c           |   46 ++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/mtd/nand/nomadik_nand.c |    6 +++---
>  include/driver.h                |   15 +++++++++++++++
>  4 files changed, 67 insertions(+), 3 deletions(-)
> 
> Best Regards,
> J.
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2012-10-27 12:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-17 13:03 [PATCH 0/2] allow to use named resources Jean-Christophe PLAGNIOL-VILLARD
2012-10-17 13:05 ` [PATCH 1/2] driver: add support for requesting resource by name Jean-Christophe PLAGNIOL-VILLARD
2012-10-17 13:05   ` [PATCH 2/2] nomadik_nand: switch to named resource Jean-Christophe PLAGNIOL-VILLARD
2012-10-23  8:44 ` [PATCH 0/2] allow to use named resources Sascha Hauer
2012-10-23 10:22   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-27 12:38 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox