Skip to contentSkip to conversation

Add GPIO support for MStar/SigmaStar ARMv7

PATCH Superseded Daniel Palmer 2 participants 9 messages Nov 9, 2020 – Nov 12, 2020

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add GPIO support for MStar/SigmaStar ARMv7

At the moment the MStar/SigmaStar support is only really capable of shell from an initramfs and not much else.

Most of the interesting drivers are blocked on clock and pinctrl drivers and those are going to take me a little while to get cleaned up.

Clock and pinctrl aren't needed for basic GPIO to work (all pins start off as GPIOs..) and it makes it possible to actually do something so this series adds everything that is needed for the main GPIO block in these chips.

Changes since v2:

- Numerous style and code cleanups as suggested by Andy Shevchenko, Linus Walleij, Marc Zyngier and Rob Herring.

- Pad names moved out of the binding header because they are no longer needed there. The pin/pad numbers are still there as I couldn't think of a better way to do this. meson8b-gpio.h seems to be similar.

Changes since v1:

- Moves the binding header commit before the yaml commit

- Fixes the license on the binding header to include BSD-2-Clause

- The driver has been reworked to use the gpiolib irqchip functionality as suggested by Linus[0]. I think I got this right. The gpio controller doesn't actually do anything with interrupts itself.. It just happens to have 4 lines that are also wired to lines on one of the interrupt controllers.

- Now that the driver is an interrupt controller in it's own right for the gpio lines that have associated interrupts the binding description has been updated to add the interrupt-controller bits and remove the description of the interrupt-names that described how the interrupts used to be passed in.

Daniel Palmer (5):
dt-bindings: gpio: Add a binding header for the MSC313 GPIO driver
dt-bindings: gpio: Binding for MStar MSC313 GPIO controller
gpio: msc313: MStar MSC313 GPIO driver
ARM: mstar: Add gpio controller to MStar base dtsi
ARM: mstar: Fill in GPIO controller properties for infinity

 .../bindings/gpio/mstar,msc313-gpio.yaml      |  62 +++
 MAINTAINERS                                   |   3 +
 arch/arm/boot/dts/mstar-infinity.dtsi         |   7 +
 arch/arm/boot/dts/mstar-v7.dtsi               |  10 +
 drivers/gpio/Kconfig                          |  11 +
 drivers/gpio/Makefile                         |   1 +
 drivers/gpio/gpio-msc313.c                    | 460 ++++++++++++++++++
 include/dt-bindings/gpio/msc313-gpio.h        |  53 ++
 8 files changed, 607 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml
 create mode 100644 drivers/gpio/gpio-msc313.c
 create mode 100644 include/dt-bindings/gpio/msc313-gpio.h
Signature · 1 line
2.29.2
#1 lore raw

PATCH v3 1/5 dt-bindings: gpio: Add a binding header for the MSC313 GPIO driver

Header adds defines for the gpio number of each pad from the driver view.

The gpio block seems to have enough registers for 128 lines but what line is mapped to a physical pin depends on the chip. The gpio block also seems to contain some registers that are not related to gpio but needed somewhere to go.

Because of the above the driver itself uses the index of a pin's offset in an array of the possible offsets for a chip as the gpio number.

---
 MAINTAINERS                            |  1 +
 include/dt-bindings/gpio/msc313-gpio.h | 53 ++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
 create mode 100644 include/dt-bindings/gpio/msc313-gpio.h
MAINTAINERS +1 -0
index 3da6d8c154e4..db9c008a0395 100644
@@ -2133,6 +2133,7 @@ W:	http://linux-chenxing.org/
 F:	Documentation/devicetree/bindings/arm/mstar/*
 F:	arch/arm/boot/dts/mstar-*
 F:	arch/arm/mach-mstar/
+F:	include/dt-bindings/gpio/msc313-gpio.h
 
 ARM/NEC MOBILEPRO 900/c MACHINE SUPPORT
 M:	Michael Petchkovsky <[email protected]>
include/dt-bindings/gpio/msc313-gpio.h new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.29.2
maintainer Reviewed-by on v3 1/5
#2 lore raw

Re: [PATCH v3 1/5] dt-bindings: gpio: Add a binding header for the MSC313 GPIO driver

Quoted 10 lines · Daniel Palmer

Header adds defines for the gpio number of each pad from the driver view.

The gpio block seems to have enough registers for 128 lines but what line is mapped to a physical pin depends on the chip. The gpio block also seems to contain some registers that are not related to gpio but needed somewhere to go.

Because of the above the driver itself uses the index of a pin's offset in an array of the possible offsets for a chip as the gpio number.

Quoted 7 lines
---
 MAINTAINERS                            |  1 +
 include/dt-bindings/gpio/msc313-gpio.h | 53 ++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
 create mode 100644 include/dt-bindings/gpio/msc313-gpio.h
#3 lore raw

PATCH v3 2/5 dt-bindings: gpio: Binding for MStar MSC313 GPIO controller

In reply to Daniel Palmer

Add a binding description for the MStar/SigmaStar GPIO controller found in the MSC313 and later ARMv7 SoCs.

---
 .../bindings/gpio/mstar,msc313-gpio.yaml      | 62 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml
Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml new file +62 -0
new file mode 100644
index 000000000000..8c7cfe3a51b3
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpio/mstar,msc313-gpio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MStar/SigmaStar GPIO controller
+
+maintainers:
+  - Daniel Palmer <[email protected]>
+
+properties:
+  $nodename:
+    pattern: "^gpio@[0-9a-f]+$"
+
+  compatible:
+    const: mstar,msc313-gpio
+
+  reg:
+    maxItems: 1
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+  gpio-ranges: true
+
+  gpio-ranges-group-names:
+    $ref: /schemas/types.yaml#/definitions/string-array
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 2
+
+required:
+  - compatible
+  - reg
+  - gpio-controller
+  - "#gpio-cells"
+  - interrupt-controller
+  - "#interrupt-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/msc313-gpio.h>
+
+    gpio: gpio@207800 {
+      compatible = "mstar,msc313e-gpio";
+      #gpio-cells = <2>;
+      reg = <0x207800 0x200>;
+      gpio-controller;
+      gpio-ranges = <&pinctrl 0 36 22>,
+                    <&pinctrl 22 63 4>,
+                    <&pinctrl 26 68 6>;
+      #interrupt-cells = <2>;
+      interrupt-controller;
+      interrupt-parent = <&intc_fiq>;
+    };
MAINTAINERS +1 -0
index db9c008a0395..87ca71f55de3 100644
@@ -2131,6 +2131,7 @@ L:	[email protected] (moderated for non-subscribers)
 S:	Maintained
 W:	http://linux-chenxing.org/
 F:	Documentation/devicetree/bindings/arm/mstar/*
+F:	Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml
 F:	arch/arm/boot/dts/mstar-*
 F:	arch/arm/mach-mstar/
 F:	include/dt-bindings/gpio/msc313-gpio.h
Signature · 1 line
2.29.2
maintainer
#4 lore raw

Re: [PATCH v3 2/5] dt-bindings: gpio: Binding for MStar MSC313 GPIO controller

Quoted 36 lines · Daniel Palmer

Add a binding description for the MStar/SigmaStar GPIO controller found in the MSC313 and later ARMv7 SoCs.

---
 .../bindings/gpio/mstar,msc313-gpio.yaml      | 62 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml
Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml new file +20 -0
new file mode 100644
index 000000000000..8c7cfe3a51b3
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpio/mstar,msc313-gpio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MStar/SigmaStar GPIO controller
+
+maintainers:
+  - Daniel Palmer <[email protected]>
+
+properties:
+  $nodename:
+    pattern: "^gpio@[0-9a-f]+$"
+
+  compatible:
+    const: mstar,msc313-gpio
+
+  reg:
+    maxItems: 1

Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml line 30

Quoted 10 lines
Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml new file +10 -0
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+  gpio-ranges: true
+
+  gpio-ranges-group-names:
+    $ref: /schemas/types.yaml#/definitions/string-array

Not a standard property. Probably should be dropped, but why do you need this and what is it for?

Quoted 47 lines
Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml new file +32 -0
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 2
+
+required:
+  - compatible
+  - reg
+  - gpio-controller
+  - "#gpio-cells"
+  - interrupt-controller
+  - "#interrupt-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/msc313-gpio.h>
+
+    gpio: gpio@207800 {
+      compatible = "mstar,msc313e-gpio";
+      #gpio-cells = <2>;
+      reg = <0x207800 0x200>;
+      gpio-controller;
+      gpio-ranges = <&pinctrl 0 36 22>,
+                    <&pinctrl 22 63 4>,
+                    <&pinctrl 26 68 6>;
+      #interrupt-cells = <2>;
+      interrupt-controller;
+      interrupt-parent = <&intc_fiq>;
+    };
MAINTAINERS +1 -0
index db9c008a0395..87ca71f55de3 100644
@@ -2131,6 +2131,7 @@ L:	[email protected] (moderated for non-subscribers)
 S:	Maintained
 W:	http://linux-chenxing.org/
 F:	Documentation/devicetree/bindings/arm/mstar/*
+F:	Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml
 F:	arch/arm/boot/dts/mstar-*
 F:	arch/arm/mach-mstar/
 F:	include/dt-bindings/gpio/msc313-gpio.h
Signature · 1 line
2.29.2
#5 lore raw

Re: [PATCH v3 2/5] dt-bindings: gpio: Binding for MStar MSC313 GPIO controller

Hi Rob,

Quoted 5 lines · Rob Herring

Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml line 30

Quoted 2 lines
Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml new file +2 -0
+  gpio-ranges-group-names:
+    $ref: /schemas/types.yaml#/definitions/string-array

Not a standard property. Probably should be dropped, but why do you need this and what is it for?

It's unneeded. I thought it was a standard item from the other files I looked at when putting together mine.
I'll delete it for the next version.

Is there anything else that looks off?

Thanks,

Daniel

#6 lore raw

PATCH v3 3/5 gpio: msc313: MStar MSC313 GPIO driver

In reply to Daniel Palmer

This adds a driver that supports the GPIO block found in MStar/SigmaStar ARMv7 SoCs.

The controller seems to have enough register for 128 lines but where they are wired up differs between chips and
no currently known chip uses anywhere near 128 lines so there needs to be some per-chip data to collect together what lines actually have physical pins attached and map the right names to them.

The core peripherals seem to use the same lines on the currently known chips but the lines used for the sensor interface, lcd controller etc pins seem to be totally different between the infinity and mercury chips

The code tries to collect all of the re-usable names, offsets etc together so that it's easy to build the extra per-chip data for other chips in the future.

So far this only supports the MSC313 and MSC313E chips.

Support for the SSC8336N (mercury5) is trivial to add once all of the lines have been mapped out.

---
 MAINTAINERS                |   1 +
 drivers/gpio/Kconfig       |  11 +
 drivers/gpio/Makefile      |   1 +
 drivers/gpio/gpio-msc313.c | 460 +++++++++++++++++++++++++++++++++++++
 4 files changed, 473 insertions(+)
 create mode 100644 drivers/gpio/gpio-msc313.c
MAINTAINERS +1 -0
index 87ca71f55de3..864e37e7659e 100644
@@ -2134,6 +2134,7 @@ F:	Documentation/devicetree/bindings/arm/mstar/*
 F:	Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml
 F:	arch/arm/boot/dts/mstar-*
 F:	arch/arm/mach-mstar/
+F:	drivers/gpio/gpio-msc313.c
 F:	include/dt-bindings/gpio/msc313-gpio.h
 
 ARM/NEC MOBILEPRO 900/c MACHINE SUPPORT
drivers/gpio/Kconfig +11 -0
index 5d4de5cd6759..22ad5902299a 100644
@@ -737,6 +737,17 @@ config GPIO_AMD_FCH
 	  Note: This driver doesn't registers itself automatically, as it
 	  needs to be provided with platform specific configuration.
 	  (See eg. CONFIG_PCENGINES_APU2.)
+
+config GPIO_MSC313
+	bool "MStar MSC313 GPIO support"
+	depends on ARCH_MSTARV7
+	default ARCH_MSTARV7
+	select GPIOLIB_IRQCHIP
+	select IRQ_DOMAIN_HIERARCHY
+	help
+	  Say Y here to support the main GPIO block on MStar/SigmaStar
+	  ARMv7 based SoCs.
+
 endmenu
 
 menu "Port-mapped I/O GPIO drivers"
drivers/gpio/Makefile +1 -0
index 09dada80ac34..b6c116a7c785 100644
@@ -101,6 +101,7 @@ obj-$(CONFIG_GPIO_MOCKUP)		+= gpio-mockup.o
 obj-$(CONFIG_GPIO_MOXTET)		+= gpio-moxtet.o
 obj-$(CONFIG_GPIO_MPC5200)		+= gpio-mpc5200.o
 obj-$(CONFIG_GPIO_MPC8XXX)		+= gpio-mpc8xxx.o
+obj-$(CONFIG_GPIO_MSC313)		+= gpio-msc313.o
 obj-$(CONFIG_GPIO_MSIC)			+= gpio-msic.o
 obj-$(CONFIG_GPIO_MT7621)		+= gpio-mt7621.o
 obj-$(CONFIG_GPIO_MVEBU)		+= gpio-mvebu.o
drivers/gpio/gpio-msc313.c new file +460 -0

460 lines not on this page · raw message

Signature · 1 line
2.29.2
#7 lore raw

PATCH v3 4/5 ARM: mstar: Add gpio controller to MStar base dtsi

In reply to Daniel Palmer

The GPIO controller is at the same address in all of the currently known chips so create a node for it in the base dtsi.

Some extra properties are needed to actually use it so disable it by default.

---
 arch/arm/boot/dts/mstar-v7.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boot/dts/mstar-v7.dtsi +10 -0
index f07880561e11..81369bc07f78 100644
@@ -109,6 +109,16 @@ l3bridge: l3bridge@204400 {
 				reg = <0x204400 0x200>;
 			};
 
+			gpio: gpio@207800 {
+				#gpio-cells = <2>;
+				reg = <0x207800 0x200>;
+				gpio-controller;
+				#interrupt-cells = <2>;
+				interrupt-controller;
+				interrupt-parent = <&intc_fiq>;
+				status = "disabled";
+			};
+
 			pm_uart: uart@221000 {
 				compatible = "ns16550a";
 				reg = <0x221000 0x100>;
Signature · 1 line
2.29.2
#8 lore raw

PATCH v3 5/5 ARM: mstar: Fill in GPIO controller properties for infinity

In reply to Daniel Palmer

Fill in the properties needed to use the GPIO controller in the infinity and infinity3 chips.

---
 arch/arm/boot/dts/mstar-infinity.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/boot/dts/mstar-infinity.dtsi +7 -0
index cd911adef014..0bee517797f4 100644
@@ -6,6 +6,13 @@
 
 #include "mstar-v7.dtsi"
 
+#include <dt-bindings/gpio/msc313-gpio.h>
+
 &imi {
 	reg = <0xa0000000 0x16000>;
 };
+
+&gpio {
+	compatible = "mstar,msc313-gpio";
+	status = "okay";
+};
Signature · 1 line
2.29.2