Skip to content

Commit 9cd847e

Browse files
committed
Merge tag 'irqchip-fixes-6.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms into irq/urgent
Pull irqchip fixes from Marc Zygnier: - Fix QC PDC v3.2 support by working around broken firmware tables - Fix rzg2l-irqc missing #interrupt-cells description in the DT binding - Fix rzg2l-irqc interrupt masking Link: https://lore.kernel.org/lkml/[email protected]
2 parents 0bb80ec + 9b8df57 commit 9cd847e

File tree

4 files changed

+56
-22
lines changed

4 files changed

+56
-22
lines changed

Documentation/devicetree/bindings/interrupt-controller/renesas,rzg2l-irqc.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ properties:
3131
- const: renesas,rzg2l-irqc
3232

3333
'#interrupt-cells':
34-
description: The first cell should contain external interrupt number (IRQ0-7) and the
35-
second cell is used to specify the flag.
34+
description: The first cell should contain a macro RZG2L_{NMI,IRQX} included in the
35+
include/dt-bindings/interrupt-controller/irqc-rzg2l.h and the second
36+
cell is used to specify the flag.
3637
const: 2
3738

3839
'#address-cells':

arch/arm64/boot/dts/qcom/sm8150.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3958,7 +3958,7 @@
39583958

39593959
pdc: interrupt-controller@b220000 {
39603960
compatible = "qcom,sm8150-pdc", "qcom,pdc";
3961-
reg = <0 0x0b220000 0 0x400>;
3961+
reg = <0 0x0b220000 0 0x30000>;
39623962
qcom,pdc-ranges = <0 480 94>, <94 609 31>,
39633963
<125 63 1>;
39643964
#interrupt-cells = <2>;

drivers/irqchip/irq-renesas-rzg2l.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static void rzg2l_irqc_irq_disable(struct irq_data *d)
118118

119119
raw_spin_lock(&priv->lock);
120120
reg = readl_relaxed(priv->base + TSSR(tssr_index));
121-
reg &= ~(TSSEL_MASK << tssr_offset);
121+
reg &= ~(TSSEL_MASK << TSSEL_SHIFT(tssr_offset));
122122
writel_relaxed(reg, priv->base + TSSR(tssr_index));
123123
raw_spin_unlock(&priv->lock);
124124
}

drivers/irqchip/qcom-pdc.c

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,20 @@
2222

2323
#define PDC_MAX_GPIO_IRQS 256
2424

25+
/* Valid only on HW version < 3.2 */
2526
#define IRQ_ENABLE_BANK 0x10
2627
#define IRQ_i_CFG 0x110
2728

29+
/* Valid only on HW version >= 3.2 */
30+
#define IRQ_i_CFG_IRQ_ENABLE 3
31+
32+
#define IRQ_i_CFG_TYPE_MASK GENMASK(2, 0)
33+
34+
#define PDC_VERSION_REG 0x1000
35+
36+
/* Notable PDC versions */
37+
#define PDC_VERSION_3_2 0x30200
38+
2839
struct pdc_pin_region {
2940
u32 pin_base;
3041
u32 parent_base;
@@ -37,6 +48,7 @@ static DEFINE_RAW_SPINLOCK(pdc_lock);
3748
static void __iomem *pdc_base;
3849
static struct pdc_pin_region *pdc_region;
3950
static int pdc_region_cnt;
51+
static unsigned int pdc_version;
4052

4153
static void pdc_reg_write(int reg, u32 i, u32 val)
4254
{
@@ -48,20 +60,32 @@ static u32 pdc_reg_read(int reg, u32 i)
4860
return readl_relaxed(pdc_base + reg + i * sizeof(u32));
4961
}
5062

51-
static void pdc_enable_intr(struct irq_data *d, bool on)
63+
static void __pdc_enable_intr(int pin_out, bool on)
5264
{
53-
int pin_out = d->hwirq;
5465
unsigned long enable;
55-
unsigned long flags;
56-
u32 index, mask;
5766

58-
index = pin_out / 32;
59-
mask = pin_out % 32;
67+
if (pdc_version < PDC_VERSION_3_2) {
68+
u32 index, mask;
69+
70+
index = pin_out / 32;
71+
mask = pin_out % 32;
72+
73+
enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
74+
__assign_bit(mask, &enable, on);
75+
pdc_reg_write(IRQ_ENABLE_BANK, index, enable);
76+
} else {
77+
enable = pdc_reg_read(IRQ_i_CFG, pin_out);
78+
__assign_bit(IRQ_i_CFG_IRQ_ENABLE, &enable, on);
79+
pdc_reg_write(IRQ_i_CFG, pin_out, enable);
80+
}
81+
}
82+
83+
static void pdc_enable_intr(struct irq_data *d, bool on)
84+
{
85+
unsigned long flags;
6086

6187
raw_spin_lock_irqsave(&pdc_lock, flags);
62-
enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
63-
__assign_bit(mask, &enable, on);
64-
pdc_reg_write(IRQ_ENABLE_BANK, index, enable);
88+
__pdc_enable_intr(d->hwirq, on);
6589
raw_spin_unlock_irqrestore(&pdc_lock, flags);
6690
}
6791

@@ -142,6 +166,7 @@ static int qcom_pdc_gic_set_type(struct irq_data *d, unsigned int type)
142166
}
143167

