From: Paul Burton Date: Thu, 8 Sep 2016 06:47:35 +0000 (+0100) Subject: dm: regmap: Implement simple regmap_read & regmap_write X-Git-Tag: v2016.11-rc1~120^2~6 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3bfb8cb4;p=oweals%2Fu-boot.git dm: regmap: Implement simple regmap_read & regmap_write The regmap_read & regmap_write functions were previously declared in regmap.h but not implemented anywhere. The regmap implementation & commit message of 6f98b7504f70 ("dm: Add support for register maps (regmap)") indicate that only memory mapped accesses are supported for now, so providing simple implementations of regmap_read & regmap_write is trivial. The access size is presumed to be 4 bytes & endianness is presumed native, which are the defaults for the regmap code in Linux. Signed-off-by: Paul Burton Reviewed-by: Simon Glass --- diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index 0299ff0879..c68bcba54f 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -13,6 +13,8 @@ #include #include +#include + DECLARE_GLOBAL_DATA_PTR; static struct regmap *regmap_alloc_count(int count) @@ -117,3 +119,21 @@ int regmap_uninit(struct regmap *map) return 0; } + +int regmap_read(struct regmap *map, uint offset, uint *valp) +{ + uint32_t *ptr = map_physmem(map->base + offset, 4, MAP_NOCACHE); + + *valp = le32_to_cpu(readl(ptr)); + + return 0; +} + +int regmap_write(struct regmap *map, uint offset, uint val) +{ + uint32_t *ptr = map_physmem(map->base + offset, 4, MAP_NOCACHE); + + writel(cpu_to_le32(val), ptr); + + return 0; +}