Skip to contentSkip to conversation

pinctrl: nuvoton: add pinmux and GPIO driver for NPCM8XX

PATCH Superseded Tomer Maimon 5 participants 19 messages Jul 14, 2022 – Sep 20, 2022

Subsystems (4)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Tomer Maimon

author maintainer
#0 lore raw

v2 cover pinctrl: nuvoton: add pinmux and GPIO driver for NPCM8XX

This patch set adds pinmux and GPIO controller for the Arbel NPCM8XX Baseboard Management Controller (BMC).

Arbel BMC NPCM8XX pinctrl driver based on Poleg NPCM7XX, except the pin mux mapping difference the NPCM8XX GPIO supports adjust debounce period time.

Arbel BMC NPCM8XX Pinmux functions accessible only for pin groups and pin configuration parameters available only for individual pins.

Arbel BMC NPCM8XX has eight identical GPIO modules, each module has 32 GPIO ports.

Most of the GPIO ports are multiplexed with other system functions.

The NPCM8XX pinctrl and GPIO driver were tested on NPCM845 evaluation board.

Addressed comments from:
- Andy Shevchenko : https://www.spinics.net/lists/devicetree/msg516573.html
- Krzysztof Kozlowski: https://www.spinics.net/lists/kernel/msg4368955.html

Changes since version 1:
- Pin controller driver
- Remove unnecessary debug prints and comments.
- Use fwnode functions.
- Remove Redundant 'else'.
- Use switch case instead of else if.
- Use GENMASK and BIT macros.
- Use dev_err_probe in probe error.
- Use callback GPIO range.
- Add GCR phandle property.
- Parameter order in reversed xmas

- Pin controller dt-binding
- Modify name from pin to mux.
- Add phandle property.

Tomer Maimon (2):
dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation
pinctrl: nuvoton: add NPCM8XX pinctrl and GPIO driver

 .../pinctrl/nuvoton,npcm845-pinctrl.yaml      |  213 ++
 drivers/pinctrl/nuvoton/Kconfig               |   13 +
 drivers/pinctrl/nuvoton/Makefile              |    1 +
 drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c     | 2528 +++++++++++++++++
 4 files changed, 2755 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml
 create mode 100644 drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
Signature · 1 line
2.33.0
author maintainer
#1 lore raw

PATCH v2 1/2 dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation

Added device tree binding documentation for Nuvoton Arbel BMC NPCM8XX pinmux and GPIO controller.

---
 .../pinctrl/nuvoton,npcm845-pinctrl.yaml      | 213 ++++++++++++++++++
 1 file changed, 213 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +213 -0
new file mode 100644
index 000000000000..104766f7acc5
@@ -0,0 +1,213 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/nuvoton,npcm845-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nuvoton NPCM845 Pin Controller and GPIO
+
+maintainers:
+  - Tomer Maimon <[email protected]>
+
+description:
+  The Nuvoton BMC NPCM8XX Pin Controller multi-function routed through
+  the multiplexing block, Each pin supports GPIO functionality (GPIOx)
+  and multiple functions that directly connect the pin to different
+  hardware blocks.
+
+properties:
+  compatible:
+    const: nuvoton,npcm845-pinctrl
+
+  ranges:
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1
+
+  nuvoton,sysgcr:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: a phandle to access GCR registers.
+
+patternProperties:
+  "^gpio@":
+    type: object
+
+    description:
+      Eight GPIO banks that each contain between 32 GPIOs.
+
+    properties:
+      gpio-controller: true
+
+      '#gpio-cells':
+        const: 2
+
+      reg:
+        maxItems: 1
+
+      interrupts:
+        maxItems: 1
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - '#gpio-cells'
+      - reg
+      - interrupts
+      - gpio-ranges
+
+  "-mux":
+    $ref: pinmux-node.yaml#
+
+    properties:
+      groups:
+        description:
+          One or more groups of pins to mux to a certain function
+        items:
+          enum: [ iox1, iox2, smb1d, smb2d, lkgpo1, lkgpo2, ioxh, gspi,
+                  smb5b, smb5c, lkgpo0, pspi2, jm1, jm2, smb4den, smb4b,
+                  smb4c, smb15, smb16, smb17, smb18, smb19, smb20, smb21,
+                  smb22, smb23, smb4d, smb14, smb5, smb4, smb3, spi0cs1,
+                  spi0cs2, spi0cs3, smb3c, smb3b, bmcuart0a, uart1, jtag2,
+                  bmcuart1, uart2, bmcuart0b, r1err, r1md, r1oen, r2oen,
+                  rmii3, r3oen, smb3d, fanin0, fanin1, fanin2, fanin3, fanin4,
+                  fanin5, fanin6, fanin7, fanin8, fanin9, fanin10, fanin11,
+                  fanin12, fanin13, fanin14, fanin15, pwm0, pwm1, pwm2, pwm3,
+                  r2, r2err, r2md, r3rxer, ga20kbc, smb5d, lpc, espi, rg1,
+                  rg1mdio, rg2, ddr, i3c0, i3c1, i3c2, i3c3, i3c4, i3c5,
+                  smb0, smb1, smb2, smb2c, smb2b, smb1c, smb1b, smb8, smb9,
+                  smb10, smb11, sd1, sd1pwr, pwm4, pwm5, pwm6, pwm7, pwm8,
+                  pwm9, pwm10, pwm11, mmc8, mmc, mmcwp, mmccd, mmcrst, clkout,
+                  serirq, lpcclk, scipme, sci, smb6, smb7, spi1, faninx, r1,
+                  spi3, spi3cs1, spi3quad, spi3cs2, spi3cs3, nprd_smi, smb0b,
+                  smb0c, smb0den, smb0d, ddc, rg2mdio, wdog1, wdog2, smb12,
+                  smb13, spix, spixcs1, clkreq, hgpio0, hgpio1, hgpio2, hgpio3,
+                  hgpio4, hgpio5, hgpio6, hgpio7 ]
+
+      function:
+        description:
+          The function that a group of pins is muxed to
+        enum: [ iox1, iox2, smb1d, smb2d, lkgpo1, lkgpo2, ioxh, gspi,
+                smb5b, smb5c, lkgpo0, pspi2, jm1, jm2, smb4den, smb4b,
+                smb4c, smb15, smb16, smb17, smb18, smb19, smb20, smb21,
+                smb22, smb23, smb4d, smb14, smb5, smb4, smb3, spi0cs1,
+                spi0cs2, spi0cs3, smb3c, smb3b, bmcuart0a, uart1, jtag2,
+                bmcuart1, uart2, bmcuart0b, r1err, r1md, r1oen, r2oen,
+                rmii3, r3oen, smb3d, fanin0, fanin1, fanin2, fanin3, fanin4,
+                fanin5, fanin6, fanin7, fanin8, fanin9, fanin10, fanin11,
+                fanin12, fanin13, fanin14, fanin15, pwm0, pwm1, pwm2, pwm3,
+                r2, r2err, r2md, r3rxer, ga20kbc, smb5d, lpc, espi, rg1,
+                rg1mdio, rg2, ddr, i3c0, i3c1, i3c2, i3c3, i3c4, i3c5,
+                smb0, smb1, smb2, smb2c, smb2b, smb1c, smb1b, smb8, smb9,
+                smb10, smb11, sd1, sd1pwr, pwm4, pwm5, pwm6, pwm7, pwm8,
+                pwm9, pwm10, pwm11, mmc8, mmc, mmcwp, mmccd, mmcrst, clkout,
+                serirq, lpcclk, scipme, sci, smb6, smb7, spi1, faninx, r1,
+                spi3, spi3cs1, spi3quad, spi3cs2, spi3cs3, nprd_smi, smb0b,
+                smb0c, smb0den, smb0d, ddc, rg2mdio, wdog1, wdog2, smb12,
+                smb13, spix, spixcs1, clkreq, hgpio0, hgpio1, hgpio2, hgpio3,
+                hgpio4, hgpio5, hgpio6, hgpio7 ]
+
+    dependencies:
+      groups: [ function ]
+      function: [ groups ]
+
+    additionalProperties: false
+
+  "^pin":
+    $ref: pincfg-node.yaml#
+
+    properties:
+      pins:
+        description:
+          A list of pins to configure in certain ways, such as enabling
+          debouncing
+
+      bias-disable: true
+
+      bias-pull-up: true
+
+      bias-pull-down: true
+
+      input-enable: true
+
+      output-low: true
+
+      output-high: true
+
+      drive-push-pull: true
+
+      drive-open-drain: true
+
+      input-debounce:
+        description:
+          Debouncing periods in microseconds, one period per interrupt
+          bank found in the controller
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+        minItems: 1
+        maxItems: 4
+
+      slew-rate:
+        description: |
+          0: Low rate
+          1: High rate
+        $ref: /schemas/types.yaml#/definitions/uint32
+        enum: [0, 1]
+
+      drive-strength:
+        enum: [ 0, 1, 2, 4, 8, 12 ]
+
+    additionalProperties: false
+
+allOf:
+  - $ref: "pinctrl.yaml#"
+
+required:
+  - compatible
+  - ranges
+  - '#address-cells'
+  - '#size-cells'
+  - nuvoton,sysgcr
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/gpio/gpio.h>
+
+    soc {
+      #address-cells = <2>;
+      #size-cells = <2>;
+
+      pinctrl: pinctrl@f0800000 {
+        compatible = "nuvoton,npcm845-pinctrl";
+        ranges = <0x0 0x0 0xf0010000 0x8000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nuvoton,sysgcr = <&gcr>;
+
+        gpio0: gpio@f0010000 {
+          gpio-controller;
+          #gpio-cells = <2>;
+          reg = <0x0 0xB0>;
+          interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>;
+          gpio-ranges = <&pinctrl 0 0 32>;
+        };
+
+        fanin0_pin: fanin0-mux {
+          groups = "fanin0";
+          function = "fanin0";
+        };
+
+        pin34_slew: pin34-slew {
+          pins = "GPIO34/I3C4_SDA";
+          bias-disable;
+        };
+      };
+    };
+
Signature · 1 line
2.33.0
maintainer
#2 lore raw

Re: [PATCH v2 1/2] dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation

Quoted 45 lines · Tomer Maimon

Added device tree binding documentation for Nuvoton Arbel BMC NPCM8XX pinmux and GPIO controller.

---
 .../pinctrl/nuvoton,npcm845-pinctrl.yaml      | 213 ++++++++++++++++++
 1 file changed, 213 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +30 -0
new file mode 100644
index 000000000000..104766f7acc5
@@ -0,0 +1,213 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/nuvoton,npcm845-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nuvoton NPCM845 Pin Controller and GPIO
+
+maintainers:
+  - Tomer Maimon <[email protected]>
+
+description:
+  The Nuvoton BMC NPCM8XX Pin Controller multi-function routed through
+  the multiplexing block, Each pin supports GPIO functionality (GPIOx)
+  and multiple functions that directly connect the pin to different
+  hardware blocks.
+
+properties:
+  compatible:
+    const: nuvoton,npcm845-pinctrl
+
+  ranges:
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1
+

Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml line 40

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +10 -0
+  nuvoton,sysgcr:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: a phandle to access GCR registers.
+
+patternProperties:
+  "^gpio@":
+    type: object
+
+    description:
+      Eight GPIO banks that each contain between 32 GPIOs.

'each contain between 32'?

Quoted 14 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +14 -0
+
+    properties:
+      gpio-controller: true
+
+      '#gpio-cells':
+        const: 2
+
+      reg:
+        maxItems: 1
+
+      interrupts:
+        maxItems: 1
+
+      gpio-ranges:

Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml line 64

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +10 -0
+        maxItems: 1
+
+    required:
+      - gpio-controller
+      - '#gpio-cells'
+      - reg
+      - interrupts
+      - gpio-ranges
+
+  "-mux":

'-mux$'? Something like 'foo-muxbar' is needed?

Quoted 120 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +120 -0
+    $ref: pinmux-node.yaml#
+
+    properties:
+      groups:
+        description:
+          One or more groups of pins to mux to a certain function
+        items:
+          enum: [ iox1, iox2, smb1d, smb2d, lkgpo1, lkgpo2, ioxh, gspi,
+                  smb5b, smb5c, lkgpo0, pspi2, jm1, jm2, smb4den, smb4b,
+                  smb4c, smb15, smb16, smb17, smb18, smb19, smb20, smb21,
+                  smb22, smb23, smb4d, smb14, smb5, smb4, smb3, spi0cs1,
+                  spi0cs2, spi0cs3, smb3c, smb3b, bmcuart0a, uart1, jtag2,
+                  bmcuart1, uart2, bmcuart0b, r1err, r1md, r1oen, r2oen,
+                  rmii3, r3oen, smb3d, fanin0, fanin1, fanin2, fanin3, fanin4,
+                  fanin5, fanin6, fanin7, fanin8, fanin9, fanin10, fanin11,
+                  fanin12, fanin13, fanin14, fanin15, pwm0, pwm1, pwm2, pwm3,
+                  r2, r2err, r2md, r3rxer, ga20kbc, smb5d, lpc, espi, rg1,
+                  rg1mdio, rg2, ddr, i3c0, i3c1, i3c2, i3c3, i3c4, i3c5,
+                  smb0, smb1, smb2, smb2c, smb2b, smb1c, smb1b, smb8, smb9,
+                  smb10, smb11, sd1, sd1pwr, pwm4, pwm5, pwm6, pwm7, pwm8,
+                  pwm9, pwm10, pwm11, mmc8, mmc, mmcwp, mmccd, mmcrst, clkout,
+                  serirq, lpcclk, scipme, sci, smb6, smb7, spi1, faninx, r1,
+                  spi3, spi3cs1, spi3quad, spi3cs2, spi3cs3, nprd_smi, smb0b,
+                  smb0c, smb0den, smb0d, ddc, rg2mdio, wdog1, wdog2, smb12,
+                  smb13, spix, spixcs1, clkreq, hgpio0, hgpio1, hgpio2, hgpio3,
+                  hgpio4, hgpio5, hgpio6, hgpio7 ]
+
+      function:
+        description:
+          The function that a group of pins is muxed to
+        enum: [ iox1, iox2, smb1d, smb2d, lkgpo1, lkgpo2, ioxh, gspi,
+                smb5b, smb5c, lkgpo0, pspi2, jm1, jm2, smb4den, smb4b,
+                smb4c, smb15, smb16, smb17, smb18, smb19, smb20, smb21,
+                smb22, smb23, smb4d, smb14, smb5, smb4, smb3, spi0cs1,
+                spi0cs2, spi0cs3, smb3c, smb3b, bmcuart0a, uart1, jtag2,
+                bmcuart1, uart2, bmcuart0b, r1err, r1md, r1oen, r2oen,
+                rmii3, r3oen, smb3d, fanin0, fanin1, fanin2, fanin3, fanin4,
+                fanin5, fanin6, fanin7, fanin8, fanin9, fanin10, fanin11,
+                fanin12, fanin13, fanin14, fanin15, pwm0, pwm1, pwm2, pwm3,
+                r2, r2err, r2md, r3rxer, ga20kbc, smb5d, lpc, espi, rg1,
+                rg1mdio, rg2, ddr, i3c0, i3c1, i3c2, i3c3, i3c4, i3c5,
+                smb0, smb1, smb2, smb2c, smb2b, smb1c, smb1b, smb8, smb9,
+                smb10, smb11, sd1, sd1pwr, pwm4, pwm5, pwm6, pwm7, pwm8,
+                pwm9, pwm10, pwm11, mmc8, mmc, mmcwp, mmccd, mmcrst, clkout,
+                serirq, lpcclk, scipme, sci, smb6, smb7, spi1, faninx, r1,
+                spi3, spi3cs1, spi3quad, spi3cs2, spi3cs3, nprd_smi, smb0b,
+                smb0c, smb0den, smb0d, ddc, rg2mdio, wdog1, wdog2, smb12,
+                smb13, spix, spixcs1, clkreq, hgpio0, hgpio1, hgpio2, hgpio3,
+                hgpio4, hgpio5, hgpio6, hgpio7 ]
+
+    dependencies:
+      groups: [ function ]
+      function: [ groups ]
+
+    additionalProperties: false
+
+  "^pin":
+    $ref: pincfg-node.yaml#
+
+    properties:
+      pins:
+        description:
+          A list of pins to configure in certain ways, such as enabling
+          debouncing
+
+      bias-disable: true
+
+      bias-pull-up: true
+
+      bias-pull-down: true
+
+      input-enable: true
+
+      output-low: true
+
+      output-high: true
+
+      drive-push-pull: true
+
+      drive-open-drain: true
+
+      input-debounce:
+        description:
+          Debouncing periods in microseconds, one period per interrupt
+          bank found in the controller
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+        minItems: 1
+        maxItems: 4
+
+      slew-rate:
+        description: |
+          0: Low rate
+          1: High rate
+        $ref: /schemas/types.yaml#/definitions/uint32
+        enum: [0, 1]
+
+      drive-strength:
+        enum: [ 0, 1, 2, 4, 8, 12 ]
+
+    additionalProperties: false
+
+allOf:
+  - $ref: "pinctrl.yaml#"
+
+required:
+  - compatible
+  - ranges
+  - '#address-cells'
+  - '#size-cells'
+  - nuvoton,sysgcr
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/gpio/gpio.h>
+
+    soc {
+      #address-cells = <2>;

Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml line 194

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +10 -0
+      #size-cells = <2>;
+
+      pinctrl: pinctrl@f0800000 {
+        compatible = "nuvoton,npcm845-pinctrl";
+        ranges = <0x0 0x0 0xf0010000 0x8000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nuvoton,sysgcr = <&gcr>;
+
+        gpio0: gpio@f0010000 {

gpio@0

Is this really a child block of the pinctrl? Doesn't really look like it based on addressess. Where are the pinctrl registers? In the sysgcr? If so, then pinctrl should be a child of it. But that doesn't really work too well with gpio child nodes...

Rob

author maintainer
#3 lore raw

Re: [PATCH v2 1/2] dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation

Hi Rob,

Thanks for your comment and sorry for the late reply.

Quoted 51 lines · Rob Herring
Quoted 49 lines · Tomer Maimon

Added device tree binding documentation for Nuvoton Arbel BMC NPCM8XX pinmux and GPIO controller.

---
 .../pinctrl/nuvoton,npcm845-pinctrl.yaml      | 213 ++++++++++++++++++
 1 file changed, 213 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +34 -0
new file mode 100644
index 000000000000..104766f7acc5
@@ -0,0 +1,213 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/nuvoton,npcm845-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nuvoton NPCM845 Pin Controller and GPIO
+
+maintainers:
+  - Tomer Maimon <[email protected]>
+
+description:
+  The Nuvoton BMC NPCM8XX Pin Controller multi-function routed through
+  the multiplexing block, Each pin supports GPIO functionality (GPIOx)
+  and multiple functions that directly connect the pin to different
+  hardware blocks.
+
+properties:
+  compatible:
+    const: nuvoton,npcm845-pinctrl
+
+  ranges:
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1
+
+  nuvoton,sysgcr:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: a phandle to access GCR registers.
+
Quoted 8 lines

Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml line 40

Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +6 -0
+patternProperties:
+  "^gpio@":
+    type: object
+
+    description:
+      Eight GPIO banks that each contain between 32 GPIOs.

'each contain between 32'?

will be fixed net version.

Quoted 19 lines
Quoted 19 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +18 -0
+
+    properties:
+      gpio-controller: true
+
+      '#gpio-cells':
+        const: 2
+
+      reg:
+        maxItems: 1
+
+      interrupts:
+        maxItems: 1
+
+      gpio-ranges:
+        maxItems: 1
+
+    required:
+      - gpio-controller
Quoted 8 lines

Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml line 64

Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +6 -0
+      - '#gpio-cells'
+      - reg
+      - interrupts
+      - gpio-ranges
+
+  "-mux":

'-mux$'? Something like 'foo-muxbar' is needed?

No.

Quoted 134 lines
Quoted 121 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +120 -0
+    $ref: pinmux-node.yaml#
+
+    properties:
+      groups:
+        description:
+          One or more groups of pins to mux to a certain function
+        items:
+          enum: [ iox1, iox2, smb1d, smb2d, lkgpo1, lkgpo2, ioxh, gspi,
+                  smb5b, smb5c, lkgpo0, pspi2, jm1, jm2, smb4den, smb4b,
+                  smb4c, smb15, smb16, smb17, smb18, smb19, smb20, smb21,
+                  smb22, smb23, smb4d, smb14, smb5, smb4, smb3, spi0cs1,
+                  spi0cs2, spi0cs3, smb3c, smb3b, bmcuart0a, uart1, jtag2,
+                  bmcuart1, uart2, bmcuart0b, r1err, r1md, r1oen, r2oen,
+                  rmii3, r3oen, smb3d, fanin0, fanin1, fanin2, fanin3, fanin4,
+                  fanin5, fanin6, fanin7, fanin8, fanin9, fanin10, fanin11,
+                  fanin12, fanin13, fanin14, fanin15, pwm0, pwm1, pwm2, pwm3,
+                  r2, r2err, r2md, r3rxer, ga20kbc, smb5d, lpc, espi, rg1,
+                  rg1mdio, rg2, ddr, i3c0, i3c1, i3c2, i3c3, i3c4, i3c5,
+                  smb0, smb1, smb2, smb2c, smb2b, smb1c, smb1b, smb8, smb9,
+                  smb10, smb11, sd1, sd1pwr, pwm4, pwm5, pwm6, pwm7, pwm8,
+                  pwm9, pwm10, pwm11, mmc8, mmc, mmcwp, mmccd, mmcrst, clkout,
+                  serirq, lpcclk, scipme, sci, smb6, smb7, spi1, faninx, r1,
+                  spi3, spi3cs1, spi3quad, spi3cs2, spi3cs3, nprd_smi, smb0b,
+                  smb0c, smb0den, smb0d, ddc, rg2mdio, wdog1, wdog2, smb12,
+                  smb13, spix, spixcs1, clkreq, hgpio0, hgpio1, hgpio2, hgpio3,
+                  hgpio4, hgpio5, hgpio6, hgpio7 ]
+
+      function:
+        description:
+          The function that a group of pins is muxed to
+        enum: [ iox1, iox2, smb1d, smb2d, lkgpo1, lkgpo2, ioxh, gspi,
+                smb5b, smb5c, lkgpo0, pspi2, jm1, jm2, smb4den, smb4b,
+                smb4c, smb15, smb16, smb17, smb18, smb19, smb20, smb21,
+                smb22, smb23, smb4d, smb14, smb5, smb4, smb3, spi0cs1,
+                spi0cs2, spi0cs3, smb3c, smb3b, bmcuart0a, uart1, jtag2,
+                bmcuart1, uart2, bmcuart0b, r1err, r1md, r1oen, r2oen,
+                rmii3, r3oen, smb3d, fanin0, fanin1, fanin2, fanin3, fanin4,
+                fanin5, fanin6, fanin7, fanin8, fanin9, fanin10, fanin11,
+                fanin12, fanin13, fanin14, fanin15, pwm0, pwm1, pwm2, pwm3,
+                r2, r2err, r2md, r3rxer, ga20kbc, smb5d, lpc, espi, rg1,
+                rg1mdio, rg2, ddr, i3c0, i3c1, i3c2, i3c3, i3c4, i3c5,
+                smb0, smb1, smb2, smb2c, smb2b, smb1c, smb1b, smb8, smb9,
+                smb10, smb11, sd1, sd1pwr, pwm4, pwm5, pwm6, pwm7, pwm8,
+                pwm9, pwm10, pwm11, mmc8, mmc, mmcwp, mmccd, mmcrst, clkout,
+                serirq, lpcclk, scipme, sci, smb6, smb7, spi1, faninx, r1,
+                spi3, spi3cs1, spi3quad, spi3cs2, spi3cs3, nprd_smi, smb0b,
+                smb0c, smb0den, smb0d, ddc, rg2mdio, wdog1, wdog2, smb12,
+                smb13, spix, spixcs1, clkreq, hgpio0, hgpio1, hgpio2, hgpio3,
+                hgpio4, hgpio5, hgpio6, hgpio7 ]
+
+    dependencies:
+      groups: [ function ]
+      function: [ groups ]
+
+    additionalProperties: false
+
+  "^pin":
+    $ref: pincfg-node.yaml#
+
+    properties:
+      pins:
+        description:
+          A list of pins to configure in certain ways, such as enabling
+          debouncing
+
+      bias-disable: true
+
+      bias-pull-up: true
+
+      bias-pull-down: true
+
+      input-enable: true
+
+      output-low: true
+
+      output-high: true
+
+      drive-push-pull: true
+
+      drive-open-drain: true
+
+      input-debounce:
+        description:
+          Debouncing periods in microseconds, one period per interrupt
+          bank found in the controller
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+        minItems: 1
+        maxItems: 4
+
+      slew-rate:
+        description: |
+          0: Low rate
+          1: High rate
+        $ref: /schemas/types.yaml#/definitions/uint32
+        enum: [0, 1]
+
+      drive-strength:
+        enum: [ 0, 1, 2, 4, 8, 12 ]
+
+    additionalProperties: false
+
+allOf:
+  - $ref: "pinctrl.yaml#"
+
+required:
+  - compatible
+  - ranges
+  - '#address-cells'
+  - '#size-cells'
+  - nuvoton,sysgcr
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/gpio/gpio.h>
+
+    soc {
+      #address-cells = <2>;

Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml line 194

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +10 -0
+      #size-cells = <2>;
+
+      pinctrl: pinctrl@f0800000 {
+        compatible = "nuvoton,npcm845-pinctrl";
+        ranges = <0x0 0x0 0xf0010000 0x8000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nuvoton,sysgcr = <&gcr>;
+
+        gpio0: gpio@f0010000 {

gpio@0

Quoted 4 lines

Is this really a child block of the pinctrl? Doesn't really look like it based on addressess. Where are the pinctrl registers? In the sysgcr? If so, then pinctrl should be a child of it. But that doesn't really work too well with gpio child nodes...

the pin controller mux is handled by sysgcr this is why the sysgcr in the mother node,
and the pin configuration are handled by the GPIO registers. each GPIO bank (child) contains 32 GPIO.
this is why the GPIO is the child node.

Quoted 2 lines

Rob

Best regards,

Tomer

#4 lore raw

Re: [PATCH v2 1/2] dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation

Quoted 3 lines · Tomer Maimon

Hi Rob,

Thanks for your comment and sorry for the late reply.

Two months... we are out of the context and this will not help your patchset.

Quoted 3 lines · Rob Herring
Quoted 1 line

(...)

Quoted 24 lines
Quoted 20 lines
Quoted 7 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +7 -0
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/gpio/gpio.h>
+
+    soc {
+      #address-cells = <2>;

Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml line 194

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +10 -0
+      #size-cells = <2>;
+
+      pinctrl: pinctrl@f0800000 {
+        compatible = "nuvoton,npcm845-pinctrl";
+        ranges = <0x0 0x0 0xf0010000 0x8000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nuvoton,sysgcr = <&gcr>;
+
+        gpio0: gpio@f0010000 {

gpio@0

Quoted 4 lines

Is this really a child block of the pinctrl? Doesn't really look like it based on addressess. Where are the pinctrl registers? In the sysgcr? If so, then pinctrl should be a child of it. But that doesn't really work too well with gpio child nodes...

Quoted 5 lines

the pin controller mux is handled by sysgcr this is why the sysgcr in the mother node,
and the pin configuration are handled by the GPIO registers. each GPIO bank (child) contains 32 GPIO.
this is why the GPIO is the child node.

Then maybe pinctrl should be the sysgcr and expose regmap for other devices?

Best regards,
Krzysztof

author maintainer
#5 lore raw

Re: [PATCH v2 1/2] dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation

Hi Krzysztof,

Sorry but I didn't understand,

Quoted 39 lines · Krzysztof Kozlowski
Quoted 3 lines · Tomer Maimon

Hi Rob,

Thanks for your comment and sorry for the late reply.

Two months... we are out of the context and this will not help your patchset.

Quoted 3 lines · Rob Herring
Quoted 1 line

(...)

Quoted 24 lines
Quoted 24 lines
Quoted 7 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +7 -0
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/gpio/gpio.h>
+
+    soc {
+      #address-cells = <2>;

Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml line 194

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +10 -0
+      #size-cells = <2>;
+
+      pinctrl: pinctrl@f0800000 {
+        compatible = "nuvoton,npcm845-pinctrl";
+        ranges = <0x0 0x0 0xf0010000 0x8000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nuvoton,sysgcr = <&gcr>;
+
+        gpio0: gpio@f0010000 {

gpio@0

Is this really a child block of the pinctrl? Doesn't really look like it based on addressess. Where are the pinctrl registers? In the sysgcr? If so, then pinctrl should be a child of it. But that doesn't really work too well with gpio child nodes...

Quoted 7 lines
Quoted 5 lines

the pin controller mux is handled by sysgcr this is why the sysgcr in the mother node,
and the pin configuration are handled by the GPIO registers. each GPIO bank (child) contains 32 GPIO.
this is why the GPIO is the child node.

Then maybe pinctrl should be the sysgcr and expose regmap for other devices?

The pin controller using the sysgcr to handle the pinmux, this is why the sysgcr is in the mother node, is it problematic?

Quoted 4 lines

Best regards,
Krzysztof

Best regards,

Tomer

#6 lore raw

Re: [PATCH v2 1/2] dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation

Quoted 30 lines · Tomer Maimon
Quoted 30 lines
Quoted 29 lines
Quoted 20 lines
Quoted 7 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +7 -0
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/gpio/gpio.h>
+
+    soc {
+      #address-cells = <2>;

Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml line 194

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +10 -0
+      #size-cells = <2>;
+
+      pinctrl: pinctrl@f0800000 {
+        compatible = "nuvoton,npcm845-pinctrl";
+        ranges = <0x0 0x0 0xf0010000 0x8000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nuvoton,sysgcr = <&gcr>;
+
+        gpio0: gpio@f0010000 {

gpio@0

Quoted 4 lines

Is this really a child block of the pinctrl? Doesn't really look like it based on addressess. Where are the pinctrl registers? In the sysgcr? If so, then pinctrl should be a child of it. But that doesn't really work too well with gpio child nodes...

the pin controller mux is handled by sysgcr this is why the sysgcr in the mother node,
and the pin configuration are handled by the GPIO registers. each GPIO bank (child) contains 32 GPIO.
this is why the GPIO is the child node.

Quoted 3 lines
Quoted 1 line

Then maybe pinctrl should be the sysgcr and expose regmap for other devices?

The pin controller using the sysgcr to handle the pinmux, this is why the sysgcr is in the mother node, is it problematic?

You said pin-controller mux registers are in sysgcr, so it should not be used via syscon.

Please provide address map description to convince us that this is correct HW representation.

Best regards,
Krzysztof

author maintainer
#7 lore raw

Re: [PATCH v2 1/2] dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation

Quoted 32 lines · Krzysztof Kozlowski
Quoted 30 lines · Tomer Maimon
Quoted 30 lines
Quoted 29 lines
Quoted 20 lines
Quoted 7 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +7 -0
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/gpio/gpio.h>
+
+    soc {
+      #address-cells = <2>;

Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml line 194

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,npcm845-pinctrl.yaml new file +10 -0
+      #size-cells = <2>;
+
+      pinctrl: pinctrl@f0800000 {
+        compatible = "nuvoton,npcm845-pinctrl";
+        ranges = <0x0 0x0 0xf0010000 0x8000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nuvoton,sysgcr = <&gcr>;
+
+        gpio0: gpio@f0010000 {

gpio@0

Quoted 4 lines

Is this really a child block of the pinctrl? Doesn't really look like it based on addressess. Where are the pinctrl registers? In the sysgcr? If so, then pinctrl should be a child of it. But that doesn't really work too well with gpio child nodes...

the pin controller mux is handled by sysgcr this is why the sysgcr in the mother node,
and the pin configuration are handled by the GPIO registers. each GPIO bank (child) contains 32 GPIO.
this is why the GPIO is the child node.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Then maybe pinctrl should be the sysgcr and expose regmap for other devices?

The pin controller using the sysgcr to handle the pinmux, this is why the sysgcr is in the mother node, is it problematic?

You said pin-controller mux registers are in sysgcr, so it should not be used via syscon.

Sorry but maybe I missed something.
the sysgcr is used for miscellaneous features and not only for the pin controller mux, this is why it used syscon and defined in the dtsi:

                gcr: system-controller@f0800000 {
                        compatible = "nuvoton,npcm845-gcr", "syscon";
                        reg = <0x0 0xf0800000 0x0 0x1000>;
                };
Quoted 3 lines

Please provide address map description to convince us that this is correct HW representation.

GCR (sysgcr) registers 0xf0800000-0xf0801000 - used for miscellaneous features, not only pin mux.
GPIO0 0xf0010000-0xf0011000
GPIO1 0xf0011000-0xf0012000
...
GPIO7 0xf0017000-0xf0018000

Quoted 3 lines

Best regards,
Krzysztof

Best regards,

Tomer

#8 lore raw

Re: [PATCH v2 1/2] dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation

Quoted 35 lines · Tomer Maimon
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 9 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+      pinctrl: pinctrl@f0800000 {
+        compatible = "nuvoton,npcm845-pinctrl";
+        ranges = <0x0 0x0 0xf0010000 0x8000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nuvoton,sysgcr = <&gcr>;
+
+        gpio0: gpio@f0010000 {
Quoted 6 lines

gpio@0

Is this really a child block of the pinctrl? Doesn't really look like it based on addressess. Where are the pinctrl registers? In the sysgcr? If so, then pinctrl should be a child of it. But that doesn't really work too well with gpio child nodes...

the pin controller mux is handled by sysgcr this is why the sysgcr in the mother node,
and the pin configuration are handled by the GPIO registers. each GPIO bank (child) contains 32 GPIO.
this is why the GPIO is the child node.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Then maybe pinctrl should be the sysgcr and expose regmap for other devices?

The pin controller using the sysgcr to handle the pinmux, this is why the sysgcr is in the mother node, is it problematic?

You said pin-controller mux registers are in sysgcr, so it should not be used via syscon.

Sorry but maybe I missed something.
the sysgcr is used for miscellaneous features and not only for the pin controller mux, this is why it used syscon and defined in the dtsi:

                gcr: system-controller@f0800000 {
                        compatible = "nuvoton,npcm845-gcr", "syscon";
                        reg = <0x0 0xf0800000 0x0 0x1000>;
                };
Quoted 1 line
Quoted 9 lines
Quoted 2 lines

Please provide address map description to convince us that this is correct HW representation.

GCR (sysgcr) registers 0xf0800000-0xf0801000 - used for miscellaneous features, not only pin mux.
GPIO0 0xf0010000-0xf0011000
GPIO1 0xf0011000-0xf0012000
...
GPIO7 0xf0017000-0xf0018000

Quoted 1 line

Then why your pinctrl is in sysgcr IO range? (pinctrl@f0800000)

Your map looks quite different from what you described in example.

Best regards,
Krzysztof

author maintainer
#9 lore raw

Re: [PATCH v2 1/2] dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation

Quoted 47 lines · Krzysztof Kozlowski
Quoted 35 lines · Tomer Maimon
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 9 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+      pinctrl: pinctrl@f0800000 {
+        compatible = "nuvoton,npcm845-pinctrl";
+        ranges = <0x0 0x0 0xf0010000 0x8000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nuvoton,sysgcr = <&gcr>;
+
+        gpio0: gpio@f0010000 {
Quoted 6 lines

gpio@0

Is this really a child block of the pinctrl? Doesn't really look like it based on addressess. Where are the pinctrl registers? In the sysgcr? If so, then pinctrl should be a child of it. But that doesn't really work too well with gpio child nodes...

the pin controller mux is handled by sysgcr this is why the sysgcr in the mother node,
and the pin configuration are handled by the GPIO registers. each GPIO bank (child) contains 32 GPIO.
this is why the GPIO is the child node.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Then maybe pinctrl should be the sysgcr and expose regmap for other devices?

The pin controller using the sysgcr to handle the pinmux, this is why the sysgcr is in the mother node, is it problematic?

You said pin-controller mux registers are in sysgcr, so it should not be used via syscon.

Sorry but maybe I missed something.
the sysgcr is used for miscellaneous features and not only for the pin controller mux, this is why it used syscon and defined in the dtsi:

                gcr: system-controller@f0800000 {
                        compatible = "nuvoton,npcm845-gcr", "syscon";
                        reg = <0x0 0xf0800000 0x0 0x1000>;
                };
Quoted 1 line
Quoted 9 lines
Quoted 2 lines

Please provide address map description to convince us that this is correct HW representation.

GCR (sysgcr) registers 0xf0800000-0xf0801000 - used for miscellaneous features, not only pin mux.
GPIO0 0xf0010000-0xf0011000
GPIO1 0xf0011000-0xf0012000
...
GPIO7 0xf0017000-0xf0018000

Quoted 1 line
Quoted 1 line

Then why your pinctrl is in sysgcr IO range? (pinctrl@f0800000)

you suggest using pinctrl@0 or pinctrl@f0010000 and not pinctrl@f0800000 because 0xf0800000 is the GCR address that serve miscellaneous features and not only pinmux controller ?

Quoted 5 lines

Your map looks quite different from what you described in example.

Best regards,
Krzysztof

Best regards,

Tomer

#10 lore raw

Re: [PATCH v2 1/2] dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation

Quoted 49 lines · Tomer Maimon
Quoted 47 lines · Krzysztof Kozlowski
Quoted 44 lines · Tomer Maimon
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 9 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+      pinctrl: pinctrl@f0800000 {
+        compatible = "nuvoton,npcm845-pinctrl";
+        ranges = <0x0 0x0 0xf0010000 0x8000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nuvoton,sysgcr = <&gcr>;
+
+        gpio0: gpio@f0010000 {
Quoted 6 lines

gpio@0

Is this really a child block of the pinctrl? Doesn't really look like it based on addressess. Where are the pinctrl registers? In the sysgcr? If so, then pinctrl should be a child of it. But that doesn't really work too well with gpio child nodes...

the pin controller mux is handled by sysgcr this is why the sysgcr in the mother node,
and the pin configuration are handled by the GPIO registers. each GPIO bank (child) contains 32 GPIO.
this is why the GPIO is the child node.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Then maybe pinctrl should be the sysgcr and expose regmap for other devices?

The pin controller using the sysgcr to handle the pinmux, this is why the sysgcr is in the mother node, is it problematic?

You said pin-controller mux registers are in sysgcr, so it should not be used via syscon.

Sorry but maybe I missed something.
the sysgcr is used for miscellaneous features and not only for the pin controller mux, this is why it used syscon and defined in the dtsi:

                gcr: system-controller@f0800000 {
                        compatible = "nuvoton,npcm845-gcr", "syscon";
                        reg = <0x0 0xf0800000 0x0 0x1000>;
                };
Quoted 3 lines

Please provide address map description to convince us that this is correct HW representation.

GCR (sysgcr) registers 0xf0800000-0xf0801000 - used for miscellaneous features, not only pin mux.
GPIO0 0xf0010000-0xf0011000
GPIO1 0xf0011000-0xf0012000
...
GPIO7 0xf0017000-0xf0018000

Quoted 1 line
Quoted 4 lines
Quoted 1 line

Then why your pinctrl is in sysgcr IO range? (pinctrl@f0800000)

you suggest using pinctrl@0 or pinctrl@f0010000 and not pinctrl@f0800000 because 0xf0800000 is the GCR address that serve miscellaneous features and not only pinmux controller ?

If you have a map like you pasted, then DTS like this:

syscon@f0800000 {}
pinctrl@f0800000 {
gpio@f0010000 {}
}

Is quite weird, don't you think? You have two devices on the same unit address which is not allowed. You have child of pinctrl with entirely different unit address, so how is it its child?

Best regards,
Krzysztof

author maintainer
#11 lore raw

Re: [PATCH v2 1/2] dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation

Quoted 58 lines · Krzysztof Kozlowski
Quoted 49 lines · Tomer Maimon
Quoted 47 lines · Krzysztof Kozlowski
Quoted 44 lines · Tomer Maimon
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 9 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+      pinctrl: pinctrl@f0800000 {
+        compatible = "nuvoton,npcm845-pinctrl";
+        ranges = <0x0 0x0 0xf0010000 0x8000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nuvoton,sysgcr = <&gcr>;
+
+        gpio0: gpio@f0010000 {
Quoted 6 lines

gpio@0

Is this really a child block of the pinctrl? Doesn't really look like it based on addressess. Where are the pinctrl registers? In the sysgcr? If so, then pinctrl should be a child of it. But that doesn't really work too well with gpio child nodes...

the pin controller mux is handled by sysgcr this is why the sysgcr in the mother node,
and the pin configuration are handled by the GPIO registers. each GPIO bank (child) contains 32 GPIO.
this is why the GPIO is the child node.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Then maybe pinctrl should be the sysgcr and expose regmap for other devices?

The pin controller using the sysgcr to handle the pinmux, this is why the sysgcr is in the mother node, is it problematic?

You said pin-controller mux registers are in sysgcr, so it should not be used via syscon.

Sorry but maybe I missed something.
the sysgcr is used for miscellaneous features and not only for the pin controller mux, this is why it used syscon and defined in the dtsi:

                gcr: system-controller@f0800000 {
                        compatible = "nuvoton,npcm845-gcr", "syscon";
                        reg = <0x0 0xf0800000 0x0 0x1000>;
                };
Quoted 3 lines

Please provide address map description to convince us that this is correct HW representation.

GCR (sysgcr) registers 0xf0800000-0xf0801000 - used for miscellaneous features, not only pin mux.
GPIO0 0xf0010000-0xf0011000
GPIO1 0xf0011000-0xf0012000
...
GPIO7 0xf0017000-0xf0018000

Quoted 1 line
Quoted 4 lines
Quoted 1 line

Then why your pinctrl is in sysgcr IO range? (pinctrl@f0800000)

you suggest using pinctrl@0 or pinctrl@f0010000 and not pinctrl@f0800000 because 0xf0800000 is the GCR address that serve miscellaneous features and not only pinmux controller ?

If you have a map like you pasted, then DTS like this:

Quoted 7 lines

syscon@f0800000 {}
pinctrl@f0800000 {
gpio@f0010000 {}
}

Is quite weird, don't you think? You have two devices on the same unit address which is not allowed. You have child of pinctrl with entirely

O.K.

Quoted 1 line

different unit address, so how is it its child?

The pinctrl node name will modify the pinctrl@f0010000 the same as the range property and the start of the child registers,is it fine?

Quoted 2 lines

Best regards,
Krzysztof

Best regards,

Tomer

#12 lore raw

Re: [PATCH v2 1/2] dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation

Quoted 65 lines · Tomer Maimon
Quoted 63 lines · Krzysztof Kozlowski
Quoted 49 lines · Tomer Maimon
Quoted 47 lines · Krzysztof Kozlowski
Quoted 44 lines · Tomer Maimon
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 9 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+      pinctrl: pinctrl@f0800000 {
+        compatible = "nuvoton,npcm845-pinctrl";
+        ranges = <0x0 0x0 0xf0010000 0x8000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nuvoton,sysgcr = <&gcr>;
+
+        gpio0: gpio@f0010000 {
Quoted 6 lines

gpio@0

Is this really a child block of the pinctrl? Doesn't really look like it based on addressess. Where are the pinctrl registers? In the sysgcr? If so, then pinctrl should be a child of it. But that doesn't really work too well with gpio child nodes...

the pin controller mux is handled by sysgcr this is why the sysgcr in the mother node,
and the pin configuration are handled by the GPIO registers. each GPIO bank (child) contains 32 GPIO.
this is why the GPIO is the child node.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Then maybe pinctrl should be the sysgcr and expose regmap for other devices?

The pin controller using the sysgcr to handle the pinmux, this is why the sysgcr is in the mother node, is it problematic?

You said pin-controller mux registers are in sysgcr, so it should not be used via syscon.

Sorry but maybe I missed something.
the sysgcr is used for miscellaneous features and not only for the pin controller mux, this is why it used syscon and defined in the dtsi:

                gcr: system-controller@f0800000 {
                        compatible = "nuvoton,npcm845-gcr", "syscon";
                        reg = <0x0 0xf0800000 0x0 0x1000>;
                };
Quoted 3 lines

Please provide address map description to convince us that this is correct HW representation.

GCR (sysgcr) registers 0xf0800000-0xf0801000 - used for miscellaneous features, not only pin mux.
GPIO0 0xf0010000-0xf0011000
GPIO1 0xf0011000-0xf0012000
...
GPIO7 0xf0017000-0xf0018000

Quoted 1 line
Quoted 4 lines
Quoted 1 line

Then why your pinctrl is in sysgcr IO range? (pinctrl@f0800000)

you suggest using pinctrl@0 or pinctrl@f0010000 and not pinctrl@f0800000 because 0xf0800000 is the GCR address that serve miscellaneous features and not only pinmux controller ?

If you have a map like you pasted, then DTS like this:

syscon@f0800000 {}
pinctrl@f0800000 {
gpio@f0010000 {}
}

Quoted 6 lines
Quoted 2 lines

Is quite weird, don't you think? You have two devices on the same unit address which is not allowed. You have child of pinctrl with entirely

O.K.

Quoted 1 line

different unit address, so how is it its child?

The pinctrl node name will modify the pinctrl@f0010000 the same as the range property and the start of the child registers,is it fine?

We are all busy, so I don't have that much bandwidth to review each of your many solutions and instead poking me with every possible solution, I would prefer if you think a bit how this all should work and look.

I don't know if it is fine. Why you should have two devices like this:
pinctrl@f0010000 {
gpio@f0010000 {}
}

???
Instead of one device? Answer such questions to yourself before asking me. Please come with reasonable DTS describing the hardware.

Best regards,
Krzysztof

author maintainer
#13 lore raw

Re: [PATCH v2 1/2] dt-binding: pinctrl: Add NPCM8XX pinctrl and GPIO documentation

Quoted 78 lines · Krzysztof Kozlowski
Quoted 65 lines · Tomer Maimon
Quoted 63 lines · Krzysztof Kozlowski
Quoted 49 lines · Tomer Maimon
Quoted 47 lines · Krzysztof Kozlowski
Quoted 44 lines · Tomer Maimon
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 9 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+      pinctrl: pinctrl@f0800000 {
+        compatible = "nuvoton,npcm845-pinctrl";
+        ranges = <0x0 0x0 0xf0010000 0x8000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nuvoton,sysgcr = <&gcr>;
+
+        gpio0: gpio@f0010000 {
Quoted 6 lines

gpio@0

Is this really a child block of the pinctrl? Doesn't really look like it based on addressess. Where are the pinctrl registers? In the sysgcr? If so, then pinctrl should be a child of it. But that doesn't really work too well with gpio child nodes...

the pin controller mux is handled by sysgcr this is why the sysgcr in the mother node,
and the pin configuration are handled by the GPIO registers. each GPIO bank (child) contains 32 GPIO.
this is why the GPIO is the child node.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Then maybe pinctrl should be the sysgcr and expose regmap for other devices?

The pin controller using the sysgcr to handle the pinmux, this is why the sysgcr is in the mother node, is it problematic?

You said pin-controller mux registers are in sysgcr, so it should not be used via syscon.

Sorry but maybe I missed something.
the sysgcr is used for miscellaneous features and not only for the pin controller mux, this is why it used syscon and defined in the dtsi:

                gcr: system-controller@f0800000 {
                        compatible = "nuvoton,npcm845-gcr", "syscon";
                        reg = <0x0 0xf0800000 0x0 0x1000>;
                };
Quoted 3 lines

Please provide address map description to convince us that this is correct HW representation.

GCR (sysgcr) registers 0xf0800000-0xf0801000 - used for miscellaneous features, not only pin mux.
GPIO0 0xf0010000-0xf0011000
GPIO1 0xf0011000-0xf0012000
...
GPIO7 0xf0017000-0xf0018000

Quoted 1 line
Quoted 4 lines
Quoted 1 line

Then why your pinctrl is in sysgcr IO range? (pinctrl@f0800000)

you suggest using pinctrl@0 or pinctrl@f0010000 and not pinctrl@f0800000 because 0xf0800000 is the GCR address that serve miscellaneous features and not only pinmux controller ?

If you have a map like you pasted, then DTS like this:

syscon@f0800000 {}
pinctrl@f0800000 {
gpio@f0010000 {}
}

Quoted 6 lines
Quoted 2 lines

Is quite weird, don't you think? You have two devices on the same unit address which is not allowed. You have child of pinctrl with entirely

O.K.

Quoted 1 line

different unit address, so how is it its child?

The pinctrl node name will modify the pinctrl@f0010000 the same as the range property and the start of the child registers,is it fine?

We are all busy, so I don't have that much bandwidth to review each of your many solutions and instead poking me with every possible solution, I would prefer if you think a bit how this all should work and look.

Quoted 9 lines

I don't know if it is fine. Why you should have two devices like this:
pinctrl@f0010000 {
gpio@f0010000 {}
}

???
Instead of one device? Answer such questions to yourself before asking me. Please come with reasonable DTS describing the hardware.

Will do, thanks.

Quoted 2 lines

Best regards,
Krzysztof

Best regards,

Tomer

author maintainer
#14 lore raw

PATCH v2 2/2 pinctrl: nuvoton: add NPCM8XX pinctrl and GPIO driver

In reply to Tomer Maimon

Add pinctrl and GPIO controller driver support to Arbel BMC NPCM8XX SoC.

Arbel BMC NPCM8XX pinctrl driver based on Poleg NPCM7XX, except the pin mux mapping difference the NPCM8XX GPIO supports adjust debounce period time.

---
 drivers/pinctrl/nuvoton/Kconfig           |   13 +
 drivers/pinctrl/nuvoton/Makefile          |    1 +
 drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c | 2528 +++++++++++++++++++++
 3 files changed, 2542 insertions(+)
 create mode 100644 drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
drivers/pinctrl/nuvoton/Kconfig +13 -0
index 852b0d0eb08e..b6a16a483145 100644
@@ -31,3 +31,16 @@ config PINCTRL_NPCM7XX
 	help
 	  Say Y here to enable pin controller and GPIO support
 	  for Nuvoton NPCM750/730/715/705 SoCs.
+
+config PINCTRL_NPCM8XX
+	bool "Pinctrl and GPIO driver for Nuvoton NPCM8XX"
+	depends on (ARCH_NPCM || COMPILE_TEST) && OF
+	select PINMUX
+	select PINCONF
+	select GENERIC_PINCONF
+	select GPIOLIB
+	select GPIO_GENERIC
+	select GPIOLIB_IRQCHIP
+	help
+	  Say Y here to enable pin controller and GPIO support
+	  for Nuvoton NPCM8XX SoC.
drivers/pinctrl/nuvoton/Makefile +1 -0
index 9e66f5dc74bf..08031eab0af6 100644
@@ -3,3 +3,4 @@
 
 obj-$(CONFIG_PINCTRL_WPCM450)	+= pinctrl-wpcm450.o
 obj-$(CONFIG_PINCTRL_NPCM7XX)	+= pinctrl-npcm7xx.o
+obj-$(CONFIG_PINCTRL_NPCM8XX)	+= pinctrl-npcm8xx.o
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +2528 -0

2,528 lines not on this page · raw message

Signature · 1 line
2.33.0
#15 lore raw

Re: [PATCH v2 2/2] pinctrl: nuvoton: add NPCM8XX pinctrl and GPIO driver

Quoted 15 lines · Tomer Maimon

Add pinctrl and GPIO controller driver support to Arbel BMC NPCM8XX SoC.

Arbel BMC NPCM8XX pinctrl driver based on Poleg NPCM7XX, except the pin mux mapping difference the NPCM8XX GPIO supports adjust debounce period time.

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +7 -0
+
+static int npcm8xx_pinctrl_probe(struct platform_device *pdev)
+{
+	struct npcm8xx_pinctrl *pctrl;
+	int ret;
+
+	pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 2487

Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +10 -0
+	if (!pctrl)
+		return -ENOMEM;
+
+	pctrl->dev = &pdev->dev;
+	dev_set_drvdata(&pdev->dev, pctrl);
+
+	pctrl->gcr_regmap =
+		syscon_regmap_lookup_by_phandle(pctrl->dev->of_node, "nuvoton,sysgcr");
+	if (IS_ERR(pctrl->gcr_regmap))
+		return dev_err_probe(pctrl->dev, PTR_ERR(pctrl->gcr_regmap), "Failed to find nuvoton,sysgcr property\n");

Please wrap your code according to Linux coding style - @80.

Best regards,
Krzysztof

#16 lore raw

Re: [PATCH v2 2/2] pinctrl: nuvoton: add NPCM8XX pinctrl and GPIO driver

Quoted 1 line · Krzysztof Kozlowski

On 14/07/2022 14:23, Tomer Maimon wrote:

...

Quoted 2 lines

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 2473

Quoted 2 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +2 -0
+static int npcm8xx_pinctrl_probe(struct platform_device *pdev)
+{

Temporary variable, i.e.

  struct device *dev = &pdev->dev;
Quoted 6 lines
Quoted 6 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +6 -0
+     struct npcm8xx_pinctrl *pctrl;
+     int ret;
+
+     pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
+     if (!pctrl)
+             return -ENOMEM;
Quoted 8 lines

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 2487

Quoted 8 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +8 -0
+
+     pctrl->dev = &pdev->dev;
+     dev_set_drvdata(&pdev->dev, pctrl);
+
+     pctrl->gcr_regmap =
+             syscon_regmap_lookup_by_phandle(pctrl->dev->of_node, "nuvoton,sysgcr");
+     if (IS_ERR(pctrl->gcr_regmap))
+             return dev_err_probe(pctrl->dev, PTR_ERR(pctrl->gcr_regmap), "Failed to find nuvoton,sysgcr property\n");

Will help to shorten the above line(s).

Quoted 1 line

Please wrap your code according to Linux coding style - @80.

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

Re: [PATCH v2 2/2] pinctrl: nuvoton: add NPCM8XX pinctrl and GPIO driver

In reply to Tomer Maimon
Quoted 6 lines · Tomer Maimon

Add pinctrl and GPIO controller driver support to Arbel BMC NPCM8XX SoC.

Arbel BMC NPCM8XX pinctrl driver based on Poleg NPCM7XX, except the pin mux mapping difference the NPCM8XX GPIO supports adjust debounce period time.

...

drivers/pinctrl/nuvoton/Kconfig config PINCTRL_NPCM7XX · line 36

Quoted 2 lines
drivers/pinctrl/nuvoton/Kconfig +2 -0
+config PINCTRL_NPCM8XX
+       bool "Pinctrl and GPIO driver for Nuvoton NPCM8XX"

Why boolean?

Quoted 1 line

+ depends on (ARCH_NPCM || COMPILE_TEST) && OF

I believe the OF is not compile time dependency, hence you may for it as functional one by

  depends on (ARCH_NPCM && OF) || COMPILE_TEST

drivers/pinctrl/nuvoton/Kconfig config PINCTRL_NPCM7XX · line 46

Quoted 9 lines
drivers/pinctrl/nuvoton/Kconfig +9 -0
+       select PINMUX
+       select PINCONF
+       select GENERIC_PINCONF
+       select GPIOLIB
+       select GPIO_GENERIC
+       select GPIOLIB_IRQCHIP
+       help
+         Say Y here to enable pin controller and GPIO support
+         for Nuvoton NPCM8XX SoC.

Depends on the answer above, this might need an addition on how module will be called.

...

Missed bits.h.

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 9

Quoted 6 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +6 -0
+#include <linux/device.h>
+#include <linux/gpio/driver.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>

Missed mod_devicetable.h.

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 12

Quoted 3 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +3 -0
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>

How are these being used?

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 18

Quoted 6 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +6 -0
+#include <linux/pinctrl/machine.h>
+#include <linux/pinctrl/pinconf.h>
+#include <linux/pinctrl/pinconf-generic.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/platform_device.h>

+ property.h.

Quoted 1 line

+#include <linux/regmap.h>

...

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 27

Quoted 7 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +7 -0
+/* GCR registers */
+#define NPCM8XX_GCR_PDID       0x00
+#define NPCM8XX_GCR_SRCNT      0x68
+#define NPCM8XX_GCR_FLOCKR1    0x74
+#define NPCM8XX_GCR_DSCNT      0x78
+#define NPCM8XX_GCR_I2CSEGCTL  0xE4
+#define NPCM8XX_GCR_I2CSEGSEL  0xE0

Format them with the same width, e.g. 0x0E0.
And, btw, why capital letters in the numbers?

Quoted 7 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +7 -0
+#define NPCM8XX_GCR_MFSEL1     0x260
+#define NPCM8XX_GCR_MFSEL2     0x264
+#define NPCM8XX_GCR_MFSEL3     0x268
+#define NPCM8XX_GCR_MFSEL4     0x26C
+#define NPCM8XX_GCR_MFSEL5     0x270
+#define NPCM8XX_GCR_MFSEL6     0x274
+#define NPCM8XX_GCR_MFSEL7     0x278

...

Quoted 1 line

+/* GPIO registers */

Ditto.

...

Quoted 1 line

+#define NPCM8XX_DEBOUNCE_NANOSEC 40

_NSEC is enough.

...

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 96

Quoted 2 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +2 -0
+#define NPCM8XX_DEBOUNCE_VAL_MASK      GENMASK(23, 4)
+#define NPCM8XX_DEBOUNCE_MAX_VAL       0xFFFFF7

How MAX_VAL is different from the MASK ?

...

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 106

Quoted 4 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +3 -0
+struct npcm8xx_gpio {
+       void __iomem            *base;
 
+       struct gpio_chip        gc;

Making this first member in the structure may reduce the code base at compile time due to pointer arithmetic. You may confirm that by using bloat-o-meter.

Quoted 11 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +11 -0
+       struct debounce_time    debounce;
+       int                     irqbase;
+       int                     irq;
+       struct irq_chip         irq_chip;
+       u32                     pinctrl_id;
+       int (*direction_input)(struct gpio_chip *chip, unsigned int offset);
+       int (*direction_output)(struct gpio_chip *chip, unsigned int offset,
+                               int value);
+       int (*request)(struct gpio_chip *chip, unsigned int offset);
+       void (*free)(struct gpio_chip *chip, unsigned int offset);
+};

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+       val = ioread32(reg) | pinmask;
+       iowrite32(val, reg);

With this kind of indentation you may even reduce codebase with

iowrite32(ioread32(reg) | pinmask, reg);

...

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 153

Quoted 2 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +2 -0
+       val = ioread32(reg) & ~pinmask;
+       iowrite32(val, reg);

Ditto.

...

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 162

Quoted 3 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +3 -0
+static void npcmgpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
+{
+       seq_printf(s, "-- module %d [gpio%d - %d]\n",

Hmm... Isn't pin range is showed in a separate debugfs node?

Quoted 1 line

+}

...

Quoted 1 line

+ for_each_set_bit(bit, (const void *)&sts, NPCM8XX_GPIO_PER_BANK)

Why this casting?

Quoted 1 line

+ generic_handle_domain_irq(gc->irq.domain, bit);

...

Quoted 1 line

+ unsigned int gpio = BIT(d->hwirq);

There is a special helper to get an H/W IRQ, which is type of irq_hw_number_t IIRC.

...

Quoted 1 line

+ if (type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) {

IRQ_TYPE_LEVEL_MASK

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 289

Quoted 5 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +4 -0
+               npcm_gpio_clr(&bank->gc, bank->base + NPCM8XX_GP_N_EVTYP, gpio);
+               irq_set_handler_locked(d, handle_level_irq);
 
+       } else if (type & (IRQ_TYPE_EDGE_BOTH | IRQ_TYPE_EDGE_RISING
+                          | IRQ_TYPE_EDGE_FALLING)) {

Why duplicating RISING and FAILING? Isn't it covered by BOTH?

Quoted 3 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +3 -0
+               npcm_gpio_set(&bank->gc, bank->base + NPCM8XX_GP_N_EVTYP, gpio);
+               irq_set_handler_locked(d, handle_edge_irq);
+       }

...

Quoted 1 line

+ unsigned int gpio = d->hwirq;

Read the documentation on how the mask()/unmask() has to be implemented (there are examples):
https://www.kernel.org/doc/html/latest/driver-api/gpio/driver.html#infrastructure-helpers-for-gpio-irqchips

...

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 627

Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +10 -0
+/*
+ * pin:             name, number
+ * group:    name, npins,   pins
+ * function: name, ngroups, groups
+ */
+struct npcm8xx_group {
+       const char *name;
+       const unsigned int *pins;
+       int npins;
+};

NIH struct pingroup.

...

Temporary variable here

...reg = base + OSCR;

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 1918

Quoted 11 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +11 -0
+       int gpio = BIT(pin % bank->gc.ngpio);
+
+       if (pincfg[pin].flag & SLEW) {
+               switch (arg) {
+               case 0:
+                       npcm_gpio_clr(&bank->gc, bank->base + NPCM8XX_GP_N_OSRC,
+                                     gpio);
+                       return 0;
+               case 1:
+                       npcm_gpio_set(&bank->gc, bank->base + NPCM8XX_GP_N_OSRC,
+                                     gpio);

...will save one LoC in this switch-case.

Quoted 5 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +5 -0
+                       return 0;
+               default:
+                       return -EINVAL;
+               }
+       }

...

Quoted 1 line

+ int gpio = (pin % bank->gc.ngpio);

Too many parentheses.

...

Quoted 1 line

+ u32 ds = 0;

This assignment is redundant, if...

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 1956

Quoted 2 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +2 -0
+       flg = pincfg[pin].flag;
+       if (flg & DRIVE_STRENGTH_MASK) {

you use traditional pattern, i.e.

if (error_condition)
return an_error;

Quoted 7 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +7 -0
+               val = ioread32(bank->base + NPCM8XX_GP_N_ODSC) & pinmask;
+               ds = val ? DSHI(flg) : DSLO(flg);
+               dev_dbg(bank->gc.parent, "pin %d strength %d = %d\n", pin, val, ds);
+               return ds;
+       }
+
+       return -EINVAL;

...

Quoted 1 line

+ v = (pincfg[pin].flag & DRIVE_STRENGTH_MASK);

Too many parentheses.

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 1986

Quoted 12 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +12 -0
+       if (!nval || !v)
+               return -ENOTSUPP;
+       if (DSLO(v) == nval) {
+               npcm_gpio_clr(&bank->gc, bank->base + NPCM8XX_GP_N_ODSC, gpio);
+               return 0;
+       }
+       if (DSHI(v) == nval) {
+               npcm_gpio_set(&bank->gc, bank->base + NPCM8XX_GP_N_ODSC, gpio);
+               return 0;
+       }
+
+       return -ENOTSUPP;

Traditional pattern:

if (LO == nval)
clr()
else if (HI == nval)
set()
else
return -ENOTSUPP;

return 0;

...

Quoted 5 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +5 -0
+static int npcm8xx_gpio_request_enable(struct pinctrl_dev *pctldev,
+                                      struct pinctrl_gpio_range *range,
+                                      unsigned int offset)
+{
+       struct npcm8xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev);

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 2083

Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +8 -0
 
+       if (!range) {
+               dev_err(npcm->dev, "invalid range\n");
+               return -EINVAL;
+       }
 
+       if (!range->gc) {
+               dev_err(npcm->dev, "invalid gpiochip\n");
+               return -EINVAL;
+       }

I'm wondering when you can have one of these triggered.

Quoted 5 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +5 -0
+
+       npcm8xx_setfunc(npcm->gcr_regmap, &offset, 1, fn_gpio);
+
+       return 0;
+}

...

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 2134

Quoted 6 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +6 -0
+static int debounce_timing_setting(struct npcm8xx_gpio *bank, u32 gpio,
+                                  u32 nanosecs)
+{
+       int gpio_debounce = (gpio % 16) * 2;
+       u32 dbncp_val, dbncp_val_mod;
+       int DBNCS_offset = gpio / 16;

Can you group it together with gpio%16 line? It would be easier for the reader who knows that on some architectures the both assignments may be done in one assembly instruction.

Quoted 1 line

+ int debounce_select;

This logically would be grouped with above int:s.

       u32 dbncp_val, dbncp_val_mod;
       int gpio_debounce = (gpio % 16) * 2;
       int DBNCS_offset = gpio / 16;
       int debounce_select;

...

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 2149

Quoted 3 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +2 -0
+                               npcm_gpio_set(&bank->gc, bank->base + NPCM8XX_GP_N_DBNCS0 + (DBNCS_offset * 4), debounce_select);
 
+                       npcm_gpio_set(&bank->gc, bank->base + NPCM8XX_GP_N_DBNCS0 + (DBNCS_offset * 4), debounce_select);

We can make this line much shorter with help of a temporary variable.

...

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 2173

Quoted 4 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +4 -0
+                               iowrite32(0x40, bank->base + NPCM8XX_GP_N_DBNCP0 + (i * 4));
+                               iowrite32(0x50, bank->base + NPCM8XX_GP_N_DBNCP0 + (i * 4));
+                               iowrite32(0x60, bank->base + NPCM8XX_GP_N_DBNCP0 + (i * 4));
+                               iowrite32(0x70, bank->base + NPCM8XX_GP_N_DBNCP0 + (i * 4));

And this lines can be shorter with a helper function, but this is up to you.

...

Quoted 1 line

+ dbncp_val_mod = dbncp_val & 0xF;

GENMASK() ?
Or (BIT(x) - 1) if it's a limitation by the hardware in bits, this will show it directly (like 4 bits limit).

Quoted 1 line

+ if (dbncp_val_mod > 0x7)

In similar way.

...

Quoted 1 line

+ int ret = 0;

Redundant assignment.

Such assignments in some cases may hide real bugs.

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 2207

Quoted 4 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +4 -0
+       if (nanosecs) {
+               ret = debounce_timing_setting(bank, pin % bank->gc.ngpio,
+                                             nanosecs);
+               if (!ret) {

Why not positive conditional and in this case aka "traditional pattern":

  if (error) {
    ...handle error...
    return error;

}

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 2212

Quoted 6 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +5 -0
+                       npcm_gpio_set(&bank->gc, bank->base + NPCM8XX_GP_N_DBNC,
+                                     gpio);
+               } else {
 
+                       dev_info(npcm->dev, "All four debounce timing values are used, please use one of exist debounce values\n");
+                       dev_err(npcm->dev, "Pin %d debounce_timing_setting failed, ret=%d\n", pin, ret);

Too much noise in the messages. Create one error message

Quoted 8 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +8 -0
+               }
+
+               return ret;
+       }
+
+       npcm_gpio_clr(&bank->gc, bank->base + NPCM8XX_GP_N_DBNC, gpio);
+
+       return 0;

...

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 2247

Quoted 6 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +6 -0
+               if (param == PIN_CONFIG_BIAS_DISABLE)
+                       rc = (!pu && !pd);
+               else if (param == PIN_CONFIG_BIAS_PULL_UP)
+                       rc = (pu && !pd);
+               else if (param == PIN_CONFIG_BIAS_PULL_DOWN)
+                       rc = (!pu && pd);

In many places (and not only in this function) you are using too many parentheses, why? Can you clean all them up?

...

Quoted 1 line

+static int npcm8xx_gpio_of(struct npcm8xx_pinctrl *pctrl)

_fw

...

Quoted 1 line

+ char gpioirqname[30];

How 30 was chosen?

...

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c line 2422

Quoted 3 lines
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +3 -0
+               pctrl->gpio_bank[id].gc.label = devm_kasprintf(dev, GFP_KERNEL, "%pfw", child);
+               if (!pctrl->gpio_bank[id].gc.label)
+                       dev_err_probe(dev, -ENOMEM, "No GPIO label %u\n", id);

-ENOMEM doesn't need an error message.

...

Quoted 1 line

+ dev_set_drvdata(&pdev->dev, pctrl);

platform_set_drvdata();

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

Re: [PATCH v2 2/2] pinctrl: nuvoton: add NPCM8XX pinctrl and GPIO driver

In reply to Tomer Maimon
I love your patch! Perhaps something to improve:

Hi Tomer,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linusw-pinctrl/devel]
[also build test WARNING on linus/master v5.19-rc7 next-20220715] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Tomer-Maimon/pinctrl-nuvoton-add-pinmux-and-GPIO-driver-for-NPCM8XX/20220714-202424
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20220718/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 07022e6cf9b5b3baa642be53d0b3c3f1c403dbfd)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/0a5f158322b21ab2b71cc606adc2ee7573d8be0d
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Tomer-Maimon/pinctrl-nuvoton-add-pinmux-and-GPIO-driver-for-NPCM8XX/20220714-202424
git checkout 0a5f158322b21ab2b71cc606adc2ee7573d8be0d
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/media/i2c/ drivers/net/pcs/ drivers/pinctrl/nuvoton/ kernel/trace/

If you fix the issue, kindly add following tag where applicable

All warnings (new ones prefixed by >>):

>> drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c:481:18: warning: unused variable 'smb14b_pins' [-Wunused-const-variable]
   static const int smb14b_pins[] = { 32, 187 };
                    ^

1 warning generated.

vim +/smb14b_pins +481 drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c

439
440 static const int smb0_pins[] = { 115, 114 };
441 static const int smb0b_pins[] = { 195, 194 };
442 static const int smb0c_pins[] = { 202, 196 };
443 static const int smb0d_pins[] = { 198, 199 };
444 static const int smb0den_pins[] = { 197 };
445 static const int smb1_pins[] = { 117, 116 };
446 static const int smb1b_pins[] = { 126, 127 };
447 static const int smb1c_pins[] = { 124, 125 };
448 static const int smb1d_pins[] = { 4, 5 };
449 static const int smb2_pins[] = { 119, 118 };
450 static const int smb2b_pins[] = { 122, 123 };
451 static const int smb2c_pins[] = { 120, 121 };
452 static const int smb2d_pins[] = { 6, 7 };
453 static const int smb3_pins[] = { 30, 31 };
454 static const int smb3b_pins[] = { 39, 40 };
455 static const int smb3c_pins[] = { 37, 38 };
456 static const int smb3d_pins[] = { 59, 60 };
457 static const int smb4_pins[] = { 28, 29 };
458 static const int smb4b_pins[] = { 18, 19 };
459 static const int smb4c_pins[] = { 20, 21 };
460 static const int smb4d_pins[] = { 22, 23 };
461 static const int smb4den_pins[] = { 17 };
462 static const int smb5_pins[] = { 26, 27 };
463 static const int smb5b_pins[] = { 13, 12 };
464 static const int smb5c_pins[] = { 15, 14 };
465 static const int smb5d_pins[] = { 94, 93 };
466 static const int smb6_pins[] = { 172, 171 };
467 static const int smb6b_pins[] = { 2, 3 };
468 static const int smb6c_pins[] = { 0, 1 };
469 static const int smb6d_pins[] = { 10, 11 };
470 static const int smb7_pins[] = { 174, 173 };

   471	static const int smb7b_pins[]  = { 16, 141 };
   472	static const int smb7c_pins[]  = { 24, 25 };
   473	static const int smb7d_pins[]  = { 142, 143 };
   474	static const int smb8_pins[]  = { 129, 128 };
   475	static const int smb9_pins[]  = { 131, 130 };
   476	static const int smb10_pins[] = { 133, 132 };
   477	static const int smb11_pins[] = { 135, 134 };
   478	static const int smb12_pins[] = { 221, 220 };
   479	static const int smb13_pins[] = { 223, 222 };
   480	static const int smb14_pins[] = { 22, 23 };
 > 481	static const int smb14b_pins[] = { 32, 187 };

482 static const int smb15_pins[] = { 20, 21 };
483 static const int smb15b_pins[] = { 192, 191 };
484 static const int smb16_pins[] = { 10, 11 };
485 static const int smb16b_pins[] = { 218, 219 };
486 static const int smb17_pins[] = { 3, 2 };
487 static const int smb18_pins[] = { 0, 1 };
488 static const int smb19_pins[] = { 60, 59 };
489 static const int smb20_pins[] = { 234, 235 };
490 static const int smb21_pins[] = { 169, 170 };
491 static const int smb22_pins[] = { 40, 39 };
492 static const int smb23_pins[] = { 38, 37 };
493 static const int smb23b_pins[] = { 134, 134 };
494

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp