From 697c3892d825fb78f42ec8e53bed065dd728db3e Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 30 Jan 2023 02:04:57 +0000 Subject: regmap: apply reg_base and reg_downshift for single register ops reg_base and reg_downshift currently don't have any effect if used with a regmap_bus or regmap_config which only offers single register operations (ie. reg_read, reg_write and optionally reg_update_bits). Fix that and take them into account also for regmap_bus with only reg_read and read_write operations by applying reg_base and reg_downshift in _regmap_bus_reg_write, _regmap_bus_reg_read. Also apply reg_base and reg_downshift in _regmap_update_bits, but only in case the operation is carried out with a reg_update_bits call defined in either regmap_bus or regmap_config. Fixes: 0074f3f2b1e43d ("regmap: allow a defined reg_base to be added to every address") Fixes: 86fc59ef818beb ("regmap: add configurable downshift for addresses") Signed-off-by: Daniel Golle Tested-by: Colin Foster Link: https://lore.kernel.org/r/Y9clyVS3tQEHlUhA@makrotopia.org Signed-off-by: Mark Brown --- drivers/base/regmap/regmap.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/base') diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index d12d669157f2..d2a54eb0efd9 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1942,6 +1942,8 @@ static int _regmap_bus_reg_write(void *context, unsigned int reg, { struct regmap *map = context; + reg += map->reg_base; + reg >>= map->format.reg_downshift; return map->bus->reg_write(map->bus_context, reg, val); } @@ -2840,6 +2842,8 @@ static int _regmap_bus_reg_read(void *context, unsigned int reg, { struct regmap *map = context; + reg += map->reg_base; + reg >>= map->format.reg_downshift; return map->bus->reg_read(map->bus_context, reg, val); } @@ -3231,6 +3235,8 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg, *change = false; if (regmap_volatile(map, reg) && map->reg_update_bits) { + reg += map->reg_base; + reg >>= map->format.reg_downshift; ret = map->reg_update_bits(map->bus_context, reg, mask, val); if (ret == 0 && change) *change = true; -- cgit v1.2.3 From 483e6ea1b35aaeffd9b6e6e660d756be49c2a9f5 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Thu, 16 Feb 2023 22:31:59 +0000 Subject: regmap-irq: Remove unused type_invert flag type_invert is deprecated and no longer used; it can now be removed. Signed-off-by: Aidan MacDonald Link: https://lore.kernel.org/r/20230216223200.150679-1-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown --- drivers/base/regmap/regmap-irq.c | 11 ++--------- include/linux/regmap.h | 3 --- 2 files changed, 2 insertions(+), 12 deletions(-) (limited to 'drivers/base') diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index a8f185430a07..e3092f522107 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -189,12 +189,8 @@ static void regmap_irq_sync_unlock(struct irq_data *data) if (!d->type_buf_def[i]) continue; reg = d->get_irq_reg(d, d->chip->type_base, i); - if (d->chip->type_invert) - ret = regmap_update_bits(d->map, reg, - d->type_buf_def[i], ~d->type_buf[i]); - else - ret = regmap_update_bits(d->map, reg, - d->type_buf_def[i], d->type_buf[i]); + ret = regmap_update_bits(d->map, reg, + d->type_buf_def[i], d->type_buf[i]); if (ret != 0) dev_err(d->map->dev, "Failed to sync type in %x\n", reg); @@ -1028,9 +1024,6 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, ret = regmap_read(map, reg, &d->type_buf_def[i]); - if (d->chip->type_invert) - d->type_buf_def[i] = ~d->type_buf_def[i]; - if (ret) { dev_err(map->dev, "Failed to get type defaults at 0x%x: %d\n", reg, ret); diff --git a/include/linux/regmap.h b/include/linux/regmap.h index f26432dc02ef..c2233aeb3843 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -1555,8 +1555,6 @@ struct regmap_irq_chip_data; * @ack_invert: Inverted ack register: cleared bits for ack. * @clear_ack: Use this to set 1 and 0 or vice-versa to clear interrupts. * @wake_invert: Inverted wake register: cleared bits are wake enabled. - * @type_invert: Invert the type flags. Deprecated, use config registers - * instead. * @type_in_mask: Use the mask registers for controlling irq type. Use this if * the hardware provides separate bits for rising/falling edge * or low/high level interrupts and they should be combined into @@ -1633,7 +1631,6 @@ struct regmap_irq_chip { unsigned int clear_ack:1; unsigned int wake_invert:1; unsigned int runtime_pm:1; - unsigned int type_invert:1; unsigned int type_in_mask:1; unsigned int clear_on_unmask:1; unsigned int not_fixed_stride:1; -- cgit v1.2.3 From c74e7af1245b2073930afc9a2a340d91e08f0f14 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Thu, 16 Feb 2023 22:32:00 +0000 Subject: regmap-irq: Remove unused mask_invert flag mask_invert is deprecated and no longer used; it can now be removed. Signed-off-by: Aidan MacDonald Link: https://lore.kernel.org/r/20230216223200.150679-2-aidanmacdonald.0x0@gmail.com Signed-off-by: Mark Brown --- drivers/base/regmap/regmap-irq.c | 14 -------------- include/linux/regmap.h | 4 ---- 2 files changed, 18 deletions(-) (limited to 'drivers/base') diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index e3092f522107..8c903b8c9714 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -878,20 +878,6 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, */ dev_warn(map->dev, "mask_base and unmask_base are inverted, please fix it"); - /* Might as well warn about mask_invert while we're at it... */ - if (chip->mask_invert) - dev_warn(map->dev, "mask_invert=true ignored"); - - d->mask_base = chip->unmask_base; - d->unmask_base = chip->mask_base; - } else if (chip->mask_invert) { - /* - * Swap the roles of mask_base and unmask_base if the bits are - * inverted. This is deprecated, drivers should use unmask_base - * directly. - */ - dev_warn(map->dev, "mask_invert=true is deprecated; please switch to unmask_base"); - d->mask_base = chip->unmask_base; d->unmask_base = chip->mask_base; } else { diff --git a/include/linux/regmap.h b/include/linux/regmap.h index c2233aeb3843..4d10790adeb0 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -1540,9 +1540,6 @@ struct regmap_irq_chip_data; * @config_base: Base address for IRQ type config regs. If null unsupported. * @irq_reg_stride: Stride to use for chips where registers are not contiguous. * @init_ack_masked: Ack all masked interrupts once during initalization. - * @mask_invert: Inverted mask register: cleared bits are masked out. - * Deprecated; prefer describing an inverted mask register as - * an unmask register. * @mask_unmask_non_inverted: Controls mask bit inversion for chips that set * both @mask_base and @unmask_base. If false, mask and unmask bits are * inverted (which is deprecated behavior); if true, bits will not be @@ -1624,7 +1621,6 @@ struct regmap_irq_chip { const unsigned int *config_base; unsigned int irq_reg_stride; unsigned int init_ack_masked:1; - unsigned int mask_invert:1; unsigned int mask_unmask_non_inverted:1; unsigned int use_ack:1; unsigned int ack_invert:1; -- cgit v1.2.3