summaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorPratyush Yadav <p.yadav@ti.com>2020-09-24 07:34:14 +0300
committerTom Rini <trini@konsulko.com>2020-09-30 18:55:22 +0300
commit0e01a7c3f4b6a42f768a19f7fc1df92d3e3b5d37 (patch)
tree1b7a060901775e87954bfcc9c3dff11b4de041c3 /drivers/core
parent7aa5ddffe7fbafe7ef828088ba1dbc76270300c5 (diff)
downloadu-boot-0e01a7c3f4b6a42f768a19f7fc1df92d3e3b5d37.tar.xz
regmap: Add regmap_init_mem_range()
Right now, the base of a regmap can only be obtained from the device tree. This makes it impossible for devices which calculate the base at runtime to use a regmap. An example of such a device is the Cadence Sierra PHY. Allow creating a regmap with one range whose start and size can be specified by the driver based on calculations at runtime. Signed-off-by: Pratyush Yadav <p.yadav@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/regmap.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
index 173ae80890..a9087df32b 100644
--- a/drivers/core/regmap.c
+++ b/drivers/core/regmap.c
@@ -164,6 +164,33 @@ err:
return ret;
}
+int regmap_init_mem_range(ofnode node, ulong r_start, ulong r_size,
+ struct regmap **mapp)
+{
+ struct regmap *map;
+ struct regmap_range *range;
+
+ map = regmap_alloc(1);
+ if (!map)
+ return -ENOMEM;
+
+ range = &map->ranges[0];
+ range->start = r_start;
+ range->size = r_size;
+
+ if (ofnode_read_bool(node, "little-endian"))
+ map->endianness = REGMAP_LITTLE_ENDIAN;
+ else if (ofnode_read_bool(node, "big-endian"))
+ map->endianness = REGMAP_BIG_ENDIAN;
+ else if (ofnode_read_bool(node, "native-endian"))
+ map->endianness = REGMAP_NATIVE_ENDIAN;
+ else /* Default: native endianness */
+ map->endianness = REGMAP_NATIVE_ENDIAN;
+
+ *mapp = map;
+ return 0;
+}
+
int regmap_init_mem(ofnode node, struct regmap **mapp)
{
struct regmap_range *range;