mfd: syscon: Set regmap max_register in of_syscon_register
Determine the regmap max_register configuration from the io resource size and the reg-io-width device tree property. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
parent
a7e4631772
commit
ca668f0edf
|
@ -50,6 +50,7 @@ static struct syscon *of_syscon_register(struct device_node *np)
|
||||||
u32 reg_io_width;
|
u32 reg_io_width;
|
||||||
int ret;
|
int ret;
|
||||||
struct regmap_config syscon_config = syscon_regmap_config;
|
struct regmap_config syscon_config = syscon_regmap_config;
|
||||||
|
struct resource res;
|
||||||
|
|
||||||
if (!of_device_is_compatible(np, "syscon"))
|
if (!of_device_is_compatible(np, "syscon"))
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
|
@ -58,7 +59,12 @@ static struct syscon *of_syscon_register(struct device_node *np)
|
||||||
if (!syscon)
|
if (!syscon)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
base = of_iomap(np, 0);
|
if (of_address_to_resource(np, 0, &res)) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto err_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
base = ioremap(res.start, resource_size(&res));
|
||||||
if (!base) {
|
if (!base) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto err_map;
|
goto err_map;
|
||||||
|
@ -81,6 +87,7 @@ static struct syscon *of_syscon_register(struct device_node *np)
|
||||||
|
|
||||||
syscon_config.reg_stride = reg_io_width;
|
syscon_config.reg_stride = reg_io_width;
|
||||||
syscon_config.val_bits = reg_io_width * 8;
|
syscon_config.val_bits = reg_io_width * 8;
|
||||||
|
syscon_config.max_register = resource_size(&res) - reg_io_width;
|
||||||
|
|
||||||
regmap = regmap_init_mmio(NULL, base, &syscon_config);
|
regmap = regmap_init_mmio(NULL, base, &syscon_config);
|
||||||
if (IS_ERR(regmap)) {
|
if (IS_ERR(regmap)) {
|
||||||
|
|
Loading…
Reference in New Issue