allow to use named resources
Subsystems (4)
cover allow to use named resources
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/2 driver: add support for requesting resource by name
this will allow to avoid issue with resource order
--- drivers/base/driver.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ include/driver.h | 15 +++++++++++++++ 2 files changed, 61 insertions(+)
drivers/base/driver.c +46 -0
@@ -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;
include/driver.h +15 -0
@@ -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);
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/2 nomadik_nand: switch to named resource
--- arch/arm/boards/nhk8815/setup.c | 3 +++ drivers/mtd/nand/nomadik_nand.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-)
arch/arm/boards/nhk8815/setup.c +3 -0
@@ -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 ,
drivers/mtd/nand/nomadik_nand.c +3 -3
@@ -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 ;
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD
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
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 9 lines · Sascha Hauer
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD
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.
Quoted 7 lines
Sascha
Signature · 4 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 8 lines · Jean-Christophe PLAGNIOL-VILLARD
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)
Quoted 7 lines
are available in the git repository at:
git://git.jcrosoft.org/barebox.gitdelivery/nomadikfor you to fetch changes up to
0bcfbe7caab23ba5c78c964e91c43456e66cd9aa:
nomadik_nand: switch to named resource (2012-10-17 12:09:16 +0800)
Applied, thanks
Sascha
Quoted 20 lines
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (2):
driver: add support for requesting resource by name
nomadik_nand: switch to named resourcearch/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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox