Skip to contentSkip to conversation

dt-bindings: gpio: sunxi:create a DT header for Allwinner pin controller

PATCH In review Frank Lee 4 participants 7 messages Jul 15, 2020 – Nov 10, 2020

Subsystems (3)
lore
Share & tools
lore

Frank Lee

author
#0 lore raw

PATCH 1/3 dt-bindings: gpio: sunxi:create a DT header for Allwinner pin controller

From: Yangtao Li <[email protected]>

The sunxi gpio binding defines a few custom cells for its gpio specifier. Provide bank name for those.

---
 include/dt-bindings/gpio/sunxi-gpio.h | 29 +++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 include/dt-bindings/gpio/sunxi-gpio.h
include/dt-bindings/gpio/sunxi-gpio.h new file +29 -0
new file mode 100644
index 000000000000..c692b4360da6
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * GPIO definitions for Allwinner SoCs
+ *
+ * Copyright (C) 2020 Yangtao Li <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_SUNXI_GPIO_H
+#define _DT_BINDINGS_SUNXI_GPIO_H
+
+#include <dt-bindings/gpio/gpio.h>
+
+/* pio */
+#define PA	0
+#define PB	1
+#define PC	2
+#define PD	3
+#define PE	4
+#define PF	5
+#define PG	6
+#define PH	7
+#define PI	8
+
+/* r-pio */
+#define PL	0
+#define PM	1
+#define PN	2
+
+#endif /* _DT_BINDINGS_SUNXI_GPIO_H */
Signature · 1 line
2.24.0
#1 lore raw

Hi!

Quoted 6 lines · Frank Lee

From: Yangtao Li <[email protected]>

The sunxi gpio binding defines a few custom cells for its gpio specifier. Provide bank name for those.

Thanks for working on this, I wanted to do it at some point but it kept getting pushed further into my todo list.

include/dt-bindings/gpio/sunxi-gpio.h

Quoted 10 lines
---
 include/dt-bindings/gpio/sunxi-gpio.h | 29 +++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 include/dt-bindings/gpio/sunxi-gpio.h
include/dt-bindings/gpio/sunxi-gpio.h new file +0 -0
new file mode 100644
index 000000000000..c692b4360da6

So generally we've been using the compatible name as the file name. You should follow that convention too, and since it was added with the A10, using the A10 compatible.

Quoted 20 lines
include/dt-bindings/gpio/sunxi-gpio.h new file +19 -0
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * GPIO definitions for Allwinner SoCs
+ *
+ * Copyright (C) 2020 Yangtao Li <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_SUNXI_GPIO_H
+#define _DT_BINDINGS_SUNXI_GPIO_H
+
+#include <dt-bindings/gpio/gpio.h>
+
+/* pio */
+#define PA	0
+#define PB	1
+#define PC	2
+#define PD	3
+#define PE	4
+#define PF	5

include/dt-bindings/gpio/sunxi-gpio.h line 29

Quoted 10 lines
include/dt-bindings/gpio/sunxi-gpio.h new file +10 -0
+#define PG	6
+#define PH	7
+#define PI	8
+
+/* r-pio */
+#define PL	0
+#define PM	1
+#define PN	2
+
+#endif /* _DT_BINDINGS_SUNXI_GPIO_H */

Maybe we can go one step further and use a macro to have something like PIN(A, 12) ?

Maxime

maintainer
#2 lore raw

Maxime,

Quoted 53 lines · Maxime Ripard

Hi!

Quoted 6 lines · Frank Lee

From: Yangtao Li <[email protected]>

The sunxi gpio binding defines a few custom cells for its gpio specifier. Provide bank name for those.

Thanks for working on this, I wanted to do it at some point but it kept getting pushed further into my todo list.

include/dt-bindings/gpio/sunxi-gpio.h

Quoted 10 lines
---
 include/dt-bindings/gpio/sunxi-gpio.h | 29 +++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 include/dt-bindings/gpio/sunxi-gpio.h
include/dt-bindings/gpio/sunxi-gpio.h new file +0 -0
new file mode 100644
index 000000000000..c692b4360da6

So generally we've been using the compatible name as the file name. You should follow that convention too, and since it was added with the A10, using the A10 compatible.

Quoted 25 lines
include/dt-bindings/gpio/sunxi-gpio.h new file +24 -0
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * GPIO definitions for Allwinner SoCs
+ *
+ * Copyright (C) 2020 Yangtao Li <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_SUNXI_GPIO_H
+#define _DT_BINDINGS_SUNXI_GPIO_H
+
+#include <dt-bindings/gpio/gpio.h>
+
+/* pio */
+#define PA	0
+#define PB	1
+#define PC	2
+#define PD	3
+#define PE	4
+#define PF	5
+#define PG	6
+#define PH	7
+#define PI	8
+
+/* r-pio */
Quoted 8 lines

include/dt-bindings/gpio/sunxi-gpio.h line 29

