diff options
author | Faiz Abbas <faiz_abbas@ti.com> | 2019-06-11 00:43:33 +0530 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-07-17 11:12:08 -0400 |
commit | 55a1a09b2acfc08bb55cb01820b00ef443f23481 (patch) | |
tree | 4337d165fd7ee3a516025ce8964d68bf3ffd6c5c /drivers/core | |
parent | 6fca7fb3a008297408489ffb696e3b360d8f343b (diff) | |
download | u-boot-55a1a09b2acfc08bb55cb01820b00ef443f23481.tar.gz u-boot-55a1a09b2acfc08bb55cb01820b00ef443f23481.tar.xz u-boot-55a1a09b2acfc08bb55cb01820b00ef443f23481.zip |
regmap: Add API regmap_init_mem_index()
In device nodes with more than one entry in the reg property,
it is sometimes useful to regmap only of the entries. Add an
API regmap_init_mem_index() to facilitate this.
Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/regmap.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index 5ef0f71c8b..d1d12eef38 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -108,6 +108,48 @@ static int init_range(ofnode node, struct regmap_range *range, int addr_len, return 0; } +int regmap_init_mem_index(ofnode node, struct regmap **mapp, int index) +{ + struct regmap *map; + int addr_len, size_len; + int ret; + + addr_len = ofnode_read_simple_addr_cells(ofnode_get_parent(node)); + if (addr_len < 0) { + debug("%s: Error while reading the addr length (ret = %d)\n", + ofnode_get_name(node), addr_len); + return addr_len; + } + + size_len = ofnode_read_simple_size_cells(ofnode_get_parent(node)); + if (size_len < 0) { + debug("%s: Error while reading the size length: (ret = %d)\n", + ofnode_get_name(node), size_len); + return size_len; + } + + map = regmap_alloc(1); + if (!map) + return -ENOMEM; + + ret = init_range(node, map->ranges, addr_len, size_len, index); + if (ret) + return ret; + + 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 ret; +} + int regmap_init_mem(ofnode node, struct regmap **mapp) { struct regmap_range *range; |