diff options
author | Nicolas Saenz Julienne <nsaenzjulienne@suse.de> | 2021-01-12 15:55:22 +0300 |
---|---|---|
committer | Matthias Brugger <mbrugger@suse.com> | 2021-02-18 13:56:25 +0300 |
commit | 51bdb50904b1ffffc1caa8dd92f5abea78e33a0b (patch) | |
tree | 861d5e3a57adaed2bd04df0489eed3df1af99369 /include/dm/read.h | |
parent | c709243ee0e1c3e1f8aaa750efb5b738493502c7 (diff) | |
download | u-boot-51bdb50904b1ffffc1caa8dd92f5abea78e33a0b.tar.xz |
dm: Introduce xxx_get_dma_range()
Add the following functions to get a specific device's DMA ranges:
- dev_get_dma_range()
- ofnode_get_dma_range()
- of_get_dma_range()
- fdt_get_dma_range()
They are specially useful in oder to be able validate a physical address
space range into a bus's and to convert addresses from and to address
spaces.
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Diffstat (limited to 'include/dm/read.h')
-rw-r--r-- | include/dm/read.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/dm/read.h b/include/dm/read.h index 97575bcad0..5bf3405614 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -648,6 +648,21 @@ u64 dev_translate_dma_address(const struct udevice *dev, const fdt32_t *in_addr); /** + * dev_get_dma_range() - Get a device's DMA constraints + * + * Provide the address bases and size of the linear mapping between the CPU and + * a device's BUS address space. + * + * @dev: device giving the context in which to translate the DMA address + * @cpu: base address for CPU's view of memory + * @bus: base address for BUS's view of memory + * @size: size of the address space + * @return 0 if ok, negative on error + */ +int dev_get_dma_range(const struct udevice *dev, phys_addr_t *cpu, + dma_addr_t *bus, u64 *size); + +/** * dev_read_alias_highest_id - Get highest alias id for the given stem * @stem: Alias stem to be examined * @@ -1005,6 +1020,12 @@ static inline u64 dev_translate_dma_address(const struct udevice *dev, return ofnode_translate_dma_address(dev_ofnode(dev), in_addr); } +static inline int dev_get_dma_range(const struct udevice *dev, phys_addr_t *cpu, + dma_addr_t *bus, u64 *size) +{ + return ofnode_get_dma_range(dev_ofnode(dev), cpu, bus, size); +} + static inline int dev_read_alias_highest_id(const char *stem) { if (!CONFIG_IS_ENABLED(OF_LIBFDT) || !gd->fdt_blob) |