Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1709679

[PATCH 1/2] pinctrl: sunxi: fix wrong irq_banks number for H5 pinctrl

From Icenowy Zheng <icenowy@aosc.io>
Newsgroups linux.kernel
Subject [PATCH 1/2] pinctrl: sunxi: fix wrong irq_banks number for H5 pinctrl
Date 2017-08-11 16:30 +0200
Message-ID <udj6P-4Eb-33@gated-at.bofh.it> (permalink)
References <udj6O-4Eb-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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: 838adb576d4a ("drivers: pinctrl: add driver for Allwinner H5 SoC")
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
 drivers/pinctrl/sunxi/pinctrl-sun50i-h5.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/sunxi/pinctrl-sun50i-h5.c b/drivers/pinctrl/sunxi/pinctrl-sun50i-h5.c
index ccf9419e9418..97b48336f84a 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun50i-h5.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun50i-h5.c
@@ -19,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/of_irq.h>
 #include <linux/pinctrl/pinctrl.h>
 
 #include "pinctrl-sunxi.h"
@@ -530,17 +531,36 @@ static const struct sunxi_desc_pin sun50i_h5_pins[] = {
 		  SUNXI_FUNCTION_IRQ_BANK(0x6, 2, 13)),	/* PG_EINT13 */
 };
 
-static const struct sunxi_pinctrl_desc sun50i_h5_pinctrl_data = {
+static const struct sunxi_pinctrl_desc sun50i_h5_pinctrl_data_broken = {
 	.pins = sun50i_h5_pins,
 	.npins = ARRAY_SIZE(sun50i_h5_pins),
 	.irq_banks = 2,
 	.irq_read_needs_mux = true
 };
 
+static const struct sunxi_pinctrl_desc sun50i_h5_pinctrl_data = {
+	.pins = sun50i_h5_pins,
+	.npins = ARRAY_SIZE(sun50i_h5_pins),
+	.irq_banks = 3,
+	.irq_read_needs_mux = true
+};
+
 static int sun50i_h5_pinctrl_probe(struct platform_device *pdev)
 {
-	return sunxi_pinctrl_init(pdev,
-				  &sun50i_h5_pinctrl_data);
+	switch (of_irq_count(pdev->dev.of_node)) {
+	case 2:
+		dev_warn(&pdev->dev,
+			 "Your device tree's pinctrl node is broken, which has no IRQ of PG bank routed.\n");
+		dev_warn(&pdev->dev,
+			 "Please update the device tree, otherwise PG bank IRQ won't work.\n");
+		return sunxi_pinctrl_init(pdev,
+					  &sun50i_h5_pinctrl_data_broken);
+	case 3:
+		return sunxi_pinctrl_init(pdev,
+					  &sun50i_h5_pinctrl_data);
+	default:
+		return -EINVAL;
+	}
 }
 
 static const struct of_device_id sun50i_h5_pinctrl_match[] = {
-- 
2.13.0

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] Allwinner H5 IRQ fixes Icenowy Zheng <icenowy@aosc.io> - 2017-08-11 16:30 +0200
  [PATCH 1/2] pinctrl: sunxi: fix wrong irq_banks number for H5 pinctrl Icenowy Zheng <icenowy@aosc.io> - 2017-08-11 16:30 +0200
    Re: [linux-sunxi] [PATCH 1/2] pinctrl: sunxi: fix wrong irq_banks  number for H5 pinctrl Chen-Yu Tsai <wens@csie.org> - 2017-08-14 08:10 +0200
    Re: [PATCH 1/2] pinctrl: sunxi: fix wrong irq_banks number for H5 pinctrl Linus Walleij <linus.walleij@linaro.org> - 2017-08-22 14:50 +0200
  [PATCH 2/2] arm64: allwinner: h5: fix pinctrl IRQs Icenowy Zheng <icenowy@aosc.io> - 2017-08-11 16:30 +0200
    Re: [linux-sunxi] [PATCH 2/2] arm64: allwinner: h5: fix pinctrl IRQs Chen-Yu Tsai <wens@csie.org> - 2017-08-14 08:30 +0200

csiph-web