* [PATCH v4 0/2] irqchip/qcom-pdc: support v3.2 HW
@ 2023-09-05 13:19 Neil Armstrong
2023-09-05 13:19 ` [PATCH v4 1/2] irqchip/qcom-pdc: Add support for " Neil Armstrong
2023-09-05 13:19 ` [PATCH v4 2/2] arm64: dts: qcom: sm8150: extend the size of the PDC resource neil.armstrong
0 siblings, 2 replies; 9+ messages in thread
From: Neil Armstrong @ 2023-09-05 13:19 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Thomas Gleixner,
Marc Zyngier
Cc: Maulik Shah (mkshah), linux-arm-msm, linux-kernel, Neil Armstrong,
Dmitry Baryshkov
Starting from HW version 3.2 the IRQ_ENABLE bit has moved to the
IRQ_i_CFG register and requires a change of the driver to avoid
writing into an undefined register address.
Get the HW version from registers and set the IRQ_ENABLE bit to the
correct register depending on the HW version.
Since SM8150 DT uses a too smal PDC reg size, it's required to:
- fix SM8150 DT
- extend the PDC reg from the driver if used with old unfixed DT
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
Changes in v4:
- Continue Dmitry's serie at https://lore.kernel.org/all/20230829092119.1017194-1-dmitry.baryshkov@linaro.org/
- Dmitry's changes:
- Fix PDC resource size if it is too short instead of setting version to dummy 0 value (Marc).
- Squashed the fix into the original patch.
- Changes requested by Marc on Dmitry's serie:
- explicit PDC_VERSION is a reg offset
- remove the enum
- move the enable_intr to a shared function
- add a warning when reg size doesn't match max size
- Link to v3: https://lore.kernel.org/r/20230823-topic-sm8x50-upstream-pdc-ver-v3-1-aa7d9ab862e4@linaro.org
Changes in v3:
- Simplify qcom_pdc_gic_set_type()
- Used __assign_bit in pdc_setup_pin_mapping()
- remove BIT() from IRQ_i_CFG_IRQ_ENABLE to be used with __assign_bit()
- Add Reviewed-by tag
- Link to v2: https://lore.kernel.org/r/20230822-topic-sm8x50-upstream-pdc-ver-v2-1-3035b8d388f7@linaro.org
Changes in v2:
- Changed IRQ_ENABLE handling based on Maulik's comments
- Link to v1: https://lore.kernel.org/r/20230821-topic-sm8x50-upstream-pdc-ver-v1-1-6d7f4dd95719@linaro.org
---
Dmitry Baryshkov (1):
arm64: dts: qcom: sm8150: extend the size of the PDC resource
Neil Armstrong (1):
irqchip/qcom-pdc: Add support for v3.2 HW
arch/arm64/boot/dts/qcom/sm8150.dtsi | 2 +-
drivers/irqchip/qcom-pdc.c | 69 ++++++++++++++++++++++++++----------
2 files changed, 52 insertions(+), 19 deletions(-)
---
base-commit: 47d9bb711707d15b19fad18c8e2b4b027a264a3a
change-id: 20230821-topic-sm8x50-upstream-pdc-ver-114ceb45e1ee
Best regards,
--
Neil Armstrong <neil.armstrong@linaro.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4 1/2] irqchip/qcom-pdc: Add support for v3.2 HW
2023-09-05 13:19 [PATCH v4 0/2] irqchip/qcom-pdc: support v3.2 HW Neil Armstrong
@ 2023-09-05 13:19 ` Neil Armstrong
2023-09-06 16:55 ` Konrad Dybcio
` (2 more replies)
2023-09-05 13:19 ` [PATCH v4 2/2] arm64: dts: qcom: sm8150: extend the size of the PDC resource neil.armstrong
1 sibling, 3 replies; 9+ messages in thread
From: Neil Armstrong @ 2023-09-05 13:19 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Thomas Gleixner,
Marc Zyngier
Cc: Maulik Shah (mkshah), linux-arm-msm, linux-kernel, Neil Armstrong,
Dmitry Baryshkov
Starting from HW version 3.2 the IRQ_ENABLE bit has moved to the
IRQ_i_CFG register and requires a change of the driver to avoid
writing into an undefined register address.
Get the HW version from registers and set the IRQ_ENABLE bit to the
correct register depending on the HW version.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Maulik Shah <quic_mkshah@quicinc.com>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
drivers/irqchip/qcom-pdc.c | 69 ++++++++++++++++++++++++++++++++++------------
1 file changed, 51 insertions(+), 18 deletions(-)
diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index d96916cf6a41..827371726ad1 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -23,9 +23,20 @@
#define PDC_MAX_GPIO_IRQS 256
+/* Valid only on HW version < 3.2 */
#define IRQ_ENABLE_BANK 0x10
#define IRQ_i_CFG 0x110
+/* Valid only on HW version >= 3.2 */
+#define IRQ_i_CFG_IRQ_ENABLE 3
+
+#define IRQ_i_CFG_TYPE_MASK GENMASK(2, 0)
+
+#define PDC_VERSION_REG 0x1000
+
+/* Notable PDC versions */
+#define PDC_VERSION_3_2 0x30200
+
struct pdc_pin_region {
u32 pin_base;
u32 parent_base;
@@ -38,6 +49,7 @@ static DEFINE_RAW_SPINLOCK(pdc_lock);
static void __iomem *pdc_base;
static struct pdc_pin_region *pdc_region;
static int pdc_region_cnt;
+static unsigned int pdc_version;
static void pdc_reg_write(int reg, u32 i, u32 val)
{
@@ -49,20 +61,32 @@ static u32 pdc_reg_read(int reg, u32 i)
return readl_relaxed(pdc_base + reg + i * sizeof(u32));
}
-static void pdc_enable_intr(struct irq_data *d, bool on)
+static void __pdc_enable_intr(int pin_out, bool on)
{
- int pin_out = d->hwirq;
unsigned long enable;
- unsigned long flags;
- u32 index, mask;
- index = pin_out / 32;
- mask = pin_out % 32;
+ if (pdc_version < PDC_VERSION_3_2) {
+ u32 index, mask;
+
+ index = pin_out / 32;
+ mask = pin_out % 32;
+
+ enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
+ __assign_bit(mask, &enable, on);
+ 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(struct irq_data *d, bool on)
+{
+ unsigned long flags;
raw_spin_lock_irqsave(&pdc_lock, flags);
- enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
- __assign_bit(mask, &enable, on);
- pdc_reg_write(IRQ_ENABLE_BANK, index, enable);
+ __pdc_enable_intr(d->hwirq, on);
raw_spin_unlock_irqrestore(&pdc_lock, flags);
}
@@ -143,6 +167,7 @@ static int qcom_pdc_gic_set_type(struct irq_data *d, unsigned int type)
}
old_pdc_type = pdc_reg_read(IRQ_i_CFG, d->hwirq);
+ pdc_type |= (old_pdc_type & ~IRQ_i_CFG_TYPE_MASK);
pdc_reg_write(IRQ_i_CFG, d->hwirq, pdc_type);
ret = irq_chip_set_type_parent(d, type);
@@ -247,7 +272,6 @@ static const struct irq_domain_ops qcom_pdc_ops = {
static int pdc_setup_pin_mapping(struct device_node *np)
{
int ret, n, i;
- u32 irq_index, reg_index, val;
n = of_property_count_elems_of_size(np, "qcom,pdc-ranges", sizeof(u32));
if (n <= 0 || n % 3)
@@ -277,29 +301,38 @@ static int pdc_setup_pin_mapping(struct device_node *np)
if (ret)
return ret;
- for (i = 0; i < pdc_region[n].cnt; i++) {
- reg_index = (i + pdc_region[n].pin_base) >> 5;
- irq_index = (i + pdc_region[n].pin_base) & 0x1f;
- val = pdc_reg_read(IRQ_ENABLE_BANK, reg_index);
- val &= ~BIT(irq_index);
- pdc_reg_write(IRQ_ENABLE_BANK, reg_index, val);
- }
+ for (i = 0; i < pdc_region[n].cnt; i++)
+ __pdc_enable_intr(i + pdc_region[n].pin_base, 0);
}
return 0;
}
+#define QCOM_PDC_SIZE 0x30000
+
static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
{
struct irq_domain *parent_domain, *pdc_domain;
+ resource_size_t res_size;
+ struct resource res;
int ret;
- pdc_base = of_iomap(node, 0);
+ /* compat with old sm8150 DT which had very small region for PDC */
+ if (of_address_to_resource(node, 0, &res))
+ return -EINVAL;
+
+ res_size = max_t(resource_size_t, resource_size(&res), QCOM_PDC_SIZE);
+ if (res_size > resource_size(&res))
+ pr_warn("%pOF: invalid reg size, please fix DT\n", node);
+
+ pdc_base = ioremap(res.start, res_size);
if (!pdc_base) {
pr_err("%pOF: unable to map PDC registers\n", node);
return -ENXIO;
}
+ pdc_version = pdc_reg_read(PDC_VERSION_REG, 0);
+
parent_domain = irq_find_host(parent);
if (!parent_domain) {
pr_err("%pOF: unable to find PDC's parent domain\n", node);
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 2/2] arm64: dts: qcom: sm8150: extend the size of the PDC resource
2023-09-05 13:19 [PATCH v4 0/2] irqchip/qcom-pdc: support v3.2 HW Neil Armstrong
2023-09-05 13:19 ` [PATCH v4 1/2] irqchip/qcom-pdc: Add support for " Neil Armstrong
@ 2023-09-05 13:19 ` neil.armstrong
2023-09-12 12:49 ` [irqchip: irq/irqchip-fixes] " irqchip-bot for Dmitry Baryshkov
1 sibling, 1 reply; 9+ messages in thread
From: neil.armstrong @ 2023-09-05 13:19 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Thomas Gleixner,
Marc Zyngier
Cc: Maulik Shah (mkshah), linux-arm-msm, linux-kernel, Neil Armstrong,
Dmitry Baryshkov
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Follow the example of other platforms and extend the PDC resource region
to 0x30000, so that the PDC driver can read the PDC_VERSION register.
Fixes: 397ad94668c1 ("arm64: dts: qcom: sm8150: Add pdc interrupt controller node")
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
arch/arm64/boot/dts/qcom/sm8150.dtsi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/qcom/sm8150.dtsi b/arch/arm64/boot/dts/qcom/sm8150.dtsi
index a7c3020a5de4..06c53000bb74 100644
--- a/arch/arm64/boot/dts/qcom/sm8150.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8150.dtsi
@@ -3958,7 +3958,7 @@ dispcc: clock-controller@af00000 {
pdc: interrupt-controller@b220000 {
compatible = "qcom,sm8150-pdc", "qcom,pdc";
- reg = <0 0x0b220000 0 0x400>;
+ reg = <0 0x0b220000 0 0x30000>;
qcom,pdc-ranges = <0 480 94>, <94 609 31>,
<125 63 1>;
#interrupt-cells = <2>;
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v4 1/2] irqchip/qcom-pdc: Add support for v3.2 HW
2023-09-05 13:19 ` [PATCH v4 1/2] irqchip/qcom-pdc: Add support for " Neil Armstrong
@ 2023-09-06 16:55 ` Konrad Dybcio
2023-09-07 7:57 ` Neil Armstrong
2023-09-12 12:49 ` [irqchip: irq/irqchip-fixes] " irqchip-bot for Neil Armstrong
2023-10-02 12:59 ` [PATCH v4 1/2] " Thomas Gleixner
2 siblings, 1 reply; 9+ messages in thread
From: Konrad Dybcio @ 2023-09-06 16:55 UTC (permalink / raw)
To: Neil Armstrong, Andy Gross, Bjorn Andersson, Thomas Gleixner,
Marc Zyngier
Cc: Maulik Shah (mkshah), linux-arm-msm, linux-kernel,
Dmitry Baryshkov
On 5.09.2023 15:19, Neil Armstrong wrote:
> Starting from HW version 3.2 the IRQ_ENABLE bit has moved to the
> IRQ_i_CFG register and requires a change of the driver to avoid
> writing into an undefined register address.
>
> Get the HW version from registers and set the IRQ_ENABLE bit to the
> correct register depending on the HW version.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Reviewed-by: Maulik Shah <quic_mkshah@quicinc.com>
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
[...]
> + if (pdc_version < PDC_VERSION_3_2) {
> + u32 index, mask;
> +
> + index = pin_out / 32;
> + mask = pin_out % 32;
I get that you're moving around existing code, but would that
not be equal to FIELD_GET() with GENMASK(31, 5) and GENMASK(4, 0)?
Perhaps it'd be clearer to read. But don't worry about it in this
series.
Otherwise:
Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Konrad
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 1/2] irqchip/qcom-pdc: Add support for v3.2 HW
2023-09-06 16:55 ` Konrad Dybcio
@ 2023-09-07 7:57 ` Neil Armstrong
0 siblings, 0 replies; 9+ messages in thread
From: Neil Armstrong @ 2023-09-07 7:57 UTC (permalink / raw)
To: Konrad Dybcio, Andy Gross, Bjorn Andersson, Thomas Gleixner,
Marc Zyngier
Cc: Maulik Shah (mkshah), linux-arm-msm, linux-kernel,
Dmitry Baryshkov
Hi,
On 06/09/2023 18:55, Konrad Dybcio wrote:
> On 5.09.2023 15:19, Neil Armstrong wrote:
>> Starting from HW version 3.2 the IRQ_ENABLE bit has moved to the
>> IRQ_i_CFG register and requires a change of the driver to avoid
>> writing into an undefined register address.
>>
>> Get the HW version from registers and set the IRQ_ENABLE bit to the
>> correct register depending on the HW version.
>>
>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>> Reviewed-by: Maulik Shah <quic_mkshah@quicinc.com>
>> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
>> ---
> [...]
>
>> + if (pdc_version < PDC_VERSION_3_2) {
>> + u32 index, mask;
>> +
>> + index = pin_out / 32;
>> + mask = pin_out % 32;
> I get that you're moving around existing code, but would that
> not be equal to FIELD_GET() with GENMASK(31, 5) and GENMASK(4, 0)?
> Perhaps it'd be clearer to read. But don't worry about it in this
> series.
Yes it would, I took the best implementation of the two :-p
I will probably send a cleanup serie afterwards because there's some
cleanup to do all over the code.
Neil
>
> Otherwise:
>
> Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>
> Konrad
^ permalink raw reply [flat|nested] 9+ messages in thread
* [irqchip: irq/irqchip-fixes] arm64: dts: qcom: sm8150: extend the size of the PDC resource
2023-09-05 13:19 ` [PATCH v4 2/2] arm64: dts: qcom: sm8150: extend the size of the PDC resource neil.armstrong
@ 2023-09-12 12:49 ` irqchip-bot for Dmitry Baryshkov
0 siblings, 0 replies; 9+ messages in thread
From: irqchip-bot for Dmitry Baryshkov @ 2023-09-12 12:49 UTC (permalink / raw)
To: linux-kernel
Cc: Konrad Dybcio, Dmitry Baryshkov, Neil Armstrong, Marc Zyngier,
tglx
The following commit has been merged into the irq/irqchip-fixes branch of irqchip:
Commit-ID: cf5716acbfc6190b3f97f4614affdf5991aed7b2
Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/cf5716acbfc6190b3f97f4614affdf5991aed7b2
Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
AuthorDate: Tue, 05 Sep 2023 15:19:26 +02:00
Committer: Marc Zyngier <maz@kernel.org>
CommitterDate: Tue, 12 Sep 2023 13:38:08 +01:00
arm64: dts: qcom: sm8150: extend the size of the PDC resource
Follow the example of other platforms and extend the PDC resource region
to 0x30000, so that the PDC driver can read the PDC_VERSION register.
Fixes: 397ad94668c1 ("arm64: dts: qcom: sm8150: Add pdc interrupt controller node")
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230905-topic-sm8x50-upstream-pdc-ver-v4-2-fc633c7df84b@linaro.org
---
arch/arm64/boot/dts/qcom/sm8150.dtsi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/qcom/sm8150.dtsi b/arch/arm64/boot/dts/qcom/sm8150.dtsi
index a7c3020..06c5300 100644
--- a/arch/arm64/boot/dts/qcom/sm8150.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8150.dtsi
@@ -3958,7 +3958,7 @@
pdc: interrupt-controller@b220000 {
compatible = "qcom,sm8150-pdc", "qcom,pdc";
- reg = <0 0x0b220000 0 0x400>;
+ reg = <0 0x0b220000 0 0x30000>;
qcom,pdc-ranges = <0 480 94>, <94 609 31>,
<125 63 1>;
#interrupt-cells = <2>;
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [irqchip: irq/irqchip-fixes] irqchip/qcom-pdc: Add support for v3.2 HW
2023-09-05 13:19 ` [PATCH v4 1/2] irqchip/qcom-pdc: Add support for " Neil Armstrong
2023-09-06 16:55 ` Konrad Dybcio
@ 2023-09-12 12:49 ` irqchip-bot for Neil Armstrong
2023-10-02 12:59 ` [PATCH v4 1/2] " Thomas Gleixner
2 siblings, 0 replies; 9+ messages in thread
From: irqchip-bot for Neil Armstrong @ 2023-09-12 12:49 UTC (permalink / raw)
To: linux-kernel
Cc: Dmitry Baryshkov, Maulik Shah, Neil Armstrong, Konrad Dybcio,
Marc Zyngier, tglx
The following commit has been merged into the irq/irqchip-fixes branch of irqchip:
Commit-ID: 5873d380f4c0ff23ec7d0d1780107e46a4637c0e
Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/5873d380f4c0ff23ec7d0d1780107e46a4637c0e
Author: Neil Armstrong <neil.armstrong@linaro.org>
AuthorDate: Tue, 05 Sep 2023 15:19:25 +02:00
Committer: Marc Zyngier <maz@kernel.org>
CommitterDate: Tue, 12 Sep 2023 13:38:08 +01:00
irqchip/qcom-pdc: Add support for v3.2 HW
Starting from HW version 3.2 the IRQ_ENABLE bit has moved to the
IRQ_i_CFG register and requires a change of the driver to avoid
writing into an undefined register address.
Get the HW version from registers and set the IRQ_ENABLE bit to the
correct register depending on the HW version.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Maulik Shah <quic_mkshah@quicinc.com>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230905-topic-sm8x50-upstream-pdc-ver-v4-1-fc633c7df84b@linaro.org
---
drivers/irqchip/qcom-pdc.c | 69 +++++++++++++++++++++++++++----------
1 file changed, 51 insertions(+), 18 deletions(-)
diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index a32c0d2..74b2f12 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -22,9 +22,20 @@
#define PDC_MAX_GPIO_IRQS 256
+/* Valid only on HW version < 3.2 */
#define IRQ_ENABLE_BANK 0x10
#define IRQ_i_CFG 0x110
+/* Valid only on HW version >= 3.2 */
+#define IRQ_i_CFG_IRQ_ENABLE 3
+
+#define IRQ_i_CFG_TYPE_MASK GENMASK(2, 0)
+
+#define PDC_VERSION_REG 0x1000
+
+/* Notable PDC versions */
+#define PDC_VERSION_3_2 0x30200
+
struct pdc_pin_region {
u32 pin_base;
u32 parent_base;
@@ -37,6 +48,7 @@ static DEFINE_RAW_SPINLOCK(pdc_lock);
static void __iomem *pdc_base;
static struct pdc_pin_region *pdc_region;
static int pdc_region_cnt;
+static unsigned int pdc_version;
static void pdc_reg_write(int reg, u32 i, u32 val)
{
@@ -48,20 +60,32 @@ static u32 pdc_reg_read(int reg, u32 i)
return readl_relaxed(pdc_base + reg + i * sizeof(u32));
}
-static void pdc_enable_intr(struct irq_data *d, bool on)
+static void __pdc_enable_intr(int pin_out, bool on)
{
- int pin_out = d->hwirq;
unsigned long enable;
- unsigned long flags;
- u32 index, mask;
- index = pin_out / 32;
- mask = pin_out % 32;
+ if (pdc_version < PDC_VERSION_3_2) {
+ u32 index, mask;
+
+ index = pin_out / 32;
+ mask = pin_out % 32;
+
+ enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
+ __assign_bit(mask, &enable, on);
+ 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(struct irq_data *d, bool on)
+{
+ unsigned long flags;
raw_spin_lock_irqsave(&pdc_lock, flags);
- enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
- __assign_bit(mask, &enable, on);
- pdc_reg_write(IRQ_ENABLE_BANK, index, enable);
+ __pdc_enable_intr(d->hwirq, on);
raw_spin_unlock_irqrestore(&pdc_lock, flags);
}
@@ -142,6 +166,7 @@ static int qcom_pdc_gic_set_type(struct irq_data *d, unsigned int type)
}
old_pdc_type = pdc_reg_read(IRQ_i_CFG, d->hwirq);
+ pdc_type |= (old_pdc_type & ~IRQ_i_CFG_TYPE_MASK);
pdc_reg_write(IRQ_i_CFG, d->hwirq, pdc_type);
ret = irq_chip_set_type_parent(d, type);
@@ -246,7 +271,6 @@ static const struct irq_domain_ops qcom_pdc_ops = {
static int pdc_setup_pin_mapping(struct device_node *np)
{
int ret, n, i;
- u32 irq_index, reg_index, val;
n = of_property_count_elems_of_size(np, "qcom,pdc-ranges", sizeof(u32));
if (n <= 0 || n % 3)
@@ -276,29 +300,38 @@ static int pdc_setup_pin_mapping(struct device_node *np)
if (ret)
return ret;
- for (i = 0; i < pdc_region[n].cnt; i++) {
- reg_index = (i + pdc_region[n].pin_base) >> 5;
- irq_index = (i + pdc_region[n].pin_base) & 0x1f;
- val = pdc_reg_read(IRQ_ENABLE_BANK, reg_index);
- val &= ~BIT(irq_index);
- pdc_reg_write(IRQ_ENABLE_BANK, reg_index, val);
- }
+ for (i = 0; i < pdc_region[n].cnt; i++)
+ __pdc_enable_intr(i + pdc_region[n].pin_base, 0);
}
return 0;
}
+#define QCOM_PDC_SIZE 0x30000
+
static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
{
struct irq_domain *parent_domain, *pdc_domain;
+ resource_size_t res_size;
+ struct resource res;
int ret;
- pdc_base = of_iomap(node, 0);
+ /* compat with old sm8150 DT which had very small region for PDC */
+ if (of_address_to_resource(node, 0, &res))
+ return -EINVAL;
+
+ res_size = max_t(resource_size_t, resource_size(&res), QCOM_PDC_SIZE);
+ if (res_size > resource_size(&res))
+ pr_warn("%pOF: invalid reg size, please fix DT\n", node);
+
+ pdc_base = ioremap(res.start, res_size);
if (!pdc_base) {
pr_err("%pOF: unable to map PDC registers\n", node);
return -ENXIO;
}
+ pdc_version = pdc_reg_read(PDC_VERSION_REG, 0);
+
parent_domain = irq_find_host(parent);
if (!parent_domain) {
pr_err("%pOF: unable to find PDC's parent domain\n", node);
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v4 1/2] irqchip/qcom-pdc: Add support for v3.2 HW
2023-09-05 13:19 ` [PATCH v4 1/2] irqchip/qcom-pdc: Add support for " Neil Armstrong
2023-09-06 16:55 ` Konrad Dybcio
2023-09-12 12:49 ` [irqchip: irq/irqchip-fixes] " irqchip-bot for Neil Armstrong
@ 2023-10-02 12:59 ` Thomas Gleixner
2023-10-02 13:16 ` Neil Armstrong
2 siblings, 1 reply; 9+ messages in thread
From: Thomas Gleixner @ 2023-10-02 12:59 UTC (permalink / raw)
To: Neil Armstrong, Andy Gross, Bjorn Andersson, Konrad Dybcio,
Marc Zyngier
Cc: Maulik Shah (mkshah), linux-arm-msm, linux-kernel, Neil Armstrong,
Dmitry Baryshkov
On Tue, Sep 05 2023 at 15:19, Neil Armstrong wrote:
> Starting from HW version 3.2 the IRQ_ENABLE bit has moved to the
> IRQ_i_CFG register and requires a change of the driver to avoid
> writing into an undefined register address.
>
> Get the HW version from registers and set the IRQ_ENABLE bit to the
> correct register depending on the HW version.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Reviewed-by: Maulik Shah <quic_mkshah@quicinc.com>
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
This S-O-B chain is broken. Who is the real author of that?
https://www.kernel.org/doc/html/latest/process/submitting-patches.html#when-to-use-acked-by-cc-and-co-developed-by
Thanks,
tglx
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 1/2] irqchip/qcom-pdc: Add support for v3.2 HW
2023-10-02 12:59 ` [PATCH v4 1/2] " Thomas Gleixner
@ 2023-10-02 13:16 ` Neil Armstrong
0 siblings, 0 replies; 9+ messages in thread
From: Neil Armstrong @ 2023-10-02 13:16 UTC (permalink / raw)
To: Thomas Gleixner, Andy Gross, Bjorn Andersson, Konrad Dybcio,
Marc Zyngier
Cc: Maulik Shah (mkshah), linux-arm-msm, linux-kernel,
Dmitry Baryshkov
Hi Thomas,
On 02/10/2023 14:59, Thomas Gleixner wrote:
> On Tue, Sep 05 2023 at 15:19, Neil Armstrong wrote:
>> Starting from HW version 3.2 the IRQ_ENABLE bit has moved to the
>> IRQ_i_CFG register and requires a change of the driver to avoid
>> writing into an undefined register address.
>>
>> Get the HW version from registers and set the IRQ_ENABLE bit to the
>> correct register depending on the HW version.
>>
>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>> Reviewed-by: Maulik Shah <quic_mkshah@quicinc.com>
>> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
>
> This S-O-B chain is broken. Who is the real author of that?
I'm the initial author, I sent a fixed version with cleaned-up S-o-b chain:
https://lore.kernel.org/all/20230929-topic-sm8x50-upstream-pdc-ver-v5-0-800111572104@linaro.org /
Neil
>
> https://www.kernel.org/doc/html/latest/process/submitting-patches.html#when-to-use-acked-by-cc-and-co-developed-by
>
> Thanks,
>
> tglx
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-10-02 13:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-05 13:19 [PATCH v4 0/2] irqchip/qcom-pdc: support v3.2 HW Neil Armstrong
2023-09-05 13:19 ` [PATCH v4 1/2] irqchip/qcom-pdc: Add support for " Neil Armstrong
2023-09-06 16:55 ` Konrad Dybcio
2023-09-07 7:57 ` Neil Armstrong
2023-09-12 12:49 ` [irqchip: irq/irqchip-fixes] " irqchip-bot for Neil Armstrong
2023-10-02 12:59 ` [PATCH v4 1/2] " Thomas Gleixner
2023-10-02 13:16 ` Neil Armstrong
2023-09-05 13:19 ` [PATCH v4 2/2] arm64: dts: qcom: sm8150: extend the size of the PDC resource neil.armstrong
2023-09-12 12:49 ` [irqchip: irq/irqchip-fixes] " irqchip-bot for Dmitry Baryshkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox