public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 01/17] dm: core: add functions to get memory-mapped I/O addreses
Date: Fri, 23 Mar 2018 15:34:26 +0100	[thread overview]
Message-ID: <ea3201f2-23b5-56d7-20c8-bb082d3c2a54@gmail.com> (raw)
In-Reply-To: <20180322183943.5466-2-noltari@gmail.com>



On 22.03.2018 19:39, Álvaro Fernández Rojas wrote:
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>  drivers/core/fdtaddr.c | 12 ++++++++++++
>  drivers/core/read.c    | 12 ++++++++++++
>  include/dm/fdtaddr.h   | 22 ++++++++++++++++++++++
>  include/dm/read.h      | 32 ++++++++++++++++++++++++++++++++
>  4 files changed, 78 insertions(+)
> 
> diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c
> index 3847dd836e..8a80000332 100644
> --- a/drivers/core/fdtaddr.c
> +++ b/drivers/core/fdtaddr.c
> @@ -132,6 +132,18 @@ void *devfdt_get_addr_ptr(struct udevice *dev)
>  	return (void *)(uintptr_t)devfdt_get_addr_index(dev, 0);
>  }
>  
> +void *devfdt_remap_addr_index(struct udevice *dev, int index)
> +{
> +	fdt_addr_t addr = devfdt_get_addr_index(dev, index);
> +
> +	return (addr == FDT_ADDR_T_NONE) ? NULL : ioremap(addr, 0);

hm, grepping through all arch's include directories it seems that
ioremap() is not available on all archs but map_physmem() is. Maybe you
should switch to map_physmem().

> +}
> +
> +void *devfdt_remap_addr(struct udevice *dev)
> +{
> +	return devfdt_remap_addr_index(dev, 0);
> +}
> +
>  void *devfdt_map_physmem(struct udevice *dev, unsigned long size)
>  {
>  	fdt_addr_t addr = devfdt_get_addr(dev);
> diff --git a/drivers/core/read.c b/drivers/core/read.c
> index 601d1322d6..0d338563ad 100644
> --- a/drivers/core/read.c
> +++ b/drivers/core/read.c
> @@ -58,6 +58,13 @@ fdt_addr_t dev_read_addr_index(struct udevice *dev, int index)
>  		return devfdt_get_addr_index(dev, index);
>  }
>  
> +void *dev_remap_addr_index(struct udevice *dev, int index)
> +{
> +	fdt_addr_t addr = dev_read_addr_index(dev, index);
> +
> +	return (addr == FDT_ADDR_T_NONE) ? NULL : ioremap(addr, 0);
> +}
> +
>  fdt_addr_t dev_read_addr(struct udevice *dev)
>  {
>  	return dev_read_addr_index(dev, 0);
> @@ -70,6 +77,11 @@ void *dev_read_addr_ptr(struct udevice *dev)
>  	return (addr == FDT_ADDR_T_NONE) ? NULL : map_sysmem(addr, 0);
>  }
>  
> +void * dev_remap_addr(struct udevice *dev)
> +{
> +	return dev_remap_addr_index(dev, 0);
> +}
> +
>  fdt_addr_t dev_read_addr_size(struct udevice *dev, const char *property,
>  			      fdt_size_t *sizep)
>  {
> diff --git a/include/dm/fdtaddr.h b/include/dm/fdtaddr.h
> index c46f0e91d0..82fc5f931d 100644
> --- a/include/dm/fdtaddr.h
> +++ b/include/dm/fdtaddr.h
> @@ -35,6 +35,28 @@ fdt_addr_t devfdt_get_addr(struct udevice *dev);
>  void *devfdt_get_addr_ptr(struct udevice *dev);
>  
>  /**
> + * devfdt_remap_addr() - Return pointer to the memory-mapped I/O address
> + *                           of the reg property of a device
> + *
> + * @dev: Pointer to a device
> + *
> + * @return Pointer to addr, or NULL if there is no such property
> + */
> +void *devfdt_remap_addr(struct udevice *dev);
> +
> +/**
> + * devfdt_remap_addr_index() - Return indexed pointer to the memory-mapped
> + *                                 I/O address of the reg property of a device
> + * @index: the 'reg' property can hold a list of <addr, size> pairs
> + *	   and @index is used to select which one is required
> + *
> + * @dev: Pointer to a device
> + *
> + * @return Pointer to addr, or NULL if there is no such property
> + */
> +void *devfdt_remap_addr_index(struct udevice *dev, int index);
> +
> +/**
>   * devfdt_map_physmem() - Read device address from reg property of the
>   *                     device node and map the address into CPU address
>   *                     space.
> diff --git a/include/dm/read.h b/include/dm/read.h
> index f14c7a7ba8..42eb585137 100644
> --- a/include/dm/read.h
> +++ b/include/dm/read.h
> @@ -114,6 +114,18 @@ int dev_read_size(struct udevice *dev, const char *propname);
>  fdt_addr_t dev_read_addr_index(struct udevice *dev, int index);
>  
>  /**
> + * dev_remap_addr_index() - Get the indexed reg property of a device
> + *                               as a memory-mapped I/O pointer
> + *
> + * @dev: Device to read from
> + * @index: the 'reg' property can hold a list of <addr, size> pairs
> + *	   and @index is used to select which one is required
> + *
> + * @return pointer or NULL if not found
> + */
> +void * dev_remap_addr_index(struct udevice *dev, int index);
> +
> +/**
>   * dev_read_addr() - Get the reg property of a device
>   *
>   * @dev: Device to read from
> @@ -133,6 +145,16 @@ fdt_addr_t dev_read_addr(struct udevice *dev);
>  void *dev_read_addr_ptr(struct udevice *dev);
>  
>  /**
> + * dev_remap_addr() - Get the reg property of a device as a
> + *                         memory-mapped I/O pointer
> + *
> + * @dev: Device to read from
> + *
> + * @return pointer or NULL if not found
> + */
> +void * dev_remap_addr(struct udevice *dev);
> +
> +/**
>   * dev_read_addr_size() - get address and size from a device property
>   *
>   * This does no address translation. It simply reads an property that contains
> @@ -483,6 +505,16 @@ static inline void *dev_read_addr_ptr(struct udevice *dev)
>  	return devfdt_get_addr_ptr(dev);
>  }
>  
> +static inline void *dev_remap_addr(struct udevice *dev)
> +{
> +	return devfdt_remap_addr(dev);
> +}
> +
> +static inline void *dev_remap_addr_index(struct udevice *dev, int index)
> +{
> +	return devfdt_remap_addr_index(dev, index);
> +}
> +
>  static inline fdt_addr_t dev_read_addr_size(struct udevice *dev,
>  					    const char *propname,
>  					    fdt_size_t *sizep)
> 

-- 
- Daniel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180323/2ffa705d/attachment.sig>

  reply	other threads:[~2018-03-23 14:34 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-22 18:39 [U-Boot] [PATCH v2 00/17] bmips: convert to use live-dt Álvaro Fernández Rojas
2018-03-22 18:39 ` [U-Boot] [PATCH v2 01/17] dm: core: add functions to get memory-mapped I/O addreses Álvaro Fernández Rojas
2018-03-23 14:34   ` Daniel Schwierzeck [this message]
2018-03-23 17:15     ` Álvaro Fernández Rojas
2018-03-23 17:36       ` Daniel Schwierzeck
2018-03-23 17:45   ` Daniel Schwierzeck
2018-04-06 12:45   ` Daniel Schwierzeck
2018-04-08 13:50     ` Simon Glass
2018-03-22 18:39 ` [U-Boot] [PATCH v2 02/17] watchdog: bcm6345: convert to use live dt Álvaro Fernández Rojas
2018-03-23 17:46   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 03/17] serial: " Álvaro Fernández Rojas
2018-03-23 17:46   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 04/17] clk: " Álvaro Fernández Rojas
2018-03-23 17:47   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 05/17] reset: " Álvaro Fernández Rojas
2018-03-23 17:47   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 06/17] gpio: " Álvaro Fernández Rojas
2018-03-23 17:48   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 07/17] led: bcm6358: " Álvaro Fernández Rojas
2018-03-23 17:50   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 08/17] led: bcm6328: " Álvaro Fernández Rojas
2018-03-23 17:51   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 09/17] power: domain: " Álvaro Fernández Rojas
2018-03-23 17:52   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 10/17] spi: bcm63xx_spi: " Álvaro Fernández Rojas
2018-03-23 17:52   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 11/17] spi: bcm63xx_hsspi: " Álvaro Fernández Rojas
2018-03-23 17:53   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 12/17] ram: bmips: " Álvaro Fernández Rojas
2018-03-23 17:54   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 13/17] cpu: " Álvaro Fernández Rojas
2018-03-23 17:55   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 14/17] phy: bcm6348-usbh: " Álvaro Fernández Rojas
2018-03-23 18:00   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 15/17] phy: bcm6358-usbh: " Álvaro Fernández Rojas
2018-03-23 18:01   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 16/17] phy: bcm6368-usbh: " Álvaro Fernández Rojas
2018-03-23 18:01   ` Daniel Schwierzeck
2018-03-22 18:39 ` [U-Boot] [PATCH v2 17/17] phy: bcm6318-usbh: " Álvaro Fernández Rojas
2018-03-23 18:02   ` Daniel Schwierzeck
2018-05-06 19:36 ` [U-Boot] [PATCH v2 00/17] bmips: convert to use live-dt Daniel Schwierzeck

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=ea3201f2-23b5-56d7-20c8-bb082d3c2a54@gmail.com \
    --to=daniel.schwierzeck@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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