Quoted 5 lines
include/dt-bindings/gpio/sunxi-gpio.h new file +5 -0
+#define PL	0
+#define PM	1
+#define PN	2
+
+#endif /* _DT_BINDINGS_SUNXI_GPIO_H */

Maybe we can go one step further and use a macro to have something like PIN(A, 12) ?

Since we have separate cells for the bank and pin, I don't think it would be appropriate to have a single macro generating both. And I'm not sure what the benefit of the macro would be, if all it does is forward its arguments. Are you concerned that P[A-M] could conflict with something else in the device tree?

Cheers,
Samuel

#3 lore raw

Hi,

Quoted 63 lines · Samuel Holland
Quoted 53 lines · Maxime Ripard

Hi!

Quoted 6 lines · Frank Lee

From: Yangtao Li <[email protected]>

The sunxi gpio binding defines a few custom cells for its gpio specifier. Provide bank name for those.

Thanks for working on this, I wanted to do it at some point but it kept getting pushed further into my todo list.

include/dt-bindings/gpio/sunxi-gpio.h

Quoted 10 lines
---
 include/dt-bindings/gpio/sunxi-gpio.h | 29 +++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 include/dt-bindings/gpio/sunxi-gpio.h
include/dt-bindings/gpio/sunxi-gpio.h new file +0 -0
new file mode 100644
index 000000000000..c692b4360da6

So generally we've been using the compatible name as the file name. You should follow that convention too, and since it was added with the A10, using the A10 compatible.

Quoted 25 lines
include/dt-bindings/gpio/sunxi-gpio.h new file +24 -0
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * GPIO definitions for Allwinner SoCs
+ *
+ * Copyright (C) 2020 Yangtao Li <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_SUNXI_GPIO_H
+#define _DT_BINDINGS_SUNXI_GPIO_H
+
+#include <dt-bindings/gpio/gpio.h>
+
+/* pio */
+#define PA	0
+#define PB	1
+#define PC	2
+#define PD	3
+#define PE	4
+#define PF	5
+#define PG	6
+#define PH	7
+#define PI	8
+
+/* r-pio */
Quoted 8 lines

include/dt-bindings/gpio/sunxi-gpio.h line 29

Quoted 5 lines
include/dt-bindings/gpio/sunxi-gpio.h new file +5 -0
+#define PL	0
+#define PM	1
+#define PN	2
+
+#endif /* _DT_BINDINGS_SUNXI_GPIO_H */

Maybe we can go one step further and use a macro to have something like PIN(A, 12) ?

Quoted 2 lines

Since we have separate cells for the bank and pin, I don't think it would be appropriate to have a single macro generating both.

Yeah, but it's "just" an encoding issue though, it's not a major concern if it makes our life easier.

Quoted 3 lines

And I'm not sure what the benefit of the macro would be, if all it does is forward its arguments. Are you concerned that P[A-M] could conflict with something else in the device tree?

There's indeed a bunch of names that are fairly generic and could be conflicting with others (PD for power domain is the first one that comes to my mind). Using a prefix would make the GPIO descriptors pretty long, so it wasn't ideal either. A macro makes it readable without increasing too much the risks of conflicts

Maxime

#4 lore raw
Quoted 77 lines · Maxime Ripard

Hi,

Quoted 63 lines · Samuel Holland
Quoted 53 lines · Maxime Ripard

Hi!

Quoted 6 lines · Frank Lee

From: Yangtao Li <[email protected]>

The sunxi gpio binding defines a few custom cells for its gpio specifier. Provide bank name for those.

Thanks for working on this, I wanted to do it at some point but it kept getting pushed further into my todo list.

include/dt-bindings/gpio/sunxi-gpio.h

Quoted 10 lines
---
 include/dt-bindings/gpio/sunxi-gpio.h | 29 +++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 include/dt-bindings/gpio/sunxi-gpio.h
include/dt-bindings/gpio/sunxi-gpio.h new file +0 -0
new file mode 100644
index 000000000000..c692b4360da6

So generally we've been using the compatible name as the file name. You should follow that convention too, and since it was added with the A10, using the A10 compatible.

Quoted 25 lines
include/dt-bindings/gpio/sunxi-gpio.h new file +24 -0
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * GPIO definitions for Allwinner SoCs
+ *
+ * Copyright (C) 2020 Yangtao Li <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_SUNXI_GPIO_H
+#define _DT_BINDINGS_SUNXI_GPIO_H
+
+#include <dt-bindings/gpio/gpio.h>
+
+/* pio */
+#define PA        0
+#define PB        1
+#define PC        2
+#define PD        3
+#define PE        4
+#define PF        5
+#define PG        6
+#define PH        7
+#define PI        8
+
+/* r-pio */
Quoted 8 lines

include/dt-bindings/gpio/sunxi-gpio.h line 29

Quoted 5 lines
include/dt-bindings/gpio/sunxi-gpio.h new file +5 -0
+#define PL        0
+#define PM        1
+#define PN        2
+
+#endif /* _DT_BINDINGS_SUNXI_GPIO_H */

Maybe we can go one step further and use a macro to have something like PIN(A, 12) ?

Quoted 2 lines

Since we have separate cells for the bank and pin, I don't think it would be appropriate to have a single macro generating both.

Yeah, but it's "just" an encoding issue though, it's not a major concern if it makes our life easier.

Quoted 3 lines

And I'm not sure what the benefit of the macro would be, if all it does is forward its arguments. Are you concerned that P[A-M] could conflict with something else in the device tree?

Quoted 5 lines

There's indeed a bunch of names that are fairly generic and could be conflicting with others (PD for power domain is the first one that comes to my mind). Using a prefix would make the GPIO descriptors pretty long, so it wasn't ideal either. A macro makes it readable without increasing too much the risks of conflicts

I tried to use macros, but failed.

I have a look at some other GPIO macros, which have a prefix in front of them. Maybe we can do the same? It's all numbers. It's not intuitive.

Yangtao

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw

HI Maxime,

Maybe let's convert to use something like SUN4I_PA?

Yangtao

#6 lore raw
In reply to Frank Lee
Quoted 84 lines · Frank Lee
Quoted 77 lines · Maxime Ripard

Hi,

Quoted 63 lines · Samuel Holland
Quoted 53 lines · Maxime Ripard

Hi!

Quoted 6 lines · Frank Lee

From: Yangtao Li <[email protected]>

The sunxi gpio binding defines a few custom cells for its gpio specifier. Provide bank name for those.

Thanks for working on this, I wanted to do it at some point but it kept getting pushed further into my todo list.

include/dt-bindings/gpio/sunxi-gpio.h

Quoted 10 lines
---
 include/dt-bindings/gpio/sunxi-gpio.h | 29 +++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 include/dt-bindings/gpio/sunxi-gpio.h
include/dt-bindings/gpio/sunxi-gpio.h new file +0 -0
new file mode 100644
index 000000000000..c692b4360da6

So generally we've been using the compatible name as the file name. You should follow that convention too, and since it was added with the A10, using the A10 compatible.

Quoted 25 lines
include/dt-bindings/gpio/sunxi-gpio.h new file +24 -0
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * GPIO definitions for Allwinner SoCs
+ *
+ * Copyright (C) 2020 Yangtao Li <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_SUNXI_GPIO_H
+#define _DT_BINDINGS_SUNXI_GPIO_H
+
+#include <dt-bindings/gpio/gpio.h>
+
+/* pio */
+#define PA        0
+#define PB        1
+#define PC        2
+#define PD        3
+#define PE        4
+#define PF        5
+#define PG        6
+#define PH        7
+#define PI        8
+
+/* r-pio */
Quoted 8 lines

include/dt-bindings/gpio/sunxi-gpio.h line 29

Quoted 5 lines
include/dt-bindings/gpio/sunxi-gpio.h new file +5 -0
+#define PL        0
+#define PM        1
+#define PN        2
+
+#endif /* _DT_BINDINGS_SUNXI_GPIO_H */

Maybe we can go one step further and use a macro to have something like PIN(A, 12) ?

Quoted 2 lines

Since we have separate cells for the bank and pin, I don't think it would be appropriate to have a single macro generating both.

Yeah, but it's "just" an encoding issue though, it's not a major concern if it makes our life easier.

Quoted 3 lines

And I'm not sure what the benefit of the macro would be, if all it does is forward its arguments. Are you concerned that P[A-M] could conflict with something else in the device tree?

Quoted 5 lines

There's indeed a bunch of names that are fairly generic and could be conflicting with others (PD for power domain is the first one that comes to my mind). Using a prefix would make the GPIO descriptors pretty long, so it wasn't ideal either. A macro makes it readable without increasing too much the risks of conflicts

Quoted 4 lines

I tried to use macros, but failed.

I have a look at some other GPIO macros, which have a prefix in front of them. Maybe we can do the same? It's all numbers. It's not intuitive.

This works

arch/arm64/boot/dts/allwinner/sun50i-a64-olinuxino.dts +4 -1
index f3f8e177ab61..3a66d1102a78 100644
@@ -8,6 +8,9 @@
 
 #include <dt-bindings/gpio/gpio.h>
 
+#define SUNXI_PE 4
+#define SUNXI_PIN(bank, pin)    SUNXI_##bank pin
+
 / {
 	model = "Olimex A64-Olinuxino";
 	compatible = "olimex,a64-olinuxino", "allwinner,sun50i-a64";
@@ -37,7 +40,7 @@ leds {
 
 		led-0 {
 			label = "a64-olinuxino:red:user";
-			gpios = <&pio 4 17 GPIO_ACTIVE_HIGH>; /* PE17 */
+			gpios = <&pio SUNXI_PIN(PE, 17) GPIO_ACTIVE_HIGH>;
 		};
 	};
 

Maxime