[PATCH v2 4/9] irqchip/irq-qcom-mpm: Prepare common access path for timer and pin regs
Sneh Mankad
sneh.mankad at oss.qualcomm.com
Thu Oct 15 02:55:20 PDT 2026
The vMPM layout starts with two timer registers followed by pin register
banks (ENABLE/FALLING/RISING/POLARITY/STATUS), each with reg_stride
number of entries.
Use qcom_mpm_offset() as the common addressing helper for both timer and
pin register accesses based on that layout.
vMPM has MPM_REG_* values represented as contiguous register IDs,
hence replace the macros with enum qcom_mpm_reg and modify the accessor
helpers accordingly.
Signed-off-by: Sneh Mankad <sneh.mankad at oss.qualcomm.com>
---
drivers/irqchip/irq-qcom-mpm.c | 39 ++++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/drivers/irqchip/irq-qcom-mpm.c b/drivers/irqchip/irq-qcom-mpm.c
index a37c20a20bed34d4f55fbcc950ba39ab9799b7b5..0de6ce818a506efc07913b16c479b5d5efb15108 100644
--- a/drivers/irqchip/irq-qcom-mpm.c
+++ b/drivers/irqchip/irq-qcom-mpm.c
@@ -64,11 +64,16 @@
*
*/
-#define MPM_REG_ENABLE 0
-#define MPM_REG_FALLING_EDGE 1
-#define MPM_REG_RISING_EDGE 2
-#define MPM_REG_POLARITY 3
-#define MPM_REG_STATUS 4
+#define MPM_TIMER_REGS 2
+
+enum qcom_mpm_reg {
+ MPM_REG_TIMER = 0,
+ MPM_REG_ENABLE,
+ MPM_REG_FALLING_EDGE,
+ MPM_REG_RISING_EDGE,
+ MPM_REG_POLARITY,
+ MPM_REG_STATUS,
+};
/* MPM pin map to GIC hwirq */
struct mpm_gic_map {
@@ -90,18 +95,30 @@ struct qcom_mpm_priv {
atomic_t cpus_in_pm;
};
-static u32 qcom_mpm_read(struct qcom_mpm_priv *priv, unsigned int reg,
- unsigned int index)
+static unsigned int qcom_mpm_offset(struct qcom_mpm_priv *priv, enum qcom_mpm_reg reg,
+ unsigned int index)
+{
+ unsigned int reg_offset = 0;
+
+ if (reg != MPM_REG_TIMER) {
+ reg_offset += MPM_TIMER_REGS;
+ reg_offset += (reg - MPM_REG_ENABLE) * priv->reg_stride;
+ }
+
+ return (reg_offset + index) * sizeof(u32);
+}
+
+static u32 qcom_mpm_read(struct qcom_mpm_priv *priv, enum qcom_mpm_reg reg, unsigned int index)
{
- unsigned int offset = (reg * priv->reg_stride + index + 2) * 4;
+ unsigned int offset = qcom_mpm_offset(priv, reg, index);
return readl_relaxed(priv->base + offset);
}
-static void qcom_mpm_write(struct qcom_mpm_priv *priv, unsigned int reg,
+static void qcom_mpm_write(struct qcom_mpm_priv *priv, enum qcom_mpm_reg reg,
unsigned int index, u32 val)
{
- unsigned int offset = (reg * priv->reg_stride + index + 2) * 4;
+ unsigned int offset = qcom_mpm_offset(priv, reg, index);
writel_relaxed(val, priv->base + offset);
@@ -142,7 +159,7 @@ static void qcom_mpm_unmask(struct irq_data *d)
irq_chip_unmask_parent(d);
}
-static void mpm_set_type(struct qcom_mpm_priv *priv, bool set, unsigned int reg,
+static void mpm_set_type(struct qcom_mpm_priv *priv, bool set, enum qcom_mpm_reg reg,
unsigned int index, unsigned int shift)
{
unsigned long flags, val;
--
2.34.1
More information about the linux-arm-kernel
mailing list