All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
To: broonie@kernel.org
Cc: agross@kernel.org, bjorn.andersson@linaro.org,
	srinivas.kandagatla@linaro.org, bgoswami@codeaurora.org,
	gregkh@linuxfoundation.org, rafael@kernel.org,
	cw00.choi@samsung.com, krzysztof.kozlowski@linaro.org,
	b.zolnierkie@samsung.com, myungjoo.ham@samsung.com,
	michael@walle.cc, linus.walleij@linaro.org, brgl@bgdev.pl,
	tglx@linutronix.de, maz@kernel.org, lee.jones@linaro.org,
	mani@kernel.org, cristian.ciocaltea@gmail.com, wens@csie.org,
	tharvey@gateworks.com, rjones@gateworks.com,
	mazziesaccount@gmail.com, orsonzhai@gmail.com,
	baolin.wang7@gmail.com, zhang.lyra@gmail.com,
	jernej.skrabec@gmail.com, samuel@sholland.org,
	lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com,
	linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-actions@lists.infradead.org, linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, alsa-devel@alsa-project.org
Subject: [PATCH 47/49] regmap-irq: Add get_irq_reg() callback
Date: Mon, 20 Jun 2022 21:06:42 +0100	[thread overview]
Message-ID: <20220620200644.1961936-48-aidanmacdonald.0x0@gmail.com> (raw)
In-Reply-To: <20220620200644.1961936-1-aidanmacdonald.0x0@gmail.com>

