Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: syscon: Add a DT property to set value width

Currently syscon has a fixed configuration of 32 bits for register and
values widths. In some cases, it would be desirable to be able to
customize the value width.

For example, certain boards (like the ones manufactured by Technologic
Systems) have a FPGA that is memory-mapped, but its registers are only
16-bit wide.

This patch adds an optional "reg-io-width" DT binding for syscon that
allows to change the width for the data bus (i.e. val_bits). If this
property is provided, it will also set the register stride to
reg-io-width's value. If not provided, the default configuration is
used.

Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Damien Riegel and committed by
Lee Jones
db2fb60c 32e9725d

+17
+4
Documentation/devicetree/bindings/mfd/syscon.txt
··· 13 13 - compatible: Should contain "syscon". 14 14 - reg: the register region can be accessed from syscon 15 15 16 + Optional property: 17 + - reg-io-width: the size (in bytes) of the IO accesses that should be 18 + performed on the device. 19 + 16 20 Examples: 17 21 gpr: iomuxc-gpr@020e0000 { 18 22 compatible = "fsl,imx6q-iomuxc-gpr", "syscon";
+13
drivers/mfd/syscon.c
··· 47 47 struct syscon *syscon; 48 48 struct regmap *regmap; 49 49 void __iomem *base; 50 + u32 reg_io_width; 50 51 int ret; 51 52 struct regmap_config syscon_config = syscon_regmap_config; 52 53 ··· 69 68 syscon_config.val_format_endian = REGMAP_ENDIAN_BIG; 70 69 else if (of_property_read_bool(np, "little-endian")) 71 70 syscon_config.val_format_endian = REGMAP_ENDIAN_LITTLE; 71 + 72 + /* 73 + * search for reg-io-width property in DT. If it is not provided, 74 + * default to 4 bytes. regmap_init_mmio will return an error if values 75 + * are invalid so there is no need to check them here. 76 + */ 77 + ret = of_property_read_u32(np, "reg-io-width", &reg_io_width); 78 + if (ret) 79 + reg_io_width = 4; 80 + 81 + syscon_config.reg_stride = reg_io_width; 82 + syscon_config.val_bits = reg_io_width * 8; 72 83 73 84 regmap = regmap_init_mmio(NULL, base, &syscon_config); 74 85 if (IS_ERR(regmap)) {