diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2023-10-27 08:12:36 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-10-27 08:12:36 +0200 |
commit | fc76c735ebca1bfafc132a66a29335db35e7b6ad (patch) | |
tree | fa688212117ccb79d2ef4b1e5b335a53b699f27d | |
parent | 5433d2ef5a0441fb2a2995d6fc13315445e5858e (diff) | |
parent | d04319f68b66e822443bcb6482544265f06d7013 (diff) | |
download | barebox-fc76c735ebca1bfafc132a66a29335db35e7b6ad.tar.gz barebox-fc76c735ebca1bfafc132a66a29335db35e7b6ad.tar.xz |
Merge branch 'for-next/regmap'
110 files changed, 436 insertions, 376 deletions
diff --git a/arch/arm/boards/phytec-som-imx8mq/board.c b/arch/arm/boards/phytec-som-imx8mq/board.c index 5dbfaf13db..45ed9cf5ad 100644 --- a/arch/arm/boards/phytec-som-imx8mq/board.c +++ b/arch/arm/boards/phytec-som-imx8mq/board.c @@ -11,6 +11,7 @@ #include <linux/sizes.h> #include <mach/imx/bbu.h> #include <mfd/pfuze.h> +#include <linux/regmap.h> #include <envfs.h> diff --git a/arch/arm/boards/protonic-imx6/board.c b/arch/arm/boards/protonic-imx6/board.c index 2e101adc28..5c5e7d6155 100644 --- a/arch/arm/boards/protonic-imx6/board.c +++ b/arch/arm/boards/protonic-imx6/board.c @@ -20,7 +20,7 @@ #include <mfd/syscon.h> #include <net.h> #include <of_device.h> -#include <regmap.h> +#include <linux/regmap.h> #include <sys/mount.h> #include <sys/stat.h> #include <unistd.h> diff --git a/arch/arm/mach-imx/iim.c b/arch/arm/mach-imx/iim.c index 8dc70d3caa..90ca644c2e 100644 --- a/arch/arm/mach-imx/iim.c +++ b/arch/arm/mach-imx/iim.c @@ -19,7 +19,7 @@ #include <malloc.h> #include <of.h> #include <io.h> -#include <regmap.h> +#include <linux/regmap.h> #include <regulator.h> #include <linux/err.h> diff --git a/arch/arm/mach-rockchip/dmc.c b/arch/arm/mach-rockchip/dmc.c index a167be7765..e23eb92110 100644 --- a/arch/arm/mach-rockchip/dmc.c +++ b/arch/arm/mach-rockchip/dmc.c @@ -11,7 +11,7 @@ #include <asm/memory.h> #include <pbl.h> #include <io.h> -#include <regmap.h> +#include <linux/regmap.h> #include <mfd/syscon.h> #include <mach/rockchip/dmc.h> #include <mach/rockchip/rk3399-regs.h> diff --git a/arch/kvx/cpu/reset.c b/arch/kvx/cpu/reset.c index df36764cb6..a19399220a 100644 --- a/arch/kvx/cpu/reset.c +++ b/arch/kvx/cpu/reset.c @@ -7,7 +7,7 @@ #include <reset_source.h> #include <mfd/syscon.h> #include <restart.h> -#include <regmap.h> +#include <linux/regmap.h> #include <init.h> #include <asm/ftu.h> diff --git a/drivers/base/regmap/regmap-fmt.c b/drivers/base/regmap/regmap-fmt.c index 47545f6919..e7f6a8da80 100644 --- a/drivers/base/regmap/regmap-fmt.c +++ b/drivers/base/regmap/regmap-fmt.c @@ -12,7 +12,7 @@ */ #include <common.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/log2.h> #include <asm/unaligned.h> diff --git a/drivers/base/regmap/regmap-i2c.c b/drivers/base/regmap/regmap-i2c.c index a64570d8dc..13ba5866c0 100644 --- a/drivers/base/regmap/regmap-i2c.c +++ b/drivers/base/regmap/regmap-i2c.c @@ -4,7 +4,7 @@ */ #include <i2c/i2c.h> -#include <regmap.h> +#include <linux/regmap.h> static int regmap_i2c_read(void *context, diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c index 4c6389689c..01b0a99631 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c @@ -7,7 +7,7 @@ #include <linux/clk.h> #include <linux/err.h> #include <io.h> -#include <regmap.h> +#include <linux/regmap.h> #include "internal.h" diff --git a/drivers/base/regmap/regmap-multi.c b/drivers/base/regmap/regmap-multi.c index e3f5b9aec1..74f3648eb4 100644 --- a/drivers/base/regmap/regmap-multi.c +++ b/drivers/base/regmap/regmap-multi.c @@ -5,7 +5,7 @@ #include <common.h> #include <fcntl.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/bitfield.h> #include <linux/export.h> @@ -46,7 +46,7 @@ static ssize_t regmap_multi_cdev_read(struct cdev *cdev, void *buf, size_t count return -EINVAL; count = ALIGN_DOWN(count, rwsize); - return regmap_bulk_read(map, offset, buf, count) ?: count; + return regmap_bulk_read(map, offset, buf, count / rwsize) ?: count; } static ssize_t regmap_multi_cdev_write(struct cdev *cdev, const void *buf, size_t count, @@ -60,7 +60,7 @@ static ssize_t regmap_multi_cdev_write(struct cdev *cdev, const void *buf, size_ return -EINVAL; count = ALIGN_DOWN(count, rwsize); - return regmap_bulk_write(map, offset, buf, count) ?: count; + return regmap_bulk_write(map, offset, buf, count / rwsize) ?: count; } static struct cdev_operations regmap_multi_fops = { diff --git a/drivers/base/regmap/regmap-spi.c b/drivers/base/regmap/regmap-spi.c index cb6e6f2b37..d15d59f635 100644 --- a/drivers/base/regmap/regmap-spi.c +++ b/drivers/base/regmap/regmap-spi.c @@ -6,7 +6,7 @@ // // Author: Mark Brown <broonie@opensource.wolfsonmicro.com> -#include <regmap.h> +#include <linux/regmap.h> #include <spi/spi.h> static int regmap_spi_write(void *context, const void *data, size_t count) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index da20dc0582..4d896c677b 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -12,7 +12,7 @@ */ #include <common.h> -#include <regmap.h> +#include <linux/regmap.h> #include <malloc.h> #include <linux/log2.h> @@ -248,27 +248,27 @@ int regmap_write_bits(struct regmap *map, unsigned int reg, * @map: Register map to read from * @reg: First register to be read from * @val: Pointer to store read value - * @val_len: Size of data to read + * @val_count: Number of registers to read * * A value of zero will be returned on success, a negative errno will * be returned in error cases. */ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, - size_t val_len) + size_t val_count) { - size_t val_bytes = map->format.val_bytes; - size_t val_count = val_len / val_bytes; unsigned int v; int ret, i; - if (val_len % val_bytes) - return -EINVAL; if (!IS_ALIGNED(reg, map->reg_stride)) return -EINVAL; if (val_count == 0) return -EINVAL; for (i = 0; i < val_count; i++) { + +#ifdef CONFIG_64BIT + u64 *u64 = val; +#endif u32 *u32 = val; u16 *u16 = val; u8 *u8 = val; @@ -278,6 +278,11 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, goto out; switch (map->format.val_bytes) { +#ifdef CONFIG_64BIT + case 8: + u64[i] = v; + break; +#endif case 4: u32[i] = v; break; @@ -303,20 +308,17 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, * @reg: Initial register to write to * @val: Block of data to be written, laid out for direct transmission to the * device - * @val_len: Length of data pointed to by val. + * @val_len: Number of registers to write * * A value of zero will be returned on success, a negative errno will * be returned in error cases. */ int regmap_bulk_write(struct regmap *map, unsigned int reg, - const void *val, size_t val_len) + const void *val, size_t val_count) { size_t val_bytes = map->format.val_bytes; - size_t val_count = val_len / val_bytes; int ret, i; - if (val_len % val_bytes) - return -EINVAL; if (!IS_ALIGNED(reg, map->reg_stride)) return -EINVAL; if (val_count == 0) @@ -335,6 +337,11 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, case 4: ival = *(u32 *)(val + (i * val_bytes)); break; +#ifdef CONFIG_64BIT + case 8: + ival = *(u64 *)(val + (i * val_bytes)); + break; +#endif default: ret = -EINVAL; goto out; @@ -374,9 +381,11 @@ static ssize_t regmap_cdev_read(struct cdev *cdev, void *buf, size_t count, loff unsigned long flags) { struct regmap *map = container_of(cdev, struct regmap, cdev); + size_t val_bytes = map->format.val_bytes; int ret; - ret = regmap_bulk_read(map, offset, buf, count); + count = ALIGN_DOWN(count, val_bytes); + ret = regmap_bulk_read(map, offset, buf, count / val_bytes); if (ret) return ret; @@ -387,9 +396,11 @@ static ssize_t regmap_cdev_write(struct cdev *cdev, const void *buf, size_t coun unsigned long flags) { struct regmap *map = container_of(cdev, struct regmap, cdev); + size_t val_bytes = map->format.val_bytes; int ret; - ret = regmap_bulk_write(map, offset, buf, count); + count = ALIGN_DOWN(count, val_bytes); + ret = regmap_bulk_write(map, offset, buf, count / val_bytes); if (ret) return ret; diff --git a/drivers/clk/at91/at91rm9200.c b/drivers/clk/at91/at91rm9200.c index dbefcd92d3..fe40ec788a 100644 --- a/drivers/clk/at91/at91rm9200.c +++ b/drivers/clk/at91/at91rm9200.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only // #include <driver.h> -#include <regmap.h> +#include <linux/regmap.h> #include <stdio.h> #include <mfd/syscon.h> diff --git a/drivers/clk/at91/at91sam9260.c b/drivers/clk/at91/at91sam9260.c index 3348cc6637..7d1d3ee5f3 100644 --- a/drivers/clk/at91/at91sam9260.c +++ b/drivers/clk/at91/at91sam9260.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include <driver.h> -#include <regmap.h> +#include <linux/regmap.h> #include <stdio.h> #include <mfd/syscon.h> diff --git a/drivers/clk/at91/at91sam9g45.c b/drivers/clk/at91/at91sam9g45.c index 95dc3d6e79..035d36580c 100644 --- a/drivers/clk/at91/at91sam9g45.c +++ b/drivers/clk/at91/at91sam9g45.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include <driver.h> -#include <regmap.h> +#include <linux/regmap.h> #include <stdio.h> #include <mfd/syscon.h> diff --git a/drivers/clk/at91/at91sam9n12.c b/drivers/clk/at91/at91sam9n12.c index bf17099453..9a12341f94 100644 --- a/drivers/clk/at91/at91sam9n12.c +++ b/drivers/clk/at91/at91sam9n12.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include <driver.h> -#include <regmap.h> +#include <linux/regmap.h> #include <stdio.h> #include <mfd/syscon.h> diff --git a/drivers/clk/at91/at91sam9rl.c b/drivers/clk/at91/at91sam9rl.c index 19002c8dab..bdec5cedca 100644 --- a/drivers/clk/at91/at91sam9rl.c +++ b/drivers/clk/at91/at91sam9rl.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include <driver.h> -#include <regmap.h> +#include <linux/regmap.h> #include <stdio.h> #include <mfd/syscon.h> diff --git a/drivers/clk/at91/at91sam9x5.c b/drivers/clk/at91/at91sam9x5.c index f9f45ed6e8..d052d67ffe 100644 --- a/drivers/clk/at91/at91sam9x5.c +++ b/drivers/clk/at91/at91sam9x5.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include <driver.h> -#include <regmap.h> +#include <linux/regmap.h> #include <stdio.h> #include <mfd/syscon.h> diff --git a/drivers/clk/at91/clk-audio-pll.c b/drivers/clk/at91/clk-audio-pll.c index e9a30b0516..780353ead1 100644 --- a/drivers/clk/at91/clk-audio-pll.c +++ b/drivers/clk/at91/clk-audio-pll.c @@ -37,7 +37,7 @@ #include <linux/clk.h> #include <linux/clk/at91_pmc.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c index e639fb3a1a..190fc7d7e9 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -13,7 +13,7 @@ #include <linux/clk.h> #include <linux/clk/at91_pmc.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/bitfield.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-h32mx.c b/drivers/clk/at91/clk-h32mx.c index b2c5007cf7..7f36fe7abb 100644 --- a/drivers/clk/at91/clk-h32mx.c +++ b/drivers/clk/at91/clk-h32mx.c @@ -12,7 +12,7 @@ #include <linux/list.h> #include <linux/clk.h> #include <linux/clk/at91_pmc.h> -#include <regmap.h> +#include <linux/regmap.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-i2s-mux.c b/drivers/clk/at91/clk-i2s-mux.c index 5e7040a5b7..97eb75a7fa 100644 --- a/drivers/clk/at91/clk-i2s-mux.c +++ b/drivers/clk/at91/clk-i2s-mux.c @@ -14,7 +14,7 @@ #include <linux/clk/at91_pmc.h> #include <linux/overflow.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include <soc/at91/atmel-sfr.h> diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c index 38e72d6538..e0c8cf108a 100644 --- a/drivers/clk/at91/clk-main.c +++ b/drivers/clk/at91/clk-main.c @@ -8,7 +8,7 @@ #include <linux/clk.h> #include <linux/clk/at91_pmc.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c index 3e4836b667..d20cea2b34 100644 --- a/drivers/clk/at91/clk-master.c +++ b/drivers/clk/at91/clk-master.c @@ -9,7 +9,7 @@ #include <linux/clk/at91_pmc.h> #include <linux/overflow.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-peripheral.c b/drivers/clk/at91/clk-peripheral.c index c768947647..ff98edef3f 100644 --- a/drivers/clk/at91/clk-peripheral.c +++ b/drivers/clk/at91/clk-peripheral.c @@ -9,7 +9,7 @@ #include <linux/clk.h> #include <linux/clk/at91_pmc.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c index d8ea566f49..400132ad1f 100644 --- a/drivers/clk/at91/clk-pll.c +++ b/drivers/clk/at91/clk-pll.c @@ -10,7 +10,7 @@ #include <linux/clk.h> #include <linux/clk/at91_pmc.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-plldiv.c b/drivers/clk/at91/clk-plldiv.c index 2830b16722..e39eb6a654 100644 --- a/drivers/clk/at91/clk-plldiv.c +++ b/drivers/clk/at91/clk-plldiv.c @@ -10,7 +10,7 @@ #include <linux/clk.h> #include <linux/clk/at91_pmc.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c index ec53f1addd..eebd96736f 100644 --- a/drivers/clk/at91/clk-programmable.c +++ b/drivers/clk/at91/clk-programmable.c @@ -11,7 +11,7 @@ #include <linux/clk/at91_pmc.h> #include <linux/overflow.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-sam9x60-pll.c b/drivers/clk/at91/clk-sam9x60-pll.c index e94b3eec41..3cd34350b9 100644 --- a/drivers/clk/at91/clk-sam9x60-pll.c +++ b/drivers/clk/at91/clk-sam9x60-pll.c @@ -11,7 +11,7 @@ #include <linux/clk.h> #include <linux/clk/at91_pmc.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/bitfield.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-slow.c b/drivers/clk/at91/clk-slow.c index bc4285e4bf..03f8ee2c6a 100644 --- a/drivers/clk/at91/clk-slow.c +++ b/drivers/clk/at91/clk-slow.c @@ -13,7 +13,7 @@ #include <linux/clk/at91_pmc.h> #include <linux/overflow.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-smd.c b/drivers/clk/at91/clk-smd.c index 6df698637c..58ccbf145e 100644 --- a/drivers/clk/at91/clk-smd.c +++ b/drivers/clk/at91/clk-smd.c @@ -11,7 +11,7 @@ #include <linux/clk/at91_pmc.h> #include <linux/overflow.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-system.c b/drivers/clk/at91/clk-system.c index 9a15d5b04a..6166622a3c 100644 --- a/drivers/clk/at91/clk-system.c +++ b/drivers/clk/at91/clk-system.c @@ -9,7 +9,7 @@ #include <linux/clk.h> #include <linux/clk/at91_pmc.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-usb.c b/drivers/clk/at91/clk-usb.c index 148befc8ac..0a715037ed 100644 --- a/drivers/clk/at91/clk-usb.c +++ b/drivers/clk/at91/clk-usb.c @@ -11,7 +11,7 @@ #include <linux/clk/at91_pmc.h> #include <linux/overflow.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include "pmc.h" diff --git a/drivers/clk/at91/clk-utmi.c b/drivers/clk/at91/clk-utmi.c index 1389983bde..d3855b18f7 100644 --- a/drivers/clk/at91/clk-utmi.c +++ b/drivers/clk/at91/clk-utmi.c @@ -9,7 +9,7 @@ #include <linux/clk.h> #include <linux/clk/at91_pmc.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include <soc/at91/atmel-sfr.h> diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 70b71422ff..fea931aa7c 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c @@ -9,7 +9,7 @@ #include <linux/overflow.h> #include <of.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include <dt-bindings/clock/at91.h> diff --git a/drivers/clk/at91/sam9x60.c b/drivers/clk/at91/sam9x60.c index 5368b0dbc9..9651b616c8 100644 --- a/drivers/clk/at91/sam9x60.c +++ b/drivers/clk/at91/sam9x60.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include <driver.h> -#include <regmap.h> +#include <linux/regmap.h> #include <stdio.h> #include <mfd/syscon.h> diff --git a/drivers/clk/at91/sama5d2.c b/drivers/clk/at91/sama5d2.c index 31c7259b91..b25adafab9 100644 --- a/drivers/clk/at91/sama5d2.c +++ b/drivers/clk/at91/sama5d2.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include <driver.h> -#include <regmap.h> +#include <linux/regmap.h> #include <stdio.h> #include <mfd/syscon.h> diff --git a/drivers/clk/at91/sama5d3.c b/drivers/clk/at91/sama5d3.c index f9c89dccee..fdd97e5834 100644 --- a/drivers/clk/at91/sama5d3.c +++ b/drivers/clk/at91/sama5d3.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include <driver.h> -#include <regmap.h> +#include <linux/regmap.h> #include <stdio.h> #include <mfd/syscon.h> diff --git a/drivers/clk/at91/sama5d4.c b/drivers/clk/at91/sama5d4.c index 2d6fc6df97..8c6b2c1e2d 100644 --- a/drivers/clk/at91/sama5d4.c +++ b/drivers/clk/at91/sama5d4.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include <driver.h> -#include <regmap.h> +#include <linux/regmap.h> #include <stdio.h> #include <mfd/syscon.h> diff --git a/drivers/clk/at91/sckc.c b/drivers/clk/at91/sckc.c index 579fbf2479..3b50c2b08c 100644 --- a/drivers/clk/at91/sckc.c +++ b/drivers/clk/at91/sckc.c @@ -15,7 +15,7 @@ #include <linux/clk/at91_pmc.h> #include <linux/overflow.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c index 3ef38b361b..d6ccfa6d15 100644 --- a/drivers/clk/clk-stm32f4.c +++ b/drivers/clk/clk-stm32f4.c @@ -12,7 +12,7 @@ #include <of_address.h> #include <linux/math64.h> #include <linux/iopoll.h> -#include <regmap.h> +#include <linux/regmap.h> #include <mfd/syscon.h> /* diff --git a/drivers/clk/rockchip/clk-inverter.c b/drivers/clk/rockchip/clk-inverter.c index 7cdcf15fd8..ea72d8c6b2 100644 --- a/drivers/clk/rockchip/clk-inverter.c +++ b/drivers/clk/rockchip/clk-inverter.c @@ -10,7 +10,7 @@ #include <xfuncs.h> #include <linux/barebox-wrapper.h> #include <linux/clk.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/spinlock.h> #include "clk.h" diff --git a/drivers/clk/rockchip/clk-muxgrf.c b/drivers/clk/rockchip/clk-muxgrf.c index f06fa69514..e81761422f 100644 --- a/drivers/clk/rockchip/clk-muxgrf.c +++ b/drivers/clk/rockchip/clk-muxgrf.c @@ -7,7 +7,7 @@ #include <xfuncs.h> #include <linux/barebox-wrapper.h> #include <linux/clk.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/spinlock.h> #include "clk.h" diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c index 736b87e32b..ee06035575 100644 --- a/drivers/clk/rockchip/clk-pll.c +++ b/drivers/clk/rockchip/clk-pll.c @@ -17,7 +17,7 @@ #include <linux/barebox-wrapper.h> #include "clk.h" #include <xfuncs.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/iopoll.h> #define PLL_MODE_WIDTH 2 diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c index 5c074f526a..aca107a45d 100644 --- a/drivers/clk/rockchip/clk.c +++ b/drivers/clk/rockchip/clk.c @@ -17,7 +17,7 @@ #include <common.h> #include <malloc.h> #include <linux/clk.h> -#include <regmap.h> +#include <linux/regmap.h> #include <mfd/syscon.h> #include <linux/spinlock.h> #include <linux/rational.h> diff --git a/drivers/clk/socfpga/clk-gate-a10.c b/drivers/clk/socfpga/clk-gate-a10.c index a78732124e..b66fbcdb8c 100644 --- a/drivers/clk/socfpga/clk-gate-a10.c +++ b/drivers/clk/socfpga/clk-gate-a10.c @@ -6,7 +6,7 @@ #include <common.h> #include <io.h> #include <malloc.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/clk.h> #include <linux/clkdev.h> #include <mach/socfpga/arria10-regs.h> diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c index 320c76af06..ff7e86d644 100644 --- a/drivers/gpio/gpio-sx150x.c +++ b/drivers/gpio/gpio-sx150x.c @@ -19,7 +19,7 @@ #include <xfuncs.h> #include <errno.h> #include <i2c/i2c.h> -#include <regmap.h> +#include <linux/regmap.h> #include <gpio.h> #include <of_device.h> diff --git a/drivers/hab/hab.c b/drivers/hab/hab.c index 1edc495aee..75a8cca71e 100644 --- a/drivers/hab/hab.c +++ b/drivers/hab/hab.c @@ -7,7 +7,7 @@ #include <libfile.h> #include <mach/imx/generic.h> #include <hab.h> -#include <regmap.h> +#include <linux/regmap.h> #include <fs.h> #include <mach/imx/iim.h> #include <mach/imx/imx25-fusemap.h> diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index 32d8a084e7..bf9ec30994 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -16,7 +16,7 @@ #include <driver.h> #include <io.h> #include <linux/clk.h> -#include <regmap.h> +#include <linux/regmap.h> struct __packed i2c_regs { u32 control; diff --git a/drivers/i2c/busses/i2c-rockchip.c b/drivers/i2c/busses/i2c-rockchip.c index 23bf4a55d7..ce029d148f 100644 --- a/drivers/i2c/busses/i2c-rockchip.c +++ b/drivers/i2c/busses/i2c-rockchip.c @@ -15,7 +15,7 @@ #include <io.h> #include <linux/clk.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/sizes.h> struct i2c_regs { diff --git a/drivers/i2c/busses/i2c-stm32.c b/drivers/i2c/busses/i2c-stm32.c index ba0d4a51b5..1be52b3dd9 100644 --- a/drivers/i2c/busses/i2c-stm32.c +++ b/drivers/i2c/busses/i2c-stm32.c @@ -9,7 +9,7 @@ #include <common.h> #include <i2c/i2c.h> #include <init.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/clk.h> #include <linux/iopoll.h> #include <linux/reset.h> diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c index 6b2796fda5..293c3d7f9d 100644 --- a/drivers/memory/atmel-ebi.c +++ b/drivers/memory/atmel-ebi.c @@ -14,7 +14,7 @@ #include <init.h> #include <driver.h> #include <of_device.h> -#include <regmap.h> +#include <linux/regmap.h> #include <soc/at91/atmel-sfr.h> #include <linux/time.h> #include <linux/printk.h> diff --git a/drivers/mfd/atmel-smc.c b/drivers/mfd/atmel-smc.c index 0eafbc06cd..9432aa2c68 100644 --- a/drivers/mfd/atmel-smc.c +++ b/drivers/mfd/atmel-smc.c @@ -11,6 +11,8 @@ #include <linux/mfd/syscon/atmel-smc.h> #include <linux/string.h> #include <linux/export.h> +#include <linux/regmap.h> +#include <linux/bitops.h> /** * atmel_smc_cs_conf_init - initialize a SMC CS conf diff --git a/drivers/mfd/axp20x-i2c.c b/drivers/mfd/axp20x-i2c.c index 578f7bfcf2..bfd93902b4 100644 --- a/drivers/mfd/axp20x-i2c.c +++ b/drivers/mfd/axp20x-i2c.c @@ -19,7 +19,7 @@ #include <i2c/i2c.h> #include <module.h> #include <linux/mfd/axp20x.h> -#include <regmap.h> +#include <linux/regmap.h> static int axp20x_i2c_probe(struct device *dev) { diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index c61a6e0024..666b9ea98c 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -23,7 +23,7 @@ #include <module.h> #include <of.h> #include <of_device.h> -#include <regmap.h> +#include <linux/regmap.h> #include <regulator.h> #define AXP20X_OFF BIT(7) diff --git a/drivers/mfd/mc13xxx.c b/drivers/mfd/mc13xxx.c index eadb845f6c..1e06a24b45 100644 --- a/drivers/mfd/mc13xxx.c +++ b/drivers/mfd/mc13xxx.c @@ -11,7 +11,7 @@ #include <errno.h> #include <malloc.h> #include <of.h> -#include <regmap.h> +#include <linux/regmap.h> #include <i2c/i2c.h> #include <spi/spi.h> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index 1361bb7101..77493a7b5b 100644 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -21,7 +21,7 @@ #include <driver.h> #include <poweroff.h> #include <of.h> -#include <regmap.h> +#include <linux/regmap.h> struct rk808_reg_data { int addr; diff --git a/drivers/mfd/rn5t568.c b/drivers/mfd/rn5t568.c index f649df944b..12de689734 100644 --- a/drivers/mfd/rn5t568.c +++ b/drivers/mfd/rn5t568.c @@ -13,7 +13,7 @@ #include <i2c/i2c.h> #include <init.h> #include <of.h> -#include <regmap.h> +#include <linux/regmap.h> #include <reset_source.h> #include <restart.h> diff --git a/drivers/mfd/rohm-bd718x7.c b/drivers/mfd/rohm-bd718x7.c index 20c572b6d7..e317a29ce5 100644 --- a/drivers/mfd/rohm-bd718x7.c +++ b/drivers/mfd/rohm-bd718x7.c @@ -14,7 +14,7 @@ #include <driver.h> #include <poweroff.h> #include <of.h> -#include <regmap.h> +#include <linux/regmap.h> static struct mfd_cell bd71837_mfd_cells[] = { { .name = "gpio-keys", }, diff --git a/drivers/mfd/stm32-timers.c b/drivers/mfd/stm32-timers.c index a7e9f53dbf..3b47800105 100644 --- a/drivers/mfd/stm32-timers.c +++ b/drivers/mfd/stm32-timers.c @@ -11,6 +11,7 @@ #include <io.h> #include <linux/bitfield.h> #include <linux/mfd/stm32-timers.h> +#include <linux/regmap.h> #include <of.h> #include <linux/reset.h> diff --git a/drivers/mfd/stpmic1.c b/drivers/mfd/stpmic1.c index 56ab682566..9985673aa6 100644 --- a/drivers/mfd/stpmic1.c +++ b/drivers/mfd/stpmic1.c @@ -9,7 +9,7 @@ #include <i2c/i2c.h> #include <init.h> #include <of.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/mfd/stpmic1.h> static const struct regmap_config stpmic1_regmap_i2c_config = { diff --git a/drivers/mfd/superio.c b/drivers/mfd/superio.c index bd16b79011..16d0bba450 100644 --- a/drivers/mfd/superio.c +++ b/drivers/mfd/superio.c @@ -7,7 +7,7 @@ #include <common.h> #include <superio.h> -#include <regmap.h> +#include <linux/regmap.h> struct device *superio_func_add(struct superio_chip *siochip, const char *name) { diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index 16d78de2af..3e12123b57 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -16,6 +16,7 @@ #include <of_address.h> #include <linux/err.h> #include <linux/clk.h> +#include <linux/regmap.h> #include <mfd/syscon.h> diff --git a/drivers/mtd/nand/atmel/nand-controller.c b/drivers/mtd/nand/atmel/nand-controller.c index cb74b365c8..5188a11cbe 100644 --- a/drivers/mtd/nand/atmel/nand-controller.c +++ b/drivers/mtd/nand/atmel/nand-controller.c @@ -57,7 +57,7 @@ #include <of.h> #include <of_device.h> #include <linux/iopoll.h> -#include <regmap.h> +#include <linux/regmap.h> #include <soc/at91/atmel-sfr.h> #include "pmecc.h" diff --git a/drivers/net/designware_imx8.c b/drivers/net/designware_imx8.c index 3dbe5824e6..73a16d5e65 100644 --- a/drivers/net/designware_imx8.c +++ b/drivers/net/designware_imx8.c @@ -3,7 +3,7 @@ #include <common.h> #include <init.h> #include <net.h> -#include <regmap.h> +#include <linux/regmap.h> #include <mfd/syscon.h> #include <linux/clk.h> diff --git a/drivers/net/designware_rockchip.c b/drivers/net/designware_rockchip.c index 04f56ce881..04e2b7f12d 100644 --- a/drivers/net/designware_rockchip.c +++ b/drivers/net/designware_rockchip.c @@ -4,7 +4,7 @@ #include <init.h> #include <dma.h> #include <net.h> -#include <regmap.h> +#include <linux/regmap.h> #include <of_net.h> #include <mfd/syscon.h> #include <linux/iopoll.h> diff --git a/drivers/net/designware_starfive.c b/drivers/net/designware_starfive.c index 9ab0de8be5..aff2cc10e1 100644 --- a/drivers/net/designware_starfive.c +++ b/drivers/net/designware_starfive.c @@ -6,6 +6,7 @@ #include <common.h> #include <init.h> #include <linux/reset.h> +#include <linux/regmap.h> #include <linux/clk.h> #include <mfd/syscon.h> #include <soc/starfive/sysmain.h> diff --git a/drivers/net/designware_stm32.c b/drivers/net/designware_stm32.c index ffcd4a5b76..54dabcc8d3 100644 --- a/drivers/net/designware_stm32.c +++ b/drivers/net/designware_stm32.c @@ -11,6 +11,7 @@ #include <net.h> #include <linux/clk.h> #include <mfd/syscon.h> +#include <linux/regmap.h> #include "designware_eqos.h" diff --git a/drivers/net/ksz8873.c b/drivers/net/ksz8873.c index 7e98ec492a..03d3530754 100644 --- a/drivers/net/ksz8873.c +++ b/drivers/net/ksz8873.c @@ -8,7 +8,7 @@ #include <linux/mdio.h> #include <net.h> #include <of_device.h> -#include <regmap.h> +#include <linux/regmap.h> #define KSZ8873_CHIP_ID0 0x00 #define KSZ8873_CHIP_ID1 0x01 diff --git a/drivers/net/ksz_common.h b/drivers/net/ksz_common.h index 995054d6e8..291488fe34 100644 --- a/drivers/net/ksz_common.h +++ b/drivers/net/ksz_common.h @@ -3,7 +3,7 @@ #define NET_KSZ_COMMON_H_ #include <linux/swab.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/bitops.h> #include <platform_data/ksz9477_reg.h> diff --git a/drivers/net/realtek-dsa/realtek-mdio.c b/drivers/net/realtek-dsa/realtek-mdio.c index 6776609b04..4637577111 100644 --- a/drivers/net/realtek-dsa/realtek-mdio.c +++ b/drivers/net/realtek-dsa/realtek-mdio.c @@ -20,7 +20,7 @@ */ #include <of_device.h> -#include <regmap.h> +#include <linux/regmap.h> #include <clock.h> #include <linux/gpio/consumer.h> #include <linux/printk.h> diff --git a/drivers/net/realtek-dsa/realtek-smi.c b/drivers/net/realtek-dsa/realtek-smi.c index 8e6f0e2ad9..f93024ace5 100644 --- a/drivers/net/realtek-dsa/realtek-smi.c +++ b/drivers/net/realtek-dsa/realtek-smi.c @@ -35,7 +35,7 @@ #include <clock.h> #include <linux/gpio/consumer.h> #include <driver.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/bitops.h> #include <linux/if_bridge.h> diff --git a/drivers/net/realtek-dsa/rtl8365mb.c b/drivers/net/realtek-dsa/rtl8365mb.c index d8e8ac714d..700773ffa6 100644 --- a/drivers/net/realtek-dsa/rtl8365mb.c +++ b/drivers/net/realtek-dsa/rtl8365mb.c @@ -96,7 +96,7 @@ #include <linux/spinlock.h> #include <linux/printk.h> #include <linux/export.h> -#include <regmap.h> +#include <linux/regmap.h> #include <net.h> #include <linux/if_bridge.h> diff --git a/drivers/net/realtek-dsa/rtl8366rb.c b/drivers/net/realtek-dsa/rtl8366rb.c index 5449b9481c..26f036dfe5 100644 --- a/drivers/net/realtek-dsa/rtl8366rb.c +++ b/drivers/net/realtek-dsa/rtl8366rb.c @@ -17,7 +17,7 @@ #include <linux/if_bridge.h> #include <linux/printk.h> #include <linux/export.h> -#include <regmap.h> +#include <linux/regmap.h> #include "realtek.h" diff --git a/drivers/nvmem/bsec.c b/drivers/nvmem/bsec.c index c381ee0836..7f24063b9e 100644 --- a/drivers/nvmem/bsec.c +++ b/drivers/nvmem/bsec.c @@ -13,7 +13,7 @@ #include <net.h> #include <io.h> #include <of.h> -#include <regmap.h> +#include <linux/regmap.h> #include <mach/stm32mp/bsec.h> #include <machine_id.h> #include <linux/nvmem-provider.h> @@ -82,7 +82,7 @@ static void stm32_bsec_set_unique_machine_id(struct regmap *map) int ret; ret = regmap_bulk_read(map, BSEC_OTP_SERIAL * 4, - unique_id, sizeof(unique_id)); + unique_id, sizeof(unique_id) / 4); if (ret) return; diff --git a/drivers/nvmem/ocotp.c b/drivers/nvmem/ocotp.c index c22e5d9585..641c825986 100644 --- a/drivers/nvmem/ocotp.c +++ b/drivers/nvmem/ocotp.c @@ -24,7 +24,7 @@ #include <io.h> #include <of.h> #include <clock.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/clk.h> #include <machine_id.h> #ifdef CONFIG_ARCH_IMX @@ -622,7 +622,7 @@ static int imx_ocotp_read_mac(const struct imx_ocotp_data *data, u8 buf[MAC_BYTES]; int ret; - ret = regmap_bulk_read(map, offset, buf, MAC_BYTES); + ret = regmap_bulk_read(map, offset, buf, MAC_BYTES / 4); if (ret < 0) return ret; @@ -649,7 +649,7 @@ static int imx_ocotp_set_mac(struct param_d *param, void *priv) struct ocotp_priv_ethaddr *ethaddr = priv; int ret; - ret = regmap_bulk_read(ethaddr->map, ethaddr->offset, buf, MAC_BYTES); + ret = regmap_bulk_read(ethaddr->map, ethaddr->offset, buf, MAC_BYTES / 4); if (ret < 0) return ret; @@ -662,7 +662,7 @@ static int imx_ocotp_set_mac(struct param_d *param, void *priv) OCOTP_MAC_TO_HW); return regmap_bulk_write(ethaddr->map, ethaddr->offset, - buf, MAC_BYTES); + buf, MAC_BYTES / 4); } static struct regmap_bus imx_ocotp_regmap_bus = { diff --git a/drivers/nvmem/regmap.c b/drivers/nvmem/regmap.c index db0221bae3..fa5405d7a8 100644 --- a/drivers/nvmem/regmap.c +++ b/drivers/nvmem/regmap.c @@ -6,12 +6,22 @@ #include <errno.h> #include <init.h> #include <io.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/nvmem-provider.h> static int nvmem_regmap_write(void *ctx, unsigned offset, const void *val, size_t bytes) { - return regmap_bulk_write(ctx, offset, val, bytes); + struct regmap *map = ctx; + + /* + * eFuse writes going through this function may be irreversible, + * so expect users to observe alignment. + */ + if (bytes % regmap_get_val_bytes(map)) + return -EINVAL; + + return regmap_bulk_write(map, offset, val, + bytes / regmap_get_val_bytes(map)); } static int nvmem_regmap_read(void *ctx, unsigned offset, void *buf, size_t bytes) @@ -32,7 +42,7 @@ static int nvmem_regmap_read(void *ctx, unsigned offset, void *buf, size_t bytes return -EINVAL; for (i = roffset; i < roffset + rbytes; i += stride) { - ret = regmap_bulk_read(map, i, &val, stride); + ret = regmap_read(map, i, &val); if (ret) { dev_err(regmap_get_device(map), "Can't read data%d (%d)\n", i, ret); return ret; diff --git a/drivers/nvmem/snvs_lpgpr.c b/drivers/nvmem/snvs_lpgpr.c index dfbd5397d2..9bbee6d587 100644 --- a/drivers/nvmem/snvs_lpgpr.c +++ b/drivers/nvmem/snvs_lpgpr.c @@ -10,7 +10,7 @@ #include <of.h> #include <of_device.h> #include <malloc.h> -#include <regmap.h> +#include <linux/regmap.h> #include <mfd/syscon.h> #include <linux/nvmem-provider.h> @@ -61,7 +61,7 @@ static int snvs_lpgpr_write(void *ctx, unsigned offset, const void *val, size_t return -EPERM; return regmap_bulk_write(priv->regmap, dcfg->offset + offset, val, - bytes); + bytes / 4); } static int snvs_lpgpr_read(void *ctx, unsigned offset, void *val, size_t bytes) @@ -70,7 +70,7 @@ static int snvs_lpgpr_read(void *ctx, unsigned offset, void *val, size_t bytes) const struct snvs_lpgpr_cfg *dcfg = priv->dcfg; return regmap_bulk_read(priv->regmap, dcfg->offset + offset, - val, bytes); + val, bytes / 4); } static int snvs_lpgpr_probe(struct device *dev) diff --git a/drivers/nvmem/starfive-otp.c b/drivers/nvmem/starfive-otp.c index 91069dc78e..d22350b10e 100644 --- a/drivers/nvmem/starfive-otp.c +++ b/drivers/nvmem/starfive-otp.c @@ -13,7 +13,7 @@ #include <net.h> #include <io.h> #include <of.h> -#include <regmap.h> +#include <linux/regmap.h> #include <machine_id.h> #include <linux/reset.h> #include <linux/clk.h> diff --git a/drivers/pci/pci-layerscape.c b/drivers/pci/pci-layerscape.c index 1689480470..0fb742af9a 100644 --- a/drivers/pci/pci-layerscape.c +++ b/drivers/pci/pci-layerscape.c @@ -21,7 +21,7 @@ #include <linux/kernel.h> #include <of_address.h> #include <of_pci.h> -#include <regmap.h> +#include <linux/regmap.h> #include <magicvar.h> #include <globalvar.h> #include <mfd/syscon.h> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index fe9f4fd325..7349a92d56 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -15,6 +15,7 @@ #include <linux/phy/phy.h> #include <linux/clk.h> #include <linux/err.h> +#include <linux/regmap.h> #include <mfd/syscon.h> #include <regulator.h> diff --git a/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c b/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c index 5fbbe1a4e4..9676d8fe99 100644 --- a/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c +++ b/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c @@ -17,6 +17,7 @@ #include <linux/clk.h> #include <linux/err.h> #include <linux/reset.h> +#include <linux/regmap.h> #include <mfd/syscon.h> #include <linux/iopoll.h> #include <dt-bindings/phy/phy.h> diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 917af927b6..c1e937ea2c 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -16,6 +16,7 @@ #include <init.h> #include <malloc.h> #include <mfd/syscon.h> +#include <linux/regmap.h> #include <of.h> #include <of_address.h> #include <pinctrl.h> diff --git a/drivers/power/reset/syscon-poweroff.c b/drivers/power/reset/syscon-poweroff.c index cdcc132684..321bd1fc7b 100644 --- a/drivers/power/reset/syscon-poweroff.c +++ b/drivers/power/reset/syscon-poweroff.c @@ -9,6 +9,7 @@ #include <common.h> #include <init.h> #include <poweroff.h> +#include <linux/regmap.h> #include <mfd/syscon.h> static struct regmap *map; diff --git a/drivers/power/reset/syscon-reboot-mode.c b/drivers/power/reset/syscon-reboot-mode.c index 9d379c9dda..7d44d9c07e 100644 --- a/drivers/power/reset/syscon-reboot-mode.c +++ b/drivers/power/reset/syscon-reboot-mode.c @@ -7,7 +7,7 @@ #include <init.h> #include <driver.h> #include <of.h> -#include <regmap.h> +#include <linux/regmap.h> #include <mfd/syscon.h> #include <linux/reboot-mode.h> #include <linux/overflow.h> diff --git a/drivers/power/reset/syscon-reboot.c b/drivers/power/reset/syscon-reboot.c index 90b125c335..61bea6169c 100644 --- a/drivers/power/reset/syscon-reboot.c +++ b/drivers/power/reset/syscon-reboot.c @@ -9,6 +9,7 @@ #include <init.h> #include <restart.h> #include <mfd/syscon.h> +#include <linux/regmap.h> struct syscon_reboot_context { struct regmap *map; diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index e73e996557..5c2029ab6a 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -14,6 +14,7 @@ #include <io.h> #include <linux/bitfield.h> #include <linux/mfd/stm32-timers.h> +#include <linux/regmap.h> #include <linux/math64.h> #include <of.h> #include <pwm.h> diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index e78b503d4f..4b4c174304 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c @@ -6,7 +6,7 @@ #include <common.h> #include <init.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include <regulator.h> struct anatop_regulator { diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index fb689a6bfc..80102e2c10 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only #include <common.h> -#include <regmap.h> +#include <linux/regmap.h> #include <regulator.h> /** diff --git a/drivers/regulator/pfuze.c b/drivers/regulator/pfuze.c index 8426d6f25b..3e8890b10c 100644 --- a/drivers/regulator/pfuze.c +++ b/drivers/regulator/pfuze.c @@ -10,7 +10,7 @@ #include <errno.h> #include <malloc.h> #include <of.h> -#include <regmap.h> +#include <linux/regmap.h> #include <mfd/pfuze.h> #include <i2c/i2c.h> diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c index 8c96b99c9b..adb0262314 100644 --- a/drivers/regulator/rk808-regulator.c +++ b/drivers/regulator/rk808-regulator.c @@ -14,7 +14,7 @@ #include <init.h> #include <i2c/i2c.h> #include <of_device.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/regulator/of_regulator.h> #include <regulator.h> #include <linux/mfd/rk808.h> diff --git a/drivers/regulator/stpmic1_regulator.c b/drivers/regulator/stpmic1_regulator.c index 1e8c1b23ac..3ed351b580 100644 --- a/drivers/regulator/stpmic1_regulator.c +++ b/drivers/regulator/stpmic1_regulator.c @@ -5,7 +5,7 @@ #include <common.h> #include <init.h> #include <of_device.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/regulator/of_regulator.h> #include <regulator.h> #include <linux/mfd/stpmic1.h> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index c1f70cf755..6ae8ef3966 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -17,7 +17,7 @@ #include <memory.h> #include <of_address.h> #include <of_device.h> -#include <regmap.h> +#include <linux/regmap.h> #define IMX7D_SRC_SCR 0x0C #define IMX7D_ENABLE_M4 BIT(3) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index a7df29e570..4dd1634a47 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -13,7 +13,7 @@ #include <mach/stm32mp/smc.h> #include <mfd/syscon.h> #include <of_address.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/remoteproc.h> #include <linux/reset.h> diff --git a/drivers/reset/reset-imx7.c b/drivers/reset/reset-imx7.c index 20542c536b..c6c38f48a8 100644 --- a/drivers/reset/reset-imx7.c +++ b/drivers/reset/reset-imx7.c @@ -14,7 +14,7 @@ #include <linux/err.h> #include <linux/reset-controller.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include <of_device.h> struct imx7_src_signal { diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c index 5b2c4e62b0..bcc251e138 100644 --- a/drivers/rtc/rtc-pcf85363.c +++ b/drivers/rtc/rtc-pcf85363.c @@ -16,7 +16,7 @@ #include <malloc.h> #include <errno.h> #include <i2c/i2c.h> -#include <regmap.h> +#include <linux/regmap.h> #include <rtc.h> #include <linux/rtc.h> #include <linux/bcd.h> diff --git a/drivers/serial/serial_clps711x.c b/drivers/serial/serial_clps711x.c index 950d22c26c..2a284909bf 100644 --- a/drivers/serial/serial_clps711x.c +++ b/drivers/serial/serial_clps711x.c @@ -8,6 +8,7 @@ #include <linux/clk.h> #include <linux/err.h> #include <mfd/syscon.h> +#include <linux/regmap.h> #define UARTDR 0x00 # define UARTDR_FRMERR (1 << 8) diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c index 57d9dcc99d..b967947478 100644 --- a/drivers/soc/imx/gpcv2.c +++ b/drivers/soc/imx/gpcv2.c @@ -10,7 +10,7 @@ #include <of_device.h> #include <common.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/clk.h> #include <linux/reset.h> #include <clock.h> diff --git a/drivers/soc/rockchip/io-domain.c b/drivers/soc/rockchip/io-domain.c index 5b32dad9ed..d31d38b1da 100644 --- a/drivers/soc/rockchip/io-domain.c +++ b/drivers/soc/rockchip/io-domain.c @@ -14,7 +14,7 @@ #include <of.h> #include <linux/err.h> #include <mfd/syscon.h> -#include <regmap.h> +#include <linux/regmap.h> #include <regulator.h> #define MAX_SUPPLIES 16 diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index f827c9fc82..f032e2673e 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -10,7 +10,7 @@ #include <errno.h> #include <init.h> #include <io.h> -#include <regmap.h> +#include <linux/regmap.h> #include <spi/spi.h> #include <linux/clk.h> #include <linux/math64.h> diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c index ed0af241f8..1d6604fee3 100644 --- a/drivers/spi/spi-nxp-fspi.c +++ b/drivers/spi/spi-nxp-fspi.c @@ -38,7 +38,7 @@ #include <errno.h> #include <init.h> #include <io.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/types.h> #include <linux/bitops.h> #include <linux/clk.h> diff --git a/drivers/usb/typec/tusb320.c b/drivers/usb/typec/tusb320.c index eb6b492481..90a846b0fb 100644 --- a/drivers/usb/typec/tusb320.c +++ b/drivers/usb/typec/tusb320.c @@ -14,7 +14,7 @@ #include <linux/printk.h> #include <linux/bitops.h> #include <module.h> -#include <regmap.h> +#include <linux/regmap.h> #include <linux/usb/typec.h> #include <linux/usb/typec_altmode.h> diff --git a/drivers/watchdog/rn5t568_wdt.c b/drivers/watchdog/rn5t568_wdt.c index 0357320822..2011e3e01c 100644 --- a/drivers/watchdog/rn5t568_wdt.c +++ b/drivers/watchdog/rn5t568_wdt.c @@ -8,7 +8,7 @@ #include <common.h> #include <init.h> #include <watchdog.h> -#include <regmap.h> +#include <linux/regmap.h> #include <of.h> #define RN5T568_WATCHDOG 0x0b diff --git a/drivers/watchdog/stpmic1_wdt.c b/drivers/watchdog/stpmic1_wdt.c index 4bde4f4e20..4a0519690a 100644 --- a/drivers/watchdog/stpmic1_wdt.c +++ b/drivers/watchdog/stpmic1_wdt.c @@ -11,6 +11,7 @@ #include <linux/iopoll.h> #include <poweroff.h> #include <mfd/syscon.h> +#include <linux/regmap.h> #include <restart.h> #include <reset_source.h> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h index b406c019e4..93d303c459 100644 --- a/include/linux/mfd/axp20x.h +++ b/include/linux/mfd/axp20x.h @@ -8,7 +8,6 @@ #ifndef __LINUX_MFD_AXP20X_H #define __LINUX_MFD_AXP20X_H -#include <regmap.h> #include <poweroff.h> enum axp20x_variants { @@ -448,6 +447,9 @@ enum { AXP813_REG_ID_MAX, }; +struct regmap; +struct regmap_config; + struct axp20x_dev { struct device *dev; struct regmap *regmap; @@ -458,28 +460,6 @@ struct axp20x_dev { struct poweroff_handler poweroff; }; -/* generic helper function for reading 9-16 bit wide regs */ -static inline int axp20x_read_variable_width(struct regmap *regmap, - unsigned int reg, unsigned int width) -{ - unsigned int reg_val, result; - int err; - - err = regmap_read(regmap, reg, ®_val); - if (err) - return err; - - result = reg_val << (width - 8); - - err = regmap_read(regmap, reg + 1, ®_val); - if (err) - return err; - - result |= reg_val; - - return result; -} - /** * axp20x_match_device(): Setup axp20x variant related fields * diff --git a/include/linux/mfd/stm32-timers.h b/include/linux/mfd/stm32-timers.h index 28fad44598..35aa0681ba 100644 --- a/include/linux/mfd/stm32-timers.h +++ b/include/linux/mfd/stm32-timers.h @@ -8,7 +8,6 @@ #define _LINUX_STM32_GPTIMER_H_ #include <clock.h> -#include <regmap.h> #define TIM_CR1 0x00 /* Control Register 1 */ #define TIM_CR2 0x04 /* Control Register 2 */ @@ -88,6 +87,8 @@ #define TIM_BDTR_BKF_SHIFT 16 #define TIM_BDTR_BK2F_SHIFT 20 +struct regmap; + struct stm32_timers { struct clk *clk; struct regmap *regmap; diff --git a/include/linux/mfd/syscon/atmel-smc.h b/include/linux/mfd/syscon/atmel-smc.h index 881edefe4e..16d09ea497 100644 --- a/include/linux/mfd/syscon/atmel-smc.h +++ b/include/linux/mfd/syscon/atmel-smc.h @@ -13,7 +13,6 @@ #include <linux/kernel.h> #include <of.h> -#include <regmap.h> #define ATMEL_SMC_SETUP(cs) (((cs) * 0x10)) #define ATMEL_HSMC_SETUP(layout, cs) \ @@ -93,6 +92,8 @@ struct atmel_smc_cs_conf { u32 mode; }; +struct regmap; + void atmel_smc_cs_conf_init(struct atmel_smc_cs_conf *conf); int atmel_smc_cs_conf_set_timing(struct atmel_smc_cs_conf *conf, unsigned int shift, diff --git a/include/linux/regmap.h b/include/linux/regmap.h new file mode 100644 index 0000000000..690dc3b1dc --- /dev/null +++ b/include/linux/regmap.h @@ -0,0 +1,260 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __LINUX_REGMAP_H +#define __LINUX_REGMAP_H + +#include <linux/compiler.h> +#include <linux/types.h> + +enum regmap_endian { + /* Unspecified -> 0 -> Backwards compatible default */ + REGMAP_ENDIAN_DEFAULT = 0, + REGMAP_ENDIAN_BIG, + REGMAP_ENDIAN_LITTLE, + REGMAP_ENDIAN_NATIVE, +}; + +/** + * Configuration for the register map of a device. + * + * @name: Optional name of the regmap. Useful when a device has multiple + * register regions. + * + * @reg_bits: Number of bits in a register address, mandatory. + * @reg_stride: The register address stride. Valid register addresses are a + * multiple of this value. If set to 0, a value of 1 will be + * used. + * @pad_bits: Number of bits of padding between register and value. + * @val_bits: Number of bits in a register value, mandatory. + * + * @write: Write operation. + * @read: Read operation. Data is returned in the buffer used to transmit + * data. + * + * @max_register: Optional, specifies the maximum valid register index. + * + * @read_flag_mask: Mask to be set in the top byte of the register when doing + * a read. + */ +struct regmap_config { + const char *name; + + int reg_bits; + int reg_stride; + int pad_bits; + int val_bits; + + unsigned int max_register; + + enum regmap_endian reg_format_endian; + enum regmap_endian val_format_endian; + + unsigned int read_flag_mask; + unsigned int write_flag_mask; +}; + +typedef int (*regmap_hw_write)(void *context, const void *data, + size_t count); +typedef int (*regmap_hw_read)(void *context, + const void *reg_buf, size_t reg_size, + void *val_buf, size_t val_size); +typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg, + unsigned int *val); +typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg, + unsigned int val); + +/** + * struct regmap_bus - Description of a hardware bus for the register map + * infrastructure. + * + * @reg_write: Write a single register value to the given register address. This + * write operation has to complete when returning from the function. + * @reg_read: Read a single register value from a given register address. + * @read: Read operation. Data is returned in the buffer used to transmit + * data. + * @write: Write operation. + * @read_flag_mask: Mask to be set in the top byte of the register when doing + * a read. + * @reg_format_endian_default: Default endianness for formatted register + * addresses. Used when the regmap_config specifies DEFAULT. If this is + * DEFAULT, BIG is assumed. + * @val_format_endian_default: Default endianness for formatted register + * values. Used when the regmap_config specifies DEFAULT. If this is + * DEFAULT, BIG is assumed. + */ +struct regmap_bus { + regmap_hw_reg_write reg_write; + regmap_hw_reg_read reg_read; + + int (*read)(void *context, + const void *reg_buf, size_t reg_size, + void *val_buf, size_t val_size); + int (*write)(void *context, const void *data, + size_t count); + + u8 read_flag_mask; + + enum regmap_endian reg_format_endian_default; + enum regmap_endian val_format_endian_default; +}; + +struct device; +struct device_node; + +struct regmap *regmap_init(struct device *dev, + const struct regmap_bus *bus, + void *bus_context, + const struct regmap_config *config); + +struct clk; + +/** + * regmap_init_mmio_clk() - Initialise register map with register clock + * + * @dev: Device that will be interacted with + * @clk_id: register clock consumer ID + * @regs: Pointer to memory-mapped IO region + * @config: Configuration for register map + * + * The return value will be an ERR_PTR() on error or a valid pointer to + * a struct regmap. + */ +struct regmap *regmap_init_mmio_clk(struct device *dev, const char *clk_id, + void __iomem *regs, + const struct regmap_config *config); + +/** + * regmap_init_i2c() - Initialise i2c register map + * + * @i2c: Device that will be interacted with + * @config: Configuration for register map + * + * The return value will be an ERR_PTR() on error or a valid pointer + * to a struct regmap. + */ +struct i2c_client; +struct regmap *regmap_init_i2c(struct i2c_client *i2c, + const struct regmap_config *config); + +struct regmap *regmap_init_i2c_smbus(struct i2c_client *client, + const struct regmap_config *config); + +/** + * regmap_init_spi() - Initialise spi register map + * + * @spi: Device that will be interacted with + * @config: Configuration for register map + * + * The return value will be an ERR_PTR() on error or a valid pointer + * to a struct regmap. + */ +struct spi_device; +struct regmap *regmap_init_spi(struct spi_device *dev, + const struct regmap_config *config); + +/** + * regmap_init_mmio() - Initialise register map + * + * @dev: Device that will be interacted with + * @regs: Pointer to memory-mapped IO region + * @config: Configuration for register map + * + * The return value will be an ERR_PTR() on error or a valid pointer to + * a struct regmap. + */ +#define regmap_init_mmio(dev, regs, config) \ + regmap_init_mmio_clk(dev, NULL, regs, config) + + +int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); +void regmap_mmio_detach_clk(struct regmap *map); + +void regmap_exit(struct regmap *map); + +struct regmap *dev_get_regmap(struct device *dev, const char *name); +struct device *regmap_get_device(struct regmap *map); + +int regmap_register_cdev(struct regmap *map, const char *name); + +/** + * regmap_multi_register_cdev() - Initialize cdev backed by multiple regmaps + * + * @map8: regmap for 8-bit wide accesses. NULL if such access + * should fail with -EINVAL + * @map16: regmap for 16-bit wide accesses. NULL if such access + * should fail with -EINVAL + * @map32: regmap for 32-bit wide accesses. NULL if such access + * should fail with -EINVAL + * @map64: regmap for 64-bit wide accesses. NULL if such access + * should fail with -EINVAL + * + * Registers a cdev that demultiplexes cdev accesses to one + * of the underlying regmaps according to the access size + * (e.g. mw -b => map8, mw -l => map32) + */ +int regmap_multi_register_cdev(struct regmap *map8, + struct regmap *map16, + struct regmap *map32, + struct regmap *map64); + +int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); +int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val); + +#ifndef regmap_bulk_read +#define regmap_bulk_read regmap_bulk_read +int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, + size_t val_count); +#endif +#ifndef regmap_bulk_write +#define regmap_bulk_write regmap_bulk_write +int regmap_bulk_write(struct regmap *map, unsigned int reg, + const void *val, size_t val_count); +#endif + +int regmap_get_val_bytes(struct regmap *map); +int regmap_get_max_register(struct regmap *map); +int regmap_get_reg_stride(struct regmap *map); + +int regmap_write_bits(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val); +int regmap_update_bits(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val); + +static inline int regmap_set_bits(struct regmap *map, + unsigned int reg, unsigned int bits) +{ + return regmap_update_bits(map, reg, bits, bits); +} + +static inline int regmap_clear_bits(struct regmap *map, + unsigned int reg, unsigned int bits) +{ + return regmap_update_bits(map, reg, bits, 0); +} + +size_t regmap_size_bytes(struct regmap *map); + +/** + * regmap_read_poll_timeout - Poll until a condition is met or a timeout occurs + * + * @map: Regmap to read from + * @addr: Address to poll + * @val: Unsigned integer variable to read the value into + * @cond: Break condition (usually involving @val) + * @timeout_us: Timeout in us, 0 means never timeout + * + * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read + * error return value in case of a error read. In the two former cases, + * the last read value at @addr is stored in @val. Must not be called + * from atomic context if sleep_us or timeout_us are used. + * + * This is modelled after the readx_poll_timeout macros in linux/iopoll.h. + */ +#define regmap_read_poll_timeout(map, addr, val, cond, timeout_us) \ +({ \ + int __ret, __tmp; \ + __tmp = read_poll_timeout(regmap_read, __ret, __ret || (cond), \ + timeout_us, (map), (addr), &(val)); \ + __ret ?: __tmp; \ +}) + +#endif /* __LINUX_REGMAP_H */ diff --git a/include/mfd/pfuze.h b/include/mfd/pfuze.h index 4fb3863a72..5cb0af939e 100644 --- a/include/mfd/pfuze.h +++ b/include/mfd/pfuze.h @@ -3,7 +3,7 @@ #ifndef __INCLUDE_PFUZE_H #define __INCLUDE_PFUZE_H -#include <regmap.h> +struct regmap; #ifdef CONFIG_REGULATOR_PFUZE /* diff --git a/include/mfd/syscon.h b/include/mfd/syscon.h index 3ccfd7fb5b..f22d4e620b 100644 --- a/include/mfd/syscon.h +++ b/include/mfd/syscon.h @@ -14,7 +14,7 @@ #ifndef __MFD_SYSCON_H__ #define __MFD_SYSCON_H__ -#include <regmap.h> +struct regmap; #ifdef CONFIG_MFD_SYSCON void __iomem *syscon_base_lookup_by_phandle diff --git a/include/regmap.h b/include/regmap.h index 98ac90523b..f2c395a896 100644 --- a/include/regmap.h +++ b/include/regmap.h @@ -5,250 +5,32 @@ #include <linux/compiler.h> #include <linux/types.h> -enum regmap_endian { - /* Unspecified -> 0 -> Backwards compatible default */ - REGMAP_ENDIAN_DEFAULT = 0, - REGMAP_ENDIAN_BIG, - REGMAP_ENDIAN_LITTLE, - REGMAP_ENDIAN_NATIVE, -}; +extern void __compiletime_error("Last argument is now number of registers, not bytes. Fix " + "it and include <linux/regmap.h> instead") +__regmap_bulk_api_changed(void); -/** - * Configuration for the register map of a device. - * - * @name: Optional name of the regmap. Useful when a device has multiple - * register regions. - * - * @reg_bits: Number of bits in a register address, mandatory. - * @reg_stride: The register address stride. Valid register addresses are a - * multiple of this value. If set to 0, a value of 1 will be - * used. - * @pad_bits: Number of bits of padding between register and value. - * @val_bits: Number of bits in a register value, mandatory. - * - * @write: Write operation. - * @read: Read operation. Data is returned in the buffer used to transmit - * data. - * - * @max_register: Optional, specifies the maximum valid register index. - * - * @read_flag_mask: Mask to be set in the top byte of the register when doing - * a read. - */ -struct regmap_config { - const char *name; +struct regmap; - int reg_bits; - int reg_stride; - int pad_bits; - int val_bits; - - unsigned int max_register; - - enum regmap_endian reg_format_endian; - enum regmap_endian val_format_endian; - - unsigned int read_flag_mask; - unsigned int write_flag_mask; -}; - -typedef int (*regmap_hw_write)(void *context, const void *data, - size_t count); -typedef int (*regmap_hw_read)(void *context, - const void *reg_buf, size_t reg_size, - void *val_buf, size_t val_size); -typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg, - unsigned int *val); -typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg, - unsigned int val); - -/** - * struct regmap_bus - Description of a hardware bus for the register map - * infrastructure. - * - * @reg_write: Write a single register value to the given register address. This - * write operation has to complete when returning from the function. - * @reg_read: Read a single register value from a given register address. - * @read: Read operation. Data is returned in the buffer used to transmit - * data. - * @write: Write operation. - * @read_flag_mask: Mask to be set in the top byte of the register when doing - * a read. - * @reg_format_endian_default: Default endianness for formatted register - * addresses. Used when the regmap_config specifies DEFAULT. If this is - * DEFAULT, BIG is assumed. - * @val_format_endian_default: Default endianness for formatted register - * values. Used when the regmap_config specifies DEFAULT. If this is - * DEFAULT, BIG is assumed. - */ -struct regmap_bus { - regmap_hw_reg_write reg_write; - regmap_hw_reg_read reg_read; - - int (*read)(void *context, - const void *reg_buf, size_t reg_size, - void *val_buf, size_t val_size); - int (*write)(void *context, const void *data, - size_t count); - - u8 read_flag_mask; - - enum regmap_endian reg_format_endian_default; - enum regmap_endian val_format_endian_default; -}; - -struct device; -struct device_node; - -struct regmap *regmap_init(struct device *dev, - const struct regmap_bus *bus, - void *bus_context, - const struct regmap_config *config); - -struct clk; - -/** - * regmap_init_mmio_clk() - Initialise register map with register clock - * - * @dev: Device that will be interacted with - * @clk_id: register clock consumer ID - * @regs: Pointer to memory-mapped IO region - * @config: Configuration for register map - * - * The return value will be an ERR_PTR() on error or a valid pointer to - * a struct regmap. - */ -struct regmap *regmap_init_mmio_clk(struct device *dev, const char *clk_id, - void __iomem *regs, - const struct regmap_config *config); - -/** - * regmap_init_i2c() - Initialise i2c register map - * - * @i2c: Device that will be interacted with - * @config: Configuration for register map - * - * The return value will be an ERR_PTR() on error or a valid pointer - * to a struct regmap. - */ -struct i2c_client; -struct regmap *regmap_init_i2c(struct i2c_client *i2c, - const struct regmap_config *config); - -struct regmap *regmap_init_i2c_smbus(struct i2c_client *client, - const struct regmap_config *config); - -/** - * regmap_init_spi() - Initialise spi register map - * - * @spi: Device that will be interacted with - * @config: Configuration for register map - * - * The return value will be an ERR_PTR() on error or a valid pointer - * to a struct regmap. - */ -struct spi_device; -struct regmap *regmap_init_spi(struct spi_device *dev, - const struct regmap_config *config); - -/** - * regmap_init_mmio() - Initialise register map - * - * @dev: Device that will be interacted with - * @regs: Pointer to memory-mapped IO region - * @config: Configuration for register map - * - * The return value will be an ERR_PTR() on error or a valid pointer to - * a struct regmap. - */ -#define regmap_init_mmio(dev, regs, config) \ - regmap_init_mmio_clk(dev, NULL, regs, config) - - -int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); -void regmap_mmio_detach_clk(struct regmap *map); - -void regmap_exit(struct regmap *map); - -struct regmap *dev_get_regmap(struct device *dev, const char *name); -struct device *regmap_get_device(struct regmap *map); - -int regmap_register_cdev(struct regmap *map, const char *name); - -/** - * regmap_multi_register_cdev() - Initialize cdev backed by multiple regmaps - * - * @map8: regmap for 8-bit wide accesses. NULL if such access - * should fail with -EINVAL - * @map16: regmap for 16-bit wide accesses. NULL if such access - * should fail with -EINVAL - * @map32: regmap for 32-bit wide accesses. NULL if such access - * should fail with -EINVAL - * @map64: regmap for 64-bit wide accesses. NULL if such access - * should fail with -EINVAL - * - * Registers a cdev that demultiplexes cdev accesses to one - * of the underlying regmaps according to the access size - * (e.g. mw -b => map8, mw -l => map32) - */ -int regmap_multi_register_cdev(struct regmap *map8, - struct regmap *map16, - struct regmap *map32, - struct regmap *map64); - -int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); -int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val); - -int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, - size_t val_len); -int regmap_bulk_write(struct regmap *map, unsigned int reg, - const void *val, size_t val_len); - -int regmap_get_val_bytes(struct regmap *map); -int regmap_get_max_register(struct regmap *map); -int regmap_get_reg_stride(struct regmap *map); - -int regmap_write_bits(struct regmap *map, unsigned int reg, - unsigned int mask, unsigned int val); -int regmap_update_bits(struct regmap *map, unsigned int reg, - unsigned int mask, unsigned int val); - -static inline int regmap_set_bits(struct regmap *map, - unsigned int reg, unsigned int bits) +#ifndef regmap_bulk_read +#define regmap_bulk_read regmap_bulk_read +static inline int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, + size_t val_bytes) { - return regmap_update_bits(map, reg, bits, bits); + __regmap_bulk_api_changed(); + return -1; } +#endif -static inline int regmap_clear_bits(struct regmap *map, - unsigned int reg, unsigned int bits) +#ifndef regmap_bulk_write +#define regmap_bulk_write regmap_bulk_write +static inline int regmap_bulk_write(struct regmap *map, unsigned int reg, + const void *val, size_t val_bytes) { - return regmap_update_bits(map, reg, bits, 0); + __regmap_bulk_api_changed(); + return -1; } +#endif -size_t regmap_size_bytes(struct regmap *map); - -/** - * regmap_read_poll_timeout - Poll until a condition is met or a timeout occurs - * - * @map: Regmap to read from - * @addr: Address to poll - * @val: Unsigned integer variable to read the value into - * @cond: Break condition (usually involving @val) - * @timeout_us: Timeout in us, 0 means never timeout - * - * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read - * error return value in case of a error read. In the two former cases, - * the last read value at @addr is stored in @val. Must not be called - * from atomic context if sleep_us or timeout_us are used. - * - * This is modelled after the readx_poll_timeout macros in linux/iopoll.h. - */ -#define regmap_read_poll_timeout(map, addr, val, cond, timeout_us) \ -({ \ - int __ret, __tmp; \ - __tmp = read_poll_timeout(regmap_read, __ret, __ret || (cond), \ - timeout_us, (map), (addr), &(val)); \ - __ret ?: __tmp; \ -}) +#include <linux/regmap.h> #endif /* __REGMAP_H */ |