Skip to content

Commit 1899ccc

Browse files
Icenowylinusw
authored andcommitted
pinctrl: sunxi: fix wrong irq_banks number for H5 pinctrl
The pin controller of Allwinner H5 has three IRQ banks, however in old versions of drivers and device trees, only two are set, which makes PG bank IRQ not available. If it's directly set to 3, the old device trees will fail to boot. Add a workaround (and a warning) for older device trees, and allow new device trees to use correct 3 IRQ banks. Fixes: 838adb5 ("drivers: pinctrl: add driver for Allwinner H5 SoC") Signed-off-by: Icenowy Zheng <icenowy@aosc.io> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 5ff56b0 commit 1899ccc

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

drivers/pinctrl/sunxi/pinctrl-sun50i-h5.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/platform_device.h>
2020
#include <linux/of.h>
2121
#include <linux/of_device.h>
22+
#include <linux/of_irq.h>
2223
#include <linux/pinctrl/pinctrl.h>
2324

2425
#include "pinctrl-sunxi.h"
@@ -530,17 +531,36 @@ static const struct sunxi_desc_pin sun50i_h5_pins[] = {
530531
SUNXI_FUNCTION_IRQ_BANK(0x6, 2, 13)), /* PG_EINT13 */
531532
};
532533

533-
static const struct sunxi_pinctrl_desc sun50i_h5_pinctrl_data = {
534+
static const struct sunxi_pinctrl_desc sun50i_h5_pinctrl_data_broken = {
534535
.pins = sun50i_h5_pins,
535536
.npins = ARRAY_SIZE(sun50i_h5_pins),
536537
.irq_banks = 2,
537538
.irq_read_needs_mux = true
538539
};
539540

541+
static const struct sunxi_pinctrl_desc sun50i_h5_pinctrl_data = {
542+
.pins = sun50i_h5_pins,
543+
.npins = ARRAY_SIZE(sun50i_h5_pins),
544+
.irq_banks = 3,
545+
.irq_read_needs_mux = true
546+
};
547+
540548
static int sun50i_h5_pinctrl_probe(struct platform_device *pdev)
541549
{
542-
return sunxi_pinctrl_init(pdev,
543-
&sun50i_h5_pinctrl_data);
550+
switch (of_irq_count(pdev->dev.of_node)) {
551+
case 2:
552+
dev_warn(&pdev->dev,
553+
"Your device tree's pinctrl node is broken, which has no IRQ of PG bank routed.\n");
554+
dev_warn(&pdev->dev,
555+
"Please update the device tree, otherwise PG bank IRQ won't work.\n");
556+
return sunxi_pinctrl_init(pdev,
557+
&sun50i_h5_pinctrl_data_broken);
558+
case 3:
559+
return sunxi_pinctrl_init(pdev,
560+
&sun50i_h5_pinctrl_data);
561+
default:
562+
return -EINVAL;
563+
}
544564
}
545565

546566
static const struct of_device_id sun50i_h5_pinctrl_match[] = {

0 commit comments

Comments
 (0)