regmap: Allow devices to specify regmap range start and size in config

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@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Pratyush Yadav
2020-09-24 10:04:15 +05:30
committed by Tom Rini
parent 0e01a7c3f4
commit d8babb9598
2 changed files with 11 additions and 1 deletions

View File

@@ -283,7 +283,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);