From 641067fb0c64dec8b6da962eb1d9fc49a6c7b499 Mon Sep 17 00:00:00 2001 From: Fabien Dessenne Date: Fri, 31 May 2019 15:11:30 +0200 Subject: dm: core: Introduce xxx_translate_dma_address() Add the following functions to translate DMA address to CPU address: - dev_translate_dma_address() - ofnode_translate_dma_address() - of_translate_dma_address() - fdt_translate_dma_address() These functions work the same way as xxx_translate_address(), with the difference that the translation relies on the "dma-ranges" property instead of the "ranges" property. Add related test. Test report: => ut dm fdt_translation Test: dm_test_fdt_translation: test-fdt.c Test: dm_test_fdt_translation: test-fdt.c (flat tree) Failures: 0 Signed-off-by: Fabien Dessenne --- include/dm/read.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'include/dm/read.h') diff --git a/include/dm/read.h b/include/dm/read.h index 60b727cbd8..62d4be6038 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -499,7 +499,7 @@ int dev_read_resource_byname(struct udevice *dev, const char *name, struct resource *res); /** - * dev_translate_address() - Tranlate a device-tree address + * dev_translate_address() - Translate a device-tree address * * Translate an address from the device-tree into a CPU physical address. This * function walks up the tree and applies the various bus mappings along the @@ -511,6 +511,19 @@ int dev_read_resource_byname(struct udevice *dev, const char *name, */ u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr); +/** + * dev_translate_dma_address() - Translate a device-tree DMA address + * + * Translate a DMA address from the device-tree into a CPU physical address. + * This function walks up the tree and applies the various bus mappings along + * the way. + * + * @dev: device giving the context in which to translate the DMA address + * @in_addr: pointer to the DMA address to translate + * @return the translated DMA address; OF_BAD_ADDR on error + */ +u64 dev_translate_dma_address(struct udevice *dev, const fdt32_t *in_addr); + /** * dev_read_alias_highest_id - Get highest alias id for the given stem * @stem: Alias stem to be examined @@ -751,6 +764,11 @@ static inline u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_a return ofnode_translate_address(dev_ofnode(dev), in_addr); } +static inline u64 dev_translate_dma_address(struct udevice *dev, const fdt32_t *in_addr) +{ + return ofnode_translate_dma_address(dev_ofnode(dev), in_addr); +} + static inline int dev_read_alias_highest_id(const char *stem) { return fdtdec_get_alias_highest_id(gd->fdt_blob, stem); -- cgit