All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
To: broonie@kernel.org
Cc: gregkh@linuxfoundation.org, rafael@kernel.org,
	andy.shevchenko@gmail.com, krzk@kernel.org,
	m.szyprowski@samsung.com, mazziesaccount@gmail.com,
	linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org
Subject: [PATCH v3 04/12] regmap-irq: Remove an unnecessary restriction on type_in_mask
Date: Sun,  3 Jul 2022 12:20:53 +0100	[thread overview]
Message-ID: <20220703112101.24493-5-aidanmacdonald.0x0@gmail.com> (raw)
In-Reply-To: <20220703112101.24493-1-aidanmacdonald.0x0@gmail.com>

Check types_supported instead of checking type_rising/falling_val
when using type_in_mask interrupts. This makes the intent clearer
and allows a type_in_mask irq to support level or edge triggers,
rather than only edge triggers.

Update the documentation and comments to reflect the new behavior.

This shouldn't affect existing drivers, because if they didn't
set types_supported properly the type buffer wouldn't be updated.

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

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index dca27b4e29d3..fd7c4315d16b 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -252,22 +252,19 @@ static void regmap_irq_enable(struct irq_data *data)
 	struct regmap *map = d->map;
 	const struct regmap_irq *irq_data = irq_to_regmap_irq(d, data->hwirq);
 	unsigned int reg = irq_data->reg_offset / map->reg_stride;
-	unsigned int mask, type;
-
-	type = irq_data->type.type_falling_val | irq_data->type.type_rising_val;
+	unsigned int mask;
 
 	/*
 	 * The type_in_mask flag means that the underlying hardware uses
-	 * separate mask bits for rising and falling edge interrupts, but
-	 * we want to make them into a single virtual interrupt with
-	 * configurable edge.
+	 * separate mask bits for each interrupt trigger type, but we want
+	 * to have a single logical interrupt with a configurable type.
 	 *
-	 * If the interrupt we're enabling defines the falling or rising
-	 * masks then instead of using the regular mask bits for this
-	 * interrupt, use the value previously written to the type buffer
-	 * at the corresponding offset in regmap_irq_set_type().
+	 * If the interrupt we're enabling defines any supported types
+	 * then instead of using the regular mask bits for this interrupt,
+	 * use the value previously written to the type buffer at the
+	 * corresponding offset in regmap_irq_set_type().
 	 */
-	if (d->chip->type_in_mask && type)
+	if (d->chip->type_in_mask && irq_data->type.types_supported)
 		mask = d->type_buf[reg] & irq_data->mask;
 	else
 		mask = irq_data->mask;
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index f75911239977..106ca1172d3d 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -1468,9 +1468,11 @@ struct regmap_irq_sub_irq_map {
  * @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.
- * @type_in_mask: Use the mask registers for controlling irq type. For
- *                interrupts defining type_rising/falling_mask use mask_base
- *                for edge configuration and never update bits in type_base.
+ * @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
+ *		  a single logical interrupt. Use &struct regmap_irq_type data
+ *		  to define the mask bit for each irq type.
  * @clear_on_unmask: For chips with interrupts cleared on read: read the status
  *                   registers before unmasking interrupts to clear any bits
  *                   set when they were masked.
-- 
2.35.1


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

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-03 11:20 [PATCH v3 00/12] regmap-irq cleanups and refactoring Aidan MacDonald
2022-07-03 11:20 ` [PATCH v3 01/12] regmap-irq: Convert bool bitfields to unsigned int Aidan MacDonald
2022-07-03 11:20 ` [PATCH v3 02/12] regmap-irq: Remove unused type_reg_stride field Aidan MacDonald
2022-07-03 11:20 ` [PATCH v3 03/12] regmap-irq: Cleanup sizeof(...) use in memory allocation Aidan MacDonald
2022-07-03 11:20 ` Aidan MacDonald [this message]
2022-07-03 11:20 ` [PATCH v3 05/12] regmap-irq: Remove inappropriate uses of regmap_irq_update_bits() Aidan MacDonald
2022-07-03 11:20 ` [PATCH v3 06/12] regmap-irq: Remove mask_writeonly and regmap_irq_update_bits() Aidan MacDonald
2022-07-03 11:20 ` [PATCH v3 07/12] regmap-irq: Refactor checks for status bulk read support Aidan MacDonald
2022-07-03 11:20 ` [PATCH v3 08/12] regmap-irq: Introduce config registers for irq types Aidan MacDonald
2022-07-03 11:20 ` [PATCH v3 09/12] regmap-irq: Deprecate type registers and virtual registers Aidan MacDonald
2022-07-03 11:20 ` [PATCH v3 10/12] regmap-irq: Fix inverted handling of unmask registers Aidan MacDonald
2022-07-03 11:21 ` [PATCH v3 11/12] regmap-irq: Add get_irq_reg() callback Aidan MacDonald
2022-07-03 11:21 ` [PATCH v3 12/12] regmap-irq: Deprecate the not_fixed_stride flag Aidan MacDonald
2022-07-03 14:27 ` [PATCH v3 00/12] regmap-irq cleanups and refactoring Andy Shevchenko
2022-07-04 10:34   ` Mark Brown
2022-07-04 10:58     ` Aidan MacDonald

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=20220703112101.24493-5-aidanmacdonald.0x0@gmail.com \
    --to=aidanmacdonald.0x0@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mazziesaccount@gmail.com \
    --cc=rafael@kernel.org \
    /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.