Message ID | 20200527125208.24881-7-p.yadav@ti.com |
---|---|
State | Accepted |
Commit | d8babb9598ce237ffb1feccb576c66a21c52e5f7 |
Headers | show |
Series | regmap: Add managed API, regmap fields, regmap config | expand |
On Wed, 27 May 2020 at 06:52, Pratyush Yadav <p.yadav at ti.com> wrote: > > Some devices need to calculate the regmap base address at runtime. This > makes it impossible to use device tree to get the regmap base. Instead, > allow devices to specify it in the regmap config. This will create a > regmap with a single range that corresponds to the start and size given > by the driver. > > Signed-off-by: Pratyush Yadav <p.yadav at ti.com> > --- > drivers/core/regmap.c | 6 +++++- > include/regmap.h | 6 ++++++ > 2 files changed, 11 insertions(+), 1 deletion(-) > Reviewed-by: Simon Glass <sjg at chromium.org>
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index f019a4e9ce..4792067f24 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -279,7 +279,11 @@ struct regmap *devm_regmap_init(struct udevice *dev, if (unlikely(!mapp)) return ERR_PTR(-ENOMEM); - rc = regmap_init_mem(dev_ofnode(dev), mapp); + if (config && config->r_size != 0) + rc = regmap_init_mem_range(dev_ofnode(dev), config->r_start, + config->r_size, mapp); + else + rc = regmap_init_mem(dev_ofnode(dev), mapp); if (rc) return ERR_PTR(rc); diff --git a/include/regmap.h b/include/regmap.h index ea6d8b253d..007e6f4b6f 100644 --- a/include/regmap.h +++ b/include/regmap.h @@ -84,10 +84,16 @@ struct regmap_bus; * REGMAP_SIZE_32 if set to 0. * @reg_offset_shift Left shift the register offset by this value before * performing read or write. + * @r_start: If specified, the regmap is created with one range + * which starts at this address, instead of finding the + * start from device tree. + * @r_size: Same as above for the range size */ struct regmap_config { enum regmap_size_t width; u32 reg_offset_shift; + ulong r_start; + ulong r_size; }; /**
Some devices need to calculate the regmap base address at runtime. This makes it impossible to use device tree to get the regmap base. Instead, allow devices to specify it in the regmap config. This will create a regmap with a single range that corresponds to the start and size given by the driver. Signed-off-by: Pratyush Yadav <p.yadav at ti.com> --- drivers/core/regmap.c | 6 +++++- include/regmap.h | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-)