Replace the internal sub_irq_reg() function with a public callback
that drivers can use when they have more complex register layouts.
The default implementation is regmap_irq_get_irq_reg_linear(), used
if the chip doesn't provide its own callback.

Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
---
 drivers/base/regmap/regmap-irq.c | 122 ++++++++++++++++++++-----------
 include/linux/regmap.h           |  15 +++-
 2 files changed, 92 insertions(+), 45 deletions(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 7b5bd1d45fc0..acbd6e22b0cd 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -41,30 +41,12 @@ struct regmap_irq_chip_data {
 
 	unsigned int irq_reg_stride;
 
+	unsigned int (*get_irq_reg)(struct regmap_irq_chip_data *data,
+				    unsigned int base, int index);
+
 	bool clear_status:1;
 };
 
-static int sub_irq_reg(struct regmap_irq_chip_data *data,
-		       unsigned int base_reg, int i)
-{
-	const struct regmap_irq_chip *chip = data->chip;
-	struct regmap *map = data->map;
-	struct regmap_irq_sub_irq_map *subreg;
-	unsigned int offset;
-	int reg = 0;
-
-	if (!chip->sub_reg_offsets || !chip->not_fixed_stride) {
-		/* Assume linear mapping */
-		reg = base_reg + (i * map->reg_stride * data->irq_reg_stride);
-	} else {
-		subreg = &chip->sub_reg_offsets[i];
-		offset = subreg->offset[0];
-		reg = base_reg + offset;
-	}
-
-	return reg;
-}
-
 static inline const
 struct regmap_irq *irq_to_regmap_irq(struct regmap_irq_chip_data *data,
 				     int irq)
@@ -76,8 +58,14 @@ static bool regmap_irq_can_bulk_read_status(struct regmap_irq_chip_data *data)
 {
 	struct regmap *map = data->map;
 
+	/*
+	 * While possible that a user-defined get_irq_reg callback might be
+	 * linear enough to support bulk reads, most of the time it won't.
+	 * Therefore only allow them if the default callback is being used.
+	 */
 	return !map->use_single_read && map->reg_stride == 1 &&
-		data->irq_reg_stride == 1;
+		data->irq_reg_stride == 1 &&
+		data->get_irq_reg == regmap_irq_get_irq_reg_linear;
 }
 
 static void regmap_irq_lock(struct irq_data *data)
@@ -114,7 +102,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 
 	if (d->clear_status) {
 		for (i = 0; i < d->chip->num_regs; i++) {
-			reg = sub_irq_reg(d, d->chip->status_base, i);
+			reg = d->get_irq_reg(d, d->chip->status_base, i);
 
 			ret = regmap_read(map, reg, &val);
 			if (ret)
@@ -132,7 +120,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 	 */
 	for (i = 0; i < d->chip->num_regs; i++) {
 		if (d->chip->mask_base) {
-			reg = sub_irq_reg(d, d->chip->mask_base, i);
+			reg = d->get_irq_reg(d, d->chip->mask_base, i);
 			ret = regmap_irq_update_mask_bits(d, reg,
 					d->mask_buf_def[i], d->mask_buf[i]);
 			if (ret != 0)
@@ -141,7 +129,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 		}
 
 		if (d->chip->unmask_base) {
-			reg = sub_irq_reg(d, d->chip->unmask_base, i);
+			reg = d->get_irq_reg(d, d->chip->unmask_base, i);
 			ret = regmap_irq_update_mask_bits(d, reg,
 					d->mask_buf_def[i], ~d->mask_buf[i]);
 			if (ret != 0)
@@ -149,7 +137,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 					reg);
 		}
 
-		reg = sub_irq_reg(d, d->chip->wake_base, i);
+		reg = d->get_irq_reg(d, d->chip->wake_base, i);
 		if (d->wake_buf) {
 			if (d->chip->wake_invert)
 				ret = regmap_update_bits(d->map, reg,
@@ -173,7 +161,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 		 * it'll be ignored in irq handler, then may introduce irq storm
 		 */
 		if (d->mask_buf[i] && (d->chip->ack_base || d->chip->use_ack)) {
-			reg = sub_irq_reg(d, d->chip->ack_base, i);
+			reg = d->get_irq_reg(d, d->chip->ack_base, i);
 
 			/* some chips ack by write 0 */
 			if (d->chip->ack_invert)
@@ -194,7 +182,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 
 	for (i = 0; i < d->chip->num_config_bases; i++) {
 		for (j = 0; j < d->chip->num_config_regs; j++) {
-			reg = sub_irq_reg(d, d->chip->config_base[i], j);
+			reg = d->get_irq_reg(d, d->chip->config_base[i], j);
 			ret = regmap_write(map, reg, d->config_buf[i][j]);
 			if (ret != 0)
 				dev_err(d->map->dev,
@@ -316,14 +304,17 @@ static inline int read_sub_irq_data(struct regmap_irq_chip_data *data,
 	const struct regmap_irq_chip *chip = data->chip;
 	struct regmap *map = data->map;
 	struct regmap_irq_sub_irq_map *subreg;
+	unsigned int reg;
 	int i, ret = 0;
 
 	if (!chip->sub_reg_offsets) {
-		/* Assume linear mapping */
-		ret = regmap_read(map, chip->status_base +
-				  (b * map->reg_stride * data->irq_reg_stride),
-				   &data->status_buf[b]);
+		reg = data->get_irq_reg(data, chip->status_base, b);
+		ret = regmap_read(map, reg, &data->status_buf[b]);
 	} else {
+		/*
+		 * Note we can't use get_irq_reg() here because the offsets
+		 * in 'subreg' are *not* interchangeable with indices.
+		 */
 		subreg = &chip->sub_reg_offsets[b];
 		for (i = 0; i < subreg->num_regs; i++) {
 			unsigned int offset = subreg->offset[i];
@@ -389,10 +380,19 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
 		 * sake of simplicity. and add bulk reads only if needed
 		 */
 		for (i = 0; i < chip->num_main_regs; i++) {
-			ret = regmap_read(map, chip->main_status +
-				  (i * map->reg_stride
-				   * data->irq_reg_stride),
-				  &data->main_status_buf[i]);
+			/*
+			 * For not_fixed_stride, don't use get_irq_reg().
+			 * It would produce an incorrect result.
+			 */
+			if (data->chip->not_fixed_stride)
+				reg = chip->main_status +
+					(i * map->reg_stride *
+					 data->irq_reg_stride);
+			else
+				reg = data->get_irq_reg(data,
+							chip->main_status, i);
+
+			ret = regmap_read(map, reg, &data->main_status_buf[i]);
 			if (ret) {
 				dev_err(map->dev,
 					"Failed to read IRQ status %d\n",
@@ -457,7 +457,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
 
 	} else {
 		for (i = 0; i < data->chip->num_regs; i++) {
-			unsigned int reg = sub_irq_reg(data,
+			unsigned int reg = data->get_irq_reg(data,
 					data->chip->status_base, i);
 			ret = regmap_read(map, reg, &data->status_buf[i]);
 
@@ -485,7 +485,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
 		data->status_buf[i] &= ~data->mask_buf[i];
 
 		if (data->status_buf[i] && (chip->ack_base || chip->use_ack)) {
-			reg = sub_irq_reg(data, data->chip->ack_base, i);
+			reg = data->get_irq_reg(data, data->chip->ack_base, i);
 
 			if (chip->ack_invert)
 				ret = regmap_write(map, reg,
@@ -545,6 +545,37 @@ static const struct irq_domain_ops regmap_domain_ops = {
 	.xlate	= irq_domain_xlate_onetwocell,
 };
 
+/**
+ * regmap_irq_get_irq_reg_linear() - Linear IRQ register mapping callback.
+ *
+ * @data: Data for the &struct regmap_irq_chip
+ * @base: Base register
+ * @index: Register index
+ *
+ * Returns the register address corresponding to the given @base and @index
+ * by the formula ``base + index * regmap_stride * irq_reg_stride``.
+ */
+unsigned int regmap_irq_get_irq_reg_linear(struct regmap_irq_chip_data *data,
+					   unsigned int base, int index)
+{
+	const struct regmap_irq_chip *chip = data->chip;
+	struct regmap *map = data->map;
+
+	/*
+	 * NOTE: This is for backward compatibility only and will be removed
+	 * when not_fixed_stride is dropped (it's only used by qcom-pm8008).
+	 */
+	if (chip->not_fixed_stride && chip->sub_reg_offsets) {
+		struct regmap_irq_sub_irq_map *subreg;
+
+		subreg = &chip->sub_reg_offsets[0];
+		return base + subreg->offset[0];
+	}
+
+	return base + index * (map->reg_stride * chip->irq_reg_stride);
+}
+EXPORT_SYMBOL_GPL(regmap_irq_get_irq_reg_linear);
+
 /**
  * regmap_irq_set_type_config_simple() - Simple IRQ type configuration callback.
  *
@@ -730,6 +761,11 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 	else
 		d->irq_reg_stride = 1;
 
+	if (chip->get_irq_reg)
+		d->get_irq_reg = chip->get_irq_reg;
+	else
+		d->get_irq_reg = regmap_irq_get_irq_reg_linear;
+
 	if (regmap_irq_can_bulk_read_status(d)) {
 		d->status_reg_buf = kmalloc_array(chip->num_regs,
 						  map->format.val_bytes,
@@ -749,7 +785,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 		d->mask_buf[i] = d->mask_buf_def[i];
 
 		if (d->chip->mask_base) {
-			reg = sub_irq_reg(d, d->chip->mask_base, i);
+			reg = d->get_irq_reg(d, d->chip->mask_base, i);
 			ret = regmap_irq_update_mask_bits(d, reg,
 					d->mask_buf_def[i], d->mask_buf[i]);
 			if (ret != 0) {
@@ -760,7 +796,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 		}
 
 		if (d->chip->unmask_base) {
-			reg = sub_irq_reg(d, d->chip->unmask_base, i);
+			reg = d->get_irq_reg(d, d->chip->unmask_base, i);
 			ret = regmap_irq_update_mask_bits(d, reg,
 					d->mask_buf_def[i], ~d->mask_buf[i]);
 			if (ret != 0) {
@@ -774,7 +810,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 			continue;
 
 		/* Ack masked but set interrupts */
-		reg = sub_irq_reg(d, d->chip->status_base, i);
+		reg = d->get_irq_reg(d, d->chip->status_base, i);
 		ret = regmap_read(map, reg, &d->status_buf[i]);
 		if (ret != 0) {
 			dev_err(map->dev, "Failed to read IRQ status: %d\n",
@@ -786,7 +822,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 			d->status_buf[i] = ~d->status_buf[i];
 
 		if (d->status_buf[i] && (chip->ack_base || chip->use_ack)) {
-			reg = sub_irq_reg(d, d->chip->ack_base, i);
+			reg = d->get_irq_reg(d, d->chip->ack_base, i);
 			if (chip->ack_invert)
 				ret = regmap_write(map, reg,
 					~(d->status_buf[i] & d->mask_buf[i]));
@@ -811,7 +847,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 	if (d->wake_buf) {
 		for (i = 0; i < chip->num_regs; i++) {
 			d->wake_buf[i] = d->mask_buf_def[i];
-			reg = sub_irq_reg(d, d->chip->wake_base, i);
+			reg = d->get_irq_reg(d, d->chip->wake_base, i);
 
 			if (chip->wake_invert)
 				ret = regmap_update_bits(d->map, reg,
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index bb625a1edef9..be51af0a2425 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -1424,6 +1424,8 @@ struct regmap_irq_sub_irq_map {
 	unsigned int *offset;
 };
 
+struct regmap_irq_chip_data;
+
 /**
  * struct regmap_irq_chip - Description of a generic regmap irq_chip.
  *
@@ -1489,6 +1491,13 @@ struct regmap_irq_sub_irq_map {
  * @handle_post_irq: Driver specific callback to handle interrupt from device
  *		     after handling the interrupts in regmap_irq_handler().
  * @set_type_config: Callback used for configuring irq types.
+ * @get_irq_reg: Callback for mapping (base register, index) pairs to register
+ *		 addresses. The base register will be one of @status_base,
+ *		 @mask_base, etc., @main_status, or any of @config_base.
+ *		 The index will be in the range [0, num_main_regs[ for the
+ *		 main status base, [0, num_type_settings[ for any config
+ *		 register base, and [0, num_regs[ for any other base.
+ *		 If unspecified then regmap_irq_get_irq_reg_linear() is used.
  * @irq_drv_data:    Driver specific IRQ data which is passed as parameter when
  *		     driver specific pre/post interrupt handler is called.
  *
@@ -1535,11 +1544,13 @@ struct regmap_irq_chip {
 	int (*handle_post_irq)(void *irq_drv_data);
 	int (*set_type_config)(unsigned int **buf, unsigned int type,
 			       const struct regmap_irq *irq_data, int idx);
+	unsigned int (*get_irq_reg)(struct regmap_irq_chip_data *data,
+				    unsigned int base, int index);
 	void *irq_drv_data;
 };
 
-struct regmap_irq_chip_data;
-
+unsigned int regmap_irq_get_irq_reg_linear(struct regmap_irq_chip_data *data,
+					   unsigned int base, int index);
 int regmap_irq_set_type_config_simple(unsigned int **buf, unsigned int type,
 				      const struct regmap_irq *irq_data, int idx);
 
-- 
2.35.1


WARNING: multiple messages have this Message-ID (diff)
From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
To: broonie@kernel.org
Cc: agross@kernel.org, bjorn.andersson@linaro.org,
	srinivas.kandagatla@linaro.org, bgoswami@codeaurora.org,
	gregkh@linuxfoundation.org, rafael@kernel.org,
	cw00.choi@samsung.com, krzysztof.kozlowski@linaro.org,
	b.zolnierkie@samsung.com, myungjoo.ham@samsung.com,
	michael@walle.cc, linus.walleij@linaro.org, brgl@bgdev.pl,
	tglx@linutronix.de, maz@kernel.org, lee.jones@linaro.org,
	mani@kernel.org, cristian.ciocaltea@gmail.com, wens@csie.org,
	tharvey@gateworks.com, rjones@gateworks.com,
	mazziesaccount@gmail.com, orsonzhai@gmail.com,
	baolin.wang7@gmail.com, zhang.lyra@gmail.com,
	jernej.skrabec@gmail.com, samuel@sholland.org,
	lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com,
	linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-actions@lists.infradead.org, linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, alsa-devel@alsa-project.org
Subject: [PATCH 47/49] regmap-irq: Add get_irq_reg() callback
Date: Mon, 20 Jun 2022 21:06:42 +0100	[thread overview]
Message-ID: <20220620200644.1961936-48-aidanmacdonald.0x0@gmail.com> (raw)
In-Reply-To: <20220620200644.1961936-1-aidanmacdonald.0x0@gmail.com>

Replace the internal sub_irq_reg() function with a public callback
that drivers can use when they have more complex register layouts.
The default implementation is regmap_irq_get_irq_reg_linear(), used
if the chip doesn't provide its own callback.

Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
---
 drivers/base/regmap/regmap-irq.c | 122 ++++++++++++++++++++-----------
 include/linux/regmap.h           |  15 +++-
 2 files changed, 92 insertions(+), 45 deletions(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 7b5bd1d45fc0..acbd6e22b0cd 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -41,30 +41,12 @@ struct regmap_irq_chip_data {
 
 	unsigned int irq_reg_stride;
 
+	unsigned int (*get_irq_reg)(struct regmap_irq_chip_data *data,
+				    unsigned int base, int index);
+
 	bool clear_status:1;
 };
 
-static int sub_irq_reg(struct regmap_irq_chip_data *data,
-		       unsigned int base_reg, int i)
-{
-	const struct regmap_irq_chip *chip = data->chip;
-	struct regmap *map = data->map;
-	struct regmap_irq_sub_irq_map *subreg;
-	unsigned int offset;
-	int reg = 0;
-
-	if (!chip->sub_reg_offsets || !chip->not_fixed_stride) {
-		/* Assume linear mapping */
-		reg = base_reg + (i * map->reg_stride * data->irq_reg_stride);
-	} else {
-		subreg = &chip->sub_reg_offsets[i];
-		offset = subreg->offset[0];
-		reg = base_reg + offset;
-	}
-
-	return reg;
-}
-
 static inline const
 struct regmap_irq *irq_to_regmap_irq(struct regmap_irq_chip_data *data,
 				     int irq)
@@ -76,8 +58,14 @@ static bool regmap_irq_can_bulk_read_status(struct regmap_irq_chip_data *data)
 {
 	struct regmap *map = data->map;
 
+	/*
+	 * While possible that a user-defined get_irq_reg callback might be
+	 * linear enough to support bulk reads, most of the time it won't.
+	 * Therefore only allow them if the default callback is being used.
+	 */
 	return !map->use_single_read && map->reg_stride == 1 &&
-		data->irq_reg_stride == 1;
+		data->irq_reg_stride == 1 &&
+		data->get_irq_reg == regmap_irq_get_irq_reg_linear;
 }
 
 static void regmap_irq_lock(struct irq_data *data)
@@ -114,7 +102,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 
 	if (d->clear_status) {
 		for (i = 0; i < d->chip->num_regs; i++) {
-			reg = sub_irq_reg(d, d->chip->status_base, i);
+			reg = d->get_irq_reg(d, d->chip->status_base, i);
 
 			ret = regmap_read(map, reg, &val);
 			if (ret)
@@ -132,7 +120,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 	 */
 	for (i = 0; i < d->chip->num_regs; i++) {
 		if (d->chip->mask_base) {
-			reg = sub_irq_reg(d, d->chip->mask_base, i);
+			reg = d->get_irq_reg(d, d->chip->mask_base, i);
 			ret = regmap_irq_update_mask_bits(d, reg,
 					d->mask_buf_def[i], d->mask_buf[i]);
 			if (ret != 0)
@@ -141,7 +129,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 		}
 
 		if (d->chip->unmask_base) {
-			reg = sub_irq_reg(d, d->chip->unmask_base, i);
+			reg = d->get_irq_reg(d, d->chip->unmask_base, i);
 			ret = regmap_irq_update_mask_bits(d, reg,
 					d->mask_buf_def[i], ~d->mask_buf[i]);
 			if (ret != 0)
@@ -149,7 +137,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 					reg);
 		}
 
-		reg = sub_irq_reg(d, d->chip->wake_base, i);
+		reg = d->get_irq_reg(d, d->chip->wake_base, i);
 		if (d->wake_buf) {
 			if (d->chip->wake_invert)
 				ret = regmap_update_bits(d->map, reg,
@@ -173,7 +161,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 		 * it'll be ignored in irq handler, then may introduce irq storm
 		 */
 		if (d->mask_buf[i] && (d->chip->ack_base || d->chip->use_ack)) {
-			reg = sub_irq_reg(d, d->chip->ack_base, i);
+			reg = d->get_irq_reg(d, d->chip->ack_base, i);
 
 			/* some chips ack by write 0 */
 			if (d->chip->ack_invert)
@@ -194,7 +182,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 
 	for (i = 0; i < d->chip->num_config_bases; i++) {
 		for (j = 0; j < d->chip->num_config_regs; j++) {
-			reg = sub_irq_reg(d, d->chip->config_base[i], j);
+			reg = d->get_irq_reg(d, d->chip->config_base[i], j);
 			ret = regmap_write(map, reg, d->config_buf[i][j]);
 			if (ret != 0)
 				dev_err(d->map->dev,
@@ -316,14 +304,17 @@ static inline int read_sub_irq_data(struct regmap_irq_chip_data *data,
 	const struct regmap_irq_chip *chip = data->chip;
 	struct regmap *map = data->map;
 	struct regmap_irq_sub_irq_map *subreg;
+	unsigned int reg;
 	int i, ret = 0;
 
 	if (!chip->sub_reg_offsets) {
-		/* Assume linear mapping */
-		ret = regmap_read(map, chip->status_base +
-				  (b * map->reg_stride * data->irq_reg_stride),
-				   &data->status_buf[b]);
+		reg = data->get_irq_reg(data, chip->status_base, b);
+		ret = regmap_read(map, reg, &data->status_buf[b]);
 	} else {
+		/*
+		 * Note we can't use get_irq_reg() here because the offsets
+		 * in 'subreg' are *not* interchangeable with indices.
+		 */
 		subreg = &chip->sub_reg_offsets[b];
 		for (i = 0; i < subreg->num_regs; i++) {
 			unsigned int offset = subreg->offset[i];
@@ -389,10 +380,19 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
 		 * sake of simplicity. and add bulk reads only if needed
 		 */
 		for (i = 0; i < chip->num_main_regs; i++) {
-			ret = regmap_read(map, chip->main_status +
-				  (i * map->reg_stride
-				   * data->irq_reg_stride),
-				  &data->main_status_buf[i]);
+			/*
+			 * For not_fixed_stride, don't use get_irq_reg().
+			 * It would produce an incorrect result.
+			 */
+			if (data->chip->not_fixed_stride)
+				reg = chip->main_status +
+					(i * map->reg_stride *
+					 data->irq_reg_stride);
+			else
+				reg = data->get_irq_reg(data,
+							chip->main_status, i);
+
+			ret = regmap_read(map, reg, &data->main_status_buf[i]);
 			if (ret) {
 				dev_err(map->dev,
 					"Failed to read IRQ status %d\n",
@@ -457,7 +457,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
 
 	} else {
 		for (i = 0; i < data->chip->num_regs; i++) {
-			unsigned int reg = sub_irq_reg(data,
+			unsigned int reg = data->get_irq_reg(data,
 					data->chip->status_base, i);
 			ret = regmap_read(map, reg, &data->status_buf[i]);
 
@@ -485,7 +485,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
 		data->status_buf[i] &= ~data->mask_buf[i];
 
 		if (data->status_buf[i] && (chip->ack_base || chip->use_ack)) {
-			reg = sub_irq_reg(data, data->chip->ack_base, i);
+			reg = data->get_irq_reg(data, data->chip->ack_base, i);
 
 			if (chip->ack_invert)
 				ret = regmap_write(map, reg,
@@ -545,6 +545,37 @@ static const struct irq_domain_ops regmap_domain_ops = {
 	.xlate	= irq_domain_xlate_onetwocell,
 };
 
+/**
+ * regmap_irq_get_irq_reg_linear() - Linear IRQ register mapping callback.
+ *
+ * @data: Data for the &struct regmap_irq_chip
+ * @base: Base register
+ * @index: Register index
+ *
+ * Returns the register address corresponding to the given @base and @index
+ * by the formula ``base + index * regmap_stride * irq_reg_stride``.
+ */
+unsigned int regmap_irq_get_irq_reg_linear(struct regmap_irq_chip_data *data,
+					   unsigned int base, int index)
+{
+	const struct regmap_irq_chip *chip = data->chip;
+	struct regmap *map = data->map;
+
+	/*
+	 * NOTE: This is for backward compatibility only and will be removed
+	 * when not_fixed_stride is dropped (it's only used by qcom-pm8008).
+	 */
+	if (chip->not_fixed_stride && chip->sub_reg_offsets) {
+		struct regmap_irq_sub_irq_map *subreg;
+
+		subreg = &chip->sub_reg_offsets[0];
+		return base + subreg->offset[0];
+	}
+
+	return base + index * (map->reg_stride * chip->irq_reg_stride);
+}
+EXPORT_SYMBOL_GPL(regmap_irq_get_irq_reg_linear);
+
 /**
  * regmap_irq_set_type_config_simple() - Simple IRQ type configuration callback.
  *
@@ -730,6 +761,11 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 	else
 		d->irq_reg_stride = 1;
 
+	if (chip->get_irq_reg)
+		d->get_irq_reg = chip->get_irq_reg;
+	else
+		d->get_irq_reg = regmap_irq_get_irq_reg_linear;
+
 	if (regmap_irq_can_bulk_read_status(d)) {
 		d->status_reg_buf = kmalloc_array(chip->num_regs,
 						  map->format.val_bytes,
@@ -749,7 +785,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 		d->mask_buf[i] = d->mask_buf_def[i];
 
 		if (d->chip->mask_base) {
-			reg = sub_irq_reg(d, d->chip->mask_base, i);
+			reg = d->get_irq_reg(d, d->chip->mask_base, i);
 			ret = regmap_irq_update_mask_bits(d, reg,
 					d->mask_buf_def[i], d->mask_buf[i]);
 			if (ret != 0) {
@@ -760,7 +796,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 		}
 
 		if (d->chip->unmask_base) {
-			reg = sub_irq_reg(d, d->chip->unmask_base, i);
+			reg = d->get_irq_reg(d, d->chip->unmask_base, i);
 			ret = regmap_irq_update_mask_bits(d, reg,
 					d->mask_buf_def[i], ~d->mask_buf[i]);
 			if (ret != 0) {
@@ -774,7 +810,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 			continue;
 
 		/* Ack masked but set interrupts */
-		reg = sub_irq_reg(d, d->chip->status_base, i);
+		reg = d->get_irq_reg(d, d->chip->status_base, i);
 		ret = regmap_read(map, reg, &d->status_buf[i]);
 		if (ret != 0) {
 			dev_err(map->dev, "Failed to read IRQ status: %d\n",
@@ -786,7 +822,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 			d->status_buf[i] = ~d->status_buf[i];
 
 		if (d->status_buf[i] && (chip->ack_base || chip->use_ack)) {
-			reg = sub_irq_reg(d, d->chip->ack_base, i);
+			reg = d->get_irq_reg(d, d->chip->ack_base, i);
 			if (chip->ack_invert)
 				ret = regmap_write(map, reg,
 					~(d->status_buf[i] & d->mask_buf[i]));
@@ -811,7 +847,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 	if (d->wake_buf) {
 		for (i = 0; i < chip->num_regs; i++) {
 			d->wake_buf[i] = d->mask_buf_def[i];
-			reg = sub_irq_reg(d, d->chip->wake_base, i);
+			reg = d->get_irq_reg(d, d->chip->wake_base, i);
 
 			if (chip->wake_invert)
 				ret = regmap_update_bits(d->map, reg,
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index bb625a1edef9..be51af0a2425 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -1424,6 +1424,8 @@ struct regmap_irq_sub_irq_map {
 	unsigned int *offset;
 };
 
+struct regmap_irq_chip_data;
+
 /**
  * struct regmap_irq_chip - Description of a generic regmap irq_chip.
  *
@@ -1489,6 +1491,13 @@ struct regmap_irq_sub_irq_map {
  * @handle_post_irq: Driver specific callback to handle interrupt from device
  *		     after handling the interrupts in regmap_irq_handler().
  * @set_type_config: Callback used for configuring irq types.
+ * @get_irq_reg: Callback for mapping (base register, index) pairs to register
+ *		 addresses. The base register will be one of @status_base,
+ *		 @mask_base, etc., @main_status, or any of @config_base.
+ *		 The index will be in the range [0, num_main_regs[ for the
+ *		 main status base, [0, num_type_settings[ for any config
+ *		 register base, and [0, num_regs[ for any other base.
+ *		 If unspecified then regmap_irq_get_irq_reg_linear() is used.
  * @irq_drv_data:    Driver specific IRQ data which is passed as parameter when
  *		     driver specific pre/post interrupt handler is called.
  *
@@ -1535,11 +1544,13 @@ struct regmap_irq_chip {
 	int (*handle_post_irq)(void *irq_drv_data);
 	int (*set_type_config)(unsigned int **buf, unsigned int type,
 			       const struct regmap_irq *irq_data, int idx);
+	unsigned int (*get_irq_reg)(struct regmap_irq_chip_data *data,
+				    unsigned int base, int index);
 	void *irq_drv_data;
 };
 
-struct regmap_irq_chip_data;
-
+unsigned int regmap_irq_get_irq_reg_linear(struct regmap_irq_chip_data *data,
+					   unsigned int base, int index);
 int regmap_irq_set_type_config_simple(unsigned int **buf, unsigned int type,
 				      const struct regmap_irq *irq_data, int idx);
 
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
To: broonie@kernel.org
Cc: alsa-devel@alsa-project.org, bgoswami@codeaurora.org,
	rafael@kernel.org, linus.walleij@linaro.org,
	bjorn.andersson@linaro.org, srinivas.kandagatla@linaro.org,
	myungjoo.ham@samsung.com, lee.jones@linaro.org,
	samuel@sholland.org, maz@kernel.org, brgl@bgdev.pl,
	mani@kernel.org, krzysztof.kozlowski@linaro.org,
	jernej.skrabec@gmail.com, cw00.choi@samsung.com, wens@csie.org,
	agross@kernel.org, orsonzhai@gmail.com,
	linux-sunxi@lists.linux.dev, b.zolnierkie@samsung.com,
	linux-arm-msm@vger.kernel.org, tharvey@gateworks.com,
	linux-actions@lists.infradead.org, linux-gpio@vger.kernel.org,
	tiwai@suse.com, tglx@linutronix.de, cristian.ciocaltea@gmail.com,
	linux-arm-kernel@lists.infradead.org, rjones@gateworks.com,
	gregkh@linuxfoundation.org, lgirdwood@gmail.com,
	linux-kernel@vger.kernel.org, michael@walle.cc,
	zhang.lyra@gmail.com, baolin.wang7@gmail.com,
	mazziesaccount@gmail.com
Subject: [PATCH 47/49] regmap-irq: Add get_irq_reg() callback
Date: Mon, 20 Jun 2022 21:06:42 +0100	[thread overview]
Message-ID: <20220620200644.1961936-48-aidanmacdonald.0x0@gmail.com> (raw)
In-Reply-To: <20220620200644.1961936-1-aidanmacdonald.0x0@gmail.com>

Replace the internal sub_irq_reg() function with a public callback
that drivers can use when they have more complex register layouts.
The default implementation is regmap_irq_get_irq_reg_linear(), used
if the chip doesn't provide its own callback.

Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
---
 drivers/base/regmap/regmap-irq.c | 122 ++++++++++++++++++++-----------
 include/linux/regmap.h           |  15 +++-
 2 files changed, 92 insertions(+), 45 deletions(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 7b5bd1d45fc0..acbd6e22b0cd 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -41,30 +41,12 @@ struct regmap_irq_chip_data {
 
 	unsigned int irq_reg_stride;
 
+	unsigned int (*get_irq_reg)(struct regmap_irq_chip_data *data,
+				    unsigned int base, int index);
+
 	bool clear_status:1;
 };
 
-static int sub_irq_reg(struct regmap_irq_chip_data *data,
-		       unsigned int base_reg, int i)
-{
-	const struct regmap_irq_chip *chip = data->chip;
-	struct regmap *map = data->map;
-	struct regmap_irq_sub_irq_map *subreg;
-	unsigned int offset;
-	int reg = 0;
-
-	if (!chip->sub_reg_offsets || !chip->not_fixed_stride) {
-		/* Assume linear mapping */
-		reg = base_reg + (i * map->reg_stride * data->irq_reg_stride);
-	} else {
-		subreg = &chip->sub_reg_offsets[i];
-		offset = subreg->offset[0];
-		reg = base_reg + offset;
-	}
-
-	return reg;
-}
-
 static inline const
 struct regmap_irq *irq_to_regmap_irq(struct regmap_irq_chip_data *data,
 				     int irq)
@@ -76,8 +58,14 @@ static bool regmap_irq_can_bulk_read_status(struct regmap_irq_chip_data *data)
 {
 	struct regmap *map = data->map;
 
+	/*
+	 * While possible that a user-defined get_irq_reg callback might be
+	 * linear enough to support bulk reads, most of the time it won't.
+	 * Therefore only allow them if the default callback is being used.
+	 */
 	return !map->use_single_read && map->reg_stride == 1 &&
-		data->irq_reg_stride == 1;
+		data->irq_reg_stride == 1 &&
+		data->get_irq_reg == regmap_irq_get_irq_reg_linear;
 }
 
 static void regmap_irq_lock(struct irq_data *data)
@@ -114,7 +102,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 
 	if (d->clear_status) {
 		for (i = 0; i < d->chip->num_regs; i++) {
-			reg = sub_irq_reg(d, d->chip->status_base, i);
+			reg = d->get_irq_reg(d, d->chip->status_base, i);
 
 			ret = regmap_read(map, reg, &val);
 			if (ret)
@@ -132,7 +120,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 	 */
 	for (i = 0; i < d->chip->num_regs; i++) {
 		if (d->chip->mask_base) {
-			reg = sub_irq_reg(d, d->chip->mask_base, i);
+			reg = d->get_irq_reg(d, d->chip->mask_base, i);
 			ret = regmap_irq_update_mask_bits(d, reg,
 					d->mask_buf_def[i], d->mask_buf[i]);
 			if (ret != 0)
@@ -141,7 +129,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 		}
 
 		if (d->chip->unmask_base) {
-			reg = sub_irq_reg(d, d->chip->unmask_base, i);
+			reg = d->get_irq_reg(d, d->chip->unmask_base, i);
 			ret = regmap_irq_update_mask_bits(d, reg,
 					d->mask_buf_def[i], ~d->mask_buf[i]);
 			if (ret != 0)
@@ -149,7 +137,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 					reg);
 		}
 
-		reg = sub_irq_reg(d, d->chip->wake_base, i);
+		reg = d->get_irq_reg(d, d->chip->wake_base, i);
 		if (d->wake_buf) {
 			if (d->chip->wake_invert)
 				ret = regmap_update_bits(d->map, reg,
@@ -173,7 +161,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 		 * it'll be ignored in irq handler, then may introduce irq storm
 		 */
 		if (d->mask_buf[i] && (d->chip->ack_base || d->chip->use_ack)) {
-			reg = sub_irq_reg(d, d->chip->ack_base, i);
+			reg = d->get_irq_reg(d, d->chip->ack_base, i);
 
 			/* some chips ack by write 0 */
 			if (d->chip->ack_invert)
@@ -194,7 +182,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 
 	for (i = 0; i < d->chip->num_config_bases; i++) {
 		for (j = 0; j < d->chip->num_config_regs; j++) {
-			reg = sub_irq_reg(d, d->chip->config_base[i], j);
+			reg = d->get_irq_reg(d, d->chip->config_base[i], j);
 			ret = regmap_write(map, reg, d->config_buf[i][j]);
 			if (ret != 0)
 				dev_err(d->map->dev,
@@ -316,14 +304,17 @@ static inline int read_sub_irq_data(struct regmap_irq_chip_data *data,
 	const struct regmap_irq_chip *chip = data->chip;
 	struct regmap *map = data->map;
 	struct regmap_irq_sub_irq_map *subreg;
+	unsigned int reg;
 	int i, ret = 0;
 
 	if (!chip->sub_reg_offsets) {
-		/* Assume linear mapping */
-		ret = regmap_read(map, chip->status_base +
-				  (b * map->reg_stride * data->irq_reg_stride),
-				   &data->status_buf[b]);
+		reg = data->get_irq_reg(data, chip->status_base, b);
+		ret = regmap_read(map, reg, &data->status_buf[b]);
 	} else {
+		/*
+		 * Note we can't use get_irq_reg() here because the offsets
+		 * in 'subreg' are *not* interchangeable with indices.
+		 */
 		subreg = &chip->sub_reg_offsets[b];
 		for (i = 0; i < subreg->num_regs; i++) {
 			unsigned int offset = subreg->offset[i];
@@ -389,10 +380,19 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
 		 * sake of simplicity. and add bulk reads only if needed
 		 */
 		for (i = 0; i < chip->num_main_regs; i++) {
-			ret = regmap_read(map, chip->main_status +
-				  (i * map->reg_stride
-				   * data->irq_reg_stride),
-				  &data->main_status_buf[i]);
+			/*
+			 * For not_fixed_stride, don't use get_irq_reg().
+			 * It would produce an incorrect result.
+			 */
+			if (data->chip->not_fixed_stride)
+				reg = chip->main_status +
+					(i * map->reg_stride *
+					 data->irq_reg_stride);
+			else
+				reg = data->get_irq_reg(data,
+							chip->main_status, i);
+
+			ret = regmap_read(map, reg, &data->main_status_buf[i]);
 			if (ret) {
 				dev_err(map->dev,
 					"Failed to read IRQ status %d\n",
@@ -457,7 +457,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
 
 	} else {
 		for (i = 0; i < data->chip->num_regs; i++) {
-			unsigned int reg = sub_irq_reg(data,
+			unsigned int reg = data->get_irq_reg(data,
 					data->chip->status_base, i);
 			ret = regmap_read(map, reg, &data->status_buf[i]);
 
@@ -485,7 +485,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
 		data->status_buf[i] &= ~data->mask_buf[i];
 
 		if (data->status_buf[i] && (chip->ack_base || chip->use_ack)) {
-			reg = sub_irq_reg(data, data->chip->ack_base, i);
+			reg = data->get_irq_reg(data, data->chip->ack_base, i);
 
 			if (chip->ack_invert)
 				ret = regmap_write(map, reg,
@@ -545,6 +545,37 @@ static const struct irq_domain_ops regmap_domain_ops = {
 	.xlate	= irq_domain_xlate_onetwocell,
 };
 
+/**
+ * regmap_irq_get_irq_reg_linear() - Linear IRQ register mapping callback.
+ *
+ * @data: Data for the &struct regmap_irq_chip
+ * @base: Base register
+ * @index: Register index
+ *
+ * Returns the register address corresponding to the given @base and @index
+ * by the formula ``base + index * regmap_stride * irq_reg_stride``.
+ */
+unsigned int regmap_irq_get_irq_reg_linear(struct regmap_irq_chip_data *data,
+					   unsigned int base, int index)
+{
+	const struct regmap_irq_chip *chip = data->chip;
+	struct regmap *map = data->map;
+
+	/*
+	 * NOTE: This is for backward compatibility only and will be removed
+	 * when not_fixed_stride is dropped (it's only used by qcom-pm8008).
+	 */
+	if (chip->not_fixed_stride && chip->sub_reg_offsets) {
+		struct regmap_irq_sub_irq_map *subreg;
+
+		subreg = &chip->sub_reg_offsets[0];
+		return base + subreg->offset[0];
+	}
+
+	return base + index * (map->reg_stride * chip->irq_reg_stride);
+}
+EXPORT_SYMBOL_GPL(regmap_irq_get_irq_reg_linear);
+
 /**
  * regmap_irq_set_type_config_simple() - Simple IRQ type configuration callback.
  *
@@ -730,6 +761,11 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 	else
 		d->irq_reg_stride = 1;
 
+	if (chip->get_irq_reg)
+		d->get_irq_reg = chip->get_irq_reg;
+	else
+		d->get_irq_reg = regmap_irq_get_irq_reg_linear;
+
 	if (regmap_irq_can_bulk_read_status(d)) {
 		d->status_reg_buf = kmalloc_array(chip->num_regs,
 						  map->format.val_bytes,
@@ -749,7 +785,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 		d->mask_buf[i] = d->mask_buf_def[i];
 
 		if (d->chip->mask_base) {
-			reg = sub_irq_reg(d, d->chip->mask_base, i);
+			reg = d->get_irq_reg(d, d->chip->mask_base, i);
 			ret = regmap_irq_update_mask_bits(d, reg,
 					d->mask_buf_def[i], d->mask_buf[i]);
 			if (ret != 0) {
@@ -760,7 +796,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 		}
 
 		if (d->chip->unmask_base) {
-			reg = sub_irq_reg(d, d->chip->unmask_base, i);
+			reg = d->get_irq_reg(d, d->chip->unmask_base, i);
 			ret = regmap_irq_update_mask_bits(d, reg,
 					d->mask_buf_def[i], ~d->mask_buf[i]);
 			if (ret != 0) {
@@ -774,7 +810,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 			continue;
 
 		/* Ack masked but set interrupts */
-		reg = sub_irq_reg(d, d->chip->status_base, i);
+		reg = d->get_irq_reg(d, d->chip->status_base, i);
 		ret = regmap_read(map, reg, &d->status_buf[i]);
 		if (ret != 0) {
 			dev_err(map->dev, "Failed to read IRQ status: %d\n",
@@ -786,7 +822,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 			d->status_buf[i] = ~d->status_buf[i];
 
 		if (d->status_buf[i] && (chip->ack_base || chip->use_ack)) {
-			reg = sub_irq_reg(d, d->chip->ack_base, i);
+			reg = d->get_irq_reg(d, d->chip->ack_base, i);
 			if (chip->ack_invert)
 				ret = regmap_write(map, reg,
 					~(d->status_buf[i] & d->mask_buf[i]));
@@ -811,7 +847,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 	if (d->wake_buf) {
 		for (i = 0; i < chip->num_regs; i++) {
 			d->wake_buf[i] = d->mask_buf_def[i];
-			reg = sub_irq_reg(d, d->chip->wake_base, i);
+			reg = d->get_irq_reg(d, d->chip->wake_base, i);
 
 			if (chip->wake_invert)
 				ret = regmap_update_bits(d->map, reg,
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index bb625a1edef9..be51af0a2425 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -1424,6 +1424,8 @@ struct regmap_irq_sub_irq_map {
 	unsigned int *offset;
 };
 
+struct regmap_irq_chip_data;
+
 /**
  * struct regmap_irq_chip - Description of a generic regmap irq_chip.
  *
@@ -1489,6 +1491,13 @@ struct regmap_irq_sub_irq_map {
  * @handle_post_irq: Driver specific callback to handle interrupt from device
  *		     after handling the interrupts in regmap_irq_handler().
  * @set_type_config: Callback used for configuring irq types.
+ * @get_irq_reg: Callback for mapping (base register, index) pairs to register
+ *		 addresses. The base register will be one of @status_base,
+ *		 @mask_base, etc., @main_status, or any of @config_base.
+ *		 The index will be in the range [0, num_main_regs[ for the
+ *		 main status base, [0, num_type_settings[ for any config
+ *		 register base, and [0, num_regs[ for any other base.
+ *		 If unspecified then regmap_irq_get_irq_reg_linear() is used.
  * @irq_drv_data:    Driver specific IRQ data which is passed as parameter when
  *		     driver specific pre/post interrupt handler is called.
  *
@@ -1535,11 +1544,13 @@ struct regmap_irq_chip {
 	int (*handle_post_irq)(void *irq_drv_data);
 	int (*set_type_config)(unsigned int **buf, unsigned int type,
 			       const struct regmap_irq *irq_data, int idx);
+	unsigned int (*get_irq_reg)(struct regmap_irq_chip_data *data,
+				    unsigned int base, int index);
 	void *irq_drv_data;
 };
 
-struct regmap_irq_chip_data;
-
+unsigned int regmap_irq_get_irq_reg_linear(struct regmap_irq_chip_data *data,
+					   unsigned int base, int index);
 int regmap_irq_set_type_config_simple(unsigned int **buf, unsigned int type,
 				      const struct regmap_irq *irq_data, int idx);
 
-- 
2.35.1


  parent reply	other threads:[~2022-06-20 20:07 UTC|newest]

Thread overview: 215+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20 20:05 [PATCH 00/49] regmap-irq cleanups and refactoring Aidan MacDonald
2022-06-20 20:05 ` Aidan MacDonald
2022-06-20 20:05 ` Aidan MacDonald
2022-06-20 20:05 ` [PATCH 01/49] regmap-irq: Fix a bug in regmap_irq_enable() for type_in_mask chips Aidan MacDonald
2022-06-20 20:05   ` Aidan MacDonald
2022-06-20 20:05   ` Aidan MacDonald
2022-06-20 20:05 ` [PATCH 02/49] regmap-irq: Fix offset/index mismatch in read_sub_irq_data() Aidan MacDonald
2022-06-20 20:05   ` Aidan MacDonald
2022-06-20 20:05   ` Aidan MacDonald
2022-06-23  9:03   ` Matti Vaittinen
2022-06-23  9:03     ` Matti Vaittinen
2022-06-23  9:03     ` Matti Vaittinen
2022-06-23 23:29   ` Guru Das Srinagesh
2022-06-23 23:29     ` Guru Das Srinagesh
2022-06-20 20:05 ` [PATCH 03/49] regmap-irq: Remove an unnecessary restriction on type_in_mask Aidan MacDonald
2022-06-20 20:05   ` Aidan MacDonald
2022-06-20 20:05   ` Aidan MacDonald
2022-06-20 20:05 ` [PATCH 04/49] regmap-irq: Introduce config registers for irq types Aidan MacDonald
2022-06-20 20:05   ` Aidan MacDonald
2022-06-20 20:05   ` Aidan MacDonald
2022-06-21  9:22   ` Andy Shevchenko
2022-06-21  9:22     ` Andy Shevchenko
2022-06-21  9:22     ` Andy Shevchenko
2022-06-20 20:06 ` [PATCH 05/49] mfd: qcom-pm8008: Convert irq chip to config regs Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 06/49] mfd: wcd934x: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 07/49] sound: soc: codecs: wcd9335: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 08/49] sound: soc: codecs: wcd938x: Remove spurious type_base from irq chip Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 09/49] mfd: max77650: Remove useless type_invert flag Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 10/49] regmap-irq: Remove virtual registers support Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 11/49] regmap-irq: Remove old type register support, refactor Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 12/49] regmap-irq: Remove unused type_reg_stride field Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 13/49] regmap-irq: Remove unused type_invert flag Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 14/49] regmap-irq: Do not use regmap_irq_update_bits() for wake regs Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 15/49] regmap-irq: Change the behavior of mask_writeonly Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-21  9:29   ` Andy Shevchenko
2022-06-21  9:29     ` Andy Shevchenko
2022-06-21  9:29     ` Andy Shevchenko
2022-06-21 21:13     ` Aidan MacDonald
2022-06-21 21:13       ` Aidan MacDonald
2022-06-21 21:13       ` Aidan MacDonald
2022-06-21 22:42       ` Andy Shevchenko
2022-06-23 20:54         ` Aidan MacDonald
2022-06-23 20:54           ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 16/49] regmap-irq: Rename regmap_irq_update_bits() Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 17/49] regmap-irq: Add broken_mask_unmask flag Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-21  9:33   ` Andy Shevchenko
2022-06-21  9:33     ` Andy Shevchenko
2022-06-21  9:33     ` Andy Shevchenko
2022-06-21 21:07     ` Aidan MacDonald
2022-06-21 21:07       ` Aidan MacDonald
2022-06-21 21:07       ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 18/49] mfd: qcom-pm8008: Add broken_mask_unmask irq chip flag Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-21  9:35   ` Andy Shevchenko
2022-06-21  9:35     ` Andy Shevchenko
2022-06-21  9:35     ` Andy Shevchenko
2022-06-24  0:03     ` Guru Das Srinagesh
2022-06-24  0:03       ` Guru Das Srinagesh
2022-06-20 20:06 ` [PATCH 19/49] mfd: stpmic1: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-21  9:35   ` Andy Shevchenko
2022-06-21  9:35     ` Andy Shevchenko
2022-06-21  9:35     ` Andy Shevchenko
2022-06-20 20:06 ` [PATCH 20/49] regmap-irq: Fix inverted handling of unmask registers Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-21  9:40   ` Andy Shevchenko
2022-06-21  9:40     ` Andy Shevchenko
2022-06-21  9:40     ` Andy Shevchenko
2022-06-24  0:21   ` Guru Das Srinagesh
2022-06-24  0:21     ` Guru Das Srinagesh
2022-06-20 20:06 ` [PATCH 21/49] mfd: tps65090: replace irqchip mask_invert with unmask_base Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 22/49] mfd: sun4i-gpadc: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 23/49] mfd: sprd-sc27xx-spi: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 24/49] mfd: rt5033: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 25/49] mfd: rohm-bd71828: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 26/49] mfd: rn5t618: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 27/49] mfd: gateworks-gsc: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 28/49] mfd: axp20x: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 29/49] mfd: atc260x: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 30/49] mfd: 88pm800: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 31/49] mfd: max14577: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 32/49] mfd: max77693: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 33/49] mfd: rohm-bd718x7: drop useless mask_invert flag on irqchip Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-23  9:09   ` Vaittinen, Matti
2022-06-23  9:09     ` Vaittinen, Matti
2022-06-23  9:09     ` Vaittinen, Matti
2022-06-20 20:06 ` [PATCH 34/49] mfd: max77843: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 35/49] extcon: max77843: replace irqchip mask_invert with unmask_base Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 36/49] extcon: sm5502: drop useless mask_invert flag on irqchip Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 37/49] extcon: rt8973a: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 38/49] irqchip: sl28cpld: replace irqchip mask_invert with unmask_base Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 39/49] gpio: " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-21  9:42   ` Andy Shevchenko
2022-06-21  9:42     ` Andy Shevchenko
2022-06-21  9:42     ` Andy Shevchenko
2022-06-23  6:33   ` Michael Walle
2022-06-23  6:33     ` Michael Walle
2022-06-23  6:33     ` Michael Walle
2022-06-20 20:06 ` [PATCH 40/49] mfd: stpmic1: Fix broken mask/unmask in irq chip Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 41/49] mfd: stpmic1: Enable mask_writeonly flag for " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 42/49] mfd: qcom-pm8008: Fix broken mask/unmask in " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 43/49] mfd: qcom-pm8008: Enable mask_writeonly flag for " Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 44/49] regmap-irq: Remove broken_mask_unmask flag Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 45/49] regmap-irq: Remove mask_invert flag Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 46/49] regmap-irq: Refactor checks for status bulk read support Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-21  9:45   ` Andy Shevchenko
2022-06-21  9:45     ` Andy Shevchenko
2022-06-21  9:45     ` Andy Shevchenko
2022-06-20 20:06 ` Aidan MacDonald [this message]
2022-06-20 20:06   ` [PATCH 47/49] regmap-irq: Add get_irq_reg() callback Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-21  9:51   ` Andy Shevchenko
2022-06-21  9:51     ` Andy Shevchenko
2022-06-21  9:51     ` Andy Shevchenko
2022-06-20 20:06 ` [PATCH 48/49] mfd: qcom-pm8008: Use get_irq_reg() for irq chip Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06 ` [PATCH 49/49] regmap-irq: Remove not_fixed_stride flag Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-20 20:06   ` Aidan MacDonald
2022-06-21  9:25 ` [PATCH 00/49] regmap-irq cleanups and refactoring Andy Shevchenko
2022-06-21  9:25   ` Andy Shevchenko
2022-06-21  9:25   ` Andy Shevchenko
2022-06-21 17:08 ` Mark Brown
2022-06-21 17:08   ` Mark Brown
2022-06-21 17:08   ` Mark Brown
2022-06-21 21:04   ` Aidan MacDonald
2022-06-21 21:04     ` Aidan MacDonald
2022-06-21 21:04     ` Aidan MacDonald
2022-06-23 13:18     ` Mark Brown
2022-06-23 13:18       ` Mark Brown
2022-06-22 15:16 ` (subset) " Mark Brown
2022-06-22 15:16   ` Mark Brown
2022-06-22 15:16   ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220620200644.1961936-48-aidanmacdonald.0x0@gmail.com \
    --to=aidanmacdonald.0x0@gmail.com \
    --cc=agross@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=baolin.wang7@gmail.com \
    --cc=bgoswami@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=cristian.ciocaltea@gmail.com \
    --cc=cw00.choi@samsung.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-actions@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=mani@kernel.org \
    --cc=maz@kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=michael@walle.cc \
    --cc=myungjoo.ham@samsung.com \
    --cc=orsonzhai@gmail.com \
    --cc=perex@perex.cz \
    --cc=rafael@kernel.org \
    --cc=rjones@gateworks.com \
    --cc=samuel@sholland.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tglx@linutronix.de \
    --cc=tharvey@gateworks.com \
    --cc=tiwai@suse.com \
    --cc=wens@csie.org \
    --cc=zhang.lyra@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.