Skip to contentSkip to conversation

pinctrl: add BCM63XX pincontrol support

PATCH Superseded Álvaro Fernández Rojas 5 participants 38 messages Mar 10, 2021 – Mar 15, 2021

Subsystems (4)

v6 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v6 cover pinctrl: add BCM63XX pincontrol support

First of all, I've based this on the patches sent by Jonas Gorski back in 2016:
https://www.spinics.net/lists/linux-gpio/msg15983.html
http://patchwork.ozlabs.org/project/linux-gpio/patch/[email protected]/

I've tried to address all coments from Linus Walleij, but I know that this may still need some other modifications

This patchset adds appropriate binding documentation and drivers for pin controller cores found in the BCM63XX MIPS SoCs currently supported.

While the GPIO part is always the same, the pinmux part varies quite a lot between different SoCs. Sometimes they have defined groups which can be muxed into different functions, sometimes each function has a different group. Sometimes you can mux individual pins. Often it is a combination of single pins and groups.

Some core versions require the GPIO direction to be set according to the function, most do not. Sometimes the mux register(s) contain bits for unrelated other functions.

v6: introduce changes suggested by Rob Herring and Andy Shevchenko.
v5: introduce changes suggested by Andy Shevchenko.
v4: fix gpiochip_irqchip_add_domain(), remove IRQ Kconfig selections and add
missing of_node_put().
v3: introduce new files for shared code and add more changes suggested by
Linus Walleij. Also add a new patch needed for properly parsing gpio-ranges.
v2: introduce changes suggested by Linus Walleij and remove interrupts
- In order to use GPIO_REGMAP, the need to get gpio_chip from gpio_regmap and use it for pinctrl_add_gpio_range() and gpio_chip.direction_input() and gpio_chip.direction_output().

Álvaro Fernández Rojas (15):
gpio: guard gpiochip_irqchip_add_domain() with GPIOLIB_IRQCHIP
gpio: regmap: set gpio_chip of_node
pinctrl: bcm: add bcm63xx base code
dt-bindings: add BCM6328 pincontroller binding documentation
pinctrl: add a pincontrol driver for BCM6328
dt-bindings: add BCM6358 pincontroller binding documentation
pinctrl: add a pincontrol driver for BCM6358
dt-bindings: add BCM6362 pincontroller binding documentation
pinctrl: add a pincontrol driver for BCM6362
dt-bindings: add BCM6368 pincontroller binding documentation
pinctrl: add a pincontrol driver for BCM6368
dt-bindings: add BCM63268 pincontroller binding documentation
pinctrl: add a pincontrol driver for BCM63268
dt-bindings: add BCM6318 pincontroller binding documentation
pinctrl: add a pincontrol driver for BCM6318

 .../pinctrl/brcm,bcm6318-pinctrl.yaml         | 190 ++++++
 .../pinctrl/brcm,bcm63268-pinctrl.yaml        | 211 ++++++
 .../pinctrl/brcm,bcm6328-pinctrl.yaml         | 174 +++++
 .../pinctrl/brcm,bcm6358-pinctrl.yaml         | 140 ++++
 .../pinctrl/brcm,bcm6362-pinctrl.yaml         | 253 +++++++
 .../pinctrl/brcm,bcm6368-pinctrl.yaml         | 264 +++++++
 drivers/gpio/gpio-regmap.c                    |   1 +
 drivers/pinctrl/bcm/Kconfig                   |  55 ++
 drivers/pinctrl/bcm/Makefile                  |   7 +
 drivers/pinctrl/bcm/pinctrl-bcm6318.c         | 498 ++++++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm63268.c        | 643 ++++++++++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm6328.c         | 404 +++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm6358.c         | 369 ++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm6362.c         | 617 +++++++++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm6368.c         | 523 ++++++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm63xx.c         | 113 +++
 drivers/pinctrl/bcm/pinctrl-bcm63xx.h         |  43 ++
 include/linux/gpio/driver.h                   |   9 +
 include/linux/gpio/regmap.h                   |   4 +
 19 files changed, 4518 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6318-pinctrl.yaml
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm63268-pinctrl.yaml
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6358-pinctrl.yaml
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6362-pinctrl.yaml
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6368-pinctrl.yaml
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6318.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63268.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6328.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6358.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6362.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6368.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63xx.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63xx.h
Signature · 1 line
2.20.1
#1 lore raw

PATCH v6 1/15 gpio: guard gpiochip_irqchip_add_domain() with GPIOLIB_IRQCHIP

The current code doesn't check if GPIOLIB_IRQCHIP is enabled, which results in a compilation error when trying to build gpio-regmap if CONFIG_GPIOLIB_IRQCHIP isn't enabled.

Fixes 6a45b0e2589f ("gpiolib: Introduce gpiochip_irqchip_add_domain()")

---
v6: no changes
v5: add missing Suggested-by tag
v4: add patch (fix include instead of gpio-regmap.c)

 include/linux/gpio/driver.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/linux/gpio/driver.h +9 -0
index 286de0520574..ecf0032a0995 100644
@@ -624,8 +624,17 @@ void gpiochip_irq_domain_deactivate(struct irq_domain *domain,
 bool gpiochip_irqchip_irq_valid(const struct gpio_chip *gc,
 				unsigned int offset);
 
+#ifdef CONFIG_GPIOLIB_IRQCHIP
 int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
 				struct irq_domain *domain);
+#else
+static inline int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
+					      struct irq_domain *domain)
+{
+	WARN_ON(1);
+	return -EINVAL;
+}
+#endif
 
 int gpiochip_generic_request(struct gpio_chip *gc, unsigned int offset);
 void gpiochip_generic_free(struct gpio_chip *gc, unsigned int offset);
Signature · 1 line
2.20.1
#2 lore raw

PATCH v6 2/15 gpio: regmap: set gpio_chip of_node

In reply to Álvaro Fernández Rojas

This is needed for properly registering GPIO regmap as a child of a regmap pin controller.

---
v6: add comment and simplify of_node assignment
v5: switch to fwnode
v4: fix documentation
v3: introduce patch needed for properly parsing gpio-range

 drivers/gpio/gpio-regmap.c  | 1 +
 include/linux/gpio/regmap.h | 4 ++++
 2 files changed, 5 insertions(+)
drivers/gpio/gpio-regmap.c +1 -0
index 5412cb3b0b2a..d4fc656e70b0 100644
@@ -249,6 +249,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
 
 	chip = &gpio->gpio_chip;
 	chip->parent = config->parent;
+	chip->of_node = to_of_node(config->fwnode);
 	chip->base = -1;
 	chip->ngpio = config->ngpio;
 	chip->names = config->names;
include/linux/gpio/regmap.h +4 -0
index ad76f3d0a6ba..334dd928042b 100644
@@ -4,6 +4,7 @@
 #define _LINUX_GPIO_REGMAP_H
 
 struct device;
+struct fwnode_handle;
 struct gpio_regmap;
 struct irq_domain;
 struct regmap;
@@ -16,6 +17,8 @@ struct regmap;
  * @parent:		The parent device
  * @regmap:		The regmap used to access the registers
  *			given, the name of the device is used
+ * @fwnode:		(Optional) The firmware node.
+ *			If not given, the fwnode of the parent is used.
  * @label:		(Optional) Descriptive name for GPIO controller.
  *			If not given, the name of the device is used.
  * @ngpio:		Number of GPIOs
@@ -57,6 +60,7 @@ struct regmap;
 struct gpio_regmap_config {
 	struct device *parent;
 	struct regmap *regmap;
+	struct fwnode_handle *fwnode;
 
 	const char *label;
 	int ngpio;
Signature · 1 line
2.20.1
#27 lore raw

PATCH v6 5/15 pinctrl: add a pincontrol driver for BCM6328

In reply to Álvaro Fernández Rojas

Add a pincontrol driver for BCM6328. BCM6328 supports muxing 32 pins as GPIOs, as LEDs for the integrated LED controller, or various other functions. Its pincontrol mux registers also control other aspects, like switching the second USB port between host and device mode.

---
v6: no changes
v5: add changes suggested by Andy Shevchenko
v4: no changes
v3: use new shared code
v2: switch to GPIO_REGMAP

 drivers/pinctrl/bcm/Kconfig           |   8 +
 drivers/pinctrl/bcm/Makefile          |   1 +
 drivers/pinctrl/bcm/pinctrl-bcm6328.c | 404 ++++++++++++++++++++++++++
 3 files changed, 413 insertions(+)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6328.c
drivers/pinctrl/bcm/Kconfig +8 -0
index 882f19bdc243..d35e5d3fe26f 100644
@@ -36,6 +36,14 @@ config PINCTRL_BCM63XX
 	select PINCONF
 	select PINMUX
 
+config PINCTRL_BCM6328
+	bool "Broadcom BCM6328 GPIO driver"
+	depends on (BMIPS_GENERIC || COMPILE_TEST)
+	select PINCTRL_BCM63XX
+	default BMIPS_GENERIC
+	help
+	   Say Y here to enable the Broadcom BCM6328 GPIO driver.
+
 config PINCTRL_IPROC_GPIO
 	bool "Broadcom iProc GPIO (with PINCONF) driver"
 	depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +1 -0
index 0e3cf9b15c65..57e5434a6db6 100644
@@ -4,6 +4,7 @@
 obj-$(CONFIG_PINCTRL_BCM281XX)		+= pinctrl-bcm281xx.o
 obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
 obj-$(CONFIG_PINCTRL_BCM63XX)		+= pinctrl-bcm63xx.o
+obj-$(CONFIG_PINCTRL_BCM6328)		+= pinctrl-bcm6328.o
 obj-$(CONFIG_PINCTRL_IPROC_GPIO)	+= pinctrl-iproc-gpio.o
 obj-$(CONFIG_PINCTRL_CYGNUS_MUX)	+= pinctrl-cygnus-mux.o
 obj-$(CONFIG_PINCTRL_NS)		+= pinctrl-ns.o
drivers/pinctrl/bcm/pinctrl-bcm6328.c new file +404 -0

404 lines not on this page · raw message

Signature · 1 line
2.20.1
#7 lore raw

PATCH v6 3/15 pinctrl: bcm: add bcm63xx base code

In reply to Álvaro Fernández Rojas

Add a helper for registering BCM63XX pin controllers.

---
v6: add changes suggested by Andy Shevchenko
v5: add changes suggested by Andy Shevchenko
v4: drop IRQ selects from Kconfig and add missing of_node_put()
v3: add new patch with shared code

 drivers/pinctrl/bcm/Kconfig           |   7 ++
 drivers/pinctrl/bcm/Makefile          |   1 +
 drivers/pinctrl/bcm/pinctrl-bcm63xx.c | 113 ++++++++++++++++++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm63xx.h |  43 ++++++++++
 4 files changed, 164 insertions(+)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63xx.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63xx.h
drivers/pinctrl/bcm/Kconfig +7 -0
index 0ed14de0134c..882f19bdc243 100644
@@ -29,6 +29,13 @@ config PINCTRL_BCM2835
 	help
 	   Say Y here to enable the Broadcom BCM2835 GPIO driver.
 
+config PINCTRL_BCM63XX
+	bool
+	select GENERIC_PINCONF
+	select GPIO_REGMAP
+	select PINCONF
+	select PINMUX
+
 config PINCTRL_IPROC_GPIO
 	bool "Broadcom iProc GPIO (with PINCONF) driver"
 	depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +1 -0
index 79d5e49fdd9a..0e3cf9b15c65 100644
@@ -3,6 +3,7 @@
 
 obj-$(CONFIG_PINCTRL_BCM281XX)		+= pinctrl-bcm281xx.o
 obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
+obj-$(CONFIG_PINCTRL_BCM63XX)		+= pinctrl-bcm63xx.o
 obj-$(CONFIG_PINCTRL_IPROC_GPIO)	+= pinctrl-iproc-gpio.o
 obj-$(CONFIG_PINCTRL_CYGNUS_MUX)	+= pinctrl-cygnus-mux.o
 obj-$(CONFIG_PINCTRL_NS)		+= pinctrl-ns.o
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +113 -0

113 lines not on this page · raw message

drivers/pinctrl/bcm/pinctrl-bcm63xx.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.20.1
#16 lore raw

PATCH v6 4/15 dt-bindings: add BCM6328 pincontroller binding documentation

In reply to Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in BCM6328 SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

 .../pinctrl/brcm,bcm6328-pinctrl.yaml         | 174 ++++++++++++++++++
 1 file changed, 174 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +174 -0
new file mode 100644
index 000000000000..471f6efa1754
@@ -0,0 +1,174 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6328-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM6328 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm6328-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm6328-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ serial_led_data, serial_led_clk, inet_act_led, pcie_clkreq,
+                  led, ephy0_act_led, ephy1_act_led, ephy2_act_led,
+                  ephy3_act_led, hsspi_cs1, usb_device_port, usb_host_port ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ gpio6, gpio7, gpio11, gpio16, gpio17, gpio18, gpio19,
+                  gpio20, gpio25, gpio26, gpio27, gpio28, hsspi_cs1,
+                  usb_port1 ]
+
+required:
+  - compatible
+  - gpio
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@10000080 {
+      compatible = "brcm,bcm6328-gpio-controller", "syscon", "simple-mfd";
+      reg = <0x10000080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6328-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6328-gpio";
+          data = <0xc>;
+          dirout = <0x4>;
+
+          gpio-controller;
+          gpio-ranges = <&pinctrl 0 0 32>;
+          #gpio-cells = <2>;
+        };
+
+        pinctrl_serial_led: serial_led-pins {
+          pinctrl_serial_led_data: serial_led_data-pins {
+            function = "serial_led_data";
+            pins = "gpio6";
+          };
+
+          pinctrl_serial_led_clk: serial_led_clk-pins {
+            function = "serial_led_clk";
+            pins = "gpio7";
+          };
+        };
+
+        pinctrl_inet_act_led: inet_act_led-pins {
+          function = "inet_act_led";
+          pins = "gpio11";
+        };
+
+        pinctrl_pcie_clkreq: pcie_clkreq-pins {
+          function = "pcie_clkreq";
+          pins = "gpio16";
+        };
+
+        pinctrl_ephy0_spd_led: ephy0_spd_led-pins {
+          function = "led";
+          pins = "gpio17";
+        };
+
+        pinctrl_ephy1_spd_led: ephy1_spd_led-pins {
+          function = "led";
+          pins = "gpio18";
+        };
+
+        pinctrl_ephy2_spd_led: ephy2_spd_led-pins {
+          function = "led";
+          pins = "gpio19";
+        };
+
+        pinctrl_ephy3_spd_led: ephy3_spd_led-pins {
+          function = "led";
+          pins = "gpio20";
+        };
+
+        pinctrl_ephy0_act_led: ephy0_act_led-pins {
+          function = "ephy0_act_led";
+          pins = "gpio25";
+        };
+
+        pinctrl_ephy1_act_led: ephy1_act_led-pins {
+          function = "ephy1_act_led";
+          pins = "gpio26";
+        };
+
+        pinctrl_ephy2_act_led: ephy2_act_led-pins {
+          function = "ephy2_act_led";
+          pins = "gpio27";
+        };
+
+        pinctrl_ephy3_act_led: ephy3_act_led-pins {
+          function = "ephy3_act_led";
+          pins = "gpio28";
+        };
+
+        pinctrl_hsspi_cs1: hsspi_cs1-pins {
+          function = "hsspi_cs1";
+          pins = "hsspi_cs1";
+        };
+
+        pinctrl_usb_port1_device: usb_port1_device-pins {
+          function = "usb_device_port";
+          pins = "usb_port1";
+        };
+
+        pinctrl_usb_port1_host: usb_port1_host-pins {
+          function = "usb_host_port";
+          pins = "usb_port1";
+        };
+      };
+    };
Signature · 1 line
2.20.1
#28 lore raw

PATCH v6 6/15 dt-bindings: add BCM6358 pincontroller binding documentation

In reply to Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in BCM6358 SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

 .../pinctrl/brcm,bcm6358-pinctrl.yaml         | 140 ++++++++++++++++++
 1 file changed, 140 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6358-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/brcm,bcm6358-pinctrl.yaml new file +140 -0
new file mode 100644
index 000000000000..a04fc445c761
@@ -0,0 +1,140 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6358-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM6358 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm6358-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm6358-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ ebi_cs, uart1, serial_led, legacy_led, led, spi_cs, utopia,
+                  pwm_syn_clk, sys_irq ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ ebi_cs_grp, uart1_grp, serial_led_grp, legacy_led_grp,
+                  led_grp, spi_cs_grp, utopia_grp, pwm_syn_clk, sys_irq_grp ]
+
+required:
+  - compatible
+  - gpio
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@fffe0080 {
+      compatible = "brcm,bcm6358-gpio-controller", "syscon", "simple-mfd";
+      reg = <0xfffe0080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6358-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6358-gpio";
+          data = <0xc>;
+          dirout = <0x4>;
+
+          gpio-controller;
+          gpio-ranges = <&pinctrl 0 0 40>;
+          #gpio-cells = <2>;
+        };
+
+        pinctrl_ebi_cs: ebi_cs-pins {
+          function = "ebi_cs";
+          groups = "ebi_cs_grp";
+        };
+
+        pinctrl_uart1: uart1-pins {
+          function = "uart1";
+          groups = "uart1_grp";
+        };
+
+        pinctrl_serial_led: serial_led-pins {
+          function = "serial_led";
+          groups = "serial_led_grp";
+        };
+
+        pinctrl_legacy_led: legacy_led-pins {
+          function = "legacy_led";
+          groups = "legacy_led_grp";
+        };
+
+        pinctrl_led: led-pins {
+          function = "led";
+          groups = "led_grp";
+        };
+
+        pinctrl_spi_cs_23: spi_cs-pins {
+          function = "spi_cs";
+          groups = "spi_cs_grp";
+        };
+
+        pinctrl_utopia: utopia-pins {
+          function = "utopia";
+          groups = "utopia_grp";
+        };
+
+        pinctrl_pwm_syn_clk: pwm_syn_clk-pins {
+          function = "pwm_syn_clk";
+          groups = "pwm_syn_clk_grp";
+        };
+
+        pinctrl_sys_irq: sys_irq-pins {
+          function = "sys_irq";
+          groups = "sys_irq_grp";
+        };
+      };
+    };
Signature · 1 line
2.20.1
#29 lore raw

PATCH v6 7/15 pinctrl: add a pincontrol driver for BCM6358

In reply to Álvaro Fernández Rojas

Add a pincotrol driver for BCM6358. BCM6358 allow overlaying different functions onto the GPIO pins. It does not support configuring individual pins but only whole groups. These groups may overlap, and still require the directions to be set correctly in the GPIO register. In addition the functions register controls other, not directly mux related functions.

---
v6: no changes
v5: add changes suggested by Andy Shevchenko
v4: no changes
v3: use new shared code
v2: switch to GPIO_REGMAP

 drivers/pinctrl/bcm/Kconfig           |   8 +
 drivers/pinctrl/bcm/Makefile          |   1 +
 drivers/pinctrl/bcm/pinctrl-bcm6358.c | 369 ++++++++++++++++++++++++++
 3 files changed, 378 insertions(+)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6358.c
drivers/pinctrl/bcm/Kconfig +8 -0
index d35e5d3fe26f..ced7cc6ab44f 100644
@@ -44,6 +44,14 @@ config PINCTRL_BCM6328
 	help
 	   Say Y here to enable the Broadcom BCM6328 GPIO driver.
 
+config PINCTRL_BCM6358
+	bool "Broadcom BCM6358 GPIO driver"
+	depends on (BMIPS_GENERIC || COMPILE_TEST)
+	select PINCTRL_BCM63XX
+	default BMIPS_GENERIC
+	help
+	   Say Y here to enable the Broadcom BCM6358 GPIO driver.
+
 config PINCTRL_IPROC_GPIO
 	bool "Broadcom iProc GPIO (with PINCONF) driver"
 	depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +1 -0
index 57e5434a6db6..c3f5b7b2f2f0 100644
@@ -5,6 +5,7 @@ obj-$(CONFIG_PINCTRL_BCM281XX)		+= pinctrl-bcm281xx.o
 obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
 obj-$(CONFIG_PINCTRL_BCM63XX)		+= pinctrl-bcm63xx.o
 obj-$(CONFIG_PINCTRL_BCM6328)		+= pinctrl-bcm6328.o
+obj-$(CONFIG_PINCTRL_BCM6358)		+= pinctrl-bcm6358.o
 obj-$(CONFIG_PINCTRL_IPROC_GPIO)	+= pinctrl-iproc-gpio.o
 obj-$(CONFIG_PINCTRL_CYGNUS_MUX)	+= pinctrl-cygnus-mux.o
 obj-$(CONFIG_PINCTRL_NS)		+= pinctrl-ns.o
drivers/pinctrl/bcm/pinctrl-bcm6358.c new file +369 -0

369 lines not on this page · raw message

Signature · 1 line
2.20.1
#30 lore raw

PATCH v6 8/15 dt-bindings: add BCM6362 pincontroller binding documentation

In reply to Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in BCM6362 SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

 .../pinctrl/brcm,bcm6362-pinctrl.yaml         | 253 ++++++++++++++++++
 1 file changed, 253 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6362-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/brcm,bcm6362-pinctrl.yaml new file +253 -0
new file mode 100644
index 000000000000..b8be37f06673
@@ -0,0 +1,253 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6362-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM6362 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm6362-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm6362-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ usb_device_led, sys_irq, serial_led_clk, serial_led_data,
+                  robosw_led_data, robosw_led_clk, robosw_led0, robosw_led1,
+                  inet_led, spi_cs2, spi_cs3, ntr_pulse, uart1_scts,
+                  uart1_srts, uart1_sdin, uart1_sdout, adsl_spi_miso,
+                  adsl_spi_mosi, adsl_spi_clk, adsl_spi_cs, ephy0_led,
+                  ephy1_led, ephy2_led, ephy3_led, ext_irq0, ext_irq1,
+                  ext_irq2, ext_irq3, nand ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ gpio0, gpio1, gpio2, gpio3, gpio4, gpio5, gpio6, gpio7,
+                  gpio8, gpio9, gpio10, gpio11, gpio12, gpio13, gpio14,
+                  gpio15, gpio16, gpio17, gpio18, gpio19, gpio20, gpio21,
+                  gpio22, gpio23, gpio24, gpio25, gpio26, gpio27, nand_grp ]
+
+required:
+  - compatible
+  - gpio
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@10000080 {
+      compatible = "brcm,bcm6362-gpio-controller", "syscon", "simple-mfd";
+      reg = <0x10000080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6362-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6362-gpio";
+          data = <0xc>;
+          dirout = <0x4>;
+
+          gpio-controller;
+          gpio-ranges = <&pinctrl 0 0 48>;
+          #gpio-cells = <2>;
+        };
+
+        pinctrl_usb_device_led: usb_device_led-pins {
+          function = "usb_device_led";
+          pins = "gpio0";
+        };
+
+        pinctrl_sys_irq: sys_irq-pins {
+          function = "sys_irq";
+          pins = "gpio1";
+        };
+
+        pinctrl_serial_led: serial_led-pins {
+          pinctrl_serial_led_clk: serial_led_clk-pins {
+            function = "serial_led_clk";
+            pins = "gpio2";
+          };
+
+          pinctrl_serial_led_data: serial_led_data-pins {
+            function = "serial_led_data";
+            pins = "gpio3";
+          };
+        };
+
+        pinctrl_robosw_led_data: robosw_led_data-pins {
+          function = "robosw_led_data";
+          pins = "gpio4";
+        };
+
+        pinctrl_robosw_led_clk: robosw_led_clk-pins {
+          function = "robosw_led_clk";
+          pins = "gpio5";
+        };
+
+        pinctrl_robosw_led0: robosw_led0-pins {
+          function = "robosw_led0";
+          pins = "gpio6";
+        };
+
+        pinctrl_robosw_led1: robosw_led1-pins {
+          function = "robosw_led1";
+          pins = "gpio7";
+        };
+
+        pinctrl_inet_led: inet_led-pins {
+          function = "inet_led";
+          pins = "gpio8";
+        };
+
+        pinctrl_spi_cs2: spi_cs2-pins {
+          function = "spi_cs2";
+          pins = "gpio9";
+        };
+
+        pinctrl_spi_cs3: spi_cs3-pins {
+          function = "spi_cs3";
+          pins = "gpio10";
+        };
+
+        pinctrl_ntr_pulse: ntr_pulse-pins {
+          function = "ntr_pulse";
+          pins = "gpio11";
+        };
+
+        pinctrl_uart1_scts: uart1_scts-pins {
+          function = "uart1_scts";
+          pins = "gpio12";
+        };
+
+        pinctrl_uart1_srts: uart1_srts-pins {
+          function = "uart1_srts";
+          pins = "gpio13";
+        };
+
+        pinctrl_uart1: uart1-pins {
+          pinctrl_uart1_sdin: uart1_sdin-pins {
+            function = "uart1_sdin";
+            pins = "gpio14";
+          };
+
+          pinctrl_uart1_sdout: uart1_sdout-pins {
+            function = "uart1_sdout";
+            pins = "gpio15";
+          };
+        };
+
+        pinctrl_adsl_spi: adsl_spi-pins {
+          pinctrl_adsl_spi_miso: adsl_spi_miso-pins {
+            function = "adsl_spi_miso";
+            pins = "gpio16";
+          };
+
+          pinctrl_adsl_spi_mosi: adsl_spi_mosi-pins {
+            function = "adsl_spi_mosi";
+            pins = "gpio17";
+          };
+
+          pinctrl_adsl_spi_clk: adsl_spi_clk-pins {
+            function = "adsl_spi_clk";
+            pins = "gpio18";
+          };
+
+          pinctrl_adsl_spi_cs: adsl_spi_cs-pins {
+            function = "adsl_spi_cs";
+            pins = "gpio19";
+          };
+        };
+
+        pinctrl_ephy0_led: ephy0_led-pins {
+          function = "ephy0_led";
+          pins = "gpio20";
+        };
+
+        pinctrl_ephy1_led: ephy1_led-pins {
+          function = "ephy1_led";
+          pins = "gpio21";
+        };
+
+        pinctrl_ephy2_led: ephy2_led-pins {
+          function = "ephy2_led";
+          pins = "gpio22";
+        };
+
+        pinctrl_ephy3_led: ephy3_led-pins {
+          function = "ephy3_led";
+          pins = "gpio23";
+        };
+
+        pinctrl_ext_irq0: ext_irq0-pins {
+          function = "ext_irq0";
+          pins = "gpio24";
+        };
+
+        pinctrl_ext_irq1: ext_irq1-pins {
+          function = "ext_irq1";
+          pins = "gpio25";
+        };
+
+        pinctrl_ext_irq2: ext_irq2-pins {
+          function = "ext_irq2";
+          pins = "gpio26";
+        };
+
+        pinctrl_ext_irq3: ext_irq3-pins {
+          function = "ext_irq3";
+          pins = "gpio27";
+        };
+
+        pinctrl_nand: nand-pins {
+          function = "nand";
+          group = "nand_grp";
+        };
+      };
+    };
Signature · 1 line
2.20.1
#32 lore raw

PATCH v6 10/15 dt-bindings: add BCM6368 pincontroller binding documentation

In reply to Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in BCM6368 SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

 .../pinctrl/brcm,bcm6368-pinctrl.yaml         | 264 ++++++++++++++++++
 1 file changed, 264 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6368-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/brcm,bcm6368-pinctrl.yaml new file +264 -0
new file mode 100644
index 000000000000..de0e4e549f9e
@@ -0,0 +1,264 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6368-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM6368 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm6368-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm6368-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ analog_afe_0, analog_afe_1, sys_irq, serial_led_data,
+                  serial_led_clk, inet_led, ephy0_led, ephy1_led, ephy2_led,
+                  ephy3_led, robosw_led_data, robosw_led_clk, robosw_led0,
+                  robosw_led1, usb_device_led, pci_req1, pci_gnt1, pci_intb,
+                  pci_req0, pci_gnt0, pcmcia_cd1, pcmcia_cd2, pcmcia_vs1,
+                  pcmcia_vs2, ebi_cs2, ebi_cs3, spi_cs2, spi_cs3, spi_cs4,
+                  spi_cs5, uart1 ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ gpio0, gpio1, gpio2, gpio3, gpio4, gpio5, gpio6, gpio7,
+                  gpio8, gpio9, gpio10, gpio11, gpio12, gpio13, gpio14,
+                  gpio16, gpio17, gpio18, gpio19, gpio20, gpio22, gpio23,
+                  gpio24, gpio25, gpio26, gpio27, gpio28, gpio29, gpio30,
+                  gpio31, uart1_grp ]
+
+required:
+  - compatible
+  - gpio
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@10000080 {
+      compatible = "brcm,bcm6368-gpio-controller", "syscon", "simple-mfd";
+      reg = <0x10000080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6368-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6368-gpio";
+          data = <0xc>;
+          dirout = <0x4>;
+
+          gpio-controller;
+          gpio-ranges = <&pinctrl 0 0 38>;
+          #gpio-cells = <2>;
+        };
+
+        pinctrl_analog_afe_0: analog_afe_0-pins {
+          function = "analog_afe_0";
+          pins = "gpio0";
+        };
+
+        pinctrl_analog_afe_1: analog_afe_1-pins {
+          function = "analog_afe_1";
+          pins = "gpio1";
+        };
+
+        pinctrl_sys_irq: sys_irq-pins {
+          function = "sys_irq";
+          pins = "gpio2";
+        };
+
+        pinctrl_serial_led: serial_led-pins {
+          pinctrl_serial_led_data: serial_led_data-pins {
+            function = "serial_led_data";
+            pins = "gpio3";
+          };
+
+          pinctrl_serial_led_clk: serial_led_clk-pins {
+            function = "serial_led_clk";
+            pins = "gpio4";
+          };
+        };
+
+        pinctrl_inet_led: inet_led-pins {
+          function = "inet_led";
+          pins = "gpio5";
+        };
+
+        pinctrl_ephy0_led: ephy0_led-pins {
+          function = "ephy0_led";
+          pins = "gpio6";
+        };
+
+        pinctrl_ephy1_led: ephy1_led-pins {
+          function = "ephy1_led";
+          pins = "gpio7";
+        };
+
+        pinctrl_ephy2_led: ephy2_led-pins {
+          function = "ephy2_led";
+          pins = "gpio8";
+        };
+
+        pinctrl_ephy3_led: ephy3_led-pins {
+          function = "ephy3_led";
+          pins = "gpio9";
+        };
+
+        pinctrl_robosw_led_data: robosw_led_data-pins {
+          function = "robosw_led_data";
+          pins = "gpio10";
+        };
+
+        pinctrl_robosw_led_clk: robosw_led_clk-pins {
+          function = "robosw_led_clk";
+          pins = "gpio11";
+        };
+
+        pinctrl_robosw_led0: robosw_led0-pins {
+          function = "robosw_led0";
+          pins = "gpio12";
+        };
+
+        pinctrl_robosw_led1: robosw_led1-pins {
+          function = "robosw_led1";
+          pins = "gpio13";
+        };
+
+        pinctrl_usb_device_led: usb_device_led-pins {
+          function = "usb_device_led";
+          pins = "gpio14";
+        };
+
+        pinctrl_pci: pci-pins {
+          pinctrl_pci_req1: pci_req1-pins {
+            function = "pci_req1";
+            pins = "gpio16";
+          };
+
+          pinctrl_pci_gnt1: pci_gnt1-pins {
+            function = "pci_gnt1";
+            pins = "gpio17";
+          };
+
+          pinctrl_pci_intb: pci_intb-pins {
+            function = "pci_intb";
+            pins = "gpio18";
+          };
+
+          pinctrl_pci_req0: pci_req0-pins {
+            function = "pci_req0";
+            pins = "gpio19";
+          };
+
+          pinctrl_pci_gnt0: pci_gnt0-pins {
+            function = "pci_gnt0";
+            pins = "gpio20";
+          };
+        };
+
+        pinctrl_pcmcia: pcmcia-pins {
+          pinctrl_pcmcia_cd1: pcmcia_cd1-pins {
+            function = "pcmcia_cd1";
+            pins = "gpio22";
+          };
+
+          pinctrl_pcmcia_cd2: pcmcia_cd2-pins {
+            function = "pcmcia_cd2";
+            pins = "gpio23";
+          };
+
+          pinctrl_pcmcia_vs1: pcmcia_vs1-pins {
+            function = "pcmcia_vs1";
+            pins = "gpio24";
+          };
+
+          pinctrl_pcmcia_vs2: pcmcia_vs2-pins {
+            function = "pcmcia_vs2";
+            pins = "gpio25";
+          };
+        };
+
+        pinctrl_ebi_cs2: ebi_cs2-pins {
+          function = "ebi_cs2";
+          pins = "gpio26";
+        };
+
+        pinctrl_ebi_cs3: ebi_cs3-pins {
+          function = "ebi_cs3";
+          pins = "gpio27";
+        };
+
+        pinctrl_spi_cs2: spi_cs2-pins {
+          function = "spi_cs2";
+          pins = "gpio28";
+        };
+
+        pinctrl_spi_cs3: spi_cs3-pins {
+          function = "spi_cs3";
+          pins = "gpio29";
+        };
+
+        pinctrl_spi_cs4: spi_cs4-pins {
+          function = "spi_cs4";
+          pins = "gpio30";
+        };
+
+        pinctrl_spi_cs5: spi_cs5-pins {
+          function = "spi_cs5";
+          pins = "gpio31";
+        };
+
+        pinctrl_uart1: uart1-pins {
+          function = "uart1";
+          group = "uart1_grp";
+        };
+      };
+    };
Signature · 1 line
2.20.1
#33 lore raw

PATCH v6 11/15 pinctrl: add a pincontrol driver for BCM6368

In reply to Álvaro Fernández Rojas

Add a pincontrol driver for BCM6368. BCM6368 allows muxing the first 32 GPIOs onto alternative functions. Not all are documented.

---
v6: no changes
v5: add changes suggested by Andy Shevchenko
v4: no changes
v3: use new shared code
v2: switch to GPIO_REGMAP

 drivers/pinctrl/bcm/Kconfig           |   8 +
 drivers/pinctrl/bcm/Makefile          |   1 +
 drivers/pinctrl/bcm/pinctrl-bcm6368.c | 523 ++++++++++++++++++++++++++
 3 files changed, 532 insertions(+)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6368.c
drivers/pinctrl/bcm/Kconfig +8 -0
index d3101d5e750f..aabd4b762aed 100644
@@ -60,6 +60,14 @@ config PINCTRL_BCM6362
 	help
 	   Say Y here to enable the Broadcom BCM6362 GPIO driver.
 
+config PINCTRL_BCM6368
+	bool "Broadcom BCM6368 GPIO driver"
+	depends on (BMIPS_GENERIC || COMPILE_TEST)
+	select PINCTRL_BCM63XX
+	default BMIPS_GENERIC
+	help
+	   Say Y here to enable the Broadcom BCM6368 GPIO driver.
+
 config PINCTRL_IPROC_GPIO
 	bool "Broadcom iProc GPIO (with PINCONF) driver"
 	depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +1 -0
index b9b09e5b914c..a1331bb9680e 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_PINCTRL_BCM63XX)		+= pinctrl-bcm63xx.o
 obj-$(CONFIG_PINCTRL_BCM6328)		+= pinctrl-bcm6328.o
 obj-$(CONFIG_PINCTRL_BCM6358)		+= pinctrl-bcm6358.o
 obj-$(CONFIG_PINCTRL_BCM6362)		+= pinctrl-bcm6362.o
+obj-$(CONFIG_PINCTRL_BCM6368)		+= pinctrl-bcm6368.o
 obj-$(CONFIG_PINCTRL_IPROC_GPIO)	+= pinctrl-iproc-gpio.o
 obj-$(CONFIG_PINCTRL_CYGNUS_MUX)	+= pinctrl-cygnus-mux.o
 obj-$(CONFIG_PINCTRL_NS)		+= pinctrl-ns.o
drivers/pinctrl/bcm/pinctrl-bcm6368.c new file +523 -0

523 lines not on this page · raw message

Signature · 1 line
2.20.1
#31 lore raw

PATCH v6 9/15 pinctrl: add a pincontrol driver for BCM6362

In reply to Álvaro Fernández Rojas

Add a pincotrol driver for BCM6362. BCM6362 allows muxing individual GPIO pins to the LED controller, to be available by the integrated wifi, or other functions. It also supports overlay groups, of which only NAND is documented.

---
v6: no changes
v5: add changes suggested by Andy Shevchenko
v4: no changes
v3: use new shared code
v2: switch to GPIO_REGMAP

 drivers/pinctrl/bcm/Kconfig           |   8 +
 drivers/pinctrl/bcm/Makefile          |   1 +
 drivers/pinctrl/bcm/pinctrl-bcm6362.c | 617 ++++++++++++++++++++++++++
 3 files changed, 626 insertions(+)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6362.c
drivers/pinctrl/bcm/Kconfig +8 -0
index ced7cc6ab44f..d3101d5e750f 100644
@@ -52,6 +52,14 @@ config PINCTRL_BCM6358
 	help
 	   Say Y here to enable the Broadcom BCM6358 GPIO driver.
 
+config PINCTRL_BCM6362
+	bool "Broadcom BCM6362 GPIO driver"
+	depends on (BMIPS_GENERIC || COMPILE_TEST)
+	select PINCTRL_BCM63XX
+	default BMIPS_GENERIC
+	help
+	   Say Y here to enable the Broadcom BCM6362 GPIO driver.
+
 config PINCTRL_IPROC_GPIO
 	bool "Broadcom iProc GPIO (with PINCONF) driver"
 	depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +1 -0
index c3f5b7b2f2f0..b9b09e5b914c 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
 obj-$(CONFIG_PINCTRL_BCM63XX)		+= pinctrl-bcm63xx.o
 obj-$(CONFIG_PINCTRL_BCM6328)		+= pinctrl-bcm6328.o
 obj-$(CONFIG_PINCTRL_BCM6358)		+= pinctrl-bcm6358.o
+obj-$(CONFIG_PINCTRL_BCM6362)		+= pinctrl-bcm6362.o
 obj-$(CONFIG_PINCTRL_IPROC_GPIO)	+= pinctrl-iproc-gpio.o
 obj-$(CONFIG_PINCTRL_CYGNUS_MUX)	+= pinctrl-cygnus-mux.o
 obj-$(CONFIG_PINCTRL_NS)		+= pinctrl-ns.o
drivers/pinctrl/bcm/pinctrl-bcm6362.c new file +617 -0

617 lines not on this page · raw message

Signature · 1 line
2.20.1
#34 lore raw

PATCH v6 12/15 dt-bindings: add BCM63268 pincontroller binding documentation

In reply to Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in the BCM63268 family SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

 .../pinctrl/brcm,bcm63268-pinctrl.yaml        | 211 ++++++++++++++++++
 1 file changed, 211 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm63268-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/brcm,bcm63268-pinctrl.yaml new file +211 -0
new file mode 100644
index 000000000000..9ff91ea96aef
@@ -0,0 +1,211 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm63268-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM63268 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm63268-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm63268-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ serial_led_clk, serial_led_data, hsspi_cs4, hsspi_cs5,
+                  hsspi_cs6, hsspi_cs7, adsl_spi_miso, adsl_spi_mosi,
+                  vreq_clk, pcie_clkreq_b, robosw_led_clk, robosw_led_data,
+                  nand, gpio35_alt, dectpd, vdsl_phy_override_0,
+                  vdsl_phy_override_1, vdsl_phy_override_2,
+                  vdsl_phy_override_3, dsl_gpio8, dsl_gpio9 ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ gpio0, gpio1, gpio16, gpio17, gpio8, gpio9, gpio18, gpio19,
+                  gpio22, gpio23, gpio30, gpio31, nand_grp, gpio35
+                  dectpd_grp, vdsl_phy_override_0_grp,
+                  vdsl_phy_override_1_grp, vdsl_phy_override_2_grp,
+                  vdsl_phy_override_3_grp, dsl_gpio8, dsl_gpio9 ]
+
+required:
+  - compatible
+  - gpio
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@100000c0 {
+      compatible = "brcm,bcm63268-gpio-controller", "syscon", "simple-mfd";
+      reg = <0x100000c0 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm63268-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm63268-gpio";
+          data = <0xc>;
+          dirout = <0x4>;
+
+          gpio-controller;
+          gpio-ranges = <&pinctrl 0 0 52>;
+          #gpio-cells = <2>;
+        };
+
+        pinctrl_serial_led: serial_led-pins {
+          pinctrl_serial_led_clk: serial_led_clk-pins {
+            function = "serial_led_clk";
+            pins = "gpio0";
+          };
+
+          pinctrl_serial_led_data: serial_led_data-pins {
+            function = "serial_led_data";
+            pins = "gpio1";
+          };
+        };
+
+        pinctrl_hsspi_cs4: hsspi_cs4-pins {
+          function = "hsspi_cs4";
+          pins = "gpio16";
+        };
+
+        pinctrl_hsspi_cs5: hsspi_cs5-pins {
+          function = "hsspi_cs5";
+          pins = "gpio17";
+        };
+
+        pinctrl_hsspi_cs6: hsspi_cs6-pins {
+          function = "hsspi_cs6";
+          pins = "gpio8";
+        };
+
+        pinctrl_hsspi_cs7: hsspi_cs7-pins {
+          function = "hsspi_cs7";
+          pins = "gpio9";
+        };
+
+        pinctrl_adsl_spi: adsl_spi-pins {
+          pinctrl_adsl_spi_miso: adsl_spi_miso-pins {
+            function = "adsl_spi_miso";
+            pins = "gpio18";
+          };
+
+          pinctrl_adsl_spi_mosi: adsl_spi_mosi-pins {
+            function = "adsl_spi_mosi";
+            pins = "gpio19";
+          };
+        };
+
+        pinctrl_vreq_clk: vreq_clk-pins {
+          function = "vreq_clk";
+          pins = "gpio22";
+        };
+
+        pinctrl_pcie_clkreq_b: pcie_clkreq_b-pins {
+          function = "pcie_clkreq_b";
+          pins = "gpio23";
+        };
+
+        pinctrl_robosw_led_clk: robosw_led_clk-pins {
+          function = "robosw_led_clk";
+          pins = "gpio30";
+        };
+
+        pinctrl_robosw_led_data: robosw_led_data-pins {
+          function = "robosw_led_data";
+          pins = "gpio31";
+        };
+
+        pinctrl_nand: nand-pins {
+          function = "nand";
+          group = "nand_grp";
+        };
+
+        pinctrl_gpio35_alt: gpio35_alt-pins {
+          function = "gpio35_alt";
+          pin = "gpio35";
+        };
+
+        pinctrl_dectpd: dectpd-pins {
+          function = "dectpd";
+          group = "dectpd_grp";
+        };
+
+        pinctrl_vdsl_phy_override_0: vdsl_phy_override_0-pins {
+          function = "vdsl_phy_override_0";
+          group = "vdsl_phy_override_0_grp";
+        };
+
+        pinctrl_vdsl_phy_override_1: vdsl_phy_override_1-pins {
+          function = "vdsl_phy_override_1";
+          group = "vdsl_phy_override_1_grp";
+        };
+
+        pinctrl_vdsl_phy_override_2: vdsl_phy_override_2-pins {
+          function = "vdsl_phy_override_2";
+          group = "vdsl_phy_override_2_grp";
+        };
+
+        pinctrl_vdsl_phy_override_3: vdsl_phy_override_3-pins {
+          function = "vdsl_phy_override_3";
+          group = "vdsl_phy_override_3_grp";
+        };
+
+        pinctrl_dsl_gpio8: dsl_gpio8-pins {
+          function = "dsl_gpio8";
+          group = "dsl_gpio8";
+        };
+
+        pinctrl_dsl_gpio9: dsl_gpio9-pins {
+          function = "dsl_gpio9";
+          group = "dsl_gpio9";
+        };
+      };
+    };
Signature · 1 line
2.20.1
#37 lore raw

PATCH v6 15/15 pinctrl: add a pincontrol driver for BCM6318

In reply to Álvaro Fernández Rojas

Add a pincontrol driver for BCM6318. BCM6318 allows muxing most GPIOs to different functions. BCM6318 is similar to BCM6328 with the addition of a pad register, and the GPIO meaning of the mux register changes based on the GPIO number.

---
v6: no changes
v5: add changes suggested by Andy Shevchenko
v4: no changes
v3: use new shared code
v2: switch to GPIO_REGMAP

 drivers/pinctrl/bcm/Kconfig           |   8 +
 drivers/pinctrl/bcm/Makefile          |   1 +
 drivers/pinctrl/bcm/pinctrl-bcm6318.c | 498 ++++++++++++++++++++++++++
 3 files changed, 507 insertions(+)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6318.c
drivers/pinctrl/bcm/Kconfig +8 -0
index 186985846120..33660e8fec05 100644
@@ -36,6 +36,14 @@ config PINCTRL_BCM63XX
 	select PINCONF
 	select PINMUX
 
+config PINCTRL_BCM6318
+	bool "Broadcom BCM6318 GPIO driver"
+	depends on (BMIPS_GENERIC || COMPILE_TEST)
+	select PINCTRL_BCM63XX
+	default BMIPS_GENERIC
+	help
+	   Say Y here to enable the Broadcom BCM6318 GPIO driver.
+
 config PINCTRL_BCM6328
 	bool "Broadcom BCM6328 GPIO driver"
 	depends on (BMIPS_GENERIC || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +1 -0
index 4117847fd279..00c7b7775e63 100644
@@ -4,6 +4,7 @@
 obj-$(CONFIG_PINCTRL_BCM281XX)		+= pinctrl-bcm281xx.o
 obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
 obj-$(CONFIG_PINCTRL_BCM63XX)		+= pinctrl-bcm63xx.o
+obj-$(CONFIG_PINCTRL_BCM6318)		+= pinctrl-bcm6318.o
 obj-$(CONFIG_PINCTRL_BCM6328)		+= pinctrl-bcm6328.o
 obj-$(CONFIG_PINCTRL_BCM6358)		+= pinctrl-bcm6358.o
 obj-$(CONFIG_PINCTRL_BCM6362)		+= pinctrl-bcm6362.o
drivers/pinctrl/bcm/pinctrl-bcm6318.c new file +498 -0

498 lines not on this page · raw message

Signature · 1 line
2.20.1
#35 lore raw

PATCH v6 13/15 pinctrl: add a pincontrol driver for BCM63268

In reply to Álvaro Fernández Rojas

Add a pincontrol driver for BCM63268. BCM63268 allows muxing GPIOs to different functions. Depending on the mux, these are either single pin configurations or whole pin groups.

---
v6: no changes
v5: add changes suggested by Andy Shevchenko
v4: no changes
v3: use new shared code
v2: switch to GPIO_REGMAP

 drivers/pinctrl/bcm/Kconfig            |   8 +
 drivers/pinctrl/bcm/Makefile           |   1 +
 drivers/pinctrl/bcm/pinctrl-bcm63268.c | 643 +++++++++++++++++++++++++
 3 files changed, 652 insertions(+)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63268.c
drivers/pinctrl/bcm/Kconfig +8 -0
index aabd4b762aed..186985846120 100644
@@ -68,6 +68,14 @@ config PINCTRL_BCM6368
 	help
 	   Say Y here to enable the Broadcom BCM6368 GPIO driver.
 
+config PINCTRL_BCM63268
+	bool "Broadcom BCM63268 GPIO driver"
+	depends on (BMIPS_GENERIC || COMPILE_TEST)
+	select PINCTRL_BCM63XX
+	default BMIPS_GENERIC
+	help
+	   Say Y here to enable the Broadcom BCM63268 GPIO driver.
+
 config PINCTRL_IPROC_GPIO
 	bool "Broadcom iProc GPIO (with PINCONF) driver"
 	depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +1 -0
index a1331bb9680e..4117847fd279 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_PINCTRL_BCM6328)		+= pinctrl-bcm6328.o
 obj-$(CONFIG_PINCTRL_BCM6358)		+= pinctrl-bcm6358.o
 obj-$(CONFIG_PINCTRL_BCM6362)		+= pinctrl-bcm6362.o
 obj-$(CONFIG_PINCTRL_BCM6368)		+= pinctrl-bcm6368.o
+obj-$(CONFIG_PINCTRL_BCM63268)		+= pinctrl-bcm63268.o
 obj-$(CONFIG_PINCTRL_IPROC_GPIO)	+= pinctrl-iproc-gpio.o
 obj-$(CONFIG_PINCTRL_CYGNUS_MUX)	+= pinctrl-cygnus-mux.o
 obj-$(CONFIG_PINCTRL_NS)		+= pinctrl-ns.o
drivers/pinctrl/bcm/pinctrl-bcm63268.c new file +643 -0

643 lines not on this page · raw message

Signature · 1 line
2.20.1
#36 lore raw

PATCH v6 14/15 dt-bindings: add BCM6318 pincontroller binding documentation

In reply to Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in BCM6318 SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

 .../pinctrl/brcm,bcm6318-pinctrl.yaml         | 190 ++++++++++++++++++
 1 file changed, 190 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6318-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/brcm,bcm6318-pinctrl.yaml new file +190 -0
new file mode 100644
index 000000000000..6b607bd8d003
@@ -0,0 +1,190 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6318-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM6318 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm6318-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm6318-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ ephy0_spd_led, ephy1_spd_led, ephy2_spd_led, ephy3_spd_led,
+                  ephy0_act_led, ephy1_act_led, ephy2_act_led, ephy3_act_led,
+                  serial_led_data, serial_led_clk, inet_act_led, inet_fail_led,
+                  dsl_led, post_fail_led, wlan_wps_led, usb_pwron,
+                  usb_device_led, usb_active ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ gpio0, gpio1, gpio2, gpio3, gpio4, gpio5, gpio6, gpio7,
+                  gpio8, gpio9, gpio10, gpio11, gpio12, gpio13, gpio40 ]
+
+required:
+  - compatible
+  - gpio
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@10000080 {
+      compatible = "brcm,bcm6318-gpio-controller", "syscon", "simple-mfd";
+      reg = <0x10000080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6318-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6318-gpio";
+          data = <0xc>;
+          dirout = <0x4>;
+
+          gpio-controller;
+          gpio-ranges = <&pinctrl 0 0 50>;
+          #gpio-cells = <2>;
+        };
+
+        pinctrl_ephy0_spd_led: ephy0_spd_led-pins {
+          function = "ephy0_spd_led";
+          pins = "gpio0";
+        };
+
+        pinctrl_ephy1_spd_led: ephy1_spd_led-pins {
+          function = "ephy1_spd_led";
+          pins = "gpio1";
+        };
+
+        pinctrl_ephy2_spd_led: ephy2_spd_led-pins {
+          function = "ephy2_spd_led";
+          pins = "gpio2";
+        };
+
+        pinctrl_ephy3_spd_led: ephy3_spd_led-pins {
+          function = "ephy3_spd_led";
+          pins = "gpio3";
+        };
+
+        pinctrl_ephy0_act_led: ephy0_act_led-pins {
+          function = "ephy0_act_led";
+          pins = "gpio4";
+        };
+
+        pinctrl_ephy1_act_led: ephy1_act_led-pins {
+          function = "ephy1_act_led";
+          pins = "gpio5";
+        };
+
+        pinctrl_ephy2_act_led: ephy2_act_led-pins {
+          function = "ephy2_act_led";
+          pins = "gpio6";
+        };
+
+        pinctrl_ephy3_act_led: ephy3_act_led-pins {
+          function = "ephy3_act_led";
+          pins = "gpio7";
+        };
+
+        pinctrl_serial_led: serial_led-pins {
+          pinctrl_serial_led_data: serial_led_data-pins {
+            function = "serial_led_data";
+            pins = "gpio6";
+          };
+
+          pinctrl_serial_led_clk: serial_led_clk-pins {
+            function = "serial_led_clk";
+            pins = "gpio7";
+          };
+        };
+
+        pinctrl_inet_act_led: inet_act_led-pins {
+          function = "inet_act_led";
+          pins = "gpio8";
+        };
+
+        pinctrl_inet_fail_led: inet_fail_led-pins {
+          function = "inet_fail_led";
+          pins = "gpio9";
+        };
+
+        pinctrl_dsl_led: dsl_led-pins {
+          function = "dsl_led";
+          pins = "gpio10";
+        };
+
+        pinctrl_post_fail_led: post_fail_led-pins {
+          function = "post_fail_led";
+          pins = "gpio11";
+        };
+
+        pinctrl_wlan_wps_led: wlan_wps_led-pins {
+          function = "wlan_wps_led";
+          pins = "gpio12";
+        };
+
+        pinctrl_usb_pwron: usb_pwron-pins {
+          function = "usb_pwron";
+          pins = "gpio13";
+        };
+
+        pinctrl_usb_device_led: usb_device_led-pins {
+          function = "usb_device_led";
+          pins = "gpio13";
+        };
+
+        pinctrl_usb_active: usb_active-pins {
+          function = "usb_active";
+          pins = "gpio40";
+        };
+      };
+    };
Signature · 1 line
2.20.1
Reviewed-by on v6 2/15
#3 lore raw

Re: [PATCH v6 02/15] gpio: regmap: set gpio_chip of_node

In reply to Álvaro Fernández Rojas
Quoted 3 lines · Álvaro Fernández Rojas

This is needed for properly registering GPIO regmap as a child of a regmap pin controller.

Thanks!

Quoted 56 lines

---
v6: add comment and simplify of_node assignment
v5: switch to fwnode
v4: fix documentation
v3: introduce patch needed for properly parsing gpio-range

 drivers/gpio/gpio-regmap.c  | 1 +
 include/linux/gpio/regmap.h | 4 ++++
 2 files changed, 5 insertions(+)
drivers/gpio/gpio-regmap.c +1 -0
index 5412cb3b0b2a..d4fc656e70b0 100644
@@ -249,6 +249,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
 
        chip = &gpio->gpio_chip;
        chip->parent = config->parent;
+       chip->of_node = to_of_node(config->fwnode);
        chip->base = -1;
        chip->ngpio = config->ngpio;
        chip->names = config->names;
include/linux/gpio/regmap.h +4 -1
index ad76f3d0a6ba..334dd928042b 100644
@@ -4,6 +4,7 @@
 #define _LINUX_GPIO_REGMAP_H
 
 struct device;
+struct fwnode_handle;
 struct gpio_regmap;
 struct irq_domain;
 struct regmap;
@@ -16,6 +17,8 @@ struct regmap;
  * @parent:            The parent device
  * @regmap:            The regmap used to access the registers
  *                     given, the name of the device is used
+ * @fwnode:            (Optional) The firmware node.
+ *                     If not given, the fwnode of the parent is used.
  * @label:             (Optional) Descriptive name for GPIO controller.
  *                     If not given, the name of the device is used.
  * @ngpio:             Number of GPIOs