144168
old_pdc_type = pdc_reg_read(IRQ_i_CFG, d->hwirq);
169+
pdc_type |= (old_pdc_type & ~IRQ_i_CFG_TYPE_MASK);
145170
pdc_reg_write(IRQ_i_CFG, d->hwirq, pdc_type);
146171

147172
ret = irq_chip_set_type_parent(d, type);
@@ -246,7 +271,6 @@ static const struct irq_domain_ops qcom_pdc_ops = {
246271
static int pdc_setup_pin_mapping(struct device_node *np)
247272
{
248273
int ret, n, i;
249-
u32 irq_index, reg_index, val;
250274

251275
n = of_property_count_elems_of_size(np, "qcom,pdc-ranges", sizeof(u32));
252276
if (n <= 0 || n % 3)
@@ -276,29 +300,38 @@ static int pdc_setup_pin_mapping(struct device_node *np)
276300
if (ret)
277301
return ret;
278302

279-
for (i = 0; i < pdc_region[n].cnt; i++) {
280-
reg_index = (i + pdc_region[n].pin_base) >> 5;
281-
irq_index = (i + pdc_region[n].pin_base) & 0x1f;
282-
val = pdc_reg_read(IRQ_ENABLE_BANK, reg_index);
283-
val &= ~BIT(irq_index);
284-
pdc_reg_write(IRQ_ENABLE_BANK, reg_index, val);
285-
}
303+
for (i = 0; i < pdc_region[n].cnt; i++)
304+
__pdc_enable_intr(i + pdc_region[n].pin_base, 0);
286305
}
287306

288307
return 0;
289308
}
290309

310+
#define QCOM_PDC_SIZE 0x30000
311+
291312
static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
292313
{
293314
struct irq_domain *parent_domain, *pdc_domain;
315+
resource_size_t res_size;
316+
struct resource res;
294317
int ret;
295318

296-
pdc_base = of_iomap(node, 0);
319+
/* compat with old sm8150 DT which had very small region for PDC */
320+
if (of_address_to_resource(node, 0, &res))
321+
return -EINVAL;
322+
323+
res_size = max_t(resource_size_t, resource_size(&res), QCOM_PDC_SIZE);
324+
if (res_size > resource_size(&res))
325+
pr_warn("%pOF: invalid reg size, please fix DT\n", node);
326+
327+
pdc_base = ioremap(res.start, res_size);
297328
if (!pdc_base) {
298329
pr_err("%pOF: unable to map PDC registers\n", node);
299330
return -ENXIO;
300331
}
301332

333+
pdc_version = pdc_reg_read(PDC_VERSION_REG, 0);
334+
302335
parent_domain = irq_find_host(parent);
303336
if (!parent_domain) {
304337
pr_err("%pOF: unable to find PDC's parent domain\n", node);

0 commit comments

Comments
 (0)