Add support for nuvoton ma35d1 pin control
Subsystems (6)
v2 cover Add support for nuvoton ma35d1 pin control
From: Jacky Huang <[email protected]>
This patch series adds the pin control and GPIO driver for the nuvoton ma35d1 ARMv8 SoC. It includes DT binding documentation, the ma35d1 pin control driver, and device tree updates.
This pin control driver has been tested on the ma35d1 som board with Linux 6.7.
v2:
- Update nuvoton,ma35d1-pinctrl.yaml
- Update the 'nuvoton,pins' to follow the style of rockchip pinctrl approch.
- Use power-source to indicate the pin voltage selection which follow the realtek pinctrl approch.
- Instead of integer, use drive-strength-microamp to specify the real driving strength capability of IO pins.
- Update ma35d1 pinctrl driver
- Add I/O drive strength lookup table for translating device tree setting into control register.
- Remove ma35d1-pinfunc.h which is unused after update definition of 'nuvoton,pins'.
Jacky Huang (4):
dt-bindings: reset: Add syscon to nuvoton ma35d1 system-management
node
dt-bindings: pinctrl: Document nuvoton ma35d1 pin control
arm64: dts: nuvoton: Add pinctrl support for ma35d1
pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver
.../pinctrl/nuvoton,ma35d1-pinctrl.yaml | 189 ++ .../bindings/reset/nuvoton,ma35d1-reset.yaml | 3 +- .../boot/dts/nuvoton/ma35d1-iot-512m.dts | 70 +- .../boot/dts/nuvoton/ma35d1-som-256m.dts | 73 +- arch/arm64/boot/dts/nuvoton/ma35d1.dtsi | 159 +- drivers/pinctrl/nuvoton/Kconfig | 22 + drivers/pinctrl/nuvoton/Makefile | 2 + drivers/pinctrl/nuvoton/pinctrl-ma35.c | 1244 ++++++++++++ drivers/pinctrl/nuvoton/pinctrl-ma35.h | 50 + drivers/pinctrl/nuvoton/pinctrl-ma35d1.c | 1797 +++++++++++++++++ 10 files changed, 3599 insertions(+), 10 deletions(-) create mode 100644 Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml create mode 100644 drivers/pinctrl/nuvoton/pinctrl-ma35.c create mode 100644 drivers/pinctrl/nuvoton/pinctrl-ma35.h create mode 100644 drivers/pinctrl/nuvoton/pinctrl-ma35d1.c
Signature · 1 line
2.34.1
PATCH v2 1/4 dt-bindings: reset: Add syscon to nuvoton ma35d1 system-management node
From: Jacky Huang <[email protected]>
Add a compatible 'syscon' to the system management node since the system control registers are mapped by this driver. The other driver must access the system control registers through 'regmap' using a phandle that references this node.
--- .../devicetree/bindings/reset/nuvoton,ma35d1-reset.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/reset/nuvoton,ma35d1-reset.yaml +2 -1
@@ -18,6 +18,7 @@ properties: compatible: items: - const: nuvoton,ma35d1-reset + - const: syscon reg: maxItems: 1
@@ -37,7 +38,7 @@ examples: - | system-management@40460000 { - compatible = "nuvoton,ma35d1-reset"; + compatible = "nuvoton,ma35d1-reset", "syscon"; reg = <0x40460000 0x200>; #reset-cells = <1>; };
Signature · 1 line
2.34.1
Re: [PATCH v2 1/4] dt-bindings: reset: Add syscon to nuvoton ma35d1 system-management node
Quoted 8 lines · Jacky Huang
From: Jacky Huang <[email protected]>
Add a compatible 'syscon' to the system management node since the system control registers are mapped by this driver. The other driver must access the system control registers through 'regmap' using a phandle that references this node.
Signed-off-by Jacky Huang <[email protected]>
Best regards,
Krzysztof
Re: [PATCH v2 1/4] dt-bindings: reset: Add syscon to nuvoton ma35d1 system-management node
In reply to Jacky HuangQuoted 8 lines · Jacky Huang
From: Jacky Huang <[email protected]>
Add a compatible 'syscon' to the system management node since the system control registers are mapped by this driver. The other driver must access the system control registers through 'regmap' using a phandle that references this node.
Signed-off-by Jacky Huang <[email protected]>
to be applied together with the dts changes.
regards
Philipp
PATCH v2 2/4 dt-bindings: pinctrl: Document nuvoton ma35d1 pin control
In reply to Jacky HuangFrom: Jacky Huang <[email protected]>
Add documentation to describe nuvoton ma35d1 pin control and GPIO.
--- .../pinctrl/nuvoton,ma35d1-pinctrl.yaml | 189 ++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +189 -0
@@ -0,0 +1,189 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/nuvoton,ma35d1-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton MA35D1 pin control and GPIO + +maintainers: + - Shan-Chun Hung <[email protected]> + +properties: + compatible: + enum: + - nuvoton,ma35d1-pinctrl + + '#address-cells': + const: 1 + + '#size-cells': + const: 1 + + nuvoton,sys: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle of the system-management node. + + ranges: true + +allOf: + - $ref: pinctrl.yaml# + +required: + - compatible + - nuvoton,sys + +patternProperties: + "^gpio@[0-9a-f]+$": + type: object + additionalProperties: false + properties: + gpio-controller: true + + '#gpio-cells': + const: 2 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + interrupt-controller: true + + '#interrupt-cells': + const: 2 + + interrupts: + description: + The interrupt outputs to sysirq. + maxItems: 1 + + required: + - gpio-controller + - '#gpio-cells' + - reg + - clocks + - interrupt-controller + - '#interrupt-cells' + - interrupts + + "^pin-[a-z0-9]+$": + type: object + description: + A pinctrl node should contain at least one subnodes representing the + pinctrl groups available on the machine. Each subnode will list the + pins it needs, and how they should be configured, with regard to muxer + configuration, pullups, drive strength, input enable/disable and input + schmitt. + + allOf: + - $ref: pincfg-node.yaml# + + properties: + bias-disable: true + + bias-pull-down: true + + bias-pull-up: true + + power-source: + description: | + Valid arguments are described as below: + 0: power supply of 1.8V + 1: power supply of 3.3V + enum: [0, 1] + + drive-strength-microamp: + oneOf: + - enum: [ 2900, 4400, 5800, 7300, 8600, 10100, 11500, 13000 ] + description: 1.8V I/O driving strength + - enum: [ 17100, 25600, 34100, 42800, 48000, 56000, 77000, 82000 ] + description: 3.3V I/O driving strength + + input-enable: true + + input-schmitt-enable: true + + unevaluatedProperties: false + + "-grp$": + type: object + description: + Pinctrl node's client devices use subnodes for desired pin configuration. + Client device subnodes use below standard properties. + properties: + nuvoton,pins: + description: + Each entry consists of 4 parameters and represents the mux and config + setting for one pin. + $ref: /schemas/types.yaml#/definitions/uint32-matrix + minItems: 1 + items: + items: + - minimum: 0 + maximum: 13 + description: + Pin bank. + - minimum: 0 + maximum: 15 + description: + Pin bank index. + - minimum: 0 + maximum: 15 + description: + Mux 0 means GPIO and mux 1 to 15 means the specific device function. + - description: + The phandle of a node contains the generic pinconfig options + to use as described in pinctrl-bindings.txt. + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/clock/nuvoton,ma35d1-clk.h> + #include <dt-bindings/pinctrl/ma35d1-pinfunc.h> + + pinctrl@40040000 { + compatible = "nuvoton,ma35d1-pinctrl"; + #address-cells = <1>; + #size-cells = <1>; + nuvoton,sys = <&sys>; + ranges = <0 0x40040000 0xc00>; + + gpio@40040000 { + reg = <0x0 0x40>; + interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk GPA_GATE>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + pcfg_default: pin-default { + slew-rate = <0>; + input-schmitt-disable; + bias-disable; + power-source = <1>; + drive-strength-microamp = <17100>; + }; + + uart-grp { + uart11-pins { + nuvoton,pins = <11 0 2 &pcfg_default>, + <11 1 2 &pcfg_default>, + <11 2 2 &pcfg_default>, + <11 3 2 &pcfg_default>; + }; + + uart12-pins { + nuvoton,pins = <8 1 2 &pcfg_default>, + <8 2 2 &pcfg_default>, + <8 3 2 &pcfg_default>; + }; + }; + };
Signature · 1 line
2.34.1
Rob Herring
maintainerRe: [PATCH v2 2/4] dt-bindings: pinctrl: Document nuvoton ma35d1 pin control
Quoted 10 lines · Jacky Huang
From: Jacky Huang <[email protected]>
Add documentation to describe nuvoton ma35d1 pin control and GPIO.
Signed-off-by Jacky Huang <[email protected]>--- .../pinctrl/nuvoton,ma35d1-pinctrl.yaml | 189 ++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.example.dts:27:18: fatal error: dt-bindings/pinctrl/ma35d1-pinfunc.h: No such file or directory
27 | #include <dt-bindings/pinctrl/ma35d1-pinfunc.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.lib:419: Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.example.dtb] Error 1 make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1424: dt_binding_check] Error 2
make: *** [Makefile:234: __sub-make] Error 2
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Re: [PATCH v2 2/4] dt-bindings: pinctrl: Document nuvoton ma35d1 pin control
In reply to Jacky HuangQuoted 6 lines · Jacky Huang
From: Jacky Huang <[email protected]>
Add documentation to describe nuvoton ma35d1 pin control and GPIO.
Signed-off-by Jacky Huang <[email protected]>---
Quoted 1 line · Your changelog
- Remove
ma35d1-pinfunc.hwhich is unused after update definition of
'nuvoton,pins'.
You forgot to add:
" - Do not test the bindings before sending"
I assume none of the driver changes compile either.
Quoted 31 lines
.../pinctrl/nuvoton,ma35d1-pinctrl.yaml | 189 ++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yamlDocumentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +21
-0@@ -0,0 +1,189 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/nuvoton,ma35d1-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton MA35D1 pin control and GPIO + +maintainers: + - Shan-Chun Hung <[email protected]> + +properties: + compatible: + enum: + - nuvoton,ma35d1-pinctrl + + '#address-cells': + const: 1 + + '#size-cells': + const: 1
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 31
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +10
-0+ + nuvoton,sys: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle of the system-management node. + + ranges: true + +allOf: + - $ref: pinctrl.yaml#
allOf goes before additionalProperties.
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 35
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +4
-0+ +required: + - compatible + - nuvoton,sys
This goes after patternProperties
Quoted 36 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +36
-0+ +patternProperties: + "^gpio@[0-9a-f]+$": + type: object + additionalProperties: false + properties: + gpio-controller: true + + '#gpio-cells': + const: 2 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + interrupt-controller: true + + '#interrupt-cells': + const: 2 + + interrupts: + description: + The interrupt outputs to sysirq. + maxItems: 1 + + required: + - gpio-controller + - '#gpio-cells' + - reg + - clocks + - interrupt-controller + - '#interrupt-cells' + - interrupts +
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 81
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +10
-0+ "^pin-[a-z0-9]+$": + type: object + description: + A pinctrl node should contain at least one subnodes representing the + pinctrl groups available on the machine. Each subnode will list the + pins it needs, and how they should be configured, with regard to muxer + configuration, pullups, drive strength, input enable/disable and input + schmitt. + + allOf:
Drop allOf, just $ref
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 85
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +4
-0+ - $ref: pincfg-node.yaml# + + properties: + bias-disable: true
Drop this and other "true", why do you need them here?
Quoted 14 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +14
-0+ + bias-pull-down: true + + bias-pull-up: true + + power-source: + description: | + Valid arguments are described as below: + 0: power supply of 1.8V + 1: power supply of 3.3V + enum: [0, 1] + + drive-strength-microamp: + oneOf:
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 109
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +10
-0+ - enum: [ 2900, 4400, 5800, 7300, 8600, 10100, 11500, 13000 ] + description: 1.8V I/O driving strength + - enum: [ 17100, 25600, 34100, 42800, 48000, 56000, 77000, 82000 ] + description: 3.3V I/O driving strength + + input-enable: true + + input-schmitt-enable: true + + unevaluatedProperties: false
Best regards,
Krzysztof
Re: [PATCH v2 2/4] dt-bindings: pinctrl: Document nuvoton ma35d1 pin control
Dear Krzysztof,
Thanks for your review.
Quoted 9 lines · Krzysztof Kozlowski
Quoted 6 lines · Jacky Huang
From: Jacky Huang <[email protected]>
Add documentation to describe nuvoton ma35d1 pin control and GPIO.
Signed-off-by Jacky Huang <[email protected]>---
Your changelog said:
Quoted 8 lines
Quoted 1 line
- Remove
ma35d1-pinfunc.hwhich is unused after update definition of'nuvoton,pins'.
You forgot to add:
" - Do not test the bindings before sending"
I assume none of the driver changes compile either.
It's my mistake. I forgot to remove 'ma35d1-pinfunc.h' from my local copy, and as a consequence, the 'dt_binding_check' did not catch this error. I will fix this.
Quoted 43 lines
Quoted 31 lines
.../pinctrl/nuvoton,ma35d1-pinctrl.yaml | 189 ++++++++++++++++++ 1 file changed, 189 insertions(+)create mode 100644
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yamlDocumentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +21
-0@@ -0,0 +1,189 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/nuvoton,ma35d1-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton MA35D1 pin control and GPIO + +maintainers: + - Shan-Chun Hung <[email protected]> + +properties: + compatible: + enum: + - nuvoton,ma35d1-pinctrl + + '#address-cells': + const: 1 + + '#size-cells': + const: 1Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 31
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +10
-0+ + nuvoton,sys: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle of the system-management node. + + ranges: true + +allOf: + - $ref: pinctrl.yaml#allOf goes before additionalProperties.
Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 35
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +4
-0+ +required: + - compatible + - nuvoton,sysThis goes after patternProperties
I will fix the above two as:
allOf:
- $ref: pinctrl.yaml#
required:
- compatible
- nuvoton,sys
additionalProperties: false
examples:
Quoted 39 lines
Quoted 39 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +39
-0+ +patternProperties: + "^gpio@[0-9a-f]+$": + type: object + additionalProperties: false + properties: + gpio-controller: true + + '#gpio-cells': + const: 2 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + interrupt-controller: true + + '#interrupt-cells': + const: 2 + + interrupts: + description: + The interrupt outputs to sysirq. + maxItems: 1 + + required: + - gpio-controller + - '#gpio-cells' + - reg + - clocks + - interrupt-controller + - '#interrupt-cells' + - interrupts + + "^pin-[a-z0-9]+$": + type: object + description:
Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 81
Quoted 7 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +7
-0+ A pinctrl node should contain at least one subnodes representing the + pinctrl groups available on the machine. Each subnode will list the + pins it needs, and how they should be configured, with regard to muxer + configuration, pullups, drive strength, input enable/disable and input + schmitt. + + allOf:Drop allOf, just $ref
OK, I will fix it.
Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 85
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +4
-0+ - $ref: pincfg-node.yaml# + + properties: + bias-disable: trueDrop this and other "true", why do you need them here?
We are following the conventions used in other pinctrl documents, such as 'realtek,rtd1315e-pinctrl.yaml' and 'xlnx,zynqmp-pinctrl.yaml'.
After comparing various pinctrl documents, I noticed that they all express it as 'bias-disable: true'. Therefore, may I keep the current format?
Quoted 20 lines
Quoted 20 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +20
-0+ + bias-pull-down: true + + bias-pull-up: true + + power-source: + description: | + Valid arguments are described as below: + 0: power supply of 1.8V + 1: power supply of 3.3V + enum: [0, 1] + + drive-strength-microamp: + oneOf: + - enum: [ 2900, 4400, 5800, 7300, 8600, 10100, 11500, 13000 ] + description: 1.8V I/O driving strength + - enum: [ 17100, 25600, 34100, 42800, 48000, 56000, 77000, 82000 ] + description: 3.3V I/O driving strength + + input-enable: true
Quoted 9 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 109
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +4
-0+ + input-schmitt-enable: true + + unevaluatedProperties: falseBest regards,
Krzysztof
Best Regards,
Jacky Huang
Re: [PATCH v2 2/4] dt-bindings: pinctrl: Document nuvoton ma35d1 pin control
Quoted 20 lines · Jacky Huang
Dear Krzysztof,
Thanks for your review.
Quoted 14 lines · Krzysztof Kozlowski
Quoted 6 lines · Jacky Huang
From: Jacky Huang <[email protected]>
Add documentation to describe nuvoton ma35d1 pin control and GPIO.
Signed-off-by Jacky Huang <[email protected]>---
Quoted 1 line · Your changelog
- Remove
ma35d1-pinfunc.hwhich is unused after update definition of'nuvoton,pins'.
You forgot to add:
Quoted 7 lines
Quoted 3 lines
" - Do not test the bindings before sending"
I assume none of the driver changes compile either.
It's my mistake. I forgot to remove '
ma35d1-pinfunc.h' from my local copy, and as a consequence, the 'dt_binding_check' did not catch this error. I will fix this.
But then git status would point you that tree is not clean and you did not finish commiting.
..
Quoted 11 lines
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 31
Quoted 3 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +3
-0+ +allOf: + - $ref: pinctrl.yaml#allOf goes before additionalProperties.
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 35
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +4
-0+ +required: + - compatible + - nuvoton,sysThis goes after patternProperties
Quoted 4 lines
I will fix the above two as:
allOf:
- $ref: pinctrl.yaml#
Look:
Quoted 1 line
Quoted 1 line
allOf goes before additionalProperties.
Open example-schema.
..
Quoted 9 lines
Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 85
Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +4
-0+ - $ref: pincfg-node.yaml# + + properties: + bias-disable: trueDrop this and other "true", why do you need them here?
We are following the conventions used in other pinctrl documents, such as 'realtek,rtd1315e-pinctrl.yaml' and 'xlnx,zynqmp-pinctrl.yaml'.
But they are quite different there.
Quoted 3 lines
After comparing various pinctrl documents, I noticed that they all express it as 'bias-disable: true'. Therefore, may I keep the current format?
No, you cannot copy pieces of other binding, selectively ignoring the rest. Look how these other bindings are constructed - they have additionalProperties, which you don't.
Drop all these true properties if the only reason of them being here is they were copied.
Best regards,
Krzysztof
Re: [PATCH v2 2/4] dt-bindings: pinctrl: Document nuvoton ma35d1 pin control
Dear Krzysztof,
Thanks for your review.
Quoted 23 lines · Krzysztof Kozlowski
Quoted 22 lines · Jacky Huang
Dear Krzysztof,
Thanks for your review.
Quoted 16 lines · Krzysztof Kozlowski
Quoted 6 lines · Jacky Huang
From: Jacky Huang <[email protected]>
Add documentation to describe nuvoton ma35d1 pin control and GPIO.
Signed-off-by Jacky Huang <[email protected]>---
Quoted 1 line · Your changelog
- Remove
ma35d1-pinfunc.hwhich is unused after update definition of'nuvoton,pins'.
You forgot to add:
" - Do not test the bindings before sending"
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
I assume none of the driver changes compile either.
It's my mistake. I forgot to remove '
ma35d1-pinfunc.h' from my local copy, and as a consequence, the 'dt_binding_check' did not catch this error. I will fix this.But then git status would point you that tree is not clean and you did not finish commiting.
..
Yes, I should have been more careful in checking.
Quoted 12 lines
Quoted 12 lines
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 31
Quoted 3 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +3
-0+ +allOf: + - $ref: pinctrl.yaml#allOf goes before additionalProperties.
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 35
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +4
-0+ +required: + - compatible + - nuvoton,sysThis goes after patternProperties
I will fix the above two as:
Quoted 8 lines
Quoted 2 lines
allOf:
- $ref: pinctrl.yaml#Look:
Quoted 1 line
Quoted 1 line
allOf goes before additionalProperties.
Open example-schema.
..
I found that 'pinctrl.yaml' is not required for this document, so I will drop it.
Quoted 15 lines
Quoted 7 lines
Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 85
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +4
-0+ - $ref: pincfg-node.yaml# + + properties: + bias-disable: trueDrop this and other "true", why do you need them here?
We are following the conventions used in other pinctrl documents, such as 'realtek,rtd1315e-pinctrl.yaml' and 'xlnx,zynqmp-pinctrl.yaml'.
But they are quite different there.
Quoted 2 lines
After comparing various pinctrl documents, I noticed that they all express it as 'bias-disable: true'. Therefore, may I keep the current format?
No, you cannot copy pieces of other binding, selectively ignoring the rest. Look how these other bindings are constructed - they have additionalProperties, which you don't.
Quoted 8 lines
Drop all these true properties if the only reason of them being here is they were copied.
Best regards,
Krzysztof
OK, I will drop these properties.
Best Regards,
Jacky Huang
Re: [PATCH v2 2/4] dt-bindings: pinctrl: Document nuvoton ma35d1 pin control
Quoted 10 lines · Jacky Huang
Quoted 10 lines
Quoted 8 lines
Quoted 4 lines
+required:
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 35
Quoted 2 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +2
-0+ - compatible + - nuvoton,sysThis goes after patternProperties
I will fix the above two as:
allOf:
- $ref: pinctrl.yaml#Look:
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
allOf goes before additionalProperties.
Open example-schema.
..
I found that '
pinctrl.yaml' is not required for this document, so I will drop it.
Why is it not required? I don't understand where this discussion is going.
Best regards,
Krzysztof
Re: [PATCH v2 2/4] dt-bindings: pinctrl: Document nuvoton ma35d1 pin control
Quoted 15 lines · Krzysztof Kozlowski
Quoted 14 lines · Jacky Huang
Quoted 14 lines
Quoted 8 lines
Quoted 4 lines
+required:
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml line 35
Quoted 2 lines
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +2
-0+ - compatible + - nuvoton,sysThis goes after patternProperties
I will fix the above two as:
allOf:
- $ref: pinctrl.yaml#Look:
Quoted 1 line
Quoted 1 line
allOf goes before additionalProperties.
Open example-schema.
..
Quoted 9 lines
Quoted 2 lines
I found that '
pinctrl.yaml' is not required for this document, so I will drop it.Why is it not required? I don't understand where this discussion is going.
Best regards,
Krzysztof
I read the description of 'pinctrl.yaml'. Yes, it is required. So, I will add it to allOf: - $ref: pinctrl.yaml# properties: compatible: enum: - nuvoton,ma35d1-pinctrl '#address-cells': const: 1 ... Best Regards, Jacky Huang
PATCH v2 3/4 arm64: dts: nuvoton: Add pinctrl support for ma35d1
In reply to Jacky HuangFrom: Jacky Huang <[email protected]>
Add 'pinctrl' node and 'gpioa' ~ 'gpion' nodes to the dtsi of ma35d1 SoC and describe default pin configurations.
Enable all UART nodes presented on som and iot boards, and add pinctrl function settings to these nodes.
--- .../boot/dts/nuvoton/ma35d1-iot-512m.dts | 70 +++++++- .../boot/dts/nuvoton/ma35d1-som-256m.dts | 73 +++++++- arch/arm64/boot/dts/nuvoton/ma35d1.dtsi | 159 +++++++++++++++++- 3 files changed, 293 insertions(+), 9 deletions(-)
arch/arm64/boot/dts/nuvoton/ma35d1-iot-512m.dts +66 -4
@@ -14,6 +14,10 @@ / { aliases { serial0 = &uart0; + serial10 = &uart10; + serial12 = &uart12; + serial13 = &uart13; + serial14 = &uart14; }; chosen {
@@ -33,10 +37,6 @@ clk_hxt: clock-hxt { }; }; -&uart0 { - status = "okay"; -}; - &clk { assigned-clocks = <&clk CAPLL>, <&clk DDRPLL>,
@@ -54,3 +54,65 @@ &clk { "integer", "integer"; }; + +&pinctrl { + uart-grp { + pinctrl_uart0: uart0-pins { + nuvoton,pins = <4 14 1 &pcfg_default>, + <4 15 1 &pcfg_default>; + }; + + pinctrl_uart10: uart10-pins { + nuvoton,pins = <7 4 2 &pcfg_default>, + <7 5 2 &pcfg_default>, + <7 6 2 &pcfg_default>, + <7 7 2 &pcfg_default>; + }; + + pinctrl_uart12: uart12-pins { + nuvoton,pins = <2 13 2 &pcfg_default>, + <2 14 2 &pcfg_default>, + <2 15 2 &pcfg_default>; + }; + + pinctrl_uart13: uart13-pins { + nuvoton,pins = <7 12 3 &pcfg_default>, + <7 13 3 &pcfg_default>; + }; + + pinctrl_uart14: uart14-pins { + nuvoton,pins = <7 14 2 &pcfg_default>, + <7 15 2 &pcfg_default>; + }; + }; +}; + +&uart0 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_uart0>; + status = "okay"; +}; + +&uart10 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_uart10>; + status = "okay"; +}; + +&uart12 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_uart12>; + status = "okay"; +}; + +&uart13 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_uart13>; + status = "okay"; +}; + +&uart14 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_uart14>; + status = "okay"; +};
arch/arm64/boot/dts/nuvoton/ma35d1-som-256m.dts +69 -4
88 lines not on this page · raw message
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +158 -1
177 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Quoted 19 lines · Jacky Huang
From: Jacky Huang <[email protected]>
Add 'pinctrl' node and 'gpioa' ~ 'gpion' nodes to the dtsi of ma35d1 SoC and describe default pin configurations.
Enable all UART nodes presented on som and iot boards, and add pinctrl function settings to these nodes.
Signed-off-by Jacky Huang <[email protected]>arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +8
-0+ + gpion: gpio@40040340 { + reg = <0x340 0x40>; + interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk GPN_GATE>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller;
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi clk: clock-controller@40460200 { · line 252
Quoted 10 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +10
-0+ #interrupt-cells = <2>; + }; + + pcfg_default: pin-default { + slew-rate = <0>; + input-schmitt-disable; + bias-disable; + power-source = <1>; + drive-strength = <17100>; + };
It does not look like you tested the DTS against bindings. Please run make dtbs_check W=1 (see Documentation/devicetree/bindings/writing-schema.rst or
https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/
for instructions).
Best regards,
Krzysztof
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Dear Krzysztof,
Thanks for your review.
Quoted 35 lines · Krzysztof Kozlowski
Quoted 18 lines · Jacky Huang
From: Jacky Huang <[email protected]>
Add 'pinctrl' node and 'gpioa' ~ 'gpion' nodes to the dtsi of ma35d1 SoC and describe default pin configurations.
Enable all UART nodes presented on som and iot boards, and add pinctrl function settings to these nodes.
Signed-off-by Jacky Huang <[email protected]>arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +8
-0+ + gpion: gpio@40040340 { + reg = <0x340 0x40>; + interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk GPN_GATE>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller;arch/arm64/boot/dts/nuvoton/ma35d1.dtsi clk: clock-controller@40460200 { · line 252
Quoted 10 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +10
-0+ #interrupt-cells = <2>; + }; + + pcfg_default: pin-default { + slew-rate = <0>; + input-schmitt-disable; + bias-disable; + power-source = <1>; + drive-strength = <17100>; + };It does not look like you tested the DTS against bindings. Please run
make dtbs_check W=1(seeDocumentation/devicetree/bindings/writing-schema.rstor
https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/
for instructions).
Quoted 3 lines
Best regards,
Krzysztof
I forgot to remove 'ma35d1-pinfunc.h' from my local copy.
After remove the '#include <dt-bindings/pinctrl/ma35d1-pinfunc.h>', it can pass the make dtbs_check W=1 check.
I will fix it in the next version.
Best Regards,
Jacky Huang
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Quoted 27 lines · Jacky Huang
Quoted 23 lines
Quoted 7 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +7
-0+ gpion: gpio@40040340 { + reg = <0x340 0x40>; + interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk GPN_GATE>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller;arch/arm64/boot/dts/nuvoton/ma35d1.dtsi clk: clock-controller@40460200 { · line 252
Quoted 10 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +10
-0+ #interrupt-cells = <2>; + }; + + pcfg_default: pin-default { + slew-rate = <0>; + input-schmitt-disable; + bias-disable; + power-source = <1>; + drive-strength = <17100>; + };It does not look like you tested the DTS against bindings. Please run
make dtbs_check W=1(seeDocumentation/devicetree/bindings/writing-schema.rstor
https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/
for instructions).Quoted 3 lines
Best regards,
Krzysztof
Quoted 5 lines
I forgot to remove '
ma35d1-pinfunc.h' from my local copy. After remove the '#include <dt-bindings/pinctrl/ma35d1-pinfunc.h>', it can pass
themake dtbs_check W=1check.
I will fix it in the next version.
Really? Then your bindings look wrong. Why do you mix MMIO nodes and non-MMIO in one device node?
Best regards,
Krzysztof
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Dear Krzysztof,
Thanks for your review.
Quoted 32 lines · Krzysztof Kozlowski
Quoted 23 lines · Jacky Huang
Quoted 23 lines
Quoted 7 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +7
-0+ gpion: gpio@40040340 { + reg = <0x340 0x40>; + interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk GPN_GATE>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller;arch/arm64/boot/dts/nuvoton/ma35d1.dtsi clk: clock-controller@40460200 { · line 252
Quoted 10 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +10
-0+ #interrupt-cells = <2>; + }; + + pcfg_default: pin-default { + slew-rate = <0>; + input-schmitt-disable; + bias-disable; + power-source = <1>; + drive-strength = <17100>; + };It does not look like you tested the DTS against bindings. Please run
make dtbs_check W=1(seeDocumentation/devicetree/bindings/writing-schema.rstor
https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/
for instructions).Quoted 8 lines
Quoted 3 lines
Best regards,
KrzysztofI forgot to remove '
ma35d1-pinfunc.h' from my local copy. After remove the '#include <dt-bindings/pinctrl/ma35d1-pinfunc.h>', it can pass
themake dtbs_check W=1check.
I will fix it in the next version.
Quoted 6 lines
Really? Then your bindings look wrong. Why do you mix MMIO nodes and non-MMIO in one device node?
Best regards,
Krzysztof
Yes, it did pass the 'dtbs_check'. I guess the tool does not detect such issues. Anyway, I will fix it in the next version.
Best Regards,
Jacky Huang
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Quoted 40 lines · Jacky Huang
Dear Krzysztof,
Thanks for your review.
Quoted 35 lines · Krzysztof Kozlowski
Quoted 23 lines · Jacky Huang
Quoted 23 lines
Quoted 7 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +7
-0+ gpion: gpio@40040340 { + reg = <0x340 0x40>; + interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk GPN_GATE>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller;arch/arm64/boot/dts/nuvoton/ma35d1.dtsi clk: clock-controller@40460200 { · line 252
Quoted 10 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +10
-0+ #interrupt-cells = <2>; + }; + + pcfg_default: pin-default { + slew-rate = <0>; + input-schmitt-disable; + bias-disable; + power-source = <1>; + drive-strength = <17100>; + };It does not look like you tested the DTS against bindings. Please run
make dtbs_check W=1(seeDocumentation/devicetree/bindings/writing-schema.rstor
https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/
for instructions).Quoted 8 lines
Quoted 3 lines
Best regards,
KrzysztofI forgot to remove '
ma35d1-pinfunc.h' from my local copy. After remove the '#include <dt-bindings/pinctrl/ma35d1-pinfunc.h>', it can pass
themake dtbs_check W=1check.
I will fix it in the next version.Really? Then your bindings look wrong. Why do you mix MMIO nodes and non-MMIO in one device node?
Quoted 7 lines
Quoted 3 lines
Best regards,
KrzysztofYes, it did pass the '
dtbs_check'. I guess the tool does not detect such issues.
Anyway, I will fix it in the next version.
Hm, I see your bindings indeed allow pin-.* and unit addresses, so it is the binding issue.
The examples you used as reference - xlnx,zynqmp-pinctrl.yaml and realtek,rtd1315e-pinctrl.yaml - do not mix these as you do.
I don't understand why do you need them yet. I don't see any populate of children. There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
Krzysztof
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Dear Krzysztof,
Thanks for your review.
Quoted 53 lines · Krzysztof Kozlowski
Quoted 40 lines · Jacky Huang
Dear Krzysztof,
Thanks for your review.
Quoted 35 lines · Krzysztof Kozlowski
Quoted 23 lines · Jacky Huang
Quoted 23 lines
Quoted 7 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +7
-0+ gpion: gpio@40040340 { + reg = <0x340 0x40>; + interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk GPN_GATE>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller;arch/arm64/boot/dts/nuvoton/ma35d1.dtsi clk: clock-controller@40460200 { · line 252
Quoted 10 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +10
-0+ #interrupt-cells = <2>; + }; + + pcfg_default: pin-default { + slew-rate = <0>; + input-schmitt-disable; + bias-disable; + power-source = <1>; + drive-strength = <17100>; + };It does not look like you tested the DTS against bindings. Please run
make dtbs_check W=1(seeDocumentation/devicetree/bindings/writing-schema.rstor
https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/
for instructions).Quoted 8 lines
Quoted 3 lines
Best regards,
KrzysztofI forgot to remove '
ma35d1-pinfunc.h' from my local copy. After remove the '#include <dt-bindings/pinctrl/ma35d1-pinfunc.h>', it can pass
themake dtbs_check W=1check.
I will fix it in the next version.Really? Then your bindings look wrong. Why do you mix MMIO nodes and non-MMIO in one device node?
Quoted 6 lines
Quoted 3 lines
Best regards,
KrzysztofYes, it did pass the '
dtbs_check'. I guess the tool does not detect such issues.
Anyway, I will fix it in the next version.Hm, I see your bindings indeed allow pin-.* and unit addresses, so it is the binding issue.
The examples you used as reference - xlnx,zynqmp-pinctrl.yaml and realtek,rtd1315e-pinctrl.yaml - do not mix these as you do.
Quoted 8 lines
I don't understand why do you need them yet. I don't see any populate of children. There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
Krzysztof
I will move the 'pcfg_default: pin-default' from dtsi to dts, like this:
&pinctrl {
pcfg_default: pin-default {
slew-rate = <0>;
input-schmitt-disable;
bias-disable;
power-source = <1>;
drive-strength = <17100>;
};
uart-grp {
pinctrl_uart0: uart0-pins { nuvoton,pins = <4 14 1 &pcfg_default>, <4 15 1 &pcfg_default>; };
pinctrl_uart11: uart11-pins { nuvoton,pins = <11 0 2 &pcfg_default>, <11 1 2 &pcfg_default>, <11 2 2 &pcfg_default>, <11 3 2 &pcfg_default>; };
...
I use the 'pin-' and just intent to define a generic pin configuration, such as the above 'pin-default'.
Best Regards,
Jacky Huang
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Quoted 23 lines · Jacky Huang
Quoted 12 lines
Quoted 6 lines
Quoted 3 lines
Best regards,
KrzysztofYes, it did pass the '
dtbs_check'. I guess the tool does not detect such issues.
Anyway, I will fix it in the next version.Hm, I see your bindings indeed allow pin-.* and unit addresses, so it is the binding issue.
The examples you used as reference - xlnx,zynqmp-pinctrl.yaml and realtek,rtd1315e-pinctrl.yaml - do not mix these as you do.
Quoted 8 lines
I don't understand why do you need them yet. I don't see any populate of children. There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
KrzysztofI will move the '
pcfg_default: pin-default' from dtsi to dts, like this:
Quoted 8 lines
&pinctrl {
pcfg_default: pin-default {
slew-rate = <0>;
input-schmitt-disable;
bias-disable;
power-source = <1>;
drive-strength = <17100>;
};
This solves nothing. It's the same placement.
Best regards,
Krzysztof
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Dear Krzysztof,
Quoted 31 lines · Krzysztof Kozlowski
Quoted 22 lines · Jacky Huang
Quoted 12 lines
Quoted 6 lines
Quoted 3 lines
Best regards,
KrzysztofYes, it did pass the '
dtbs_check'. I guess the tool does not detect such issues.
Anyway, I will fix it in the next version.Hm, I see your bindings indeed allow pin-.* and unit addresses, so it is the binding issue.
The examples you used as reference - xlnx,zynqmp-pinctrl.yaml and realtek,rtd1315e-pinctrl.yaml - do not mix these as you do.
Quoted 8 lines
I don't understand why do you need them yet. I don't see any populate of children. There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
KrzysztofI will move the '
pcfg_default: pin-default' from dtsi to dts, like this:Quoted 8 lines
&pinctrl {
pcfg_default: pin-default {
slew-rate = <0>;
input-schmitt-disable;
bias-disable;
power-source = <1>;
drive-strength = <17100>;
};
Quoted 6 lines
This solves nothing. It's the same placement.
Best regards,
Krzysztof
OK, it stil be the binding issues.
For "^pin-[a-z0-9]+$", I reference to the "pcfg-[a-z0-9-]+$" of rockchip,pinctrl.yaml.
My intention is to describe a generic pin configuration, aiming to make the pin description more concise. In actual testing, it proves to be effective.
Best Regards,
Jacky Huang
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Quoted 43 lines · Jacky Huang
Dear Krzysztof,
Quoted 31 lines · Krzysztof Kozlowski
Quoted 22 lines · Jacky Huang
Quoted 12 lines
Quoted 6 lines
Quoted 3 lines
Best regards,
KrzysztofYes, it did pass the '
dtbs_check'. I guess the tool does not detect such issues.
Anyway, I will fix it in the next version.Hm, I see your bindings indeed allow pin-.* and unit addresses, so it is the binding issue.
The examples you used as reference - xlnx,zynqmp-pinctrl.yaml and realtek,rtd1315e-pinctrl.yaml - do not mix these as you do.
Quoted 8 lines
I don't understand why do you need them yet. I don't see any populate of children. There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
KrzysztofI will move the '
pcfg_default: pin-default' from dtsi to dts, like this:Quoted 8 lines
&pinctrl {
pcfg_default: pin-default {
slew-rate = <0>;
input-schmitt-disable;
bias-disable;
power-source = <1>;
drive-strength = <17100>;
};Quoted 6 lines
This solves nothing. It's the same placement.
Best regards,
Krzysztof
Quoted 7 lines
OK, it stil be the binding issues.
For "^pin-[a-z0-9]+$", I reference to the "pcfg-[a-z0-9-]+$" of rockchip,pinctrl.yaml.My intention is to describe a generic pin configuration, aiming to make the pin
description more concise. In actual testing, it proves to be effective.
Can you instead respond to my actual questions?
Best regards,
Krzysztof
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Dear Krzysztof,
Quoted 46 lines · Krzysztof Kozlowski
Quoted 45 lines · Jacky Huang
Dear Krzysztof,
Quoted 31 lines · Krzysztof Kozlowski
Quoted 22 lines · Jacky Huang
Quoted 12 lines
Quoted 6 lines
Quoted 3 lines
Best regards,
KrzysztofYes, it did pass the '
dtbs_check'. I guess the tool does not detect such issues.
Anyway, I will fix it in the next version.Hm, I see your bindings indeed allow pin-.* and unit addresses, so it is the binding issue.
The examples you used as reference - xlnx,zynqmp-pinctrl.yaml and realtek,rtd1315e-pinctrl.yaml - do not mix these as you do.
Quoted 8 lines
I don't understand why do you need them yet. I don't see any populate of children. There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
KrzysztofI will move the '
pcfg_default: pin-default' from dtsi to dts, like this:Quoted 8 lines
&pinctrl { pcfg_default: pin-default { slew-rate = <0>; input-schmitt-disable; bias-disable; power-source = <1>; drive-strength = <17100>; };Quoted 6 lines
This solves nothing. It's the same placement.
Best regards,
KrzysztofOK, it stil be the binding issues.
For "^pin-[a-z0-9]+$", I reference to the "pcfg-[a-z0-9-]+$" of rockchip,pinctrl.yaml.
Quoted 8 lines
Quoted 3 lines
My intention is to describe a generic pin configuration, aiming to make the pin
description more concise. In actual testing, it proves to be effective.Can you instead respond to my actual questions?
Best regards,
Krzysztof
The the last one item of nuvoton,pins is a phandle, which can refer to '&pin-default'. The following code of driver pinctrl-ma35.c parse "nuvoton,pins", including the node reference by phandle. list = of_get_property(np, "nuvoton,pins", &size); size /= sizeof(*list); if (!size || size % 4) { dev_err(npctl->dev, "wrong setting!\n"); return -EINVAL; } grp->npins = size / 4; grp->pins = devm_kzalloc(npctl->dev, grp->npins * sizeof(*grp->pins), GFP_KERNEL); if (!grp->pins) return -ENOMEM; pin = grp->settings = devm_kzalloc(npctl->dev, grp->npins * sizeof(*grp->settings), GFP_KERNEL); if (!grp->settings) return -ENOMEM; for (i = 0, j = 0; i < size; i += 4, j++) { struct device_node *np_config; const __be32 *phandle; pin->offset = be32_to_cpu(*list++) * MA35_MFP_REG_SZ_PER_BANK + MA35_MFP_REG_BASE; pin->shift = (be32_to_cpu(*list++) * MA35_MFP_BITS_PER_PORT) % 32; pin->muxval = be32_to_cpu(*list++); phandle = list++; if (!phandle) return -EINVAL; np_config = of_find_node_by_phandle(be32_to_cpup(phandle)); ret = pinconf_generic_parse_dt_config(np_config, NULL, &pin->configs, &pin->nconfigs); if (ret) return ret; grp->pins[j] = npctl->info->get_pin_num(pin->offset, pin->shift); pin++; } Best Regards, Jacky Huang
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Quoted 71 lines · Jacky Huang
Dear Krzysztof,
Quoted 46 lines · Krzysztof Kozlowski
Quoted 45 lines · Jacky Huang
Dear Krzysztof,
Quoted 31 lines · Krzysztof Kozlowski
Quoted 22 lines · Jacky Huang
Quoted 12 lines
Quoted 6 lines
Quoted 3 lines
Best regards,
KrzysztofYes, it did pass the '
dtbs_check'. I guess the tool does not detect such issues.
Anyway, I will fix it in the next version.Hm, I see your bindings indeed allow pin-.* and unit addresses, so it is the binding issue.
The examples you used as reference - xlnx,zynqmp-pinctrl.yaml and realtek,rtd1315e-pinctrl.yaml - do not mix these as you do.
Quoted 8 lines
I don't understand why do you need them yet. I don't see any populate of children. There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
KrzysztofI will move the '
pcfg_default: pin-default' from dtsi to dts, like this:Quoted 8 lines
&pinctrl { pcfg_default: pin-default { slew-rate = <0>; input-schmitt-disable; bias-disable; power-source = <1>; drive-strength = <17100>; };Quoted 6 lines
This solves nothing. It's the same placement.
Best regards,
KrzysztofOK, it stil be the binding issues.
For "^pin-[a-z0-9]+$", I reference to the "pcfg-[a-z0-9-]+$" of rockchip,pinctrl.yaml.Quoted 8 lines
Quoted 3 lines
My intention is to describe a generic pin configuration, aiming to make the pin
description more concise. In actual testing, it proves to be effective.Can you instead respond to my actual questions?
Best regards,
KrzysztofThe the last one item of nuvoton,pins is a phandle, which can refer to '&pin-default'. The following code of driver
pinctrl-ma35.cparse "nuvoton,pins", including the node reference by phandle. list =of_get_property(np, "nuvoton,pins", &size); size /=sizeof(*list); if (!size || size % 4) {dev_err(npctl->dev, "wrong setting!\n"); return-EINVAL; }grp->npins= size / 4;grp->pins=devm_kzalloc(npctl->dev, grp->npins * sizeof(*grp->pins), GFP_KERNEL); if (!grp->pins) return-ENOMEM; pin =grp->settings=devm_kzalloc(npctl->dev, grp->npins * sizeof(*grp->settings), GFP_KERNEL); if (!grp->settings) return-ENOMEM; for (i = 0, j = 0; i < size; i += 4, j++) { structdevice_node*np_config; const__be32*phandle;pin->offset=be32_to_cpu(*list++)*
Quoted 8 lines
MA35_MFP_REG_SZ_PER_BANK+MA35_MFP_REG_BASE;pin->shift= (be32_to_cpu(*list++)*MA35_MFP_BITS_PER_PORT) % 32;pin->muxval=be32_to_cpu(*list++); phandle = list++; if (!phandle) return-EINVAL;np_config= of_find_node_by_phandle(be32_to_cpup(phandle)); ret =pinconf_generic_parse_dt_config(np_config, NULL, &pin->configs, &pin->nconfigs); if (ret) return ret; grp->pins[j] =npctl->info->get_pin_num(pin->offset, pin->shift); pin++; } Best Regards, Jacky Huang
Sorry, I cannot parse it.
I was referring to the children with unit addresses. I don't see any populate of the children, so why do you need them?
There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
Krzysztof
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Dear Krzysztof,
Quoted 83 lines · Krzysztof Kozlowski
Quoted 69 lines · Jacky Huang
Dear Krzysztof,
Quoted 46 lines · Krzysztof Kozlowski
Quoted 45 lines · Jacky Huang
Dear Krzysztof,
Quoted 31 lines · Krzysztof Kozlowski
Quoted 22 lines · Jacky Huang
Quoted 12 lines
Quoted 6 lines
Quoted 3 lines
Best regards,
KrzysztofYes, it did pass the '
dtbs_check'. I guess the tool does not detect such issues.
Anyway, I will fix it in the next version.Hm, I see your bindings indeed allow pin-.* and unit addresses, so it is the binding issue.
The examples you used as reference - xlnx,zynqmp-pinctrl.yaml and realtek,rtd1315e-pinctrl.yaml - do not mix these as you do.
Quoted 8 lines
I don't understand why do you need them yet. I don't see any populate of children. There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
KrzysztofI will move the '
pcfg_default: pin-default' from dtsi to dts, like this:Quoted 8 lines
&pinctrl { pcfg_default: pin-default { slew-rate = <0>; input-schmitt-disable; bias-disable; power-source = <1>; drive-strength = <17100>; };Quoted 6 lines
This solves nothing. It's the same placement.
Best regards,
KrzysztofOK, it stil be the binding issues.
For "^pin-[a-z0-9]+$", I reference to the "pcfg-[a-z0-9-]+$" of rockchip,pinctrl.yaml.Quoted 8 lines
Quoted 3 lines
My intention is to describe a generic pin configuration, aiming to make the pin
description more concise. In actual testing, it proves to be effective.Can you instead respond to my actual questions?
Best regards,
KrzysztofThe the last one item of nuvoton,pins is a phandle, which can refer to '&pin-default'. The following code of driver
pinctrl-ma35.cparse "nuvoton,pins", including the node reference by phandle. list =of_get_property(np, "nuvoton,pins", &size); size /=sizeof(*list); if (!size || size % 4) {dev_err(npctl->dev, "wrong setting!\n"); return-EINVAL; }grp->npins= size / 4;grp->pins=devm_kzalloc(npctl->dev, grp->npins * sizeof(*grp->pins), GFP_KERNEL); if (!grp->pins) return-ENOMEM; pin =grp->settings=devm_kzalloc(npctl->dev, grp->npins * sizeof(*grp->settings), GFP_KERNEL); if (!grp->settings) return-ENOMEM; for (i = 0, j = 0; i < size; i += 4, j++) { structdevice_node*np_config; const__be32*phandle;pin->offset=be32_to_cpu(*list++)*Quoted 8 lines
MA35_MFP_REG_SZ_PER_BANK+MA35_MFP_REG_BASE;pin->shift= (be32_to_cpu(*list++)*MA35_MFP_BITS_PER_PORT) % 32;pin->muxval=be32_to_cpu(*list++); phandle = list++; if (!phandle) return-EINVAL;np_config= of_find_node_by_phandle(be32_to_cpup(phandle)); ret =pinconf_generic_parse_dt_config(np_config, NULL, &pin->configs, &pin->nconfigs); if (ret) return ret; grp->pins[j] =npctl->info->get_pin_num(pin->offset, pin->shift); pin++; } Best Regards, Jacky HuangSorry, I cannot parse it.
I was referring to the children with unit addresses. I don't see any populate of the children, so why do you need them?
Quoted 7 lines
There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
Krzysztof
So, I should update the binding from "^pin-[a-z0-9]+$" to something like "-pincfg$". Just remove the unit address part, and it will become:
default-pincfg {
slew-rate = <0>;
input-schmitt-disable;
bias-disable;
power-source = <1>;
drive-strength = <17100>;
};
Best Regards,
Jacky Huang
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Quoted 98 lines · Jacky Huang
Dear Krzysztof,
Quoted 83 lines · Krzysztof Kozlowski
Quoted 69 lines · Jacky Huang
Dear Krzysztof,
Quoted 46 lines · Krzysztof Kozlowski
Quoted 45 lines · Jacky Huang
Dear Krzysztof,
Quoted 31 lines · Krzysztof Kozlowski
Quoted 22 lines · Jacky Huang
Quoted 12 lines
Quoted 6 lines
Quoted 3 lines
Best regards,
KrzysztofYes, it did pass the '
dtbs_check'. I guess the tool does not detect such issues.
Anyway, I will fix it in the next version.Hm, I see your bindings indeed allow pin-.* and unit addresses, so it is the binding issue.
The examples you used as reference - xlnx,zynqmp-pinctrl.yaml and realtek,rtd1315e-pinctrl.yaml - do not mix these as you do.
Quoted 8 lines
I don't understand why do you need them yet. I don't see any populate of children. There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
KrzysztofI will move the '
pcfg_default: pin-default' from dtsi to dts, like this:Quoted 8 lines
&pinctrl { pcfg_default: pin-default { slew-rate = <0>; input-schmitt-disable; bias-disable; power-source = <1>; drive-strength = <17100>; };Quoted 6 lines
This solves nothing. It's the same placement.
Best regards,
KrzysztofOK, it stil be the binding issues.
For "^pin-[a-z0-9]+$", I reference to the "pcfg-[a-z0-9-]+$" of rockchip,pinctrl.yaml.Quoted 8 lines
Quoted 3 lines
My intention is to describe a generic pin configuration, aiming to make the pin
description more concise. In actual testing, it proves to be effective.Can you instead respond to my actual questions?
Best regards,
KrzysztofThe the last one item of nuvoton,pins is a phandle, which can refer to '&pin-default'. The following code of driver
pinctrl-ma35.cparse "nuvoton,pins", including the node reference by phandle. list =of_get_property(np, "nuvoton,pins", &size); size /=sizeof(*list); if (!size || size % 4) {dev_err(npctl->dev, "wrong setting!\n"); return-EINVAL; }grp->npins= size / 4;grp->pins=devm_kzalloc(npctl->dev, grp->npins * sizeof(*grp->pins), GFP_KERNEL); if (!grp->pins) return-ENOMEM; pin =grp->settings=devm_kzalloc(npctl->dev, grp->npins * sizeof(*grp->settings), GFP_KERNEL); if (!grp->settings) return-ENOMEM; for (i = 0, j = 0; i < size; i += 4, j++) { structdevice_node*np_config; const__be32*phandle;pin->offset=be32_to_cpu(*list++)*Quoted 8 lines
MA35_MFP_REG_SZ_PER_BANK+MA35_MFP_REG_BASE;pin->shift= (be32_to_cpu(*list++)*MA35_MFP_BITS_PER_PORT) % 32;pin->muxval=be32_to_cpu(*list++); phandle = list++; if (!phandle) return-EINVAL;np_config= of_find_node_by_phandle(be32_to_cpup(phandle)); ret =pinconf_generic_parse_dt_config(np_config, NULL, &pin->configs, &pin->nconfigs); if (ret) return ret; grp->pins[j] =npctl->info->get_pin_num(pin->offset, pin->shift); pin++; } Best Regards, Jacky HuangSorry, I cannot parse it.
I was referring to the children with unit addresses. I don't see any populate of the children, so why do you need them?
Quoted 7 lines
There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
KrzysztofSo, I should update the binding from "^pin-[a-z0-9]+$" to something like "-pincfg$".
Just remove the unit address part, and it will become:
Quoted 8 lines
default-pincfg {
slew-rate = <0>;
input-schmitt-disable;
bias-disable;
power-source = <1>;
drive-strength = <17100>;
};
No, it solves nothing. Instead of pasting more code, can you answer my questions?
Best regards,
Krzysztof
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Quoted 107 lines · Krzysztof Kozlowski
Quoted 98 lines · Jacky Huang
Dear Krzysztof,
Quoted 83 lines · Krzysztof Kozlowski
Quoted 69 lines · Jacky Huang
Dear Krzysztof,
Quoted 46 lines · Krzysztof Kozlowski
Quoted 45 lines · Jacky Huang
Dear Krzysztof,
Quoted 31 lines · Krzysztof Kozlowski
Quoted 22 lines · Jacky Huang
Quoted 12 lines
Quoted 6 lines
Quoted 3 lines
Best regards,
KrzysztofYes, it did pass the '
dtbs_check'. I guess the tool does not detect such issues.
Anyway, I will fix it in the next version.Hm, I see your bindings indeed allow pin-.* and unit addresses, so it is the binding issue.
The examples you used as reference - xlnx,zynqmp-pinctrl.yaml and realtek,rtd1315e-pinctrl.yaml - do not mix these as you do.
Quoted 8 lines
I don't understand why do you need them yet. I don't see any populate of children. There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
KrzysztofI will move the '
pcfg_default: pin-default' from dtsi to dts, like this:Quoted 8 lines
&pinctrl { pcfg_default: pin-default { slew-rate = <0>; input-schmitt-disable; bias-disable; power-source = <1>; drive-strength = <17100>; };Quoted 6 lines
This solves nothing. It's the same placement.
Best regards,
KrzysztofOK, it stil be the binding issues.
For "^pin-[a-z0-9]+$", I reference to the "pcfg-[a-z0-9-]+$" of rockchip,pinctrl.yaml.Quoted 8 lines
Quoted 3 lines
My intention is to describe a generic pin configuration, aiming to make the pin
description more concise. In actual testing, it proves to be effective.Can you instead respond to my actual questions?
Best regards,
KrzysztofThe the last one item of nuvoton,pins is a phandle, which can refer to '&pin-default'. The following code of driver
pinctrl-ma35.cparse "nuvoton,pins", including the node reference by phandle. list =of_get_property(np, "nuvoton,pins", &size); size /=sizeof(*list); if (!size || size % 4) {dev_err(npctl->dev, "wrong setting!\n"); return-EINVAL; }grp->npins= size / 4;grp->pins=devm_kzalloc(npctl->dev, grp->npins * sizeof(*grp->pins), GFP_KERNEL); if (!grp->pins) return-ENOMEM; pin =grp->settings=devm_kzalloc(npctl->dev, grp->npins * sizeof(*grp->settings), GFP_KERNEL); if (!grp->settings) return-ENOMEM; for (i = 0, j = 0; i < size; i += 4, j++) { structdevice_node*np_config; const__be32*phandle;pin->offset=be32_to_cpu(*list++)*Quoted 8 lines
MA35_MFP_REG_SZ_PER_BANK+MA35_MFP_REG_BASE;pin->shift= (be32_to_cpu(*list++)*MA35_MFP_BITS_PER_PORT) % 32;pin->muxval=be32_to_cpu(*list++); phandle = list++; if (!phandle) return-EINVAL;np_config= of_find_node_by_phandle(be32_to_cpup(phandle)); ret =pinconf_generic_parse_dt_config(np_config, NULL, &pin->configs, &pin->nconfigs); if (ret) return ret; grp->pins[j] =npctl->info->get_pin_num(pin->offset, pin->shift); pin++; } Best Regards, Jacky HuangSorry, I cannot parse it.
I was referring to the children with unit addresses. I don't see any populate of the children, so why do you need them?
Quoted 7 lines
There are no compatibles, either.
Which part of your driver uses them exactly?
Best regards,
KrzysztofSo, I should update the binding from "^pin-[a-z0-9]+$" to something like "-pincfg$".
Just remove the unit address part, and it will become:Quoted 8 lines
default-pincfg { slew-rate = <0>; input-schmitt-disable; bias-disable; power-source = <1>; drive-strength = <17100>; };
Quoted 6 lines
No, it solves nothing. Instead of pasting more code, can you answer my questions?
Best regards,
Krzysztof
Yes, this node is invalid.
I will drop this node and update the yaml.
Best Regards,
Jacky Huang
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
In reply to Jacky HuangQuoted 2 lines · Jacky Huang
From: Jacky Huang <[email protected]>
...
Quoted 10 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +1
-1sys: system-management@40460000 { - compatible = "nuvoton,ma35d1-reset"; + compatible = "nuvoton,ma35d1-reset", "syscon"; reg = <0x0 0x40460000 0x0 0x200>; #reset-cells = <1>; };@@ -95,6 +96,162 @@ clk: clock-controller@40460200 { clocks = <&clk_hxt>; };
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi clk: clock-controller@40460200 { · line 107
Quoted 10 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +9
-0+ pinctrl: pinctrl@40040000 { + compatible = "nuvoton,ma35d1-pinctrl"; + #address-cells = <1>; + #size-cells = <1>; + nuvoton,sys = <&sys>; + ranges = <0x0 0x0 0x40040000 0xc00>; + + gpioa: gpio@40040000 { + reg = <0x0 0x40>;
Your unit address does not match reg.
You must test your DTS with dtbs_check W=1.
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi clk: clock-controller@40460200 { · line 111
Quoted 4 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +4
-0+ interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk GPA_GATE>; + gpio-controller; + #gpio-cells = <2>;
Best regards,
Krzysztof
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
Dear Krzysztof,
Quoted 30 lines · Krzysztof Kozlowski
Quoted 2 lines · Jacky Huang
From: Jacky Huang <[email protected]>
...
Quoted 10 lines
sys: system-management@40460000 {arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +1
-1- compatible = "nuvoton,ma35d1-reset"; + compatible = "nuvoton,ma35d1-reset", "syscon"; reg = <0x0 0x40460000 0x0 0x200>; #reset-cells = <1>; };@@ -95,6 +96,162 @@ clk: clock-controller@40460200 { clocks = <&clk_hxt>; };arch/arm64/boot/dts/nuvoton/ma35d1.dtsi clk: clock-controller@40460200 { · line 107
Quoted 10 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +9
-0+ pinctrl: pinctrl@40040000 { + compatible = "nuvoton,ma35d1-pinctrl"; + #address-cells = <1>; + #size-cells = <1>; + nuvoton,sys = <&sys>; + ranges = <0x0 0x0 0x40040000 0xc00>; + + gpioa: gpio@40040000 { + reg = <0x0 0x40>;Your unit address does not match reg.
You must test your DTS with
dtbs_check W=1.
Quoted 8 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi clk: clock-controller@40460200 { · line 111
Quoted 4 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +4
-0+ interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk GPA_GATE>; + gpio-controller; + #gpio-cells = <2>;Best regards,
Krzysztof
Sure, I will fix it. thank you.
Best Regards,
Jacky Huang
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
In reply to Krzysztof KozlowskiDear Krzysztof,
Thanks for your review.
Quoted 30 lines · Krzysztof Kozlowski
Quoted 2 lines · Jacky Huang
From: Jacky Huang <[email protected]>
...
Quoted 10 lines
sys: system-management@40460000 {arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +1
-1- compatible = "nuvoton,ma35d1-reset"; + compatible = "nuvoton,ma35d1-reset", "syscon"; reg = <0x0 0x40460000 0x0 0x200>; #reset-cells = <1>; };@@ -95,6 +96,162 @@ clk: clock-controller@40460200 { clocks = <&clk_hxt>; };arch/arm64/boot/dts/nuvoton/ma35d1.dtsi clk: clock-controller@40460200 { · line 107
Quoted 10 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +9
-0+ pinctrl: pinctrl@40040000 { + compatible = "nuvoton,ma35d1-pinctrl"; + #address-cells = <1>; + #size-cells = <1>; + nuvoton,sys = <&sys>; + ranges = <0x0 0x0 0x40040000 0xc00>; + + gpioa: gpio@40040000 { + reg = <0x0 0x40>;Your unit address does not match reg.
You must test your DTS with
dtbs_check W=1.
Quoted 8 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi clk: clock-controller@40460200 { · line 111
Quoted 4 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +4
-0+ interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk GPA_GATE>; + gpio-controller; + #gpio-cells = <2>;Best regards,
Krzysztof
"OK, I will fix 'gpioa: gpio@40040000' to 'gpioa: gpio@0', and similarly for gpiob to gpion. I will also eliminate all redundant spaces behind GIC_SPI." Best Regards, Jacky Huang
Re: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
In reply to Jacky Huangarch/arm64/boot/dts/nuvoton/ma35d1.dtsi clk: clock-controller@40460200 { · line 188
Quoted 3 lines · Jacky Huang
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +3
-0+ gpioi: gpio@40040200 { + reg = <0x200 0x40>; + interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>;
One space after GIC_SPI, not two.
Best regards,
Krzysztof
kernel test robot
build botRe: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
In reply to Jacky Huangkernel test robot noticed the following build errors:
Hi Jacky,
kernel test robot noticed the following build errors:
[auto build test ERROR on linusw-pinctrl/devel]
[also build test ERROR on linusw-pinctrl/for-next robh/for-next linus/master v6.7-rc3] [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/Jacky-Huang/dt-bindings-reset-Add-syscon-to-nuvoton-ma35d1-system-management-node/20231128-141443 base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel patch link: https://lore.kernel.org/r/20231128061118.575847-4-ychuang570808%40gmail.com patch subject: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1 config: arm64-randconfig-001-20231128 (https://download.01.org/0day-ci/archive/20231129/[email protected]/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231129/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from arch/arm64/boot/dts/nuvoton/ma35d1-iot-512m.dts:9:
>> arch/arm64/boot/dts/nuvoton/ma35d1.dtsi:13:10: fatal error: 'dt-bindings/pinctrl/ma35d1-pinfunc.h' file not found
13 | #include <dt-bindings/pinctrl/ma35d1-pinfunc.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1 error generated.
vim +13 arch/arm64/boot/dts/nuvoton/ma35d1.dtsi
> 13 #include <dt-bindings/pinctrl/ma35d1-pinfunc.h>
14 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1
In reply to Jacky Huangkernel test robot noticed the following build errors:
Hi Jacky,
kernel test robot noticed the following build errors:
[auto build test ERROR on linusw-pinctrl/devel]
[also build test ERROR on linusw-pinctrl/for-next robh/for-next linus/master v6.7-rc3 next-20231128] [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/Jacky-Huang/dt-bindings-reset-Add-syscon-to-nuvoton-ma35d1-system-management-node/20231128-141443 base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel patch link: https://lore.kernel.org/r/20231128061118.575847-4-ychuang570808%40gmail.com patch subject: [PATCH v2 3/4] arm64: dts: nuvoton: Add pinctrl support for ma35d1 config: arm64-defconfig (https://download.01.org/0day-ci/archive/20231129/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231129/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from arch/arm64/boot/dts/nuvoton/ma35d1-iot-512m.dts:9:
>> arch/arm64/boot/dts/nuvoton/ma35d1.dtsi:13:10: fatal error: dt-bindings/pinctrl/ma35d1-pinfunc.h: No such file or directory
13 | #include <dt-bindings/pinctrl/ma35d1-pinfunc.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~compilation terminated.
vim +13 arch/arm64/boot/dts/nuvoton/ma35d1.dtsi
> 13 #include <dt-bindings/pinctrl/ma35d1-pinfunc.h>
14 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v2 4/4 pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver
In reply to Jacky HuangFrom: Jacky Huang <[email protected]>
Add common pinctrl and GPIO driver for Nuvoton MA35 series SoC, and add support for ma35d1 pinctrl.
--- drivers/pinctrl/nuvoton/Kconfig | 22 + drivers/pinctrl/nuvoton/Makefile | 2 + drivers/pinctrl/nuvoton/pinctrl-ma35.c | 1244 +++++++++++++++ drivers/pinctrl/nuvoton/pinctrl-ma35.h | 50 + drivers/pinctrl/nuvoton/pinctrl-ma35d1.c | 1797 ++++++++++++++++++++++ 5 files changed, 3115 insertions(+) create mode 100644 drivers/pinctrl/nuvoton/pinctrl-ma35.c create mode 100644 drivers/pinctrl/nuvoton/pinctrl-ma35.h create mode 100644 drivers/pinctrl/nuvoton/pinctrl-ma35d1.c
drivers/pinctrl/nuvoton/Kconfig +22 -0
@@ -45,3 +45,25 @@ config PINCTRL_NPCM8XX Say Y or M here to enable pin controller and GPIO support for the Nuvoton NPCM8XX SoC. This is strongly recommended when building a kernel that will run on this chip. + +if ARCH_MA35 || COMPILE_TEST + +config PINCTRL_MA35 + bool + depends on OF + select GENERIC_PINCTRL_GROUPS + select GENERIC_PINMUX_FUNCTIONS + select GENERIC_PINCONF + select GPIOLIB + select GPIO_GENERIC + select GPIOLIB_IRQCHIP + select MFD_SYSCON + +config PINCTRL_MA35D1 + bool "Pinctrl and GPIO driver for Nuvoton MA35D1" + depends on OF + select PINCTRL_MA35 + help + Say Y here to enable pin controller and GPIO support + for Nuvoton MA35D1 SoC. +endif
drivers/pinctrl/nuvoton/Makefile +2 -0
@@ -4,3 +4,5 @@ obj-$(CONFIG_PINCTRL_WPCM450) += pinctrl-wpcm450.o obj-$(CONFIG_PINCTRL_NPCM7XX) += pinctrl-npcm7xx.o obj-$(CONFIG_PINCTRL_NPCM8XX) += pinctrl-npcm8xx.o +obj-$(CONFIG_PINCTRL_MA35) += pinctrl-ma35.o +obj-$(CONFIG_PINCTRL_MA35D1) += pinctrl-ma35d1.o
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +1244 -0
1,244 lines not on this page · raw message
drivers/pinctrl/nuvoton/pinctrl-ma35.h new file +50 -0
50 lines not on this page · raw message
drivers/pinctrl/nuvoton/pinctrl-ma35d1.c new file +1797 -0
1,676 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH v2 4/4] pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver
Hi Jacky,
thanks for your patch!
This is an interesting new driver. The initial review pass will be along the lines "utilize helpers and library functions please". You will see that this will shrink the core driver and make it rely on core code helpers making it much easier to maintain in the long run (I think).
Quoted 1 line · Jacky Huang
+if
ARCH_MA35||COMPILE_TEST
Isn't it cleaner to put the depends on inside the Kconfig entries? This looks a bit convoluted.
drivers/pinctrl/nuvoton/Kconfig config PINCTRL_NPCM8XX · line 53
Quoted 3 lines
drivers/pinctrl/nuvoton/Kconfig +3
-0+config PINCTRL_MA35 + bool + depends on OF
So
depends on ARCH_MA35 || COMPILE_TEST here
drivers/pinctrl/nuvoton/Kconfig config PINCTRL_NPCM8XX · line 64
Quoted 11 lines
drivers/pinctrl/nuvoton/Kconfig +11
-0+ select GENERIC_PINCTRL_GROUPS + select GENERIC_PINMUX_FUNCTIONS + select GENERIC_PINCONF + select GPIOLIB + select GPIO_GENERIC + select GPIOLIB_IRQCHIP + select MFD_SYSCON + +config PINCTRL_MA35D1 + bool "Pinctrl and GPIO driver for Nuvoton MA35D1" + depends on OF
Now depends on OF gets listed twice, which is confusing
Quoted 1 line
+ select
PINCTRL_MA35
So use
depends on PINCTRL_MA35
instead, and this becomes a sub-choice.
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 13
Quoted 6 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +6
-0+#include <linux/clk.h> +#include <linux/mfd/syscon.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/of_device.h> +#include <linux/of_address.h>
Do you really need them all?
Then I think you need <linux/platform_device.h> because ma35d1_pinctrl_probe(struct platform_device *pdev) passes a platform_device into this file.
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 107
Quoted 9 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +9
-0+struct ma35_pin_bank { +void __iomem *reg_base; +struct clk *clk; +int irq; +u8 nr_pins; +const char *name; +u8 bank_num; +bool valid; +struct device_node *of_node;
Just call the variable *np ("noide pointer") this is the most usual practice despite struct device using thus long "of_node" name.
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 109
Quoted 2 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +2
-0+struct gpio_chip chip; +struct irq_chip irqc;
Please do not use dynamic irq_chips anymore, use an immutable irq_chip, look in other drivers how to do this because we changed almost all of them.
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 161
Quoted 13 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +13
-0+static int ma35_get_group_pins (struct pinctrl_dev *pctldev,unsigned int selector, +const unsigned int **pins,unsigned int *npins) +{ +struct ma35_pinctrl *npctl =pinctrl_dev_get_drvdata (pctldev); + +if (selector >= npctl->ngroups) +return -EINVAL ; + + *pins = npctl->groups[selector].pins; + *npins = npctl->groups[selector].npins; + +return 0 ; +}
Hm it looks simple.
Have you looked into using CONFIG_GENERIC_PINCTRL_GROUPS and then you get a bunch of these functions such as pinctrl_generic_get_group_count pinctrl_generic_get_group_name pinctrl_generic_get_group_name(this function) pinctrl_generic_get_group pinctrl_generic_group_name_to_selector
(etc)
for FREE, also using a radix tree which is neat.
Quoted 43 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +43
-0+static int ma35_pinctrl_dt_node_to_map_func (struct pinctrl_dev *pctldev, +struct device_node *np, +struct pinctrl_map **map, +unsigned int *num_maps) +{ +struct ma35_pinctrl *npctl =pinctrl_dev_get_drvdata (pctldev); +struct ma35_pin_group *grp; +struct pinctrl_map *new_map; +struct device_node *parent; +int map_num =1 ; +int i; + +/* +* first find the group of this node and check if we need create +* config maps for pins +*/ + grp =ma35_pinctrl_find_group_by_name (npctl, np->name); +if (!grp) { +dev_err (npctl->dev,"unable to find group for node %s\n" , np->name); +return -EINVAL ; + } + + map_num += grp->npins; + new_map =devm_kzalloc (pctldev->dev,sizeof (*new_map) * map_num,GFP_KERNEL ); +if (!new_map) +return -ENOMEM ; + + *map = new_map; + *num_maps = map_num; +/* create mux map */ + parent =of_get_parent (np); +if (!parent) { +devm_kfree (pctldev->dev, new_map); +return -EINVAL ; + } + + new_map[0 ].type =PIN_MAP_TYPE_MUX_GROUP ; + new_map[0 ].data.mux.function = parent->name; + new_map[0 ].data.mux.group = np->name; +of_node_put (parent); + + new_map++; +for (i =0 ; i < grp->npins; i++) {
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 228
Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +10
-0+ new_map[i].type =PIN_MAP_TYPE_CONFIGS_PIN ; + new_map[i].data.configs.group_or_pin =pin_get_name (pctldev, grp->pins[i]); + new_map[i].data.configs.configs = grp->settings[i].configs; + new_map[i].data.configs.num_configs = grp->settings[i].nconfigs; + } +dev_dbg (pctldev->dev,"maps: function %s group %s num %d\n" , + (*map)->data.mux.function, (*map)->data.mux.group, map_num); + +return 0 ; +}
This looks like it could be replaced with:pinconf_generic_dt_node_to_map_grouppinconf_generic_dt_node_to_map_all
please check the generic helpers closely.
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 234
Quoted 5 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +5
-0+static void ma35_dt_free_map (struct pinctrl_dev *pctldev,struct pinctrl_map *map, +unsigned int num_maps) +{ +devm_kfree (pctldev->dev, map); +}
pinconf_generic_dt_free_map
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 249
Quoted 6 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +6
-0+static int ma35_pinmux_get_func_count (struct pinctrl_dev *pctldev) +{ +struct ma35_pinctrl *npctl =pinctrl_dev_get_drvdata (pctldev); + +return npctl->nfunctions; +}
pinmux_generic_get_function_countpinmux_generic_get_function_namepinmux_generic_get_function_groups
(etc)
Please check the CONFIG_GENERIC_PINMUX_FUNCTIONS
option because these are again all very generic.
Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +10
-0+static int ma35_gpio_core_direction_in (struct gpio_chip *gc,unsigned int gpio) +{ +struct ma35_pin_bank *bank =gpiochip_get_data (gc); +void __iomem *reg_mode = bank->reg_base +MA35_GP_REG_MODE ; +unsigned long flags; +unsigned int regval; + +spin_lock_irqsave (&bank->lock, flags); + + regval =readl (reg_mode);
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 321
Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +10
-0+ + regval &= ~GENMASK (gpio *2 +1 , gpio *2 ); + regval |=MA35_GP_MODE_INPUT << gpio *2 ; + +writel (regval, reg_mode); + +spin_unlock_irqrestore (&bank->lock, flags); + +return 0 ; +}
The pinctrl set_mux is using a regmap but not the GPIO which is a bit of a weird mix.
Further, if you were using regmap-mmio for GPIO, you could probably utilize CONFIG_GPIO_REGMAP to simplify also this part of the code with a library. Look at other drivers using this!
Quoted 15 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +15
-0+if (bank->irq >0 ) { +struct gpio_irq_chip *girq; + + girq = &bank->chip.irq; + girq->chip = &bank->irqc; + girq->chip->name = bank->name; + girq->chip->irq_disable = ma35_irq_gpio_mask; + girq->chip->irq_enable = ma35_irq_gpio_unmask; + girq->chip->irq_set_type = ma35_irq_irqtype; + girq->chip->irq_mask = ma35_irq_gpio_mask; + girq->chip->irq_unmask = ma35_irq_gpio_unmask; + girq->chip->flags =IRQCHIP_MASK_ON_SUSPEND | +IRQCHIP_SKIP_SET_WAKE |IRQCHIP_IMMUTABLE ; + girq->parent_handler = ma35_irq_demux_intgroup; + girq->num_parents =1 ;
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 562
Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +10
-0+ + girq->parents =devm_kcalloc (&pdev->dev,1 ,sizeof (*girq->parents), +GFP_KERNEL ); +if (!girq->parents) +return -ENOMEM ; + + girq->parents[0 ] = bank->irq; + girq->default_type =IRQ_TYPE_NONE ; + girq->handler = handle_level_irq; + }
As menioned, replace this with an immutable irq_chip.
Yours,
Linus Walleij
Re: [PATCH v2 4/4] pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver
Dear Linus,
Thanks for your review.
Quoted 35 lines · Linus Walleij
Hi Jacky,
thanks for your patch!
This is an interesting new driver. The initial review pass will be along the lines "utilize helpers and library functions please". You will see that this will shrink the core driver and make it rely on core code helpers making it much easier to maintain in the long run (I think).
Quoted 1 line · Jacky Huang
+if
ARCH_MA35||COMPILE_TESTIsn't it cleaner to put the depends on inside the
Kconfigentries? This looks a bit convoluted.drivers/pinctrl/nuvoton/Kconfig config PINCTRL_NPCM8XX · line 53
Quoted 3 lines
drivers/pinctrl/nuvoton/Kconfig +3
-0+config PINCTRL_MA35 + bool + depends on OFSo
depends onARCH_MA35||COMPILE_TESTheredrivers/pinctrl/nuvoton/Kconfig config PINCTRL_NPCM8XX · line 64
Quoted 11 lines
drivers/pinctrl/nuvoton/Kconfig +11
-0+ select GENERIC_PINCTRL_GROUPS + select GENERIC_PINMUX_FUNCTIONS + select GENERIC_PINCONF + select GPIOLIB + select GPIO_GENERIC + select GPIOLIB_IRQCHIP + select MFD_SYSCON + +config PINCTRL_MA35D1 + bool "Pinctrl and GPIO driver for Nuvoton MA35D1" + depends on OFNow depends on OF gets listed twice, which is confusing
Quoted 5 lines
Quoted 1 line
+ select
PINCTRL_MA35So use
depends onPINCTRL_MA35instead, and this becomes a sub-choice.
OK, I will fix the above issues. It will be:
config PINCTRL_MA35
bool "Pinctrl and GPIO driver for Nuvoton MA35 series" depends on (ARCH_MA35 || COMPILE_TEST) && OF select GENERIC_PINCTRL_GROUPS
select GENERIC_PINMUX_FUNCTIONS
select GENERIC_PINCONF
select GPIOLIB
select GPIO_GENERIC
select GPIOLIB_IRQCHIP
select MFD_SYSCON
config PINCTRL_MA35D1
bool "Pinctrl and GPIO driver for Nuvoton MA35D1" depends on PINCTRL_MA35
help
Say Y here to enable pin controller and GPIO support for Nuvoton MA35D1 SoC.
Quoted 11 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 13
Quoted 6 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +6
-0+#include <linux/clk.h> +#include <linux/mfd/syscon.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/of_device.h> +#include <linux/of_address.h> Do you really need them all?
Then I think you need <
linux/platform_device.h> becausema35d1_pinctrl_probe(struct platform_device *pdev)passes aplatform_deviceinto this file.
I will have a compile test and remove unnecessary ones and add <linux/platform_device.h>.
Quoted 9 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 107
Quoted 9 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +9
-0+struct ma35_pin_bank { +void __iomem *reg_base; +struct clk *clk; +int irq; +u8 nr_pins; +const char *name; +u8 bank_num; +bool valid; +struct device_node *of_node;
Quoted 3 lines
Just call the variable *np ("noide pointer") this is the most usual practice despite struct device using thus long "
of_node" name.
OK, I will use 'struct device_node *np'.
Quoted 5 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 109
Quoted 2 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +2
-0+struct gpio_chip chip; +struct irq_chip irqc;Please do not use dynamic
irq_chipsanymore, use an immutableirq_chip, look in other drivers how to do this because we changed almost all of them.
I will use immutable instead.
Quoted 24 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 161
Quoted 13 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +13
-0+static int ma35_get_group_pins (struct pinctrl_dev *pctldev,unsigned int selector, +const unsigned int **pins,unsigned int *npins) +{ +struct ma35_pinctrl *npctl =pinctrl_dev_get_drvdata (pctldev); + +if (selector >= npctl->ngroups) +return -EINVAL ; + + *pins = npctl->groups[selector].pins; + *npins = npctl->groups[selector].npins; + +return 0 ; +}Hm it looks simple.
Have you looked into using
CONFIG_GENERIC_PINCTRL_GROUPSand then you get a bunch of these functions such aspinctrl_generic_get_group_countpinctrl_generic_get_group_namepinctrl_generic_get_group_name(this function)pinctrl_generic_get_grouppinctrl_generic_group_name_to_selector
(etc)
Quoted 1 line
for FREE, also using a radix tree which is neat.
Thank you for your reminder. I will look into how to use CONFIG_GENERIC_PINCTRL_GROUPS.
Quoted 57 lines
Quoted 43 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +43
-0+static int ma35_pinctrl_dt_node_to_map_func (struct pinctrl_dev *pctldev, +struct device_node *np, +struct pinctrl_map **map, +unsigned int *num_maps) +{ +struct ma35_pinctrl *npctl =pinctrl_dev_get_drvdata (pctldev); +struct ma35_pin_group *grp; +struct pinctrl_map *new_map; +struct device_node *parent; +int map_num =1 ; +int i; + +/* +* first find the group of this node and check if we need create +* config maps for pins +*/ + grp =ma35_pinctrl_find_group_by_name (npctl, np->name); +if (!grp) { +dev_err (npctl->dev,"unable to find group for node %s\n" , np->name); +return -EINVAL ; + } + + map_num += grp->npins; + new_map =devm_kzalloc (pctldev->dev,sizeof (*new_map) * map_num,GFP_KERNEL ); +if (!new_map) +return -ENOMEM ; + + *map = new_map; + *num_maps = map_num; +/* create mux map */ + parent =of_get_parent (np); +if (!parent) { +devm_kfree (pctldev->dev, new_map); +return -EINVAL ; + } + + new_map[0 ].type =PIN_MAP_TYPE_MUX_GROUP ; + new_map[0 ].data.mux.function = parent->name; + new_map[0 ].data.mux.group = np->name; +of_node_put (parent); + + new_map++; +for (i =0 ; i < grp->npins; i++) {drivers/pinctrl/nuvoton/pinctrl-ma35.c line 228
Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +10
-0+ new_map[i].type =PIN_MAP_TYPE_CONFIGS_PIN ; + new_map[i].data.configs.group_or_pin =pin_get_name (pctldev, grp->pins[i]); + new_map[i].data.configs.configs = grp->settings[i].configs; + new_map[i].data.configs.num_configs = grp->settings[i].nconfigs; + } +dev_dbg (pctldev->dev,"maps: function %s group %s num %d\n" , + (*map)->data.mux.function, (*map)->data.mux.group, map_num); + +return 0 ; +}This looks like it could be replaced with:
pinconf_generic_dt_node_to_map_grouppinconf_generic_dt_node_to_map_all
Quoted 1 line
please check the generic helpers closely.
Alright, I will try using these helpers to simplify the code.
Quoted 6 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 234
Quoted 5 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +5
-0+static void ma35_dt_free_map (struct pinctrl_dev *pctldev,struct pinctrl_map *map, +unsigned int num_maps) +{ +devm_kfree (pctldev->dev, map); +}
pinconf_generic_dt_free_map
I will fix it.
Quoted 12 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 249
Quoted 7 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +6
-0+static int ma35_pinmux_get_func_count (struct pinctrl_dev *pctldev) +{ +struct ma35_pinctrl *npctl =pinctrl_dev_get_drvdata (pctldev); + +return npctl->nfunctions; +}
pinmux_generic_get_function_countpinmux_generic_get_function_namepinmux_generic_get_function_groups
(etc)
Quoted 2 lines
Please check the
CONFIG_GENERIC_PINMUX_FUNCTIONS
option because these are again all very generic.
I will try to use these helpers and have a test.
Quoted 23 lines
Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +10
-0+static int ma35_gpio_core_direction_in (struct gpio_chip *gc,unsigned int gpio) +{ +struct ma35_pin_bank *bank =gpiochip_get_data (gc); +void __iomem *reg_mode = bank->reg_base +MA35_GP_REG_MODE ; +unsigned long flags; +unsigned int regval; + +spin_lock_irqsave (&bank->lock, flags); + + regval =readl (reg_mode);drivers/pinctrl/nuvoton/pinctrl-ma35.c line 321
Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +10
-0+ + regval &= ~GENMASK (gpio *2 +1 , gpio *2 ); + regval |=MA35_GP_MODE_INPUT << gpio *2 ; + +writel (regval, reg_mode); + +spin_unlock_irqrestore (&bank->lock, flags); + +return 0 ; +}The pinctrl
set_muxis using a regmap but not the GPIO which is a bit of a weird mix.
Quoted 3 lines
Further, if you were using regmap-mmio for GPIO, you could probably utilize
CONFIG_GPIO_REGMAPto simplify also this part of the code with a library. Look at other drivers using this!
Sorry, I'm not quite clear on the issue. This function is just setting the input/output direction for a GPIO pin. The code here is only configuring the GPIO control register. I've observed similar implementations in other drivers, such as in pinctrl-amd.c.
Quoted 18 lines
Quoted 18 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +18
-0+if (bank->irq >0 ) { +struct gpio_irq_chip *girq; + + girq = &bank->chip.irq; + girq->chip = &bank->irqc; + girq->chip->name = bank->name; + girq->chip->irq_disable = ma35_irq_gpio_mask; + girq->chip->irq_enable = ma35_irq_gpio_unmask; + girq->chip->irq_set_type = ma35_irq_irqtype; + girq->chip->irq_mask = ma35_irq_gpio_mask; + girq->chip->irq_unmask = ma35_irq_gpio_unmask; + girq->chip->flags =IRQCHIP_MASK_ON_SUSPEND | +IRQCHIP_SKIP_SET_WAKE |IRQCHIP_IMMUTABLE ; + girq->parent_handler = ma35_irq_demux_intgroup; + girq->num_parents =1 ; + + girq->parents =devm_kcalloc (&pdev->dev,1 ,sizeof (*girq->parents), +GFP_KERNEL );
Quoted 8 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 562
Quoted 7 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +7
-0+if (!girq->parents) +return -ENOMEM ; + + girq->parents[0 ] = bank->irq; + girq->default_type =IRQ_TYPE_NONE ; + girq->handler = handle_level_irq; + }As menioned, replace this with an immutable
irq_chip.
OK, I will fix it.
Quoted 2 lines
Yours,
Linus Walleij
Best Regards,
Jacky Huang