Add support for nuvoton ma35d1 pin control
Subsystems (5)
v8 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 and the ma35d1 pin control driver.
This pin control driver has been tested on the ma35d1 som board with Linux 6.9.0-rc7.
v8:
- Update pinctrl driver:
- Utilize macros wherever possible for managing register bit fields.
- Revise the usage of 'hwirq'.
- Transition to fwnode-based operations instead of device_node as possible.
- Refactor function ma35_pinctrl_parse_groups().
- Adopt new PM macros.
- Implement other minor fixes.
- Update dt-binding docuemnt:
- Add property 'reg' to this pinctrl node.
- Correct the patternProperties name from "pins-" to "-pins" and relocate it under "-grp".
v7:
- Replace the magic numbers appearing in the driver with defined constants, or provide comments to explain them.
- Update the ma35_irq_irqtype()
- irq_set_handler_locked(d, handle_edge_irq) and irq_set_handler_locked(d, handle_level_irq)
- add case IRQ_TYPE_EDGE_BOTH
- Use handle_bad_irq for girq->handler, instead of handle_level_irq
v6:
- Remove DTS from this patchset. The DTS will be submitted in another patchset.
v5:
- Update the pinctrl driver header file pinctrl-ma35.h
- Include platform_device.h to fix compile issues.
v4:
- Update the pinctrl driver Kconfig
- Add depends to CONFIG_PINCTRL_MA35D1 to prevent compilation errors.
- Update the pinctrl driver
- Utilize devm_kcalloc() instead of devm_kzalloc().
- Employ ARRAY_SIZE() instead of sizeof()/sizeof().
v3:
- Update DTS and YAML files
- Corrected the unit address of nodes gpioa ~ gpion.
- Removed the invalid "pin-default" node.
- Removed the phandle entry from "nuvoton,pins".
- Update pinctrl driver
- Fixed the Kconfig by using "depend on" instead of "if".
- Removed unused #include of header files.
- Utilized immutable irq_chip instead of dynamic irq_chip.
- Replaced ma35_dt_free_map() with pinconf_generic_dt_free_map().
- Implemented other minor fixes as suggested by the reviewer.
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 (3):
dt-bindings: reset: Add syscon to nuvoton ma35d1 system-management
node
dt-bindings: pinctrl: Document nuvoton ma35d1 pin control
pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver
.../pinctrl/nuvoton,ma35d1-pinctrl.yaml | 178 ++ .../bindings/reset/nuvoton,ma35d1-reset.yaml | 3 +- drivers/pinctrl/nuvoton/Kconfig | 19 + drivers/pinctrl/nuvoton/Makefile | 2 + drivers/pinctrl/nuvoton/pinctrl-ma35.c | 1197 +++++++++++ drivers/pinctrl/nuvoton/pinctrl-ma35.h | 52 + drivers/pinctrl/nuvoton/pinctrl-ma35d1.c | 1799 +++++++++++++++++ 7 files changed, 3249 insertions(+), 1 deletion(-) 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 v8 1/3 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
PATCH v8 2/3 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 | 178 ++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/nuvoton,ma35d1-pinctrl.yaml new file +178 -0
@@ -0,0 +1,178 @@ +# 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]> + - Jacky Huang <[email protected]> + +allOf: + - $ref: pinctrl.yaml# + +properties: + compatible: + enum: + - nuvoton,ma35d1-pinctrl + + reg: + maxItems: 1 + + '#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 + +patternProperties: + "^gpio@[0-9a-f]+$": + type: object + 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 + + additionalProperties: false + + "-grp$": + type: object + description: + Pinctrl node's client devices use subnodes for desired pin configuration. + Client device subnodes use below standard properties. + patternProperties: + "-pins$": + 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. + $ref: /schemas/pinctrl/pincfg-node.yaml + + 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. + + 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 + + bias-disable: true + + bias-pull-up: true + + bias-pull-down: true + + input-schmitt-disable: true + + additionalProperties: false + + additionalProperties: false + +required: + - compatible + - reg + - nuvoton,sys + +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> + + pinctrl@40040000 { + compatible = "nuvoton,ma35d1-pinctrl"; + reg = <0x40040000 0xc00>; + #address-cells = <1>; + #size-cells = <1>; + nuvoton,sys = <&sys>; + ranges = <0x0 0x40040000 0x400>; + + gpio@0 { + 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>; + }; + + uart-grp { + uart11-pins { + nuvoton,pins = <11 0 2>, + <11 1 2>, + <11 2 2>, + <11 3 2>; + power-source = <1>; + bias-disable; + }; + }; + };
Signature · 1 line
2.34.1
PATCH v8 3/3 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 | 19 + drivers/pinctrl/nuvoton/Makefile | 2 + drivers/pinctrl/nuvoton/pinctrl-ma35.c | 1197 ++++++++++++++ drivers/pinctrl/nuvoton/pinctrl-ma35.h | 52 + drivers/pinctrl/nuvoton/pinctrl-ma35d1.c | 1799 ++++++++++++++++++++++ 5 files changed, 3069 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 +19 -0
@@ -45,3 +45,22 @@ 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. + +config PINCTRL_MA35 + bool + 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 (ARCH_MA35 || COMPILE_TEST) && OF + select PINCTRL_MA35 + help + Say Y here to enable pin controller and GPIO support + for Nuvoton MA35D1 SoC.
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 +1197 -0
1,197 lines not on this page · raw message
drivers/pinctrl/nuvoton/pinctrl-ma35.h new file +52 -0
52 lines not on this page · raw message
drivers/pinctrl/nuvoton/pinctrl-ma35d1.c new file +1799 -0
1,724 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 v8 3/3] pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver
Le 08/05/2024 à 08:51, Jacky Huang a écrit :
Quoted 7 lines
From: Jacky Huang <[email protected]>
Add common pinctrl and GPIO driver for Nuvoton MA35 series SoC, and add support for ma35d1 pinctrl.
Signed-off-by Jacky Huang <[email protected]>---
...
Quoted 52 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +52
-0+static int ma35_gpiolib_register (struct platform_device *pdev,struct ma35_pinctrl *npctl) +{ +struct ma35_pin_ctrl *ctrl = npctl->ctrl; +struct ma35_pin_bank *bank = ctrl->pin_banks; +int ret; +int i; + +for (i =0 ; i < ctrl->nr_banks; i++, bank++) { +if (!bank->valid) { +dev_warn (&pdev->dev,"%pfw: bank is not valid\n" , bank->fwnode); +continue ; + } + bank->irqtype =0 ; + bank->irqinten =0 ; + bank->chip.label = bank->name; + bank->chip.of_gpio_n_cells =2 ; + bank->chip.parent = &pdev->dev; + bank->chip.request = ma35_gpio_core_to_request; + bank->chip.direction_input = ma35_gpio_core_direction_in; + bank->chip.direction_output = ma35_gpio_core_direction_out; + bank->chip.get = ma35_gpio_core_get; + bank->chip.set = ma35_gpio_core_set; + bank->chip.base =-1 ; + bank->chip.ngpio = bank->nr_pins; + bank->chip.can_sleep = false; + +if (bank->irq >0 ) { +struct gpio_irq_chip *girq; + + girq = &bank->chip.irq; +gpio_irq_chip_set_chip (girq, &ma35_gpio_irqchip); + girq->parent_handler = ma35_irq_demux_intgroup; + girq->num_parents =1 ; + + girq->parents =devm_kcalloc (&pdev->dev, girq->num_parents, +sizeof (*girq->parents),GFP_KERNEL ); +if (!girq->parents) { + ret = -ENOMEM ; + goto fail; + } + + girq->parents[0 ] = bank->irq; + girq->default_type =IRQ_TYPE_NONE ; + girq->handler = handle_bad_irq; + } + + ret =devm_gpiochip_add_data (&pdev->dev, &bank->chip, bank); +if (ret) { +dev_err (&pdev->dev,"failed to register gpio_chip %s, error code: %d\n" , + bank->chip.label, ret); + goto fail; + }
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 578
Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +10
-0+ } +return 0 ; + +fail: +while (i--) { + bank--; +if (!bank->valid) +continue ; +gpiochip_remove (&bank->chip); + }
I don't think this is correct. This is to undo the devm_gpiochip_add_data(), right? Because of the devm_, no need to explicityl call gpiochip_remove()
(more over, it should have been --i and not i-- in the while)
Quoted 2 lines
(quoted diff) +2
-0+ return ret; +}
...
Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +10
-0+static int ma35_pinconf_set_drive_strength (struct ma35_pinctrl *npctl,unsigned int pin, +int strength) +{ +unsigned int port, group_num; +void __iomem *base; +int i, ds_val =-1 ; +u32 regval; + +if (ma35_pinconf_get_power_source (npctl, pin) ==MVOLT_1800 ) { +for (i =0 ; i <ARRAY_SIZE (ds_1800mv_tbl); i++) {
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 809
Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +10
-0+if (ds_1800mv_tbl[i] == strength) { + ds_val = i; +break ; + } + } + }else { +for (i =0 ; i <ARRAY_SIZE (ds_3300mv_tbl); i++) { +if (ds_3300mv_tbl[i] == strength) { + ds_val = i; +continue ;
break; ?
Quoted 17 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +17
-0+ } + } + } +if (ds_val ==-1 ) +return -EINVAL ; + +ma35_gpio_cla_port (pin, &group_num, &port); + base = npctl->ctrl->pin_banks[group_num].reg_base; + + regval =readl (base +MA35_GP_DS_REG (port)); + regval &= ~MA35_GP_DS_MASK (port); + regval |=field_prep (MA35_GP_DS_MASK (port), ds_val); + +writel (regval, base +MA35_GP_DS_REG (port)); + +return 0 ; +}
...
Quoted 23 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +23
-0+static int ma35_pinctrl_probe_dt (struct platform_device *pdev,struct ma35_pinctrl *npctl) +{ +struct fwnode_handle *child; +u32 idx =0 ; +int ret; + +device_for_each_child_node (&pdev->dev, child) { +if (fwnode_property_present (child,"gpio-controller" )) +continue ; + npctl->nfunctions++; + npctl->ngroups +=of_get_child_count (to_of_node (child)); + } + +if (!npctl->nfunctions) +return -EINVAL ; + + npctl->functions =devm_kcalloc (&pdev->dev, npctl->nfunctions, +sizeof (*npctl->functions),GFP_KERNEL ); +if (!npctl->functions) +return -ENOMEM ; + + npctl->groups =devm_kcalloc (&pdev->dev, npctl->ngroups, +sizeof (*npctl->groups),GFP_KERNEL );
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 1117
Quoted 10 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +10
-0+if (!npctl->groups) +return -ENOMEM ; + +device_for_each_child_node (&pdev->dev, child) { +if (fwnode_property_present (child,"gpio-controller" )) +continue ; + + ret =ma35_pinctrl_parse_functions (to_of_node (child), npctl, idx++); +if (ret) { +dev_err (&pdev->dev,"failed to parse function\n" );
Missing fwnode_handle_put(child); ?
(or a scoped version of device_for_each_child_node() if it exists)
drivers/pinctrl/nuvoton/pinctrl-ma35.c line 630
Quoted 5 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +5
-0+return ret; + } + } +return 0 ; +
...
CJ
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v8 3/3] pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver
Dear Christophe,
Thanks for the review.
Quoted 80 lines · Christophe JAILLET
Le 08/05/2024 à 08:51, Jacky Huang a écrit :
Quoted 7 lines
From: Jacky Huang <[email protected]>
Add common pinctrl and GPIO driver for Nuvoton MA35 series SoC, and add support for ma35d1 pinctrl.
Signed-off-by Jacky Huang <[email protected]>---
...
Quoted 57 lines
+static int
ma35_gpiolib_register(struct platform_device *pdev, struct ma35_pinctrl *npctl)drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +9
-0+{ + struct ma35_pin_ctrl *ctrl = npctl->ctrl; + struct ma35_pin_bank *bank = ctrl->pin_banks; + int ret; + int i; + + for (i = 0; i < ctrl->nr_banks; i++, bank++) { + if (!bank->valid) { + dev_warn(&pdev->dev, "%pfw: bank is not valid\n",
bank->fwnode);
+ continue;
+ }
+bank->irqtype= 0;
+bank->irqinten= 0;
+bank->chip.label=bank->name;
+bank->chip.of_gpio_n_cells= 2;
+bank->chip.parent=&pdev->dev;
+bank->chip.request=ma35_gpio_core_to_request; +bank->chip.direction_input=ma35_gpio_core_direction_in; +bank->chip.direction_output=ma35_gpio_core_direction_out; +bank->chip.get=ma35_gpio_core_get;
+bank->chip.set=ma35_gpio_core_set;
+bank->chip.base= -1;
+bank->chip.ngpio=bank->nr_pins;
+bank->chip.can_sleep= false;drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +24
-0+ + if (bank->irq > 0) { + struct gpio_irq_chip *girq; + + girq = &bank->chip.irq; + gpio_irq_chip_set_chip(girq, &ma35_gpio_irqchip); + girq->parent_handler = ma35_irq_demux_intgroup; + girq->num_parents = 1; + + girq->parents = devm_kcalloc(&pdev->dev, girq->num_parents, + sizeof(*girq->parents), GFP_KERNEL); + if (!girq->parents) { + ret = -ENOMEM; + goto fail; + } + + girq->parents[0] = bank->irq; + girq->default_type = IRQ_TYPE_NONE; + girq->handler = handle_bad_irq; + } + + ret = devm_gpiochip_add_data(&pdev->dev, &bank->chip, bank); + if (ret) { + dev_err(&pdev->dev, "failed to register gpio_chip %s,error code: %d\n",
+bank->chip.label, ret);
+ goto fail;
+ }
+ }
+ return 0;drivers/pinctrl/nuvoton/pinctrl-ma35.c line 578
Quoted 8 lines
drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +8
-0+ +fail: + while (i--) { + bank--; + if (!bank->valid) + continue; + gpiochip_remove(&bank->chip); + }I don't think this is correct. This is to undo the
devm_gpiochip_add_data(), right? Because of thedevm_, no need to explicityl callgpiochip_remove()
Quoted 2 lines
(more over, it should have been --i and not i-- in the while)
Yes, I will just drop the whole "fail:" case and make it return from "goto fail" with the error code.
Quoted 20 lines
Quoted 2 lines
+ return ret;
+}...
Quoted 15 lines
+static int ma35_pinconf_set_drive_strength(struct
ma35_pinctrl*npctl, unsigned int pin,
+ int strength)drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +12
-0+{ + unsigned int port, group_num; + void __iomem *base; + int i, ds_val = -1; + u32 regval; + + if (ma35_pinconf_get_power_source(npctl, pin) == MVOLT_1800) { + for (i = 0; i < ARRAY_SIZE(ds_1800mv_tbl); i++) { + if (ds_1800mv_tbl[i] == strength) { + ds_val = i; + break; + }
Quoted 8 lines
Quoted 6 lines
+ }
+ } else {
+ for (i = 0; i <ARRAY_SIZE(ds_3300mv_tbl); i++) { + if (ds_3300mv_tbl[i] == strength) { +ds_val= i;
+ continue;break; ?
I will fix it.
Quoted 51 lines
Quoted 18 lines
+ }
+ }
+ }
+ if (ds_val== -1)
+ return-EINVAL;drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +12
-0+ + ma35_gpio_cla_port(pin, &group_num, &port); + base = npctl->ctrl->pin_banks[group_num].reg_base; + + regval = readl(base + MA35_GP_DS_REG(port)); + regval &= ~MA35_GP_DS_MASK(port); + regval |= field_prep(MA35_GP_DS_MASK(port), ds_val); + + writel(regval, base + MA35_GP_DS_REG(port)); + + return 0; +}...
Quoted 30 lines
+static int
ma35_pinctrl_probe_dt(struct platform_device *pdev, struct ma35_pinctrl *npctl)drivers/pinctrl/nuvoton/pinctrl-ma35.c new file +28
-0+{ + struct fwnode_handle *child; + u32 idx = 0; + int ret; + + device_for_each_child_node(&pdev->dev, child) { + if (fwnode_property_present(child, "gpio-controller")) + continue; + npctl->nfunctions++; + npctl->ngroups += of_get_child_count(to_of_node(child)); + } + + if (!npctl->nfunctions) + return -EINVAL; + + npctl->functions = devm_kcalloc(&pdev->dev, npctl->nfunctions, + sizeof(*npctl->functions), GFP_KERNEL); + if (!npctl->functions) + return -ENOMEM; + + npctl->groups = devm_kcalloc(&pdev->dev, npctl->ngroups, + sizeof(*npctl->groups), GFP_KERNEL); + if (!npctl->groups) + return -ENOMEM; + + device_for_each_child_node(&pdev->dev, child) { + if (fwnode_property_present(child, "gpio-controller")) + continue;
Quoted 9 lines
Quoted 5 lines
+
+ ret =ma35_pinctrl_parse_functions(to_of_node(child), npctl, idx++);
+ if (ret) {
+dev_err(&pdev->dev, "failed to parse function\n");Missing
fwnode_handle_put(child); ?
(or a scoped version ofdevice_for_each_child_node()if it exists)
Yes, I will add fwnode_handle_put(child) here.
Quoted 9 lines
Quoted 5 lines
+ return ret;
+ }
+ }
+ return 0;
+...
CJ
Best Regards,
Jacky Huang