diff options
author | Pratyush Yadav <p.yadav@ti.com> | 2020-09-24 07:34:13 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-09-30 18:55:22 +0300 |
commit | 7aa5ddffe7fbafe7ef828088ba1dbc76270300c5 (patch) | |
tree | a0d6b807b712d780a3ea7f5ea0c5dfcd2346b925 /drivers | |
parent | 78aaedba9f1b92335a4f0ce8344f6abf7a63dccb (diff) | |
download | u-boot-7aa5ddffe7fbafe7ef828088ba1dbc76270300c5.tar.xz |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/core/regmap.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index c71b961234..173ae80890 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -261,8 +261,10 @@ struct regmap *devm_regmap_init(struct udevice *dev, return ERR_PTR(rc); map = *mapp; - if (config) + if (config) { map->width = config->width; + map->reg_offset_shift = config->reg_offset_shift; + } devres_add(dev, 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]; + offset <<= map->reg_offset_shift; if (offset + val_len > range->size) { debug("%s: offset/size combination invalid\n", __func__); return -ERANGE; @@ -458,6 +461,7 @@ int regmap_raw_write_range(struct regmap *map, uint range_num, uint offset, } range = &map->ranges[range_num]; + offset <<= map->reg_offset_shift; if (offset + val_len > range->size) { debug("%s: offset/size combination invalid\n", __func__); return -ERANGE; |