@@ -57,6 +60,7 @@ struct regmap;
 struct gpio_regmap_config {
        struct device *parent;
        struct regmap *regmap;
+       struct fwnode_handle *fwnode;
 
        const char *label;
        int ngpio;
--

2.20.1

Signature · 2 lines
With Best Regards,
Andy Shevchenko
Reviewed-by on v6 3/15
#8 lore raw

Re: [PATCH v6 03/15] pinctrl: bcm: add bcm63xx base code

In reply to Álvaro Fernández Rojas
Quoted 2 lines · Álvaro Fernández Rojas

Add a helper for registering BCM63XX pin controllers.

(from use of the fwnode API perspective)

I'll think about of_match_node() case and perhaps come up with corresponding fwnode API solution.

Quoted 2 lines

Other way around (Co-DB followed by SoB), but this is minor thingy

Quoted 216 lines

---
v6: add changes suggested by Andy Shevchenko
v5: add changes suggested by Andy Shevchenko
v4: drop IRQ selects from Kconfig and add missing of_node_put()
v3: add new patch with shared code

 drivers/pinctrl/bcm/Kconfig           |   7 ++
 drivers/pinctrl/bcm/Makefile          |   1 +
 drivers/pinctrl/bcm/pinctrl-bcm63xx.c | 113 ++++++++++++++++++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm63xx.h |  43 ++++++++++
 4 files changed, 164 insertions(+)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63xx.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63xx.h
drivers/pinctrl/bcm/Kconfig +7 -0
index 0ed14de0134c..882f19bdc243 100644
@@ -29,6 +29,13 @@ config PINCTRL_BCM2835
        help
           Say Y here to enable the Broadcom BCM2835 GPIO driver.
 
+config PINCTRL_BCM63XX
+       bool
+       select GENERIC_PINCONF
+       select GPIO_REGMAP
+       select PINCONF
+       select PINMUX
+
 config PINCTRL_IPROC_GPIO
        bool "Broadcom iProc GPIO (with PINCONF) driver"
        depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +1 -0
index 79d5e49fdd9a..0e3cf9b15c65 100644
@@ -3,6 +3,7 @@
 
 obj-$(CONFIG_PINCTRL_BCM281XX)         += pinctrl-bcm281xx.o
 obj-$(CONFIG_PINCTRL_BCM2835)          += pinctrl-bcm2835.o
+obj-$(CONFIG_PINCTRL_BCM63XX)          += pinctrl-bcm63xx.o
 obj-$(CONFIG_PINCTRL_IPROC_GPIO)       += pinctrl-iproc-gpio.o
 obj-$(CONFIG_PINCTRL_CYGNUS_MUX)       += pinctrl-cygnus-mux.o
 obj-$(CONFIG_PINCTRL_NS)               += pinctrl-ns.o
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +113 -0
new file mode 100644
index 000000000000..2eaac8e6f79f
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Driver for BCM63xx GPIO unit (pinctrl + GPIO)
+ *
+ * Copyright (C) 2021 Álvaro Fernández Rojas <[email protected]>
+ * Copyright (C) 2016 Jonas Gorski <[email protected]>
+ */
+
+#include <linux/gpio/regmap.h>
+#include <linux/mfd/syscon.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+#include "pinctrl-bcm63xx.h"
+
+#define BCM63XX_BANK_SIZE      4
+
+#define BCM63XX_DIROUT_REG     0x04
+#define BCM63XX_DATA_REG       0x0c
+
+static int bcm63xx_reg_mask_xlate(struct gpio_regmap *gpio,
+                                 unsigned int base, unsigned int offset,
+                                 unsigned int *reg, unsigned int *mask)
+{
+       unsigned int line = offset % BCM63XX_BANK_GPIOS;
+       unsigned int stride = offset / BCM63XX_BANK_GPIOS;
+
+       *reg = base - stride * BCM63XX_BANK_SIZE;
+       *mask = BIT(line);
+
+       return 0;
+}
+
+static const struct of_device_id bcm63xx_gpio_of_match[] = {
+       { .compatible = "brcm,bcm6318-gpio", },
+       { .compatible = "brcm,bcm6328-gpio", },
+       { .compatible = "brcm,bcm6358-gpio", },
+       { .compatible = "brcm,bcm6362-gpio", },
+       { .compatible = "brcm,bcm6368-gpio", },
+       { .compatible = "brcm,bcm63268-gpio", },
+       { /* sentinel */ }
+};
+
+static int bcm63xx_gpio_probe(struct device *dev,
+                             struct fwnode_handle *node,
+                             const struct bcm63xx_pinctrl_soc *soc,
+                             struct bcm63xx_pinctrl *pc)
+{
+       struct gpio_regmap_config grc = {0};
+
+       grc.parent = dev;
+       grc.fwnode = node;
+       grc.ngpio = soc->ngpios;
+       grc.ngpio_per_reg = BCM63XX_BANK_GPIOS;
+       grc.regmap = pc->regs;
+       grc.reg_mask_xlate = bcm63xx_reg_mask_xlate;
+
+       if (fwnode_property_read_u32(node, "data", &grc.reg_dat_base))
+               grc.reg_dat_base = BCM63XX_DATA_REG;
+       grc.reg_set_base = grc.reg_dat_base;
+
+       if (fwnode_property_read_u32(node, "dirout", &grc.reg_dir_out_base))
+               grc.reg_dir_out_base = BCM63XX_DIROUT_REG;
+
+       return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &grc));
+}
+
+int bcm63xx_pinctrl_probe(struct platform_device *pdev,
+                         const struct bcm63xx_pinctrl_soc *soc,
+                         void *driver_data)
+{
+       struct device *dev = &pdev->dev;
+       struct bcm63xx_pinctrl *pc;
+       struct fwnode_handle *node;
+       int err;
+
+       pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
+       if (!pc)
+               return -ENOMEM;
+
+       platform_set_drvdata(pdev, pc);
+
+       pc->dev = dev;
+       pc->driver_data = driver_data;
+
+       pc->regs = syscon_node_to_regmap(dev->parent->of_node);
+       if (IS_ERR(pc->regs))
+               return PTR_ERR(pc->regs);
+
+       pc->pctl_desc.name = dev_name(dev);
+       pc->pctl_desc.pins = soc->pins;
+       pc->pctl_desc.npins = soc->npins;
+       pc->pctl_desc.pctlops = soc->pctl_ops;
+       pc->pctl_desc.pmxops = soc->pmx_ops;
+       pc->pctl_desc.owner = THIS_MODULE;
+
+       pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc);
+       if (IS_ERR(pc->pctl_dev))
+               return PTR_ERR(pc->pctl_dev);
+
+       device_for_each_child_node(dev, node) {
+               if (of_match_node(bcm63xx_gpio_of_match, to_of_node(node))) {
+                       err = bcm63xx_gpio_probe(dev, node, soc, pc);
+                       if (err) {
+                               dev_err(dev, "could not add GPIO chip\n");
+                               fwnode_handle_put(node);
+                               return err;
+                       }
+               }
+       }
+
+       return 0;
+}
drivers/pinctrl/bcm/pinctrl-bcm63xx.h new file +43 -1
new file mode 100644
index 000000000000..3bdb50021f1b
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Álvaro Fernández Rojas <[email protected]>
+ * Copyright (C) 2016 Jonas Gorski <[email protected]>
+ */
+
+#ifndef __PINCTRL_BCM63XX_H__
+#define __PINCTRL_BCM63XX_H__
+
+#include <linux/pinctrl/pinctrl.h>
+
+#define BCM63XX_BANK_GPIOS 32
+
+struct bcm63xx_pinctrl_soc {
+       struct pinctrl_ops *pctl_ops;
+       struct pinmux_ops *pmx_ops;
+
+       const struct pinctrl_pin_desc *pins;
+       unsigned npins;
+
+       unsigned int ngpios;
+};
+
+struct bcm63xx_pinctrl {
+       struct device *dev;
+       struct regmap *regs;
+
+       struct pinctrl_desc pctl_desc;
+       struct pinctrl_dev *pctl_dev;
+
+       void *driver_data;
+};
+
+static inline unsigned int bcm63xx_bank_pin(unsigned int pin)
+{
+       return pin % BCM63XX_BANK_GPIOS;
+}
+
+int bcm63xx_pinctrl_probe(struct platform_device *pdev,
+                         const struct bcm63xx_pinctrl_soc *soc,
+                         void *driver_data);
+
+#endif /* __PINCTRL_BCM63XX_H__ */
--

2.20.1

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#17 lore raw

Re: [PATCH v6 04/15] dt-bindings: add BCM6328 pincontroller binding documentation

In reply to Álvaro Fernández Rojas
Quoted 94 lines · Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in BCM6328 SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

 .../pinctrl/brcm,bcm6328-pinctrl.yaml         | 174 ++++++++++++++++++
 1 file changed, 174 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +71 -0
new file mode 100644
index 000000000000..471f6efa1754
@@ -0,0 +1,174 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6328-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM6328 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm6328-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm6328-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ serial_led_data, serial_led_clk, inet_act_led, pcie_clkreq,
+                  led, ephy0_act_led, ephy1_act_led, ephy2_act_led,
+                  ephy3_act_led, hsspi_cs1, usb_device_port, usb_host_port ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ gpio6, gpio7, gpio11, gpio16, gpio17, gpio18, gpio19,
+                  gpio20, gpio25, gpio26, gpio27, gpio28, hsspi_cs1,
+                  usb_port1 ]
+

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 81

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +10 -0
+required:
+  - compatible
+  - gpio
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@10000080 {
+      compatible = "brcm,bcm6328-gpio-controller", "syscon", "simple-mfd";

You just added "brcm,bcm6328-gpio-controller", it would need to be documented.

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 88

Quoted 7 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +7 -0
+      reg = <0x10000080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6328-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6328-gpio";

I'm still trying to understand why you need 3 levels of nodes here? The gpio controller contains a pin controller plus other undefined functions (because of 'syscon') and the pin controller contains a gpio controller?

I think "brcm,bcm6328-gpio-controller" and "brcm,bcm6328-pinctrl" should be a single node.

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 90

Quoted 2 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +2 -0
+          data = <0xc>;
+          dirout = <0x4>;

This looks similar to the brcm,bcm6345-gpio.txt binding which then uses the gpio-mmio driver. Defining addresses with 'reg' is much preferred over custom properties. That binding also captures the bank size.

Rob

#9 lore raw

Re: [PATCH v6 03/15] pinctrl: bcm: add bcm63xx base code

In reply to Álvaro Fernández Rojas
Quoted 2 lines · Álvaro Fernández Rojas

Add a helper for registering BCM63XX pin controllers.

Comments below based on my binding changes suggested.

Quoted 84 lines

---
v6: add changes suggested by Andy Shevchenko
v5: add changes suggested by Andy Shevchenko
v4: drop IRQ selects from Kconfig and add missing of_node_put()
v3: add new patch with shared code

 drivers/pinctrl/bcm/Kconfig           |   7 ++
 drivers/pinctrl/bcm/Makefile          |   1 +
 drivers/pinctrl/bcm/pinctrl-bcm63xx.c | 113 ++++++++++++++++++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm63xx.h |  43 ++++++++++
 4 files changed, 164 insertions(+)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63xx.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63xx.h
drivers/pinctrl/bcm/Kconfig +7 -0
index 0ed14de0134c..882f19bdc243 100644
@@ -29,6 +29,13 @@ config PINCTRL_BCM2835
        help
           Say Y here to enable the Broadcom BCM2835 GPIO driver.
 
+config PINCTRL_BCM63XX
+       bool
+       select GENERIC_PINCONF
+       select GPIO_REGMAP
+       select PINCONF
+       select PINMUX
+
 config PINCTRL_IPROC_GPIO
        bool "Broadcom iProc GPIO (with PINCONF) driver"
        depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +1 -0
index 79d5e49fdd9a..0e3cf9b15c65 100644
@@ -3,6 +3,7 @@
 
 obj-$(CONFIG_PINCTRL_BCM281XX)         += pinctrl-bcm281xx.o
 obj-$(CONFIG_PINCTRL_BCM2835)          += pinctrl-bcm2835.o
+obj-$(CONFIG_PINCTRL_BCM63XX)          += pinctrl-bcm63xx.o
 obj-$(CONFIG_PINCTRL_IPROC_GPIO)       += pinctrl-iproc-gpio.o
 obj-$(CONFIG_PINCTRL_CYGNUS_MUX)       += pinctrl-cygnus-mux.o
 obj-$(CONFIG_PINCTRL_NS)               += pinctrl-ns.o
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +30 -0
new file mode 100644
index 000000000000..2eaac8e6f79f
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Driver for BCM63xx GPIO unit (pinctrl + GPIO)
+ *
+ * Copyright (C) 2021 Álvaro Fernández Rojas <[email protected]>
+ * Copyright (C) 2016 Jonas Gorski <[email protected]>
+ */
+
+#include <linux/gpio/regmap.h>
+#include <linux/mfd/syscon.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+#include "pinctrl-bcm63xx.h"
+
+#define BCM63XX_BANK_SIZE      4
+
+#define BCM63XX_DIROUT_REG     0x04
+#define BCM63XX_DATA_REG       0x0c
+
+static int bcm63xx_reg_mask_xlate(struct gpio_regmap *gpio,
+                                 unsigned int base, unsigned int offset,
+                                 unsigned int *reg, unsigned int *mask)
+{
+       unsigned int line = offset % BCM63XX_BANK_GPIOS;
+       unsigned int stride = offset / BCM63XX_BANK_GPIOS;
+
+       *reg = base - stride * BCM63XX_BANK_SIZE;
+       *mask = BIT(line);
+

drivers/pinctrl/bcm/pinctrl-bcm63xx.c line 40

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +10 -0
+       return 0;
+}
+
+static const struct of_device_id bcm63xx_gpio_of_match[] = {
+       { .compatible = "brcm,bcm6318-gpio", },
+       { .compatible = "brcm,bcm6328-gpio", },
+       { .compatible = "brcm,bcm6358-gpio", },
+       { .compatible = "brcm,bcm6362-gpio", },
+       { .compatible = "brcm,bcm6368-gpio", },
+       { .compatible = "brcm,bcm63268-gpio", },

All these would be moved to gpio-mmio.c (or maybe that can have a fallback compatible?).

Quoted 16 lines
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +16 -0
+       { /* sentinel */ }
+};
+
+static int bcm63xx_gpio_probe(struct device *dev,
+                             struct fwnode_handle *node,
+                             const struct bcm63xx_pinctrl_soc *soc,
+                             struct bcm63xx_pinctrl *pc)
+{
+       struct gpio_regmap_config grc = {0};
+
+       grc.parent = dev;
+       grc.fwnode = node;
+       grc.ngpio = soc->ngpios;
+       grc.ngpio_per_reg = BCM63XX_BANK_GPIOS;
+       grc.regmap = pc->regs;
+       grc.reg_mask_xlate = bcm63xx_reg_mask_xlate;

drivers/pinctrl/bcm/pinctrl-bcm63xx.c line 66

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +10 -0
+
+       if (fwnode_property_read_u32(node, "data", &grc.reg_dat_base))
+               grc.reg_dat_base = BCM63XX_DATA_REG;
+       grc.reg_set_base = grc.reg_dat_base;
+
+       if (fwnode_property_read_u32(node, "dirout", &grc.reg_dir_out_base))
+               grc.reg_dir_out_base = BCM63XX_DIROUT_REG;
+
+       return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &grc));
+}

This function can go.

Quoted 27 lines
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +27 -0
+
+int bcm63xx_pinctrl_probe(struct platform_device *pdev,
+                         const struct bcm63xx_pinctrl_soc *soc,
+                         void *driver_data)
+{
+       struct device *dev = &pdev->dev;
+       struct bcm63xx_pinctrl *pc;
+       struct fwnode_handle *node;
+       int err;
+
+       pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
+       if (!pc)
+               return -ENOMEM;
+
+       platform_set_drvdata(pdev, pc);
+
+       pc->dev = dev;
+       pc->driver_data = driver_data;
+
+       pc->regs = syscon_node_to_regmap(dev->parent->of_node);
+       if (IS_ERR(pc->regs))
+               return PTR_ERR(pc->regs);
+
+       pc->pctl_desc.name = dev_name(dev);
+       pc->pctl_desc.pins = soc->pins;
+       pc->pctl_desc.npins = soc->npins;
+       pc->pctl_desc.pctlops = soc->pctl_ops;

drivers/pinctrl/bcm/pinctrl-bcm63xx.c line 103

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +10 -0
+       pc->pctl_desc.pmxops = soc->pmx_ops;
+       pc->pctl_desc.owner = THIS_MODULE;
+
+       pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc);
+       if (IS_ERR(pc->pctl_dev))
+               return PTR_ERR(pc->pctl_dev);
+
+       device_for_each_child_node(dev, node) {
+               if (of_match_node(bcm63xx_gpio_of_match, to_of_node(node))) {
+                       err = bcm63xx_gpio_probe(dev, node, soc, pc);

This would just need an of_platform_populate call.

Quoted 62 lines
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +10 -0
+                       if (err) {
+                               dev_err(dev, "could not add GPIO chip\n");
+                               fwnode_handle_put(node);
+                               return err;
+                       }
+               }
+       }
+
+       return 0;
+}
drivers/pinctrl/bcm/pinctrl-bcm63xx.h new file +43 -1
new file mode 100644
index 000000000000..3bdb50021f1b
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Álvaro Fernández Rojas <[email protected]>
+ * Copyright (C) 2016 Jonas Gorski <[email protected]>
+ */
+
+#ifndef __PINCTRL_BCM63XX_H__
+#define __PINCTRL_BCM63XX_H__
+
+#include <linux/pinctrl/pinctrl.h>
+
+#define BCM63XX_BANK_GPIOS 32
+
+struct bcm63xx_pinctrl_soc {
+       struct pinctrl_ops *pctl_ops;
+       struct pinmux_ops *pmx_ops;
+
+       const struct pinctrl_pin_desc *pins;
+       unsigned npins;
+
+       unsigned int ngpios;
+};
+
+struct bcm63xx_pinctrl {
+       struct device *dev;
+       struct regmap *regs;
+
+       struct pinctrl_desc pctl_desc;
+       struct pinctrl_dev *pctl_dev;
+
+       void *driver_data;
+};
+
+static inline unsigned int bcm63xx_bank_pin(unsigned int pin)
+{
+       return pin % BCM63XX_BANK_GPIOS;
+}
+
+int bcm63xx_pinctrl_probe(struct platform_device *pdev,
+                         const struct bcm63xx_pinctrl_soc *soc,
+                         void *driver_data);
+
+#endif /* __PINCTRL_BCM63XX_H__ */
--

2.20.1

#18 lore raw

Re: [PATCH v6 04/15] dt-bindings: add BCM6328 pincontroller binding documentation

In reply to Rob Herring

Hi Rob,

Quoted 102 lines · Rob Herring
Quoted 98 lines · Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in BCM6328 SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

.../pinctrl/brcm,bcm6328-pinctrl.yaml | 174 ++++++++++++++++++

1 file changed, 174 insertions(+)

create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +75 -0
new file mode 100644
index 000000000000..471f6efa1754
@@ -0,0 +1,174 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6328-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM6328 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm6328-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm6328-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ serial_led_data, serial_led_clk, inet_act_led, pcie_clkreq,
+                  led, ephy0_act_led, ephy1_act_led, ephy2_act_led,
+                  ephy3_act_led, hsspi_cs1, usb_device_port, usb_host_port ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ gpio6, gpio7, gpio11, gpio16, gpio17, gpio18, gpio19,
+                  gpio20, gpio25, gpio26, gpio27, gpio28, hsspi_cs1,
+                  usb_port1 ]
+
+required:
+  - compatible
+  - gpio
+
Quoted 8 lines

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 81

Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +6 -0
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@10000080 {
+      compatible = "brcm,bcm6328-gpio-controller", "syscon", "simple-mfd";

You just added "brcm,bcm6328-gpio-controller", it would need to be documented.

I just added that because you requested me to do it ¯\_(ツ)_/¯ What should I do to document it?
I still don’t get most of this .yaml stuff...

Quoted 13 lines

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 88

Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +7 -0
+      reg = <0x10000080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6328-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6328-gpio";

I'm still trying to understand why you need 3 levels of nodes here? The gpio controller contains a pin controller plus other undefined functions (because of 'syscon') and the pin controller contains a gpio controller?

In previous versions the gpio controller was registered along with the pin controller, but @Linus requested me to register the gpio pin controller ranges through device tree by using gpio-ranges and I decided to use this approach, which was already used by other pin controllers. However, there aren’t any pinctrl drivers using gpio-regmap, so this is kind of new…

Quoted 3 lines

I think "brcm,bcm6328-gpio-controller" and "brcm,bcm6328-pinctrl" should be a single node.

I agree, but does it make sense to add gpio-ranges to a pinctrl node referencing itself? Something like:

syscon {
	pinctrl: pinctrl {
		compatible …

		gpio-controller;
		gpio-ranges = <&pinctrl 0 0 32>;
		#gpio-cells = <2>;

		…
	};
};
Quoted 8 lines

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 90

Quoted 3 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +2 -0
+          data = <0xc>;
+          dirout = <0x4>;

This looks similar to the brcm,bcm6345-gpio.txt binding which then uses the gpio-mmio driver. Defining addresses with 'reg' is much preferred over custom properties. That binding also captures the bank size.

It’s similar, but Linus requested to use gpio regmap because we had a large amount of registers, so we’re not using it.

Quoted 2 lines

Rob

Best regards,
Álvaro.

#4 lore raw

Re: [PATCH v6 02/15] gpio: regmap: set gpio_chip of_node

In reply to Álvaro Fernández Rojas

Am 2021-03-10 13:54, schrieb Álvaro Fernández Rojas:

Quoted 7 lines

This is needed for properly registering GPIO regmap as a child of a regmap pin controller.

---
v6: add comment and simplify of_node assignment

Ah, I see you add the comment for the documentation. Nice. But I'd like to see it in the code, too. See below.

Quoted 15 lines

v5: switch to fwnode
v4: fix documentation
v3: introduce patch needed for properly parsing gpio-range

 drivers/gpio/gpio-regmap.c  | 1 +
 include/linux/gpio/regmap.h | 4 ++++
 2 files changed, 5 insertions(+)
drivers/gpio/gpio-regmap.c +0 -0
index 5412cb3b0b2a..d4fc656e70b0 100644
@@ -249,6 +249,7 @@ struct gpio_regmap *gpio_regmap_register(const

struct gpio_regmap_config *config

drivers/gpio/gpio-regmap.c struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config · line 251

Quoted 2 lines
drivers/gpio/gpio-regmap.c +0 -0
 	chip = &gpio->gpio_chip;
 	chip->parent = config->parent;

If there will be a new version, please add the following comment:

/* gpiolib will use of_node of the parent if chip->of_node is NULL */

Quoted 1 line
Quoted 1 line

+ chip->of_node = to_of_node(config->fwnode);

Otherwise, it is not obvious that config->fwnode is optional.

-michael

Quoted 33 lines
drivers/gpio/gpio-regmap.c +1 -0
+	chip->of_node = to_of_node(config->fwnode);
 	chip->base = -1;
 	chip->ngpio = config->ngpio;
 	chip->names = config->names;
include/linux/gpio/regmap.h +4 -0
index ad76f3d0a6ba..334dd928042b 100644
@@ -4,6 +4,7 @@
 #define _LINUX_GPIO_REGMAP_H
 
 struct device;
+struct fwnode_handle;
 struct gpio_regmap;
 struct irq_domain;
 struct regmap;
@@ -16,6 +17,8 @@ struct regmap;
  * @parent:		The parent device
  * @regmap:		The regmap used to access the registers
  *			given, the name of the device is used
+ * @fwnode:		(Optional) The firmware node.
+ *			If not given, the fwnode of the parent is used.
  * @label:		(Optional) Descriptive name for GPIO controller.
  *			If not given, the name of the device is used.
  * @ngpio:		Number of GPIOs
@@ -57,6 +60,7 @@ struct regmap;
 struct gpio_regmap_config {
 	struct device *parent;
 	struct regmap *regmap;
+	struct fwnode_handle *fwnode;
 
 	const char *label;
 	int ngpio;
#19 lore raw

Re: [PATCH v6 04/15] dt-bindings: add BCM6328 pincontroller binding documentation

In reply to Álvaro Fernández Rojas
Quoted 114 lines · Álvaro Fernández Rojas

Hi Rob,

Quoted 102 lines · Rob Herring
Quoted 98 lines · Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in BCM6328 SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

.../pinctrl/brcm,bcm6328-pinctrl.yaml | 174 ++++++++++++++++++

1 file changed, 174 insertions(+)

create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +75 -0
new file mode 100644
index 000000000000..471f6efa1754
@@ -0,0 +1,174 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6328-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM6328 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm6328-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm6328-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ serial_led_data, serial_led_clk, inet_act_led, pcie_clkreq,
+                  led, ephy0_act_led, ephy1_act_led, ephy2_act_led,
+                  ephy3_act_led, hsspi_cs1, usb_device_port, usb_host_port ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ gpio6, gpio7, gpio11, gpio16, gpio17, gpio18, gpio19,
+                  gpio20, gpio25, gpio26, gpio27, gpio28, hsspi_cs1,
+                  usb_port1 ]
+
+required:
+  - compatible
+  - gpio
+
Quoted 8 lines

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 81

Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +6 -0
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@10000080 {
+      compatible = "brcm,bcm6328-gpio-controller", "syscon", "simple-mfd";

You just added "brcm,bcm6328-gpio-controller", it would need to be documented.

Quoted 1 line

I just added that because you requested me to do it ¯\_(ツ)_/¯

I said 'syscon' by itself was not allowed, then asked about the multiple levels.

Quoted 17 lines

What should I do to document it?
I still don’t get most of this .yaml stuff...

Quoted 13 lines

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 88

Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +7 -0
+      reg = <0x10000080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6328-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6328-gpio";

I'm still trying to understand why you need 3 levels of nodes here? The gpio controller contains a pin controller plus other undefined functions (because of 'syscon') and the pin controller contains a gpio controller?

Quoted 8 lines

In previous versions the gpio controller was registered along with the pin controller, but @Linus requested me to register the gpio pin controller ranges through device tree by using gpio-ranges and I decided to use this approach, which was already used by other pin controllers. However, there aren’t any pinctrl drivers using gpio-regmap, so this is kind of new…

Quoted 3 lines

I think "brcm,bcm6328-gpio-controller" and "brcm,bcm6328-pinctrl" should be a single node.

I agree, but does it make sense to add gpio-ranges to a pinctrl node referencing itself?

It wouldn't be. I wasn't saying the pinctrl and gpio controller are the same node. My suggestion was combining syscon and pinctrl.

Quoted 2 lines

Something like:
syscon {

Again with the syscon. If pinctrl and GPIO are the only functions within this h/w block, then this is not a syscon. You are just abusing that having 'syscon' compatible means you get a regmap created automagically for you. Nothing here looks like a 'system controller' to me. A 'system controller' is a random collection of register bits with functions that don't fit anywhere else.

Quoted 6 lines
        pinctrl: pinctrl {
                compatible …

                gpio-controller;
                gpio-ranges = <&pinctrl 0 0 32>;
                #gpio-cells = <2>;

I was assuming you have multiple GPIO controllers within 1 pinctlr? The pinctrl and gpio could be a single node like above if there's only 1 GPIO controller. But I'm still somewhat guessing what the h/w looks like because I have to go searching thru the driver to decipher. Please describe the h/w in the binding.

If there's more than 1 GPIO controller, then I'd imagine you have something like this:

pinctrl {
...
reg = <base 0x80>;
ranges = <0 base 0x80;

  gpio@4 {
    reg = <4 4>, <c 4>;
    reg-names = "dirout", "dat";

};
gpio@? {};

foo-pins {};
};

Quoted 9 lines
                …
        };
};
Quoted 4 lines
Quoted 3 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +2 -0
+          data = <0xc>;
+          dirout = <0x4>;
Quoted 6 lines
Quoted 4 lines

This looks similar to the brcm,bcm6345-gpio.txt binding which then uses the gpio-mmio driver. Defining addresses with 'reg' is much preferred over custom properties. That binding also captures the bank size.

It’s similar, but Linus requested to use gpio regmap because we had a large amount of registers, so we’re not using it.

Looks like you have 2 registers to me.

Rob

#20 lore raw

Re: [PATCH v6 04/15] dt-bindings: add BCM6328 pincontroller binding documentation

Hi Rob,

Quoted 118 lines · Rob Herring
Quoted 114 lines · Álvaro Fernández Rojas

Hi Rob,

Quoted 110 lines · Rob Herring
Quoted 94 lines · Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in BCM6328 SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

.../pinctrl/brcm,bcm6328-pinctrl.yaml | 174 ++++++++++++++++++

1 file changed, 174 insertions(+)

create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +71 -0
new file mode 100644
index 000000000000..471f6efa1754
@@ -0,0 +1,174 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6328-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM6328 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm6328-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm6328-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ serial_led_data, serial_led_clk, inet_act_led, pcie_clkreq,
+                  led, ephy0_act_led, ephy1_act_led, ephy2_act_led,
+                  ephy3_act_led, hsspi_cs1, usb_device_port, usb_host_port ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ gpio6, gpio7, gpio11, gpio16, gpio17, gpio18, gpio19,
+                  gpio20, gpio25, gpio26, gpio27, gpio28, hsspi_cs1,
+                  usb_port1 ]
+

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 81

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +10 -0
+required:
+  - compatible
+  - gpio
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@10000080 {
+      compatible = "brcm,bcm6328-gpio-controller", "syscon", "simple-mfd";

You just added "brcm,bcm6328-gpio-controller", it would need to be documented.

Quoted 3 lines
Quoted 1 line

I just added that because you requested me to do it ¯\_(ツ)_/¯

I said 'syscon' by itself was not allowed, then asked about the multiple levels.

Why not?
What if you have several controllers inside a syscon? The root should also have “something" in it?

Quoted 22 lines
Quoted 22 lines

What should I do to document it?
I still don’t get most of this .yaml stuff...

Quoted 13 lines

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 88

Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +7 -0
+      reg = <0x10000080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6328-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6328-gpio";

I'm still trying to understand why you need 3 levels of nodes here? The gpio controller contains a pin controller plus other undefined functions (because of 'syscon') and the pin controller contains a gpio controller?

In previous versions the gpio controller was registered along with the pin controller, but @Linus requested me to register the gpio pin controller ranges through device tree by using gpio-ranges and I decided to use this approach, which was already used by other pin controllers. However, there aren’t any pinctrl drivers using gpio-regmap, so this is kind of new…

Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I think "brcm,bcm6328-gpio-controller" and "brcm,bcm6328-pinctrl" should be a single node.

I agree, but does it make sense to add gpio-ranges to a pinctrl node referencing itself?

It wouldn't be. I wasn't saying the pinctrl and gpio controller are the same node. My suggestion was combining syscon and pinctrl.

But that wouldn’t be correct if there were more “things” inside the syscon, right?

Quoted 10 lines
Quoted 3 lines

Something like:
syscon {

Again with the syscon. If pinctrl and GPIO are the only functions within this h/w block, then this is not a syscon. You are just abusing that having 'syscon' compatible means you get a regmap created automagically for you. Nothing here looks like a 'system controller' to me. A 'system controller' is a random collection of register bits with functions that don't fit anywhere else.

pinctrl and GPIO aren’t the only functions within this HW block.
Maybe I didn’t document/code it properly, but I’m sure I’m not abusing what a system controller is.
Please, take a look at http://www.datashed.science/misc/bcm/gpl/broadcom-sdk-416L05/shared/opensource/include/bcm963xx/6328_map_part.h:
typedef struct GpioControl {

    uint32      GPIODirHi;                  /* 0 */
    uint32      GPIODir;                    /* 4 */
    uint32      GPIOioHi;                   /* 8 */
    uint32      GPIOio;                     /* C */
    uint32      unused0;                    /* 10 */
    uint32      SpiSlaveCfg;                /* 14 */
    uint32      GPIOMode;                   /* 18 */
    uint64      PinMuxSel;                  /* 1C */
    uint32      PinMuxSelOther;             /* 24 */
    uint32      TestControl;                /* 28 */
    uint32      unused2;                    /* 2C */
    uint32      RoboSWLEDControl;           /* 30 */
    uint32      RoboSWLEDLSR;               /* 34 */
    uint32      unused3;                    /* 38 */
    uint32      RoboswEphyCtrl;             /* 3C */
    uint32      RoboswSwitchCtrl;           /* 40 */
    uint32      RegFileTmCtl;               /* 44 */
    uint32      RingOscCtrl0;               /* 48 */
    uint32      RingOscCtrl1;               /* 4C */
    uint32      unused4[6];                 /* 50 - 64 */
    uint32      DieRevID;                   /* 68 */
    uint32      unused5;                    /* 6c */
    uint32      DiagSelControl;             /* 70 */
    uint32      DiagReadBack;               /* 74 */
    uint32      DiagReadBackHi;             /* 78 */
    uint32      DiagMiscControl;            /* 7c */

} GpioControl;

So we’re using GPIODirHi, GPIODir, GPIOioHi and GPIOio registers for GPIO regmap driver. And we’re using GPIOMode, PinMuxSel (u64 -> x2 u32), PinMuxSelOther for pinctrl driver. And this is for BCM6328, but some of the other SoCs are even more scattered.

Quoted 8 lines
Quoted 7 lines
       pinctrl: pinctrl {
               compatible …

               gpio-controller;
               gpio-ranges = <&pinctrl 0 0 32>;
               #gpio-cells = <2>;
Quoted 5 lines

I was assuming you have multiple GPIO controllers within 1 pinctlr? The pinctrl and gpio could be a single node like above if there's only 1 GPIO controller. But I'm still somewhat guessing what the h/w looks like because I have to go searching thru the driver to decipher. Please describe the h/w in the binding.

GPIO dirout and data rely on 2x u32 registers or a single u64 register.
This is can be either be implemented as a single GPIO controller, or as 2 separate GPIO controllers.
However, since I’m overriding reg_mask_xlate with bcm63xx_reg_mask_xlate I can register it as a single GPIO controller, which makes more sense to me.

Quoted 26 lines

If there's more than 1 GPIO controller, then I'd imagine you have something like this:

pinctrl {
...
reg = <base 0x80>;
ranges = <0 base 0x80;

 gpio@4 {
   reg = <4 4>, <c 4>;
   reg-names = "dirout", "dat";

};
gpio@? {};

foo-pins {};
};

Quoted 9 lines
               …
       };
};
Quoted 4 lines
Quoted 3 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +2 -0
+          data = <0xc>;
+          dirout = <0x4>;
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

This looks similar to the brcm,bcm6345-gpio.txt binding which then uses the gpio-mmio driver. Defining addresses with 'reg' is much preferred over custom properties. That binding also captures the bank size.

It’s similar, but Linus requested to use gpio regmap because we had a large amount of registers, so we’re not using it.

Looks like you have 2 registers to me.

For the GPIO controller there are 4 registers (data high and low, and dirout high and low). For the pinctrl there are 3 registers (Pinmux high, low and other).

Quoted 2 lines

Rob

Best regards,
Álvaro.

#5 lore raw

Re: [PATCH v6 02/15] gpio: regmap: set gpio_chip of_node

In reply to Michael Walle

Hi Michael,

Quoted 10 lines · Michael Walle

Am 2021-03-10 13:54, schrieb Álvaro Fernández Rojas:

Quoted 6 lines

This is needed for properly registering GPIO regmap as a child of a regmap pin controller.

---
v6: add comment and simplify of_node assignment

Quoted 2 lines

Ah, I see you add the comment for the documentation. Nice. But I'd like to see it in the code, too. See below.

Ah, sorry for that, I thought you wanted it on the header. Excuse me for that...

Quoted 17 lines
Quoted 13 lines

v5: switch to fwnode
v4: fix documentation
v3: introduce patch needed for properly parsing gpio-range drivers/gpio/gpio-regmap.c | 1 + include/linux/gpio/regmap.h | 4 ++++

2 files changed, 5 insertions(+)
drivers/gpio/gpio-regmap.c +0 -0
index 5412cb3b0b2a..d4fc656e70b0 100644
@@ -249,6 +249,7 @@ struct gpio_regmap *gpio_regmap_register(const

struct gpio_regmap_config *config

Quoted 2 lines
	chip = &gpio->gpio_chip;
	chip->parent = config->parent;

If there will be a new version, please add the following comment:

Right now I don’t know that either, because I’m honestly getting tired of this…

Quoted 6 lines

/* gpiolib will use of_node of the parent if chip->of_node is NULL */

Quoted 1 line
Quoted 1 line

+ chip->of_node = to_of_node(config->fwnode);

Otherwise, it is not obvious that config->fwnode is optional.

Yes, you’re right.

Quoted 34 lines

-michael

Quoted 31 lines
drivers/gpio/gpio-regmap.c +1 -0
+	chip->of_node = to_of_node(config->fwnode);
	chip->base = -1;
	chip->ngpio = config->ngpio;
	chip->names = config->names;
include/linux/gpio/regmap.h +4 -0
index ad76f3d0a6ba..334dd928042b 100644
@@ -4,6 +4,7 @@
 #define _LINUX_GPIO_REGMAP_H
 struct device;
+struct fwnode_handle;
 struct gpio_regmap;
 struct irq_domain;
 struct regmap;
@@ -16,6 +17,8 @@ struct regmap;
 * @parent:		The parent device
 * @regmap:		The regmap used to access the registers
 *			given, the name of the device is used
+ * @fwnode:		(Optional) The firmware node.
+ *			If not given, the fwnode of the parent is used.
 * @label:		(Optional) Descriptive name for GPIO controller.
 *			If not given, the name of the device is used.
 * @ngpio:		Number of GPIOs
@@ -57,6 +60,7 @@ struct regmap;
 struct gpio_regmap_config {
 	struct device *parent;
 	struct regmap *regmap;
+	struct fwnode_handle *fwnode;
 	const char *label;
 	int ngpio;
#21 lore raw

Re: [PATCH v6 04/15] dt-bindings: add BCM6328 pincontroller binding documentation

In reply to Álvaro Fernández Rojas
Quoted 121 lines · Álvaro Fernández Rojas

Hi Rob,

Quoted 118 lines · Rob Herring
Quoted 114 lines · Álvaro Fernández Rojas

Hi Rob,

Quoted 110 lines · Rob Herring
Quoted 94 lines · Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in BCM6328 SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

.../pinctrl/brcm,bcm6328-pinctrl.yaml | 174 ++++++++++++++++++

1 file changed, 174 insertions(+)

create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +71 -0
new file mode 100644
index 000000000000..471f6efa1754
@@ -0,0 +1,174 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6328-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM6328 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm6328-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm6328-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ serial_led_data, serial_led_clk, inet_act_led, pcie_clkreq,
+                  led, ephy0_act_led, ephy1_act_led, ephy2_act_led,
+                  ephy3_act_led, hsspi_cs1, usb_device_port, usb_host_port ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ gpio6, gpio7, gpio11, gpio16, gpio17, gpio18, gpio19,
+                  gpio20, gpio25, gpio26, gpio27, gpio28, hsspi_cs1,
+                  usb_port1 ]
+

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 81

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +10 -0
+required:
+  - compatible
+  - gpio
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@10000080 {
+      compatible = "brcm,bcm6328-gpio-controller", "syscon", "simple-mfd";

You just added "brcm,bcm6328-gpio-controller", it would need to be documented.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I just added that because you requested me to do it ¯\_(ツ)_/¯

I said 'syscon' by itself was not allowed, then asked about the multiple levels.

Why not?

Because 'syscon' alone doesn't mean anything and doesn't describe what registers it contains. You need something that says this is the XYZ block in the ABC SoC.

Quoted 1 line

What if you have several controllers inside a syscon?

You either just add properties (e.g. just add #clock-cells and it's a clock provider) or you have child nodes. Which one you do generally depends on if the providers have DT resources themselves.

Quoted 27 lines

The root should also have “something" in it?

Quoted 25 lines
Quoted 25 lines

What should I do to document it?
I still don’t get most of this .yaml stuff...

Quoted 13 lines

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 88

Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +7 -0
+      reg = <0x10000080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6328-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6328-gpio";

I'm still trying to understand why you need 3 levels of nodes here? The gpio controller contains a pin controller plus other undefined functions (because of 'syscon') and the pin controller contains a gpio controller?

In previous versions the gpio controller was registered along with the pin controller, but @Linus requested me to register the gpio pin controller ranges through device tree by using gpio-ranges and I decided to use this approach, which was already used by other pin controllers. However, there aren’t any pinctrl drivers using gpio-regmap, so this is kind of new…

Quoted 3 lines

I think "brcm,bcm6328-gpio-controller" and "brcm,bcm6328-pinctrl" should be a single node.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

I agree, but does it make sense to add gpio-ranges to a pinctrl node referencing itself?

It wouldn't be. I wasn't saying the pinctrl and gpio controller are the same node. My suggestion was combining syscon and pinctrl.

But that wouldn’t be correct if there were more “things” inside the syscon, right?

Right.

Quoted 10 lines
Quoted 9 lines
Quoted 2 lines

Something like:
syscon {

Again with the syscon. If pinctrl and GPIO are the only functions within this h/w block, then this is not a syscon. You are just abusing that having 'syscon' compatible means you get a regmap created automagically for you. Nothing here looks like a 'system controller' to me. A 'system controller' is a random collection of register bits with functions that don't fit anywhere else.

Quoted 2 lines

pinctrl and GPIO aren’t the only functions within this HW block.
Maybe I didn’t document/code it properly, but I’m sure I’m not abusing what a system controller is.

Okay, that's the detail missing from this patch.

Quoted 28 lines

Please, take a look at http://www.datashed.science/misc/bcm/gpl/broadcom-sdk-416L05/shared/opensource/include/bcm963xx/6328_map_part.h:
typedef struct GpioControl {

    uint32      GPIODirHi;                  /* 0 */
    uint32      GPIODir;                    /* 4 */
    uint32      GPIOioHi;                   /* 8 */
    uint32      GPIOio;                     /* C */
    uint32      unused0;                    /* 10 */
    uint32      SpiSlaveCfg;                /* 14 */
    uint32      GPIOMode;                   /* 18 */
    uint64      PinMuxSel;                  /* 1C */
    uint32      PinMuxSelOther;             /* 24 */
    uint32      TestControl;                /* 28 */
    uint32      unused2;                    /* 2C */
    uint32      RoboSWLEDControl;           /* 30 */
    uint32      RoboSWLEDLSR;               /* 34 */
    uint32      unused3;                    /* 38 */
    uint32      RoboswEphyCtrl;             /* 3C */
    uint32      RoboswSwitchCtrl;           /* 40 */
    uint32      RegFileTmCtl;               /* 44 */
    uint32      RingOscCtrl0;               /* 48 */
    uint32      RingOscCtrl1;               /* 4C */
    uint32      unused4[6];                 /* 50 - 64 */
    uint32      DieRevID;                   /* 68 */
    uint32      unused5;                    /* 6c */
    uint32      DiagSelControl;             /* 70 */
    uint32      DiagReadBack;               /* 74 */
    uint32      DiagReadBackHi;             /* 78 */
    uint32      DiagMiscControl;            /* 7c */
Quoted 5 lines

} GpioControl;

So we’re using GPIODirHi, GPIODir, GPIOioHi and GPIOio registers for GPIO regmap driver. And we’re using GPIOMode, PinMuxSel (u64 -> x2 u32), PinMuxSelOther for pinctrl driver. And this is for BCM6328, but some of the other SoCs are even more scattered.

So based on this I'd do something like this:

syscon {
reg = <base 0x80>;
ranges = <0 base 0x80>;

  pinctrl@18 {
    reg = <0x18 0x10>;
    foo-pins {};
  gpio@0 {
    reg = <0x0 0x10>;

};
};

If things are more scattered within gpio or pinctrl, then maybe you need multiple reg entries. Whether the OS uses 'reg' and mmio or a regmap from the syscon is up to you. That's independent of the binding.

Quoted 13 lines
Quoted 7 lines
Quoted 6 lines
       pinctrl: pinctrl {
               compatible …

               gpio-controller;
               gpio-ranges = <&pinctrl 0 0 32>;
               #gpio-cells = <2>;
Quoted 5 lines

I was assuming you have multiple GPIO controllers within 1 pinctlr? The pinctrl and gpio could be a single node like above if there's only 1 GPIO controller. But I'm still somewhat guessing what the h/w looks like because I have to go searching thru the driver to decipher. Please describe the h/w in the binding.

Quoted 3 lines

GPIO dirout and data rely on 2x u32 registers or a single u64 register.
This is can be either be implemented as a single GPIO controller, or as 2 separate GPIO controllers.
However, since I’m overriding reg_mask_xlate with bcm63xx_reg_mask_xlate I can register it as a single GPIO controller, which makes more sense to me.

I think 1 makes more sense.

Rob

#10 lore raw

Re: [PATCH v6 03/15] pinctrl: bcm: add bcm63xx base code

In reply to Rob Herring
Quoted 10 lines · Rob Herring

drivers/pinctrl/bcm/pinctrl-bcm63xx.c line 40

Quoted 7 lines
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +7 -0
+static const struct of_device_id bcm63xx_gpio_of_match[] = {
+       { .compatible = "brcm,bcm6318-gpio", },
+       { .compatible = "brcm,bcm6328-gpio", },
+       { .compatible = "brcm,bcm6358-gpio", },
+       { .compatible = "brcm,bcm6362-gpio", },
+       { .compatible = "brcm,bcm6368-gpio", },
+       { .compatible = "brcm,bcm63268-gpio", },

All these would be moved to gpio-mmio.c (or maybe that can have a fallback compatible?).

This is gpio-regmap.c and it can only be used as a library by a certain driver. gpio-mmio.c can be used stand-alone for certain really simple hardware (though most use that as a library as well).

Yours,
Linus Walleij

#6 lore raw

Re: [PATCH v6 02/15] gpio: regmap: set gpio_chip of_node

In reply to Álvaro Fernández Rojas
Quoted 3 lines · Álvaro Fernández Rojas
Quoted 1 line

If there will be a new version, please add the following comment:

Right now I don’t know that either, because I’m honestly getting tired of this…

IMO there is indeed such a thing as over-review when it comes to migrating legacy platforms: as subsystem maintainer I ask the bigger
question: does the kernel look better after than before this patch? If the author is stressed by too much review I tend to just apply it and say that comments can be addressed by additional patches.

DT bindings are different because they are written in stone. We just need to settle the DT bindings. Give the patch set some rest and come back and poke me to apply it when the chatter stops.

Yours,
Linus Walleij

#26 lore raw

Re: [PATCH v6 04/15] dt-bindings: add BCM6328 pincontroller binding documentation

In reply to Álvaro Fernández Rojas
Quoted 15 lines · Álvaro Fernández Rojas
Quoted 14 lines · Rob Herring

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 88

Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +7 -0
+      reg = <0x10000080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6328-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6328-gpio";

I'm still trying to understand why you need 3 levels of nodes here? The gpio controller contains a pin controller plus other undefined functions (because of 'syscon') and the pin controller contains a gpio controller?

Quoted 2 lines

In previous versions the gpio controller was registered along with the pin controller, but @Linus requested me to register the gpio pin controller ranges through device tree by using gpio-ranges and I decided to use this approach, which was already used by other pin controllers. However, there aren’t any pinctrl drivers using gpio-regmap, so this is kind of new…

I think the crucial point is that these hardwares (all patches in the series) is very similar and some contain several GPIO blocks rather than just one.

The structure needs to be seen as a common pattern. We are doing this because it gives a common structure to all BCM SoCs in this family, which is nice.

Yours,
Linus Walleij

#11 lore raw

Re: [PATCH v6 03/15] pinctrl: bcm: add bcm63xx base code

In reply to Linus Walleij
Quoted 11 lines · Linus Walleij
Quoted 8 lines · Rob Herring
Quoted 7 lines
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +7 -0
+static const struct of_device_id bcm63xx_gpio_of_match[] = {
+       { .compatible = "brcm,bcm6318-gpio", },
+       { .compatible = "brcm,bcm6328-gpio", },
+       { .compatible = "brcm,bcm6358-gpio", },
+       { .compatible = "brcm,bcm6362-gpio", },
+       { .compatible = "brcm,bcm6368-gpio", },
+       { .compatible = "brcm,bcm63268-gpio", },
Quoted 7 lines
Quoted 2 lines

All these would be moved to gpio-mmio.c (or maybe that can have a fallback compatible?).

This is gpio-regmap.c and it can only be used as a library by a certain driver. gpio-mmio.c can be used stand-alone for certain really simple hardware (though most use that as a library as well).

I don't really care which one is used, but the problem is that this choice is leaking into the binding design. The primary problem here is once someone uses regmap, then they think they must have a syscon and can abandon using 'reg' and normal address properties as Linux happens to not use them (currently). I think we really need some better regmap vs. mmio handling to eliminate this duplication of foo-mmio and foo-regmap drivers and difference in binding design. Not sure exactly what that looks like, but basically some sort of 'reg' property to regmap creation.

Given we already have a Broadcom GPIO binding for what looks to be similar to this one, I'm left wondering what's the real difference here?

Rob

#12 lore raw

Re: [PATCH v6 03/15] pinctrl: bcm: add bcm63xx base code

Quoted 14 lines · Rob Herring
Quoted 13 lines · Linus Walleij
Quoted 10 lines · Rob Herring

drivers/pinctrl/bcm/pinctrl-bcm63xx.c line 40

Quoted 7 lines
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +7 -0
+static const struct of_device_id bcm63xx_gpio_of_match[] = {
+       { .compatible = "brcm,bcm6318-gpio", },
+       { .compatible = "brcm,bcm6328-gpio", },
+       { .compatible = "brcm,bcm6358-gpio", },
+       { .compatible = "brcm,bcm6362-gpio", },
+       { .compatible = "brcm,bcm6368-gpio", },
+       { .compatible = "brcm,bcm63268-gpio", },

All these would be moved to gpio-mmio.c (or maybe that can have a fallback compatible?).

Quoted 7 lines
Quoted 4 lines

This is gpio-regmap.c and it can only be used as a library by a certain driver. gpio-mmio.c can be used stand-alone for certain really simple hardware (though most use that as a library as well).

I don't really care which one is used, but the problem is that this choice is leaking into the binding design.

Aha I guess I misunderstood your comment.

Quoted 8 lines

The primary problem here is
once someone uses regmap, then they think they must have a syscon and can abandon using 'reg' and normal address properties as Linux happens to not use them (currently). I think we really need some better regmap vs. mmio handling to eliminate this duplication of foo-mmio and foo-regmap drivers and difference in binding design. Not sure exactly what that looks like, but basically some sort of 'reg' property to regmap creation.

I see the problem. Yeah we should try to be more strict around these things. To me there are syscons and "other regmaps", where syscon is a real hurdle of registers while "other regmaps" are just regmaps by convenience.

Documentation/devicetree/bindings/mfd/syscon.yaml describes what a syscon really is so if everyone could just read the documentation that would be great ...

Quoted 3 lines

Given we already have a Broadcom GPIO binding for what looks to be similar to this one, I'm left wondering what's the real difference here?

Which one is similar? I can take a look.

We currently have four Broadcom GPIO bindings, which are stand alone GPIO blocks and eight Broadcom pin controllers that all do GPIO as well.

This family of pin controllers are (as per subject) is the bcm63xx series which is a MIPS-based family of SoCs found in routers, top bindings in Documentation/devicetree/bindings/mips/brcm/soc.txt These all have a GPIO block as part of the pin controller and the GPIO block is a distinct sub-function of the pin controller, and it has up to 32 GPIOs per block, hence it has its own subnode inside the pin controller.

This driver follows the pattern of the Ingenic
pin controller, another MIPS SoC:
Documentation/devicetree/bindings/pinctrl/ingenic,pinctrl.yaml

Another SoC with several GPIO blocks inside the pin controller is SparX5 and that also follows this pattern:
Documentation/devicetree/bindings/pinctrl/microchip,sparx5-sgpio.yaml (This has an example with more than one GPIO block
inside the pin controller.)

Yours,
Linus Walleij

#13 lore raw

Re: [PATCH v6 03/15] pinctrl: bcm: add bcm63xx base code

Hi Rob and Linus,

Quoted 43 lines · Linus Walleij
Quoted 14 lines · Rob Herring
Quoted 13 lines · Linus Walleij
Quoted 10 lines · Rob Herring

drivers/pinctrl/bcm/pinctrl-bcm63xx.c line 40

Quoted 7 lines
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +7 -0
+static const struct of_device_id bcm63xx_gpio_of_match[] = {
+       { .compatible = "brcm,bcm6318-gpio", },
+       { .compatible = "brcm,bcm6328-gpio", },
+       { .compatible = "brcm,bcm6358-gpio", },
+       { .compatible = "brcm,bcm6362-gpio", },
+       { .compatible = "brcm,bcm6368-gpio", },
+       { .compatible = "brcm,bcm63268-gpio", },

All these would be moved to gpio-mmio.c (or maybe that can have a fallback compatible?).

Quoted 7 lines
Quoted 4 lines

This is gpio-regmap.c and it can only be used as a library by a certain driver. gpio-mmio.c can be used stand-alone for certain really simple hardware (though most use that as a library as well).

I don't really care which one is used, but the problem is that this choice is leaking into the binding design.

Aha I guess I misunderstood your comment.

Quoted 8 lines

The primary problem here is
once someone uses regmap, then they think they must have a syscon and can abandon using 'reg' and normal address properties as Linux happens to not use them (currently). I think we really need some better regmap vs. mmio handling to eliminate this duplication of foo-mmio and foo-regmap drivers and difference in binding design. Not sure exactly what that looks like, but basically some sort of 'reg' property to regmap creation.

I see the problem. Yeah we should try to be more strict around these things. To me there are syscons and "other regmaps", where syscon is a real hurdle of registers while "other regmaps" are just regmaps by convenience.

Documentation/devicetree/bindings/mfd/syscon.yaml describes what a syscon really is so if everyone could just read the documentation that would be great ...

Quoted 5 lines
Quoted 3 lines

Given we already have a Broadcom GPIO binding for what looks to be similar to this one, I'm left wondering what's the real difference here?

Which one is similar? I can take a look.

@Linus I think @Rob is referring to brcm,bcm6345-gpio:
https://github.com/torvalds/linux/blob/a74e6a014c9d4d4161061f770c9b4f98372ac778/drivers/gpio/gpio-mmio.c#L686

However, the real difference between BCM6345 (and BCM6338) is that these SoCs have no pin controller at all, only a GPIO controller:

BCM6345:
typedef struct GpioControl {

  uint16        unused0;
  byte          unused1;
  byte          TBusSel;
  uint16        unused2;
  uint16        GPIODir;
  byte          unused3;
  byte          Leds;
  uint16        GPIOio;
  uint32        UartCtl;

} GpioControl;

BCM6338:
typedef struct GpioControl {

  uint32        unused0;
  uint32        GPIODir;      /* bits 7:0 */
  uint32        unused1;
  uint32        GPIOio;       /* bits 7:0 */
  uint32        LEDCtrl;
  uint32        SpiSlaveCfg;
  uint32        vRegConfig;

} GpioControl;

BCM6348 and newer also have pinctrl.
That's the main difference between that driver @Rob's referring to and the ones in this patch series.

Quoted 27 lines

We currently have four Broadcom GPIO bindings, which are stand alone GPIO blocks and eight Broadcom pin controllers that all do GPIO as well.

This family of pin controllers are (as per subject) is the bcm63xx series which is a MIPS-based family of SoCs found in routers, top bindings in Documentation/devicetree/bindings/mips/brcm/soc.txt These all have a GPIO block as part of the pin controller and the GPIO block is a distinct sub-function of the pin controller, and it has up to 32 GPIOs per block, hence it has its own subnode inside the pin controller.

This driver follows the pattern of the Ingenic
pin controller, another MIPS SoC:
Documentation/devicetree/bindings/pinctrl/ingenic,pinctrl.yaml

Another SoC with several GPIO blocks inside the pin controller is SparX5 and that also follows this pattern:
Documentation/devicetree/bindings/pinctrl/microchip,sparx5-sgpio.yaml (This has an example with more than one GPIO block
inside the pin controller.)

Yours,
Linus Walleij

#22 lore raw

Re: [PATCH v6 04/15] dt-bindings: add BCM6328 pincontroller binding documentation

In reply to Rob Herring

Hi Rob,

Quoted 133 lines · Rob Herring
Quoted 121 lines · Álvaro Fernández Rojas

Hi Rob,

Quoted 118 lines · Rob Herring
Quoted 114 lines · Álvaro Fernández Rojas

Hi Rob,

Quoted 110 lines · Rob Herring
Quoted 94 lines · Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in BCM6328 SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

.../pinctrl/brcm,bcm6328-pinctrl.yaml | 174 ++++++++++++++++++

1 file changed, 174 insertions(+)

create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +71 -0
new file mode 100644
index 000000000000..471f6efa1754
@@ -0,0 +1,174 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6328-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM6328 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm6328-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm6328-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ serial_led_data, serial_led_clk, inet_act_led, pcie_clkreq,
+                  led, ephy0_act_led, ephy1_act_led, ephy2_act_led,
+                  ephy3_act_led, hsspi_cs1, usb_device_port, usb_host_port ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ gpio6, gpio7, gpio11, gpio16, gpio17, gpio18, gpio19,
+                  gpio20, gpio25, gpio26, gpio27, gpio28, hsspi_cs1,
+                  usb_port1 ]
+

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 81

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +10 -0
+required:
+  - compatible
+  - gpio
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@10000080 {
+      compatible = "brcm,bcm6328-gpio-controller", "syscon", "simple-mfd";

You just added "brcm,bcm6328-gpio-controller", it would need to be documented.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I just added that because you requested me to do it ¯\_(ツ)_/¯

I said 'syscon' by itself was not allowed, then asked about the multiple levels.

Why not?

Because 'syscon' alone doesn't mean anything and doesn't describe what registers it contains. You need something that says this is the XYZ block in the ABC SoC.

Quoted 10 lines
Quoted 1 line

What if you have several controllers inside a syscon?

You either just add properties (e.g. just add #clock-cells and it's a clock provider) or you have child nodes. Which one you do generally depends on if the providers have DT resources themselves.

Quoted 4 lines

The root should also have “something" in it?

Quoted 2 lines
Quoted 2 lines

What should I do to document it?

You didn't answer my question about adding documentation...

An example driver which adds a custom compatible string and doesn't document it:
https://github.com/torvalds/linux/blob/a74e6a014c9d4d4161061f770c9b4f98372ac778/Documentation/devicetree/bindings/clock/sprd%2Csc9863a-clk.yaml#L90

Quoted 83 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

I still don’t get most of this .yaml stuff...

Quoted 13 lines

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 88

Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +7 -0
+      reg = <0x10000080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6328-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6328-gpio";

I'm still trying to understand why you need 3 levels of nodes here? The gpio controller contains a pin controller plus other undefined functions (because of 'syscon') and the pin controller contains a gpio controller?

In previous versions the gpio controller was registered along with the pin controller, but @Linus requested me to register the gpio pin controller ranges through device tree by using gpio-ranges and I decided to use this approach, which was already used by other pin controllers. However, there aren’t any pinctrl drivers using gpio-regmap, so this is kind of new…

Quoted 3 lines

I think "brcm,bcm6328-gpio-controller" and "brcm,bcm6328-pinctrl" should be a single node.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

I agree, but does it make sense to add gpio-ranges to a pinctrl node referencing itself?

It wouldn't be. I wasn't saying the pinctrl and gpio controller are the same node. My suggestion was combining syscon and pinctrl.

But that wouldn’t be correct if there were more “things” inside the syscon, right?

Right.

Quoted 10 lines
Quoted 9 lines
Quoted 2 lines

Something like:
syscon {

Again with the syscon. If pinctrl and GPIO are the only functions within this h/w block, then this is not a syscon. You are just abusing that having 'syscon' compatible means you get a regmap created automagically for you. Nothing here looks like a 'system controller' to me. A 'system controller' is a random collection of register bits with functions that don't fit anywhere else.

Quoted 2 lines

pinctrl and GPIO aren’t the only functions within this HW block.
Maybe I didn’t document/code it properly, but I’m sure I’m not abusing what a system controller is.

Okay, that's the detail missing from this patch.

Quoted 28 lines

Please, take a look at http://www.datashed.science/misc/bcm/gpl/broadcom-sdk-416L05/shared/opensource/include/bcm963xx/6328_map_part.h:
typedef struct GpioControl {

     uint32      GPIODirHi;                  /* 0 */
     uint32      GPIODir;                    /* 4 */
     uint32      GPIOioHi;                   /* 8 */
     uint32      GPIOio;                     /* C */
     uint32      unused0;                    /* 10 */
     uint32      SpiSlaveCfg;                /* 14 */
     uint32      GPIOMode;                   /* 18 */
     uint64      PinMuxSel;                  /* 1C */
     uint32      PinMuxSelOther;             /* 24 */
     uint32      TestControl;                /* 28 */
     uint32      unused2;                    /* 2C */
     uint32      RoboSWLEDControl;           /* 30 */
     uint32      RoboSWLEDLSR;               /* 34 */
     uint32      unused3;                    /* 38 */
     uint32      RoboswEphyCtrl;             /* 3C */
     uint32      RoboswSwitchCtrl;           /* 40 */
     uint32      RegFileTmCtl;               /* 44 */
     uint32      RingOscCtrl0;               /* 48 */
     uint32      RingOscCtrl1;               /* 4C */
     uint32      unused4[6];                 /* 50 - 64 */
     uint32      DieRevID;                   /* 68 */
     uint32      unused5;                    /* 6c */
     uint32      DiagSelControl;             /* 70 */
     uint32      DiagReadBack;               /* 74 */
     uint32      DiagReadBackHi;             /* 78 */
     uint32      DiagMiscControl;            /* 7c */
Quoted 5 lines

} GpioControl;

So we’re using GPIODirHi, GPIODir, GPIOioHi and GPIOio registers for GPIO regmap driver. And we’re using GPIOMode, PinMuxSel (u64 -> x2 u32), PinMuxSelOther for pinctrl driver. And this is for BCM6328, but some of the other SoCs are even more scattered.

So based on this I'd do something like this:

Quoted 10 lines
syscon {
   reg = <base 0x80>;
   ranges = <0 base 0x80>;
   pinctrl@18 {
     reg = <0x18 0x10>;
     foo-pins {};
   gpio@0 {
     reg = <0x0 0x10>;
   };
};

You're missing a "};", so I'm not sure if you want me to go this way (1):

syscon {
	compatible = "brcm,bcm6328-gpio-regs", "syscon", "simple-mfd";
	reg = <0x10000080 0x80>;
	ranges = <0 0x10000080 0x80>;

	gpio: gpio@0 {
		compatible = "brcm,bcm6328-gpio";
		reg = <0x0 0x10>;

		data = <0xc>;
		dirout = <0x4>;

		gpio-controller;
		gpio-ranges = <&pinctrl 0 0 32>;
		#gpio-cells = <2>;
	};

	pinctrl: pinctrl@18 {
		compatible = "brcm,bcm6328-pinctrl";
		reg = <0x18 0x10>;

		foo-pins {};
		...
	};
};

Or this way (2):

syscon {
	compatible = "brcm,bcm6328-gpio-regs", "syscon", "simple-mfd";
	reg = <0x10000080 0x80>;
	ranges = <0 0x10000080 0x80>;

	pinctrl: pinctrl@18 {
		compatible = "brcm,bcm6328-pinctrl";
		reg = <0x0 0x28>;

		gpio: gpio@0 {
			compatible = "brcm,bcm6328-gpio";
			reg = <0x0 0x10>;

			data = <0xc>;
			dirout = <0x4>;

			gpio-controller;
			gpio-ranges = <&pinctrl 0 0 32>;
			#gpio-cells = <2>;
		};

		foo-pins {};
		...
	};
};
Quoted 19 lines

If things are more scattered within gpio or pinctrl, then maybe you need multiple reg entries. Whether the OS uses 'reg' and mmio or a regmap from the syscon is up to you. That's independent of the binding.

Quoted 13 lines
Quoted 12 lines
Quoted 6 lines
        pinctrl: pinctrl {
                compatible …

                gpio-controller;
                gpio-ranges = <&pinctrl 0 0 32>;
                #gpio-cells = <2>;

I was assuming you have multiple GPIO controllers within 1 pinctlr? The pinctrl and gpio could be a single node like above if there's only 1 GPIO controller. But I'm still somewhat guessing what the h/w looks like because I have to go searching thru the driver to decipher. Please describe the h/w in the binding.

Quoted 8 lines
Quoted 3 lines

GPIO dirout and data rely on 2x u32 registers or a single u64 register.
This is can be either be implemented as a single GPIO controller, or as 2 separate GPIO controllers.
However, since I’m overriding reg_mask_xlate with bcm63xx_reg_mask_xlate I can register it as a single GPIO controller, which makes more sense to me.

I think 1 makes more sense.

Rob

Best regards,
Álvaro.

#23 lore raw

Re: [PATCH v6 04/15] dt-bindings: add BCM6328 pincontroller binding documentation

Quoted 143 lines · Álvaro Fernández Rojas

Hi Rob,

Quoted 139 lines · Rob Herring
Quoted 121 lines · Álvaro Fernández Rojas

Hi Rob,

Quoted 118 lines · Rob Herring
Quoted 114 lines · Álvaro Fernández Rojas

Hi Rob,

Quoted 110 lines · Rob Herring
Quoted 94 lines · Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in BCM6328 SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

.../pinctrl/brcm,bcm6328-pinctrl.yaml | 174 ++++++++++++++++++

1 file changed, 174 insertions(+)

create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +71 -0
new file mode 100644
index 000000000000..471f6efa1754
@@ -0,0 +1,174 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6328-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM6328 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm6328-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm6328-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ serial_led_data, serial_led_clk, inet_act_led, pcie_clkreq,
+                  led, ephy0_act_led, ephy1_act_led, ephy2_act_led,
+                  ephy3_act_led, hsspi_cs1, usb_device_port, usb_host_port ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ gpio6, gpio7, gpio11, gpio16, gpio17, gpio18, gpio19,
+                  gpio20, gpio25, gpio26, gpio27, gpio28, hsspi_cs1,
+                  usb_port1 ]
+

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 81

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +10 -0
+required:
+  - compatible
+  - gpio
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@10000080 {
+      compatible = "brcm,bcm6328-gpio-controller", "syscon", "simple-mfd";

You just added "brcm,bcm6328-gpio-controller", it would need to be documented.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I just added that because you requested me to do it ¯\_(ツ)_/¯

I said 'syscon' by itself was not allowed, then asked about the multiple levels.

Why not?

Because 'syscon' alone doesn't mean anything and doesn't describe what registers it contains. You need something that says this is the XYZ block in the ABC SoC.

Quoted 1 line

What if you have several controllers inside a syscon?

You either just add properties (e.g. just add #clock-cells and it's a clock provider) or you have child nodes. Which one you do generally depends on if the providers have DT resources themselves.

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

The root should also have “something" in it?

Quoted 2 lines
Quoted 2 lines

What should I do to document it?

You didn't answer my question about adding documentation...

You have to document it. Whether it's 1 or 3 schema files depends on where we end up, but the top-level one should reference the others if it's more than 1 file:

child-node:
type: object
$ref: "/schemas/foo/child-node.yaml#"

Quoted 3 lines

An example driver which adds a custom compatible string and doesn't document it:
https://github.com/torvalds/linux/blob/a74e6a014c9d4d4161061f770c9b4f98372ac778/Documentation/devicetree/bindings/clock/sprd%2Csc9863a-clk.yaml#L90

*it Happens.

Those cases are now blocking my adding a check that they are undocumented. There's no shortage of examples of what not to do.

Quoted 113 lines
Quoted 84 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines

I still don’t get most of this .yaml stuff...

Quoted 13 lines

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 88

Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +7 -0
+      reg = <0x10000080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6328-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6328-gpio";

I'm still trying to understand why you need 3 levels of nodes here? The gpio controller contains a pin controller plus other undefined functions (because of 'syscon') and the pin controller contains a gpio controller?

In previous versions the gpio controller was registered along with the pin controller, but @Linus requested me to register the gpio pin controller ranges through device tree by using gpio-ranges and I decided to use this approach, which was already used by other pin controllers. However, there aren’t any pinctrl drivers using gpio-regmap, so this is kind of new…

Quoted 3 lines

I think "brcm,bcm6328-gpio-controller" and "brcm,bcm6328-pinctrl" should be a single node.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

I agree, but does it make sense to add gpio-ranges to a pinctrl node referencing itself?

It wouldn't be. I wasn't saying the pinctrl and gpio controller are the same node. My suggestion was combining syscon and pinctrl.

But that wouldn’t be correct if there were more “things” inside the syscon, right?

Right.

Quoted 10 lines
Quoted 9 lines
Quoted 2 lines

Something like:
syscon {

Again with the syscon. If pinctrl and GPIO are the only functions within this h/w block, then this is not a syscon. You are just abusing that having 'syscon' compatible means you get a regmap created automagically for you. Nothing here looks like a 'system controller' to me. A 'system controller' is a random collection of register bits with functions that don't fit anywhere else.

Quoted 2 lines

pinctrl and GPIO aren’t the only functions within this HW block.
Maybe I didn’t document/code it properly, but I’m sure I’m not abusing what a system controller is.

Okay, that's the detail missing from this patch.

Quoted 28 lines

Please, take a look at http://www.datashed.science/misc/bcm/gpl/broadcom-sdk-416L05/shared/opensource/include/bcm963xx/6328_map_part.h:
typedef struct GpioControl {

     uint32      GPIODirHi;                  /* 0 */
     uint32      GPIODir;                    /* 4 */
     uint32      GPIOioHi;                   /* 8 */
     uint32      GPIOio;                     /* C */
     uint32      unused0;                    /* 10 */
     uint32      SpiSlaveCfg;                /* 14 */
     uint32      GPIOMode;                   /* 18 */
     uint64      PinMuxSel;                  /* 1C */
     uint32      PinMuxSelOther;             /* 24 */
     uint32      TestControl;                /* 28 */
     uint32      unused2;                    /* 2C */
     uint32      RoboSWLEDControl;           /* 30 */
     uint32      RoboSWLEDLSR;               /* 34 */
     uint32      unused3;                    /* 38 */
     uint32      RoboswEphyCtrl;             /* 3C */
     uint32      RoboswSwitchCtrl;           /* 40 */
     uint32      RegFileTmCtl;               /* 44 */
     uint32      RingOscCtrl0;               /* 48 */
     uint32      RingOscCtrl1;               /* 4C */
     uint32      unused4[6];                 /* 50 - 64 */
     uint32      DieRevID;                   /* 68 */
     uint32      unused5;                    /* 6c */
     uint32      DiagSelControl;             /* 70 */
     uint32      DiagReadBack;               /* 74 */
     uint32      DiagReadBackHi;             /* 78 */
     uint32      DiagMiscControl;            /* 7c */
Quoted 5 lines

} GpioControl;

So we’re using GPIODirHi, GPIODir, GPIOioHi and GPIOio registers for GPIO regmap driver. And we’re using GPIOMode, PinMuxSel (u64 -> x2 u32), PinMuxSelOther for pinctrl driver. And this is for BCM6328, but some of the other SoCs are even more scattered.

So based on this I'd do something like this:

Quoted 10 lines
syscon {
   reg = <base 0x80>;
   ranges = <0 base 0x80>;
   pinctrl@18 {
     reg = <0x18 0x10>;
     foo-pins {};
   gpio@0 {
     reg = <0x0 0x10>;
   };
};

You're missing a "};", so I'm not sure if you want me to go this way (1):

syscon {
        compatible = "brcm,bcm6328-gpio-regs", "syscon", "simple-mfd";
        reg = <0x10000080 0x80>;
        ranges = <0 0x10000080 0x80>;

        gpio: gpio@0 {
                compatible = "brcm,bcm6328-gpio";
                reg = <0x0 0x10>;

                data = <0xc>;
                dirout = <0x4>;

                gpio-controller;
                gpio-ranges = <&pinctrl 0 0 32>;
                #gpio-cells = <2>;
        };
Quoted 8 lines
        pinctrl: pinctrl@18 {
                compatible = "brcm,bcm6328-pinctrl";
                reg = <0x18 0x10>;

                foo-pins {};
                ...
        };
};

This way.

Quoted 12 lines

Or this way (2):

syscon {
        compatible = "brcm,bcm6328-gpio-regs", "syscon", "simple-mfd";
        reg = <0x10000080 0x80>;
        ranges = <0 0x10000080 0x80>;

        pinctrl: pinctrl@18 {
                compatible = "brcm,bcm6328-pinctrl";
                reg = <0x0 0x28>;

                gpio: gpio@0 {

This doesn't make sense IMO because GPIO is not a sub-function of the pinctrl h/w. They are peers.

Quoted 15 lines
                        compatible = "brcm,bcm6328-gpio";
                        reg = <0x0 0x10>;

                        data = <0xc>;
                        dirout = <0x4>;

                        gpio-controller;
                        gpio-ranges = <&pinctrl 0 0 32>;
                        #gpio-cells = <2>;
                };

                foo-pins {};
                ...
        };
};
#14 lore raw

Re: [PATCH v6 03/15] pinctrl: bcm: add bcm63xx base code

In reply to Álvaro Fernández Rojas
Quoted 47 lines · Álvaro Fernández Rojas

Hi Rob and Linus,

Quoted 43 lines · Linus Walleij
Quoted 14 lines · Rob Herring
Quoted 13 lines · Linus Walleij
Quoted 10 lines · Rob Herring

drivers/pinctrl/bcm/pinctrl-bcm63xx.c line 40

Quoted 7 lines
drivers/pinctrl/bcm/pinctrl-bcm63xx.c new file +7 -0
+static const struct of_device_id bcm63xx_gpio_of_match[] = {
+       { .compatible = "brcm,bcm6318-gpio", },
+       { .compatible = "brcm,bcm6328-gpio", },
+       { .compatible = "brcm,bcm6358-gpio", },
+       { .compatible = "brcm,bcm6362-gpio", },
+       { .compatible = "brcm,bcm6368-gpio", },
+       { .compatible = "brcm,bcm63268-gpio", },

All these would be moved to gpio-mmio.c (or maybe that can have a fallback compatible?).

Quoted 7 lines
Quoted 4 lines

This is gpio-regmap.c and it can only be used as a library by a certain driver. gpio-mmio.c can be used stand-alone for certain really simple hardware (though most use that as a library as well).

I don't really care which one is used, but the problem is that this choice is leaking into the binding design.

Aha I guess I misunderstood your comment.

Quoted 8 lines

The primary problem here is
once someone uses regmap, then they think they must have a syscon and can abandon using 'reg' and normal address properties as Linux happens to not use them (currently). I think we really need some better regmap vs. mmio handling to eliminate this duplication of foo-mmio and foo-regmap drivers and difference in binding design. Not sure exactly what that looks like, but basically some sort of 'reg' property to regmap creation.

I see the problem. Yeah we should try to be more strict around these things. To me there are syscons and "other regmaps", where syscon is a real hurdle of registers while "other regmaps" are just regmaps by convenience.

Documentation/devicetree/bindings/mfd/syscon.yaml describes what a syscon really is so if everyone could just read the documentation that would be great ...

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Given we already have a Broadcom GPIO binding for what looks to be similar to this one, I'm left wondering what's the real difference here?

Which one is similar? I can take a look.

@Linus I think @Rob is referring to brcm,bcm6345-gpio:
https://github.com/torvalds/linux/blob/a74e6a014c9d4d4161061f770c9b4f98372ac778/drivers/gpio/gpio-mmio.c#L686

Well, since it's the bindings we're talking about:
Documentation/devicetree/bindings/gpio/brcm,bcm6345-gpio.txt

Which says this:
"These bindings can be used on any BCM63xx SoC. However, BCM6338 and BCM6345 are the only ones which don't need a pinctrl driver."

Not that the 1 in tree user of this is perfect. Seems like it too should be a child of a system controller if there's other registers.

Quoted 31 lines

However, the real difference between BCM6345 (and BCM6338) is that these SoCs have no pin controller at all, only a GPIO controller:

BCM6345:

typedef struct GpioControl {
   uint16        unused0;
   byte          unused1;
   byte          TBusSel;
   uint16        unused2;
   uint16        GPIODir;
   byte          unused3;
   byte          Leds;
   uint16        GPIOio;
   uint32        UartCtl;
} GpioControl;

BCM6338:

typedef struct GpioControl {
   uint32        unused0;
   uint32        GPIODir;      /* bits 7:0 */
   uint32        unused1;
   uint32        GPIOio;       /* bits 7:0 */
   uint32        LEDCtrl;
   uint32        SpiSlaveCfg;
   uint32        vRegConfig;
} GpioControl;

BCM6348 and newer also have pinctrl.
That's the main difference between that driver @Rob's referring to and the ones in this patch series.

#15 lore raw

Re: [PATCH v6 03/15] pinctrl: bcm: add bcm63xx base code

Hi Rob,

Quoted 60 lines · Rob Herring
Quoted 47 lines · Álvaro Fernández Rojas

Hi Rob and Linus,

Quoted 43 lines · Linus Walleij
Quoted 14 lines · Rob Herring
Quoted 13 lines · Linus Walleij
Quoted 10 lines · Rob Herring

Review

Quoted 7 lines
(quoted diff) +7 -0
+static const struct of_device_id bcm63xx_gpio_of_match[] = {
+       { .compatible = "brcm,bcm6318-gpio", },
+       { .compatible = "brcm,bcm6328-gpio", },
+       { .compatible = "brcm,bcm6358-gpio", },
+       { .compatible = "brcm,bcm6362-gpio", },
+       { .compatible = "brcm,bcm6368-gpio", },
+       { .compatible = "brcm,bcm63268-gpio", },

All these would be moved to gpio-mmio.c (or maybe that can have a fallback compatible?).

Quoted 7 lines
Quoted 4 lines

This is gpio-regmap.c and it can only be used as a library by a certain driver. gpio-mmio.c can be used stand-alone for certain really simple hardware (though most use that as a library as well).

I don't really care which one is used, but the problem is that this choice is leaking into the binding design.

Aha I guess I misunderstood your comment.

Quoted 8 lines

The primary problem here is
once someone uses regmap, then they think they must have a syscon and can abandon using 'reg' and normal address properties as Linux happens to not use them (currently). I think we really need some better regmap vs. mmio handling to eliminate this duplication of foo-mmio and foo-regmap drivers and difference in binding design. Not sure exactly what that looks like, but basically some sort of 'reg' property to regmap creation.

I see the problem. Yeah we should try to be more strict around these things. To me there are syscons and "other regmaps", where syscon is a real hurdle of registers while "other regmaps" are just regmaps by convenience.

Documentation/devicetree/bindings/mfd/syscon.yaml describes what a syscon really is so if everyone could just read the documentation that would be great ...

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Given we already have a Broadcom GPIO binding for what looks to be similar to this one, I'm left wondering what's the real difference here?

Which one is similar? I can take a look.

@Linus I think @Rob is referring to brcm,bcm6345-gpio:
https://github.com/torvalds/linux/blob/a74e6a014c9d4d4161061f770c9b4f98372ac778/drivers/gpio/gpio-mmio.c#L686

Quoted 6 lines

Well, since it's the bindings we're talking about:
Documentation/devicetree/bindings/gpio/brcm,bcm6345-gpio.txt

Which says this:
"These bindings can be used on any BCM63xx SoC. However, BCM6338 and BCM6345 are the only ones which don't need a pinctrl driver."

Yes, I know because I’m the author of that driver…
What I meant at that time is that it could be used temporarily until a proper “full” pinctrl driver was added.

Quoted 3 lines

Not that the 1 in tree user of this is perfect. Seems like it too should be a child of a system controller if there's other registers.

There are other registers, but dirout and data registers are contiguous and separate from the others.

Quoted 29 lines
Quoted 29 lines

However, the real difference between BCM6345 (and BCM6338) is that these SoCs have no pin controller at all, only a GPIO controller:

BCM6345:
typedef struct GpioControl {

  uint16        unused0;
  byte          unused1;
  byte          TBusSel;
  uint16        unused2;
  uint16        GPIODir;
  byte          unused3;
  byte          Leds;
  uint16        GPIOio;
  uint32        UartCtl;

} GpioControl;

BCM6338:
typedef struct GpioControl {

  uint32        unused0;
  uint32        GPIODir;      /* bits 7:0 */
  uint32        unused1;
  uint32        GPIOio;       /* bits 7:0 */
  uint32        LEDCtrl;
  uint32        SpiSlaveCfg;
  uint32        vRegConfig;

} GpioControl;

Quoted 3 lines
Quoted 3 lines

BCM6348 and newer also have pinctrl.
That's the main difference between that driver @Rob's referring to and the ones in this patch series.

Best regards,
Álvaro.

#24 lore raw

Re: [PATCH v6 04/15] dt-bindings: add BCM6328 pincontroller binding documentation

In reply to Rob Herring

Hi Rob,

Quoted 154 lines · Rob Herring
Quoted 143 lines · Álvaro Fernández Rojas

Hi Rob,

Quoted 139 lines · Rob Herring
Quoted 121 lines · Álvaro Fernández Rojas

Hi Rob,

Quoted 118 lines · Rob Herring
Quoted 114 lines · Álvaro Fernández Rojas

Hi Rob,

Quoted 110 lines · Rob Herring
Quoted 94 lines · Álvaro Fernández Rojas

Add binding documentation for the pincontrol core found in BCM6328 SoCs.

---
v6: add changes suggested by Rob Herring
v5: change Documentation to dt-bindings in commit title
v4: no changes
v3: add new gpio node
v2: remove interrupts

.../pinctrl/brcm,bcm6328-pinctrl.yaml | 174 ++++++++++++++++++

1 file changed, 174 insertions(+)

create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +71 -0
new file mode 100644
index 000000000000..471f6efa1754
@@ -0,0 +1,174 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6328-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM6328 pin controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+  - Jonas Gorski <[email protected]>
+
+description: |+
+  The pin controller node should be the child of a syscon node.
+
+  Refer to the the bindings described in
+  Documentation/devicetree/bindings/mfd/syscon.yaml
+
+properties:
+  compatible:
+    const: brcm,bcm6328-pinctrl
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: brcm,bcm6328-gpio
+
+      data:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the data register (in bytes).
+
+      dirout:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: |
+          Offset in the register map for the dirout register (in bytes).
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - gpio-ranges
+      - '#gpio-cells'
+
+    additionalProperties: false
+
+patternProperties:
+  '^.*-pins$':
+    if:
+      type: object
+    then:
+      properties:
+        function:
+          $ref: "pinmux-node.yaml#/properties/function"
+          enum: [ serial_led_data, serial_led_clk, inet_act_led, pcie_clkreq,
+                  led, ephy0_act_led, ephy1_act_led, ephy2_act_led,
+                  ephy3_act_led, hsspi_cs1, usb_device_port, usb_host_port ]
+
+        pins:
+          $ref: "pinmux-node.yaml#/properties/pins"
+          enum: [ gpio6, gpio7, gpio11, gpio16, gpio17, gpio18, gpio19,
+                  gpio20, gpio25, gpio26, gpio27, gpio28, hsspi_cs1,
+                  usb_port1 ]
+

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 81

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +10 -0
+required:
+  - compatible
+  - gpio
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio_cntl@10000080 {
+      compatible = "brcm,bcm6328-gpio-controller", "syscon", "simple-mfd";

You just added "brcm,bcm6328-gpio-controller", it would need to be documented.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I just added that because you requested me to do it ¯\_(ツ)_/¯

I said 'syscon' by itself was not allowed, then asked about the multiple levels.

Why not?

Because 'syscon' alone doesn't mean anything and doesn't describe what registers it contains. You need something that says this is the XYZ block in the ABC SoC.

Quoted 1 line

What if you have several controllers inside a syscon?

You either just add properties (e.g. just add #clock-cells and it's a clock provider) or you have child nodes. Which one you do generally depends on if the providers have DT resources themselves.

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

The root should also have “something" in it?

Quoted 2 lines
Quoted 2 lines

What should I do to document it?

You didn't answer my question about adding documentation...

Quoted 7 lines

You have to document it. Whether it's 1 or 3 schema files depends on where we end up, but the top-level one should reference the others if it's more than 1 file:

child-node:
type: object
$ref: "/schemas/foo/child-node.yaml#"

Can you give me an example of a driver which is documenting that? I’m sorry, but I still don’t know how to do it properly...

Quoted 141 lines
Quoted 4 lines

An example driver which adds a custom compatible string and doesn't document it:
https://github.com/torvalds/linux/blob/a74e6a014c9d4d4161061f770c9b4f98372ac778/Documentation/devicetree/bindings/clock/sprd%2Csc9863a-clk.yaml#L90

*it Happens.

Those cases are now blocking my adding a check that they are undocumented. There's no shortage of examples of what not to do.

Quoted 113 lines
Quoted 87 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines

I still don’t get most of this .yaml stuff...

Quoted 13 lines

Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml line 88

Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file +7 -0
+      reg = <0x10000080 0x80>;
+
+      pinctrl: pinctrl {
+        compatible = "brcm,bcm6328-pinctrl";
+
+        gpio {
+          compatible = "brcm,bcm6328-gpio";

I'm still trying to understand why you need 3 levels of nodes here? The gpio controller contains a pin controller plus other undefined functions (because of 'syscon') and the pin controller contains a gpio controller?

In previous versions the gpio controller was registered along with the pin controller, but @Linus requested me to register the gpio pin controller ranges through device tree by using gpio-ranges and I decided to use this approach, which was already used by other pin controllers. However, there aren’t any pinctrl drivers using gpio-regmap, so this is kind of new…

Quoted 3 lines

I think "brcm,bcm6328-gpio-controller" and "brcm,bcm6328-pinctrl" should be a single node.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

I agree, but does it make sense to add gpio-ranges to a pinctrl node referencing itself?

It wouldn't be. I wasn't saying the pinctrl and gpio controller are the same node. My suggestion was combining syscon and pinctrl.

But that wouldn’t be correct if there were more “things” inside the syscon, right?

Right.

Quoted 10 lines
Quoted 9 lines
Quoted 2 lines

Something like:
syscon {

Again with the syscon. If pinctrl and GPIO are the only functions within this h/w block, then this is not a syscon. You are just abusing that having 'syscon' compatible means you get a regmap created automagically for you. Nothing here looks like a 'system controller' to me. A 'system controller' is a random collection of register bits with functions that don't fit anywhere else.

Quoted 2 lines

pinctrl and GPIO aren’t the only functions within this HW block.
Maybe I didn’t document/code it properly, but I’m sure I’m not abusing what a system controller is.

Okay, that's the detail missing from this patch.

Quoted 28 lines

Please, take a look at http://www.datashed.science/misc/bcm/gpl/broadcom-sdk-416L05/shared/opensource/include/bcm963xx/6328_map_part.h:
typedef struct GpioControl {

    uint32      GPIODirHi;                  /* 0 */
    uint32      GPIODir;                    /* 4 */
    uint32      GPIOioHi;                   /* 8 */
    uint32      GPIOio;                     /* C */
    uint32      unused0;                    /* 10 */
    uint32      SpiSlaveCfg;                /* 14 */
    uint32      GPIOMode;                   /* 18 */
    uint64      PinMuxSel;                  /* 1C */
    uint32      PinMuxSelOther;             /* 24 */
    uint32      TestControl;                /* 28 */
    uint32      unused2;                    /* 2C */
    uint32      RoboSWLEDControl;           /* 30 */
    uint32      RoboSWLEDLSR;               /* 34 */
    uint32      unused3;                    /* 38 */
    uint32      RoboswEphyCtrl;             /* 3C */
    uint32      RoboswSwitchCtrl;           /* 40 */
    uint32      RegFileTmCtl;               /* 44 */
    uint32      RingOscCtrl0;               /* 48 */
    uint32      RingOscCtrl1;               /* 4C */
    uint32      unused4[6];                 /* 50 - 64 */
    uint32      DieRevID;                   /* 68 */
    uint32      unused5;                    /* 6c */
    uint32      DiagSelControl;             /* 70 */
    uint32      DiagReadBack;               /* 74 */
    uint32      DiagReadBackHi;             /* 78 */
    uint32      DiagMiscControl;            /* 7c */
Quoted 5 lines

} GpioControl;

So we’re using GPIODirHi, GPIODir, GPIOioHi and GPIOio registers for GPIO regmap driver. And we’re using GPIOMode, PinMuxSel (u64 -> x2 u32), PinMuxSelOther for pinctrl driver. And this is for BCM6328, but some of the other SoCs are even more scattered.

So based on this I'd do something like this:

syscon {
reg = <base 0x80>;
ranges = <0 base 0x80>;

Quoted 7 lines
  pinctrl@18 {
    reg = <0x18 0x10>;
    foo-pins {};
  gpio@0 {
    reg = <0x0 0x10>;

};
};

You're missing a "};", so I'm not sure if you want me to go this way (1):

syscon {
       compatible = "brcm,bcm6328-gpio-regs", "syscon", "simple-mfd";
       reg = <0x10000080 0x80>;
       ranges = <0 0x10000080 0x80>;

       gpio: gpio@0 {
               compatible = "brcm,bcm6328-gpio";
               reg = <0x0 0x10>;

               data = <0xc>;
               dirout = <0x4>;

               gpio-controller;
               gpio-ranges = <&pinctrl 0 0 32>;
               #gpio-cells = <2>;
       };
Quoted 8 lines
       pinctrl: pinctrl@18 {
               compatible = "brcm,bcm6328-pinctrl";
               reg = <0x18 0x10>;

               foo-pins {};
               ...
       };
};

This way.

Quoted 7 lines

Or this way (2):

syscon {
       compatible = "brcm,bcm6328-gpio-regs", "syscon", "simple-mfd";
       reg = <0x10000080 0x80>;
       ranges = <0 0x10000080 0x80>;
Quoted 8 lines
Quoted 5 lines
       pinctrl: pinctrl@18 {
               compatible = "brcm,bcm6328-pinctrl";
               reg = <0x0 0x28>;

               gpio: gpio@0 {

This doesn't make sense IMO because GPIO is not a sub-function of the pinctrl h/w. They are peers.

Well, that’s where @Linus and I disagree...

Quoted 12 lines
Quoted 12 lines
                       compatible = "brcm,bcm6328-gpio";
                       reg = <0x0 0x10>;

                       data = <0xc>;
                       dirout = <0x4>;

                       gpio-controller;
                       gpio-ranges = <&pinctrl 0 0 32>;
                       #gpio-cells = <2>;
               };
Quoted 4 lines
Quoted 4 lines
               foo-pins {};
               ...
       };
};

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

#25 lore raw

Re: [PATCH v6 04/15] dt-bindings: add BCM6328 pincontroller binding documentation

In reply to Rob Herring
Quoted 6 lines · Rob Herring
Quoted 6 lines

Or this way (2):

syscon {
        compatible = "brcm,bcm6328-gpio-regs", "syscon", "simple-mfd";
        reg = <0x10000080 0x80>;
        ranges = <0 0x10000080 0x80>;
Quoted 8 lines
Quoted 5 lines
        pinctrl: pinctrl@18 {
                compatible = "brcm,bcm6328-pinctrl";
                reg = <0x0 0x28>;

                gpio: gpio@0 {

This doesn't make sense IMO because GPIO is not a sub-function of the pinctrl h/w. They are peers.

This becomes an ontological discussion, as in "what does the world consist of and what are the proper definitions of the things in it".

A couple of years back I had this presentation:
https://dflund.se/~triad/papers/pincontrol.pdf
where I try to investigate how hardware engineers build these blocks.

TL;DR: it depends on what the hardware engineer did.

A HW block can be pin controller, GPIO controller and interrupt chip at the same time, that case is straight-forward. One compatible, lots of properties.
.
A second case is when the pin controller and the GPIO+irqchip are two completely different HW entities, and then they also get two different device nodes on the same level in the device tree. (We usually see this when the different blocks live in totally different memory locations.)

However in the third case HW can also be bolted with a front-end pin controller (facing the pins) with several GPIO+interrupt controller back-ends. Then it gets the structure in this patch, subnodes for each GPIO controller.

Our current bindings have all three examples and it simply reflects the different ways HW engineers have chosen to integrate their stuff.

Yours,
Linus Walleij