mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 15:14:43 +00:00
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>
This commit is contained in:
parent
6fca7fb3a0
commit
55a1a09b2a
2 changed files with 44 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -330,6 +330,8 @@ int regmap_init_mem(ofnode node, struct regmap **mapp);
|
|||
int regmap_init_mem_platdata(struct udevice *dev, fdt_val_t *reg, int count,
|
||||
struct regmap **mapp);
|
||||
|
||||
int regmap_init_mem_index(ofnode node, struct regmap **mapp, int index);
|
||||
|
||||
/**
|
||||
* regmap_get_range() - Obtain the base memory address of a regmap range
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue