[PATCH 1/3] common: driver: Allow for I/O mapped I/O in resource requests

Sascha Hauer s.hauer at pengutronix.de
Wed Mar 26 02:46:54 EDT 2014


On Tue, Mar 25, 2014 at 12:11:44PM +0100, Michel Stam wrote:
> The current resource framework is fully geared towards memory
> mapped I/O.
> This patch adds support for other types of I/O in the resource
> structures / function calls.
> ---
>  common/memory.c        |  2 +-
>  common/resource.c      | 18 ++++++++++++++++--
>  drivers/base/driver.c  | 36 ++++++++++++++++++------------------
>  include/driver.h       | 24 +++++++++++++++++-------
>  include/linux/ioport.h |  5 ++++-
>  5 files changed, 56 insertions(+), 29 deletions(-)
> 
> diff --git a/common/memory.c b/common/memory.c
> index c82bbaa..d36c8df 100644
> --- a/common/memory.c
> +++ b/common/memory.c
> @@ -148,7 +148,7 @@ struct resource *request_sdram_region(const char
> *name, resource_size_t start,
>  	for_each_memory_bank(bank) {
>  		struct resource *res;
>  -		res = request_region(bank->res, name, start, start + size - 1);
> +		res = request_region(bank->res, name, start, start + size - 1,
> IORESOURCE_MEM);
>  		if (res)
>  			return res;
>  	}
> diff --git a/common/resource.c b/common/resource.c
> index 5795e79..6600444 100644
> --- a/common/resource.c
> +++ b/common/resource.c
> @@ -38,7 +38,7 @@ static int init_resource(struct resource *res,
> const char *name)
>   */
>  struct resource *request_region(struct resource *parent,
>  		const char *name, resource_size_t start,
> -		resource_size_t end)
> +		resource_size_t end, int type)
>  {
>  	struct resource *r, *new;
>  @@ -70,6 +70,10 @@ struct resource *request_region(struct resource
> *parent,
>  			goto ok;
>  		if (start > r->end)
>  			continue;
> +
> +		if (type != resource_type(r->parent))
> +			continue;
> +
>  		debug("%s: 0x%08llx:0x%08llx conflicts with 0x%08llx:0x%08llx\n",
>  				__func__,
>  				(unsigned long long)start,
> @@ -89,6 +93,7 @@ ok:
>  	new->start = start;
>  	new->end = end;
>  	new->parent = parent;
> +	new->flags = type;
>  	list_add_tail(&new->sibling, &r->sibling);
>   	return new;
> @@ -123,5 +128,14 @@ struct resource iomem_resource = {
>  struct resource *request_iomem_region(const char *name,
>  		resource_size_t start, resource_size_t end)
>  {
> -	return request_region(&iomem_resource, name, start, end);
> +	return request_region(&iomem_resource, name, start, end, IORESOURCE_MEM);
> +}
> +
> +/*
> + * request an io region inside the io space
> + */
> +struct resource *request_io_region(const char *name,
> +		resource_size_t start, resource_size_t end,int type)
> +{
> +	return request_region(&iomem_resource, name, start, end, type);
>  }

iomem and memory really are two different resource trees. There is
memory from 0x0 to 0xffff and there are also ioports in this region. We
really have two toplevel resources. Also the iports do not span the
whole 32bit area, on x86 they are only up to 0xffff.
You would have to create a ioport command equivalent to the iomem
command we have now.

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 |



More information about the barebox mailing list