mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/4] irqchip/qcom-pdc: Misc. changes
@ 2026-05-27  9:54 Mukesh Ojha
  2026-05-27  9:54 ` [PATCH v2 1/4] irqchip/qcom-pdc: Split __pdc_enable_intr() into per-version helpers Mukesh Ojha
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Mukesh Ojha @ 2026-05-27  9:54 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-arm-msm, linux-kernel, Mukesh Ojha

The Qualcomm PDC (Power Domain Controller) hardware exposes multiple DRV
(Driver) regions, each 0x10000 bytes in size, where each region serves a
specific client like HLOS(High Level OS), TZ, HYP etc., in the system .
Linux only needs access to the OS DRV region.

Despite this, the driver was mapping up to 0x30000 bytes (three DRV
regions) via a QCOM_PDC_SIZE clamp introduced as a workaround for old
sm8150 DTs that described a too-small register window. Correspondingly,
most platform DTS files described the PDC reg as 0x30000 in size.

This series cleans up and refactors the PDC driver, motivated by the above.

2/4 has a dependency on https://lore.kernel.org/lkml/20260527094333.2311731-1-mukesh.ojha@oss.qualcomm.com/
for a warning fix, otherwise "OF: invalid reg size, please fix DT" will be seen, however there is no
functional dependency.

Changes in v2: https://lore.kernel.org/lkml/20260410184124.1068210-1-mukesh.ojha@oss.qualcomm.com/
 - Split the series into two: one for driver changes and the other for DTS corrections.
   DTS is sent here https://lore.kernel.org/lkml/20260527094333.2311731-1-mukesh.ojha@oss.qualcomm.com/
 - Dropped the 4/35 from the series as current code looks more clean.
 - Added R-b tag and rebased the series.

Mukesh Ojha (4):
  irqchip/qcom-pdc: Split __pdc_enable_intr() into per-version helpers
  irqchip/qcom-pdc: Tighten ioremap clamp to single DRV region size
  irqchip/qcom-pdc: Add PDC_VERSION() macro to describe version register
    fields
  irqchip/qcom-pdc: Use FIELD_GET() to extract bank index and bit
    position

 drivers/irqchip/qcom-pdc.c | 61 +++++++++++++++++++++++++-------------
 1 file changed, 40 insertions(+), 21 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/4] irqchip/qcom-pdc: Split __pdc_enable_intr() into per-version helpers
  2026-05-27  9:54 [PATCH v2 0/4] irqchip/qcom-pdc: Misc. changes Mukesh Ojha
@ 2026-05-27  9:54 ` Mukesh Ojha
  2026-06-03 16:29   ` [tip: irq/drivers] " tip-bot2 for Mukesh Ojha
  2026-05-27  9:54 ` [PATCH v2 2/4] irqchip/qcom-pdc: Tighten ioremap clamp to single DRV region size Mukesh Ojha
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Mukesh Ojha @ 2026-05-27  9:54 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: linux-arm-msm, linux-kernel, Mukesh Ojha, Dmitry Baryshkov,
	Konrad Dybcio

The __pdc_enable_intr() function contains a version branch that selects
between two distinct enable mechanisms: a bank-based IRQ_ENABLE_BANK
register for HW < 3.2, and a per-pin enable bit in IRQ_i_CFG for
HW >= 3.2. These two paths share no code and serve different hardware.

Split them into two focused static functions: pdc_enable_intr_bank()
for HW < 3.2 and pdc_enable_intr_cfg() for HW >= 3.2. No functional
change.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
---
 drivers/irqchip/qcom-pdc.c | 42 +++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index 32b77fa93f73..a72e32896e64 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -97,28 +97,38 @@ static void pdc_x1e_irq_enable_write(u32 bank, u32 enable)
 	pdc_base_reg_write(base, IRQ_ENABLE_BANK, bank, enable);
 }
 
