mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 03:15:00 +00:00
regmap: Allow left shifting register offset before access
Drivers can configure it to adjust the final read/write location. Signed-off-by: Pratyush Yadav <p.yadav@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
78aaedba9f
commit
7aa5ddffe7
2 changed files with 11 additions and 1 deletions
|
@ -261,8 +261,10 @@ struct regmap *devm_regmap_init(struct udevice *dev,
|
||||||
return ERR_PTR(rc);
|
return ERR_PTR(rc);
|
||||||
|
|
||||||
map = *mapp;
|
map = *mapp;
|
||||||
if (config)
|
if (config) {
|
||||||
map->width = config->width;
|
map->width = config->width;
|
||||||
|
map->reg_offset_shift = config->reg_offset_shift;
|
||||||
|
}
|
||||||
|
|
||||||
devres_add(dev, mapp);
|
devres_add(dev, mapp);
|
||||||
return *mapp;
|
return *mapp;
|
||||||
|
@ -349,6 +351,7 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
|
||||||
}
|
}
|
||||||
range = &map->ranges[range_num];
|
range = &map->ranges[range_num];
|
||||||
|
|
||||||
|
offset <<= map->reg_offset_shift;
|
||||||
if (offset + val_len > range->size) {
|
if (offset + val_len > range->size) {
|
||||||
debug("%s: offset/size combination invalid\n", __func__);
|
debug("%s: offset/size combination invalid\n", __func__);
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
|
@ -458,6 +461,7 @@ int regmap_raw_write_range(struct regmap *map, uint range_num, uint offset,
|
||||||
}
|
}
|
||||||
range = &map->ranges[range_num];
|
range = &map->ranges[range_num];
|
||||||
|
|
||||||
|
offset <<= map->reg_offset_shift;
|
||||||
if (offset + val_len > range->size) {
|
if (offset + val_len > range->size) {
|
||||||
debug("%s: offset/size combination invalid\n", __func__);
|
debug("%s: offset/size combination invalid\n", __func__);
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
|
|
|
@ -82,9 +82,12 @@ struct regmap_bus;
|
||||||
*
|
*
|
||||||
* @width: Width of the read/write operations. Defaults to
|
* @width: Width of the read/write operations. Defaults to
|
||||||
* REGMAP_SIZE_32 if set to 0.
|
* REGMAP_SIZE_32 if set to 0.
|
||||||
|
* @reg_offset_shift Left shift the register offset by this value before
|
||||||
|
* performing read or write.
|
||||||
*/
|
*/
|
||||||
struct regmap_config {
|
struct regmap_config {
|
||||||
enum regmap_size_t width;
|
enum regmap_size_t width;
|
||||||
|
u32 reg_offset_shift;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,12 +95,15 @@ struct regmap_config {
|
||||||
*
|
*
|
||||||
* @width: Width of the read/write operations. Defaults to
|
* @width: Width of the read/write operations. Defaults to
|
||||||
* REGMAP_SIZE_32 if set to 0.
|
* REGMAP_SIZE_32 if set to 0.
|
||||||
|
* @reg_offset_shift Left shift the register offset by this value before
|
||||||
|
* performing read or write.
|
||||||
* @range_count: Number of ranges available within the map
|
* @range_count: Number of ranges available within the map
|
||||||
* @ranges: Array of ranges
|
* @ranges: Array of ranges
|
||||||
*/
|
*/
|
||||||
struct regmap {
|
struct regmap {
|
||||||
enum regmap_endianness_t endianness;
|
enum regmap_endianness_t endianness;
|
||||||
enum regmap_size_t width;
|
enum regmap_size_t width;
|
||||||
|
u32 reg_offset_shift;
|
||||||
int range_count;
|
int range_count;
|
||||||
struct regmap_range ranges[0];
|
struct regmap_range ranges[0];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue