Skip to contentSkip to conversation

dt-bindings: pinctrl: Add bindings for Awinic AW9523/AW9523B

PATCH In review David Bauer 4 participants 8 messages Jun 24, 2021 – Mar 6, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v6 1/2 dt-bindings: pinctrl: Add bindings for Awinic AW9523/AW9523B

From: AngeloGioacchino Del Regno <[email protected]>

Add bindings for the Awinic AW9523/AW9523B I2C GPIO Expander driver.

---
 .../pinctrl/awinic,aw9523-pinctrl.yaml        | 139 ++++++++++++++++++
 1 file changed, 139 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/awinic,aw9523-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/awinic,aw9523-pinctrl.yaml new file +139 -0
new file mode 100644
index 000000000000..640d4d7e4cab
@@ -0,0 +1,139 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/awinic,aw9523-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Awinic AW9523/AW9523B I2C GPIO Expander
+
+maintainers:
+  - AngeloGioacchino Del Regno <[email protected]>
+
+description: |
+  The Awinic AW9523/AW9523B I2C GPIO Expander featuring 16 multi-function
+  I/O, 256 steps PWM mode and interrupt support.
+
+properties:
+  compatible:
+    const: awinic,aw9523-pinctrl
+
+  reg:
+    maxItems: 1
+
+  '#gpio-cells':
+    description: |
+      Specifying the pin number and flags, as defined in
+      include/dt-bindings/gpio/gpio.h
+    const: 2
+
+  gpio-controller: true
+
+  gpio-ranges:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  interrupts:
+    maxItems: 1
+    description: Specifies the INTN pin IRQ.
+
+  '#interrupt-cells':
+    description:
+      Specifies the PIN numbers and Flags, as defined in defined in
+      include/dt-bindings/interrupt-controller/irq.h
+    const: 2
+
+  reset-gpios:
+    maxItems: 1
+
+#PIN CONFIGURATION NODES
+patternProperties:
+  '-pins$':
+    type: object
+    description:
+      Pinctrl node's client devices use subnodes for desired pin configuration.
+      Client device subnodes use below standard properties.
+    $ref: "/schemas/pinctrl/pincfg-node.yaml"
+
+    properties:
+      pins:
+        description:
+          List of gpio pins affected by the properties specified in
+          this subnode.
+        items:
+          pattern: "^gpio([0-9]|1[0-5])$"
+        minItems: 1
+        maxItems: 16
+
+      function:
+        description:
+          Specify the alternative function to be configured for the
+          specified pins.
+
+        enum: [ gpio, pwm ]
+
+      bias-disable: true
+      bias-pull-down: true
+      bias-pull-up: true
+      drive-open-drain: true
+      drive-push-pull: true
+      input-enable: true
+      input-disable: true
+      output-high: true
+      output-low: true
+
+    required:
+      - pins
+      - function
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - gpio-controller
+  - '#gpio-cells'
+  - gpio-ranges
+
+additionalProperties: false
+
+examples:
+  # Example configuration to drive pins for a keyboard matrix
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        aw9523: gpio-expander@58 {
+                compatible = "awinic,aw9523-pinctrl";
+                reg = <0x58>;
+                interrupt-parent = <&tlmm>;
+                interrupts = <50 IRQ_TYPE_EDGE_FALLING>;
+                gpio-controller;
+                #gpio-cells = <2>;
+                gpio-ranges = <&tlmm 0 0 16>;
+                interrupt-controller;
+                #interrupt-cells = <2>;
+                reset-gpios = <&tlmm 51 GPIO_ACTIVE_HIGH>;
+
+                keyboard-matrix-col-pins {
+                        pins = "gpio8", "gpio9", "gpio10", "gpio11",
+                               "gpio12", "gpio13", "gpio14", "gpio15";
+                        function = "gpio";
+                        input-disable;
+                        output-low;
+                };
+
+                keyboard-matrix-row-pins {
+                        pins = "gpio0", "gpio1", "gpio2", "gpio3",
+                               "gpio4", "gpio5", "gpio6", "gpio7";
+                        function = "gpio";
+                        bias-pull-up;
+                        drive-open-drain;
+                        input-enable;
+                };
+        };
+    };
Signature · 1 line
2.32.0
#1 lore raw

PATCH v6 2/2 pinctrl: Add driver for Awinic AW9523/B I2C GPIO Expander

From: AngeloGioacchino Del Regno <[email protected]>

The Awinic AW9523(B) is a multi-function I2C gpio expander in a TQFN-24L package, featuring PWM (max 37mA per pin, or total max power 3.2Watts) for LED driving capability.

It has two ports with 8 pins per port (for a total of 16 pins), configurable as either PWM with 1/256 stepping or GPIO input/output, 1.8V logic input; each GPIO can be configured as input or output independently from each other.

This IC also has an internal interrupt controller, which is capable of generating an interrupt for each GPIO, depending on the configuration, and will raise an interrupt on the INTN pin to advertise this to an external interrupt controller.

---
Changes since v5:
- Select REGMAP_I2C for Kconfig
- Add missing imports
- Fix GPIO IRQ default type
- Replace -ENOTSUPP with -EOPNOTSUPP.

 drivers/pinctrl/Kconfig          |   18 +
 drivers/pinctrl/Makefile         |    1 +
 drivers/pinctrl/pinctrl-aw9523.c | 1124 ++++++++++++++++++++++++++++++
 3 files changed, 1143 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-aw9523.c
drivers/pinctrl/Kconfig +18 -0
index c2c7e7963ed0..29c9b6f28332 100644
@@ -111,6 +111,24 @@ config PINCTRL_AMD
 	  Requires ACPI/FDT device enumeration code to set up a platform
 	  device.
 
+config PINCTRL_AW9523
+	bool "Awinic AW9523/AW9523B I2C GPIO expander pinctrl driver"
+	depends on OF && I2C
+	select PINMUX
+	select PINCONF
+	select GENERIC_PINCONF
+	select GPIOLIB
+	select GPIOLIB_IRQCHIP
+	select REGMAP
+	select REGMAP_I2C
+	help
+	  The Awinic AW9523/AW9523B is a multi-function I2C GPIO
+	  expander with PWM functionality. This driver bundles a
+	  pinctrl driver to select the function muxing and a GPIO
+	  driver to handle GPIO, when the GPIO function is selected.
+
+	  Say yes to enable pinctrl and GPIO support for the AW9523(B).
+
 config PINCTRL_BM1880
 	bool "Bitmain BM1880 Pinctrl driver"
 	depends on OF && (ARCH_BITMAIN || COMPILE_TEST)
drivers/pinctrl/Makefile +1 -0
index 5ef5334a797f..5e27d6cef1b8 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_PINCTRL_AXP209)	+= pinctrl-axp209.o
 obj-$(CONFIG_PINCTRL_AT91)	+= pinctrl-at91.o
 obj-$(CONFIG_PINCTRL_AT91PIO4)	+= pinctrl-at91-pio4.o
 obj-$(CONFIG_PINCTRL_AMD)	+= pinctrl-amd.o
+obj-$(CONFIG_PINCTRL_AW9523)	+= pinctrl-aw9523.o
 obj-$(CONFIG_PINCTRL_BM1880)	+= pinctrl-bm1880.o
 obj-$(CONFIG_PINCTRL_DA850_PUPD) += pinctrl-da850-pupd.o
 obj-$(CONFIG_PINCTRL_DA9062)	+= pinctrl-da9062.o
drivers/pinctrl/pinctrl-aw9523.c new file +1124 -0

1,124 lines not on this page · raw message

Signature · 1 line
2.32.0
#2 lore raw

Re: [PATCH v6 2/2] pinctrl: Add driver for Awinic AW9523/B I2C GPIO Expander

Thank you for the patch! Yet something to improve:

Hi David,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on pinctrl/devel]
[also build test ERROR on robh/for-next v5.13-rc7 next-20210624] [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]

url:    https://github.com/0day-ci/linux/commits/David-Bauer/dt-bindings-pinctrl-Add-bindings-for-Awinic-AW9523-AW9523B/20210625-055313
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: s390-allmodconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/dd31385136eaa3a3feb0934f1e4ae4846a308c0c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review David-Bauer/dt-bindings-pinctrl-Add-bindings-for-Awinic-AW9523-AW9523B/20210625-055313 git checkout dd31385136eaa3a3feb0934f1e4ae4846a308c0c
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=s390

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

drivers/pinctrl/pinctrl-aw9523.c: In function 'aw9523_init_gpiochip':

>> drivers/pinctrl/pinctrl-aw9523.c:812:10: error: 'struct gpio_chip' has no member named 'of_node'
     812 |  gpiochip->of_node = dev->of_node;
         |          ^~

vim +812 drivers/pinctrl/pinctrl-aw9523.c

791
792 static int aw9523_init_gpiochip(struct aw9523 *awi, unsigned int npins)
793 {
794 struct device *dev = awi->dev;
795 struct gpio_chip *gpiochip = &awi->gpio;
796
797 gpiochip->label = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL);
798 if (!gpiochip->label)
799 return -ENOMEM;
800
801 gpiochip->base = -1;
802 gpiochip->ngpio = npins;
803 gpiochip->get_direction = aw9523_gpio_get_direction;
804 gpiochip->direction_input = aw9523_direction_input;
805 gpiochip->direction_output = aw9523_direction_output;
806 gpiochip->get = aw9523_gpio_get;
807 gpiochip->get_multiple = aw9523_gpio_get_multiple;
808 gpiochip->set = aw9523_gpio_set;
809 gpiochip->set_multiple = aw9523_gpio_set_multiple;
810 gpiochip->set_config = gpiochip_generic_config;
811 gpiochip->parent = dev;

 > 812		gpiochip->of_node = dev->of_node;

813 gpiochip->owner = THIS_MODULE;
814 gpiochip->can_sleep = false;
815
816 return 0;
817 }
818

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#3 lore raw

Re: [PATCH v6 2/2] pinctrl: Add driver for Awinic AW9523/B I2C GPIO Expander

Quoted 7 lines · kernel test robot
   drivers/pinctrl/pinctrl-aw9523.c: In function 'aw9523_init_gpiochip':
Quoted 1 line
Quoted 1 line

drivers/pinctrl/pinctrl-aw9523.c:812:10: error: 'struct gpio_chip' has no member named 'of_node'

     812 |  gpiochip->of_node = dev->of_node;
         |          ^~

vim +812 drivers/pinctrl/pinctrl-aw9523.c

I haven't even seen the patch adding this driver, is the problem on my side?

Yours,
Linus Walleij

#4 lore raw

Re: [PATCH v6 2/2] pinctrl: Add driver for Awinic AW9523/B I2C GPIO Expander

In reply to David Bauer
Thank you for the patch! Yet something to improve:

Hi David,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on pinctrl/devel]
[also build test ERROR on robh/for-next v5.13-rc7 next-20210624] [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]

url:    https://github.com/0day-ci/linux/commits/David-Bauer/dt-bindings-pinctrl-Add-bindings-for-Awinic-AW9523-AW9523B/20210625-055313
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/dd31385136eaa3a3feb0934f1e4ae4846a308c0c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review David-Bauer/dt-bindings-pinctrl-Add-bindings-for-Awinic-AW9523-AW9523B/20210625-055313 git checkout dd31385136eaa3a3feb0934f1e4ae4846a308c0c
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sh

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

sh4-linux-ld: drivers/pinctrl/pinctrl-aw9523.o: in function `aw9523_probe':

>> pinctrl-aw9523.c:(.text+0x1288): undefined reference to `__devm_regmap_init_i2c'
>> sh4-linux-ld: pinctrl-aw9523.c:(.text+0x12b0): undefined reference to `i2c_adapter_depth'
   sh4-linux-ld: drivers/pinctrl/pinctrl-aw9523.o: in function `aw9523_driver_init':
>> pinctrl-aw9523.c:(.init.text+0x28): undefined reference to `i2c_register_driver'
   sh4-linux-ld: drivers/pinctrl/pinctrl-aw9523.o: in function `aw9523_driver_exit':
>> pinctrl-aw9523.c:(.exit.text+0x18): undefined reference to `i2c_del_driver'

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for SND_ATMEL_SOC_PDC
Depends on SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC && HAS_DMA Selected by
- SND_ATMEL_SOC_SSC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC
- SND_ATMEL_SOC_SSC_PDC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC && ATMEL_SSC

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#5 lore raw
In reply to David Bauer
Quoted 11 lines · David Bauer

From: AngeloGioacchino Del Regno <[email protected]>

Add bindings for the Awinic AW9523/AW9523B I2C GPIO Expander driver.

---
 .../pinctrl/awinic,aw9523-pinctrl.yaml        | 139 ++++++++++++++++++
 1 file changed, 139 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/awinic,aw9523-pinctrl.yaml

Linus, did you just apply this 3 year old bit-rotted patch? Linux-next now warns:

./Documentation/devicetree/bindings/pinctrl/awinic,aw9523-pinctrl.yaml:49:2:
[error] missing starting space in comment (comments) ./Documentation/devicetree/bindings/pinctrl/awinic,aw9523-pinctrl.yaml:56:11:
[error] string value is redundantly quoted with any quotes (quoted-strings)

Also, David's S-o-b is missing if you picked up this one.

Rob

#6 lore raw
Quoted 2 lines · Rob Herring

Linus, did you just apply this 3 year old bit-rotted patch? Linux-next now warns:

Not "just", I did run checks on it first i.e.:

$ make DT_SCHEMA_FILES=Documentation/devicetree/bindings/pinctrl/awinic,aw9523-pinctrl.yaml
dt_binding_check
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/dtc/dtc.o
  HOSTCC  scripts/dtc/flattree.o
  HOSTCC  scripts/dtc/fstree.o
  HOSTCC  scripts/dtc/data.o
  HOSTCC  scripts/dtc/livetree.o
  HOSTCC  scripts/dtc/treesource.o
  HOSTCC  scripts/dtc/srcpos.o
  HOSTCC  scripts/dtc/checks.o
  HOSTCC  scripts/dtc/util.o
  LEX     scripts/dtc/dtc-lexer.lex.c
  YACC    scripts/dtc/dtc-parser.tab.[ch]
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  HOSTCC  scripts/dtc/dtc-parser.tab.o
  HOSTLD  scripts/dtc/dtc
  LINT    Documentation/devicetree/bindings
usage: yamllint [-h] [-] [-c CONFIG_FILE | -d CONFIG_DATA] [-f
{parsable,standard,colored,github,auto}] [-s] [--no-warnings] [-v]
[FILE_OR_DIR ...]
yamllint: error: one of the arguments FILE_OR_DIR - is required
  CHKDT   Documentation/devicetree/bindings/processed-schema.json
  SCHEMA  Documentation/devicetree/bindings/processed-schema.json

So that's at least something but apparently not enough, hm the yamllint moaning should be a hint should it not... it's on v6.8-rc1.

Quoted 5 lines

./Documentation/devicetree/bindings/pinctrl/awinic,aw9523-pinctrl.yaml:49:2:
[error] missing starting space in comment (comments) ./Documentation/devicetree/bindings/pinctrl/awinic,aw9523-pinctrl.yaml:56:11:
[error] string value is redundantly quoted with any quotes (quoted-strings)

They were so simple that I just fixed them up in-tree.

Quoted 1 line

Also, David's S-o-b is missing if you picked up this one.

I mailed David about it.

Yours,
Linus Walleij

#7 lore raw
Quoted 7 lines · Linus Walleij
Quoted 2 lines · Rob Herring

Linus, did you just apply this 3 year old bit-rotted patch? Linux-next now warns:

Not "just", I did run checks on it first i.e.:

Sorry, I meant "just now".

Quoted 25 lines
$ make DT_SCHEMA_FILES=Documentation/devicetree/bindings/pinctrl/awinic,aw9523-pinctrl.yaml
dt_binding_check
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/dtc/dtc.o
  HOSTCC  scripts/dtc/flattree.o
  HOSTCC  scripts/dtc/fstree.o
  HOSTCC  scripts/dtc/data.o
  HOSTCC  scripts/dtc/livetree.o
  HOSTCC  scripts/dtc/treesource.o
  HOSTCC  scripts/dtc/srcpos.o
  HOSTCC  scripts/dtc/checks.o
  HOSTCC  scripts/dtc/util.o
  LEX     scripts/dtc/dtc-lexer.lex.c
  YACC    scripts/dtc/dtc-parser.tab.[ch]
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  HOSTCC  scripts/dtc/dtc-parser.tab.o
  HOSTLD  scripts/dtc/dtc
  LINT    Documentation/devicetree/bindings
usage: yamllint [-h] [-] [-c CONFIG_FILE | -d CONFIG_DATA] [-f
{parsable,standard,colored,github,auto}] [-s] [--no-warnings] [-v]
[FILE_OR_DIR ...]
yamllint: error: one of the arguments FILE_OR_DIR - is required
  CHKDT   Documentation/devicetree/bindings/processed-schema.json
  SCHEMA  Documentation/devicetree/bindings/processed-schema.json
Quoted 2 lines

So that's at least something but apparently not enough, hm the yamllint moaning should be a hint should it not... it's on v6.8-rc1.

That's fixed in later RCs.

BTW, you can do just "DT_SCHEMA_FILES=awinic,aw9523-pinctrl" or even "DT_SCHEMA_FILES=pinctrl" to test all pinctrl. It's just a substring match. (It was just the full path that broke.)

Rob