-static void __pdc_enable_intr(int pin_out, bool on)
+static void pdc_enable_intr_bank(int pin_out, bool on)
 {
 	unsigned long enable;
+	u32 index, mask;
 
-	if (pdc_version < PDC_VERSION_3_2) {
-		u32 index, mask;
+	index = pin_out / 32;
+	mask = pin_out % 32;
 
-		index = pin_out / 32;
-		mask = pin_out % 32;
+	enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
+	__assign_bit(mask, &enable, on);
 
-		enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
-		__assign_bit(mask, &enable, on);
+	if (pdc_x1e_quirk)
+		pdc_x1e_irq_enable_write(index, enable);
+	else
+		pdc_reg_write(IRQ_ENABLE_BANK, index, enable);
+}
 
-		if (pdc_x1e_quirk)
-			pdc_x1e_irq_enable_write(index, enable);
-		else
-			pdc_reg_write(IRQ_ENABLE_BANK, index, enable);
-	} else {
-		enable = pdc_reg_read(IRQ_i_CFG, pin_out);
-		__assign_bit(IRQ_i_CFG_IRQ_ENABLE, &enable, on);
-		pdc_reg_write(IRQ_i_CFG, pin_out, enable);
-	}
+static void pdc_enable_intr_cfg(int pin_out, bool on)
+{
+	unsigned long enable;
+
+	enable = pdc_reg_read(IRQ_i_CFG, pin_out);
+	__assign_bit(IRQ_i_CFG_IRQ_ENABLE, &enable, on);
+	pdc_reg_write(IRQ_i_CFG, pin_out, enable);
+}
+
+static void __pdc_enable_intr(int pin_out, bool on)
+{
+	if (pdc_version < PDC_VERSION_3_2)
+		pdc_enable_intr_bank(pin_out, on);
+	else
+		pdc_enable_intr_cfg(pin_out, on);
 }
 
 static void pdc_enable_intr(struct irq_data *d, bool on)
-- 
2.53.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 2/4] irqchip/qcom-pdc: Tighten ioremap clamp to single DRV region size
  2026-05-27  9:54 [PATCH v2 0/4] irqchip/qcom-pdc: Misc. changes Mukesh Ojha
  2026-05-27  9:54 ` [PATCH v2 1/4] irqchip/qcom-pdc: Split __pdc_enable_intr() into per-version helpers Mukesh Ojha
@ 2026-05-27  9:54 ` Mukesh Ojha
  2026-06-03 16:29   ` [tip: irq/drivers] " tip-bot2 for Mukesh Ojha
  2026-06-11 10:40   ` [PATCH v2 2/4] " Konrad Dybcio
  2026-05-27  9:54 ` [PATCH v2 3/4] irqchip/qcom-pdc: Add PDC_VERSION() macro to describe version register fields Mukesh Ojha
  2026-05-27  9:54 ` [PATCH v2 4/4] irqchip/qcom-pdc: Use FIELD_GET() to extract bank index and bit position Mukesh Ojha
  3 siblings, 2 replies; 10+ messages in thread
From: Mukesh Ojha @ 2026-05-27  9:54 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: linux-arm-msm, linux-kernel, Mukesh Ojha, Dmitry Baryshkov

The QCOM_PDC_SIZE constant (0x30000) was introduced to work around old
sm8150 DTs that described a too-small PDC register region, causing the
driver to silently expand the ioremap to cover three DRV regions. Now
that the preceding DT fixes have corrected all platforms to describe only
the APSS DRV region (0x10000), the oversized clamp is no longer needed.

Replace QCOM_PDC_SIZE with PDC_DRV_SIZE (0x10000) in the clamp so the
minimum mapped size matches a single DRV region. The clamp and warning
are intentionally kept to preserve backward compatibility with any old
DTs that may still describe a smaller region.

While at it, rename PDC_DRV_OFFSET to PDC_DRV_SIZE since the constant
represents the size of a DRV region and is used as both the ioremap
minimum size and the offset to the previous DRV region.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
---
 drivers/irqchip/qcom-pdc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index a72e32896e64..21e2b4b884ee 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -21,7 +21,7 @@
 #include <linux/types.h>
 
 #define PDC_MAX_GPIO_IRQS	256
-#define PDC_DRV_OFFSET		0x10000
+#define PDC_DRV_SIZE		0x10000
 
 /* Valid only on HW version < 3.2 */
 #define IRQ_ENABLE_BANK		0x10
@@ -358,7 +358,6 @@ static int pdc_setup_pin_mapping(struct device_node *np)
 	return 0;
 }
 
-#define QCOM_PDC_SIZE 0x30000
 
 static int qcom_pdc_probe(struct platform_device *pdev, struct device_node *parent)
 {
@@ -372,7 +371,7 @@ static int qcom_pdc_probe(struct platform_device *pdev, struct device_node *pare
 	if (of_address_to_resource(node, 0, &res))
 		return -EINVAL;
 
-	res_size = max_t(resource_size_t, resource_size(&res), QCOM_PDC_SIZE);
+	res_size = max_t(resource_size_t, resource_size(&res), PDC_DRV_SIZE);
 	if (res_size > resource_size(&res))
 		pr_warn("%pOF: invalid reg size, please fix DT\n", node);
 
@@ -385,7 +384,7 @@ static int qcom_pdc_probe(struct platform_device *pdev, struct device_node *pare
 	 * region with the expected offset to preserve support for old DTs.
 	 */
 	if (of_device_is_compatible(node, "qcom,x1e80100-pdc")) {
-		pdc_prev_base = ioremap(res.start - PDC_DRV_OFFSET, IRQ_ENABLE_BANK_MAX);
+		pdc_prev_base = ioremap(res.start - PDC_DRV_SIZE, IRQ_ENABLE_BANK_MAX);
 		if (!pdc_prev_base) {
 			pr_err("%pOF: unable to map previous PDC DRV region\n", node);
 			return -ENXIO;
-- 
2.53.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 3/4] irqchip/qcom-pdc: Add PDC_VERSION() macro to describe version register fields
  2026-05-27  9:54 [PATCH v2 0/4] irqchip/qcom-pdc: Misc. changes Mukesh Ojha
  2026-05-27  9:54 ` [PATCH v2 1/4] irqchip/qcom-pdc: Split __pdc_enable_intr() into per-version helpers Mukesh Ojha
  2026-05-27  9:54 ` [PATCH v2 2/4] irqchip/qcom-pdc: Tighten ioremap clamp to single DRV region size Mukesh Ojha
@ 2026-05-27  9:54 ` Mukesh Ojha
  2026-06-03 16:29   ` [tip: irq/drivers] " tip-bot2 for Mukesh Ojha
  2026-05-27  9:54 ` [PATCH v2 4/4] irqchip/qcom-pdc: Use FIELD_GET() to extract bank index and bit position Mukesh Ojha
  3 siblings, 1 reply; 10+ messages in thread
From: Mukesh Ojha @ 2026-05-27  9:54 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: linux-arm-msm, linux-kernel, Mukesh Ojha, Dmitry Baryshkov,
	Konrad Dybcio

The PDC hardware version register encodes major, minor and step fields
in byte-sized fields at bits [23:16], [15:8] and [7:0] respectively.
The existing PDC_VERSION_3_2 constant was a bare magic number (0x30200)
with no indication of this encoding.

Add GENMASK-based field definitions for each sub-field and a
PDC_VERSION(maj, min, step) constructor macro using FIELD_PREP, making
the encoding self-documenting. Replace the magic constant with
PDC_VERSION(3, 2, 0).

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
---
 drivers/irqchip/qcom-pdc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index 21e2b4b884ee..9ad2c22342e1 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
  */
 
+#include <linux/bitfield.h>
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -34,9 +35,16 @@
 #define IRQ_i_CFG_TYPE_MASK	GENMASK(2, 0)
 
 #define PDC_VERSION_REG		0x1000
+#define PDC_VERSION_MAJOR	GENMASK(23, 16)
+#define PDC_VERSION_MINOR	GENMASK(15, 8)
+#define PDC_VERSION_STEP	GENMASK(7, 0)
+#define PDC_VERSION(maj, min, step)	\
+	(FIELD_PREP(PDC_VERSION_MAJOR, (maj)) | \
+	 FIELD_PREP(PDC_VERSION_MINOR, (min)) | \
+	 FIELD_PREP(PDC_VERSION_STEP,  (step)))
 
 /* Notable PDC versions */
-#define PDC_VERSION_3_2		0x30200
+#define PDC_VERSION_3_2		PDC_VERSION(3, 2, 0)
 
 struct pdc_pin_region {
 	u32 pin_base;
-- 
2.53.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 4/4] irqchip/qcom-pdc: Use FIELD_GET() to extract bank index and bit position
  2026-05-27  9:54 [PATCH v2 0/4] irqchip/qcom-pdc: Misc. changes Mukesh Ojha
                   ` (2 preceding siblings ...)
  2026-05-27  9:54 ` [PATCH v2 3/4] irqchip/qcom-pdc: Add PDC_VERSION() macro to describe version register fields Mukesh Ojha
@ 2026-05-27  9:54 ` Mukesh Ojha
  2026-06-03 16:29   ` [tip: irq/drivers] " tip-bot2 for Mukesh Ojha
  3 siblings, 1 reply; 10+ messages in thread
From: Mukesh Ojha @ 2026-05-27  9:54 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-arm-msm, linux-kernel, Mukesh Ojha, Konrad Dybcio

The IRQ_ENABLE_BANK register is a bank of 32-bit words where each bit
represents one PDC pin. The bank index and bit position within the bank
are encoded in the flat pin number as bits [31:5] and [4:0] respectively.

Replace the open-coded division and modulo with FIELD_GET() and GENMASK()
to make the bit extraction self-documenting and consistent with the
FIELD_PREP() style already used in the PDC_VERSION() macro.

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
---
 drivers/irqchip/qcom-pdc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index 9ad2c22342e1..17ca26d66fea 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -27,6 +27,8 @@
 /* Valid only on HW version < 3.2 */
 #define IRQ_ENABLE_BANK		0x10
 #define IRQ_ENABLE_BANK_MAX	(IRQ_ENABLE_BANK + BITS_TO_BYTES(PDC_MAX_GPIO_IRQS))
+#define IRQ_ENABLE_BANK_INDEX_MASK	GENMASK(31, 5)
+#define IRQ_ENABLE_BANK_BIT_MASK	GENMASK(4, 0)
 #define IRQ_i_CFG		0x110
 
 /* Valid only on HW version >= 3.2 */
@@ -110,8 +112,8 @@ static void pdc_enable_intr_bank(int pin_out, bool on)
 	unsigned long enable;
 	u32 index, mask;
 
-	index = pin_out / 32;
-	mask = pin_out % 32;
+	index = FIELD_GET(IRQ_ENABLE_BANK_INDEX_MASK, pin_out);
+	mask = FIELD_GET(IRQ_ENABLE_BANK_BIT_MASK, pin_out);
 
 	enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
 	__assign_bit(mask, &enable, on);
-- 
2.53.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [tip: irq/drivers] irqchip/qcom-pdc: Use FIELD_GET() to extract bank index and bit position
  2026-05-27  9:54 ` [PATCH v2 4/4] irqchip/qcom-pdc: Use FIELD_GET() to extract bank index and bit position Mukesh Ojha
@ 2026-06-03 16:29   ` tip-bot2 for Mukesh Ojha
  0 siblings, 0 replies; 10+ messages in thread
From: tip-bot2 for Mukesh Ojha @ 2026-06-03 16:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Mukesh Ojha, Thomas Gleixner, Konrad Dybcio, x86, linux-kernel

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     8766c87e9bb499b5e2b04b9f51f9e525d41c5b46
Gitweb:        https://git.kernel.org/tip/8766c87e9bb499b5e2b04b9f51f9e525d41c5b46
Author:        Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
AuthorDate:    Wed, 27 May 2026 15:24:26 +05:30
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Wed, 03 Jun 2026 18:27:06 +02:00

irqchip/qcom-pdc: Use FIELD_GET() to extract bank index and bit position

The IRQ_ENABLE_BANK register is a bank of 32-bit words where each bit
represents one PDC pin. The bank index and bit position within the bank
are encoded in the flat pin number as bits [31:5] and [4:0] respectively.

Replace the open-coded division and modulo with FIELD_GET() and GENMASK()
to make the bit extraction self-documenting and consistent with the
FIELD_PREP() style already used in the PDC_VERSION() macro.

Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://patch.msgid.link/20260527095426.2324504-5-mukesh.ojha@oss.qualcomm.com
---
 drivers/irqchip/qcom-pdc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index 08eec00..2014dbb 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -27,6 +27,8 @@
 /* Valid only on HW version < 3.2 */
 #define IRQ_ENABLE_BANK		0x10
 #define IRQ_ENABLE_BANK_MAX	(IRQ_ENABLE_BANK + BITS_TO_BYTES(PDC_MAX_GPIO_IRQS))
+#define IRQ_ENABLE_BANK_INDEX_MASK	GENMASK(31, 5)
+#define IRQ_ENABLE_BANK_BIT_MASK	GENMASK(4, 0)
 #define IRQ_i_CFG		0x110
 
 /* Valid only on HW version >= 3.2 */
@@ -109,8 +111,8 @@ static void pdc_enable_intr_bank(int pin_out, bool on)
 	unsigned long enable;
 	u32 index, mask;
 
-	index = pin_out / 32;
-	mask = pin_out % 32;
+	index = FIELD_GET(IRQ_ENABLE_BANK_INDEX_MASK, pin_out);
+	mask = FIELD_GET(IRQ_ENABLE_BANK_BIT_MASK, pin_out);
 
 	enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
 	__assign_bit(mask, &enable, on);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [tip: irq/drivers] irqchip/qcom-pdc: Add PDC_VERSION() macro to describe version register fields
  2026-05-27  9:54 ` [PATCH v2 3/4] irqchip/qcom-pdc: Add PDC_VERSION() macro to describe version register fields Mukesh Ojha
@ 2026-06-03 16:29   ` tip-bot2 for Mukesh Ojha
  0 siblings, 0 replies; 10+ messages in thread
From: tip-bot2 for Mukesh Ojha @ 2026-06-03 16:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Mukesh Ojha, Thomas Gleixner, Dmitry Baryshkov, Konrad Dybcio,
	x86, linux-kernel

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     ef631c422f2cc3f5a8c0687364bfafec4f3d531c
Gitweb:        https://git.kernel.org/tip/ef631c422f2cc3f5a8c0687364bfafec4f3d531c
Author:        Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
AuthorDate:    Wed, 27 May 2026 15:24:25 +05:30
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Wed, 03 Jun 2026 18:27:05 +02:00

irqchip/qcom-pdc: Add PDC_VERSION() macro to describe version register fields

The PDC hardware version register encodes major, minor and step fields
in byte-sized fields at bits [23:16], [15:8] and [7:0] respectively.
The existing PDC_VERSION_3_2 constant was a bare magic number (0x30200)
with no indication of this encoding.

Add GENMASK-based field definitions for each sub-field and a
PDC_VERSION(maj, min, step) constructor macro using FIELD_PREP, making
the encoding self-documenting. Replace the magic constant with
PDC_VERSION(3, 2, 0).

Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://patch.msgid.link/20260527095426.2324504-4-mukesh.ojha@oss.qualcomm.com
---
 drivers/irqchip/qcom-pdc.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index 0b82306..08eec00 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
  */
 
+#include <linux/bitfield.h>
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -31,12 +32,18 @@
 /* Valid only on HW version >= 3.2 */
 #define IRQ_i_CFG_IRQ_ENABLE	3
 
-#define IRQ_i_CFG_TYPE_MASK	GENMASK(2, 0)
+#define IRQ_i_CFG_TYPE_MASK		GENMASK(2, 0)
 
-#define PDC_VERSION_REG		0x1000
+#define PDC_VERSION_REG			0x1000
+#define PDC_VERSION_MAJOR		GENMASK(23, 16)
+#define PDC_VERSION_MINOR		GENMASK(15, 8)
+#define PDC_VERSION_STEP		GENMASK(7, 0)
+#define PDC_VERSION(maj, min, step)	(FIELD_PREP(PDC_VERSION_MAJOR, (maj)) | \
+					 FIELD_PREP(PDC_VERSION_MINOR, (min)) | \
+					 FIELD_PREP(PDC_VERSION_STEP,  (step)))
 
 /* Notable PDC versions */
-#define PDC_VERSION_3_2		0x30200
+#define PDC_VERSION_3_2			PDC_VERSION(3, 2, 0)
 
 struct pdc_pin_region {
 	u32 pin_base;

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [tip: irq/drivers] irqchip/qcom-pdc: Tighten ioremap clamp to single DRV region size
  2026-05-27  9:54 ` [PATCH v2 2/4] irqchip/qcom-pdc: Tighten ioremap clamp to single DRV region size Mukesh Ojha
@ 2026-06-03 16:29   ` tip-bot2 for Mukesh Ojha
  2026-06-11 10:40   ` [PATCH v2 2/4] " Konrad Dybcio
  1 sibling, 0 replies; 10+ messages in thread
From: tip-bot2 for Mukesh Ojha @ 2026-06-03 16:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Mukesh Ojha, Thomas Gleixner, Dmitry Baryshkov, x86, linux-kernel

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     f1a5a0f4c0eab83299201129cffb7907d7dc99c6
Gitweb:        https://git.kernel.org/tip/f1a5a0f4c0eab83299201129cffb7907d7dc99c6
Author:        Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
AuthorDate:    Wed, 27 May 2026 15:24:24 +05:30
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Wed, 03 Jun 2026 18:27:05 +02:00

irqchip/qcom-pdc: Tighten ioremap clamp to single DRV region size

The QCOM_PDC_SIZE constant (0x30000) was introduced to work around old
sm8150 DTs that described a too-small PDC register region, causing the
driver to silently expand the ioremap to cover three DRV regions. Now
that the preceding DT fixes have corrected all platforms to describe only
the APSS DRV region (0x10000), the oversized clamp is no longer needed.

Replace QCOM_PDC_SIZE with PDC_DRV_SIZE (0x10000) in the clamp so the
minimum mapped size matches a single DRV region. The clamp and warning
are intentionally kept to preserve backward compatibility with any old
DTs that may still describe a smaller region.

While at it, rename PDC_DRV_OFFSET to PDC_DRV_SIZE since the constant
represents the size of a DRV region and is used as both the ioremap
minimum size and the offset to the previous DRV region.

Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://patch.msgid.link/20260527095426.2324504-3-mukesh.ojha@oss.qualcomm.com
---
 drivers/irqchip/qcom-pdc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index 5f0da15..0b82306 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -21,7 +21,7 @@
 #include <linux/types.h>
 
 #define PDC_MAX_GPIO_IRQS	256
-#define PDC_DRV_OFFSET		0x10000
+#define PDC_DRV_SIZE		0x10000
 
 /* Valid only on HW version < 3.2 */
 #define IRQ_ENABLE_BANK		0x10
@@ -357,7 +357,6 @@ static int pdc_setup_pin_mapping(struct device_node *np)
 	return 0;
 }
 
-#define QCOM_PDC_SIZE 0x30000
 
 static int qcom_pdc_probe(struct platform_device *pdev, struct device_node *parent)
 {
@@ -371,7 +370,7 @@ static int qcom_pdc_probe(struct platform_device *pdev, struct device_node *pare
 	if (of_address_to_resource(node, 0, &res))
 		return -EINVAL;
 
-	res_size = max_t(resource_size_t, resource_size(&res), QCOM_PDC_SIZE);
+	res_size = max_t(resource_size_t, resource_size(&res), PDC_DRV_SIZE);
 	if (res_size > resource_size(&res))
 		pr_warn("%pOF: invalid reg size, please fix DT\n", node);
 
@@ -384,7 +383,7 @@ static int qcom_pdc_probe(struct platform_device *pdev, struct device_node *pare
 	 * region with the expected offset to preserve support for old DTs.
 	 */
 	if (of_device_is_compatible(node, "qcom,x1e80100-pdc")) {
-		pdc_prev_base = ioremap(res.start - PDC_DRV_OFFSET, IRQ_ENABLE_BANK_MAX);
+		pdc_prev_base = ioremap(res.start - PDC_DRV_SIZE, IRQ_ENABLE_BANK_MAX);
 		if (!pdc_prev_base) {
 			pr_err("%pOF: unable to map previous PDC DRV region\n", node);
 			return -ENXIO;

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [tip: irq/drivers] irqchip/qcom-pdc: Split __pdc_enable_intr() into per-version helpers
  2026-05-27  9:54 ` [PATCH v2 1/4] irqchip/qcom-pdc: Split __pdc_enable_intr() into per-version helpers Mukesh Ojha
@ 2026-06-03 16:29   ` tip-bot2 for Mukesh Ojha
  0 siblings, 0 replies; 10+ messages in thread
From: tip-bot2 for Mukesh Ojha @ 2026-06-03 16:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Mukesh Ojha, Thomas Gleixner, Dmitry Baryshkov, Konrad Dybcio,
	x86, linux-kernel

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     668f3382845b3751220c6fcdd4c4cda0c2f0c78f
Gitweb:        https://git.kernel.org/tip/668f3382845b3751220c6fcdd4c4cda0c2f0c78f
Author:        Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
AuthorDate:    Wed, 27 May 2026 15:24:23 +05:30
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Wed, 03 Jun 2026 18:27:05 +02:00

irqchip/qcom-pdc: Split __pdc_enable_intr() into per-version helpers

The __pdc_enable_intr() function contains a version branch that selects
between two distinct enable mechanisms: a bank-based IRQ_ENABLE_BANK
register for HW < 3.2, and a per-pin enable bit in IRQ_i_CFG for
HW >= 3.2. These two paths share no code and serve different hardware.

Split them into two focused static functions: pdc_enable_intr_bank()
for HW < 3.2 and pdc_enable_intr_cfg() for HW >= 3.2. No functional
change.

Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://patch.msgid.link/20260527095426.2324504-2-mukesh.ojha@oss.qualcomm.com
---
 drivers/irqchip/qcom-pdc.c | 41 ++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index 32b77fa..5f0da15 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -97,28 +97,37 @@ static void pdc_x1e_irq_enable_write(u32 bank, u32 enable)
 	pdc_base_reg_write(base, IRQ_ENABLE_BANK, bank, enable);
 }
 
-static void __pdc_enable_intr(int pin_out, bool on)
+static void pdc_enable_intr_bank(int pin_out, bool on)
 {
 	unsigned long enable;
+	u32 index, mask;
 
-	if (pdc_version < PDC_VERSION_3_2) {
-		u32 index, mask;
+	index = pin_out / 32;
+	mask = pin_out % 32;
 
-		index = pin_out / 32;
-		mask = pin_out % 32;
+	enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
+	__assign_bit(mask, &enable, on);
 
-		enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
-		__assign_bit(mask, &enable, on);
+	if (pdc_x1e_quirk)
+		pdc_x1e_irq_enable_write(index, enable);
+	else
+		pdc_reg_write(IRQ_ENABLE_BANK, index, enable);
+}
 
-		if (pdc_x1e_quirk)
-			pdc_x1e_irq_enable_write(index, enable);
-		else
-			pdc_reg_write(IRQ_ENABLE_BANK, index, enable);
-	} else {
-		enable = pdc_reg_read(IRQ_i_CFG, pin_out);
-		__assign_bit(IRQ_i_CFG_IRQ_ENABLE, &enable, on);
-		pdc_reg_write(IRQ_i_CFG, pin_out, enable);
-	}
+static void pdc_enable_intr_cfg(int pin_out, bool on)
+{
+	unsigned long enable = pdc_reg_read(IRQ_i_CFG, pin_out);
+
+	__assign_bit(IRQ_i_CFG_IRQ_ENABLE, &enable, on);
+	pdc_reg_write(IRQ_i_CFG, pin_out, enable);
+}
+
+static void __pdc_enable_intr(int pin_out, bool on)
+{
+	if (pdc_version < PDC_VERSION_3_2)
+		pdc_enable_intr_bank(pin_out, on);
+	else
+		pdc_enable_intr_cfg(pin_out, on);
 }
 
 static void pdc_enable_intr(struct irq_data *d, bool on)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/4] irqchip/qcom-pdc: Tighten ioremap clamp to single DRV region size
  2026-05-27  9:54 ` [PATCH v2 2/4] irqchip/qcom-pdc: Tighten ioremap clamp to single DRV region size Mukesh Ojha
  2026-06-03 16:29   ` [tip: irq/drivers] " tip-bot2 for Mukesh Ojha
@ 2026-06-11 10:40   ` Konrad Dybcio
  1 sibling, 0 replies; 10+ messages in thread
From: Konrad Dybcio @ 2026-06-11 10:40 UTC (permalink / raw)
  To: Mukesh Ojha, Thomas Gleixner
  Cc: linux-arm-msm, linux-kernel, Dmitry Baryshkov

On 5/27/26 11:54 AM, Mukesh Ojha wrote:
> The QCOM_PDC_SIZE constant (0x30000) was introduced to work around old
> sm8150 DTs that described a too-small PDC register region, causing the
> driver to silently expand the ioremap to cover three DRV regions. Now
> that the preceding DT fixes have corrected all platforms to describe only
> the APSS DRV region (0x10000), the oversized clamp is no longer needed.
> 
> Replace QCOM_PDC_SIZE with PDC_DRV_SIZE (0x10000) in the clamp so the
> minimum mapped size matches a single DRV region. The clamp and warning
> are intentionally kept to preserve backward compatibility with any old
> DTs that may still describe a smaller region.
> 
> While at it, rename PDC_DRV_OFFSET to PDC_DRV_SIZE since the constant
> represents the size of a DRV region and is used as both the ioremap
> minimum size and the offset to the previous DRV region.
> 
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-06-11 10:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-27  9:54 [PATCH v2 0/4] irqchip/qcom-pdc: Misc. changes Mukesh Ojha
2026-05-27  9:54 ` [PATCH v2 1/4] irqchip/qcom-pdc: Split __pdc_enable_intr() into per-version helpers Mukesh Ojha
2026-06-03 16:29   ` [tip: irq/drivers] " tip-bot2 for Mukesh Ojha
2026-05-27  9:54 ` [PATCH v2 2/4] irqchip/qcom-pdc: Tighten ioremap clamp to single DRV region size Mukesh Ojha
2026-06-03 16:29   ` [tip: irq/drivers] " tip-bot2 for Mukesh Ojha
2026-06-11 10:40   ` [PATCH v2 2/4] " Konrad Dybcio
2026-05-27  9:54 ` [PATCH v2 3/4] irqchip/qcom-pdc: Add PDC_VERSION() macro to describe version register fields Mukesh Ojha
2026-06-03 16:29   ` [tip: irq/drivers] " tip-bot2 for Mukesh Ojha
2026-05-27  9:54 ` [PATCH v2 4/4] irqchip/qcom-pdc: Use FIELD_GET() to extract bank index and bit position Mukesh Ojha
2026-06-03 16:29   ` [tip: irq/drivers] " tip-bot2 for Mukesh Ojha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®