Add support for cy8c95x0 pinctrl
Subsystems (4)
Patrick Rudolph
maintainercover Add support for cy8c95x0 pinctrl
Patrick Rudolph (2):
dt-binding: Add cypress,cy8c95x0 binding
pinctrl: Add Cypress cy8c95x0 support
.../bindings/pinctrl/cypress,cy8c95x0.yaml | 139 ++ MAINTAINERS | 6 + drivers/pinctrl/Kconfig | 14 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-cy8c95x0.c | 1388 +++++++++++++++++ 5 files changed, 1548 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml create mode 100644 drivers/pinctrl/pinctrl-cy8c95x0.c
Signature · 1 line
2.35.1
Patrick Rudolph
maintainerPATCH 1/2 dt-binding: Add cypress,cy8c95x0 binding
Added device tree binding documentation for
Cypress CY8C95x0 I2C pin-controller.
--- .../bindings/pinctrl/cypress,cy8c95x0.yaml | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml new file +139 -0
@@ -0,0 +1,139 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/cypress,cy8c95x0.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cypress CY8C95X0 I2C GPIO expander + +maintainers: + - Patrick Rudolph <[email protected]> + +description: | + This supports the 20/40/60 pin Cypress CYC95x0 GPIO I2C expanders. + Pin function configuration is performed on a per-pin basis. + +properties: + compatible: + enum: + - cypress,cy8c9520 + - cypress,cy8c9540 + - cypress,cy8c9560 + + reg: + maxItems: 1 + + gpio-controller: true + + '#gpio-cells': + description: + The first cell is the pin number and the second cell is used + to specify optional parameters. + const: 2 + + gpio-reserved-ranges: true + + interrupts: + maxItems: 1 + + interrupt-controller: true + + '#interrupt-cells': + description: + Specifies the pin number and flags, as defined in + include/dt-bindings/interrupt-controller/irq.h + const: 2 + + ngpios: + minimum: 1 + maximum: 60 + + gpio-line-names: + minItems: 1 + maxItems: 60 + + vdd-supply: + description: + Optional power supply. + +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: + oneOf: + - pattern: "^gp([0-7][0-7])$" + minItems: 1 + maxItems: 60 + + function: + enum: [ gpio, pwm ] + + description: + Specify the alternative function to be configured for the specified + pins. + + bias-pull-down: true + + bias-pull-up: true + + bias-disable: true + + output-high: true + + output-low: true + + drive-push-pull: true + + drive-open-drain: true + + drive-open-source: true + + required: + - pins + - function + + additionalProperties: false + +required: + - compatible + - reg + - interrupts + - interrupt-controller + - '#interrupt-cells' + - gpio-controller + - '#gpio-cells' + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + pinctrl@20 { + compatible = "cypress,cy8c9520"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + #interrupt-cells = <2>; + interrupts = <GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH>; + interrupt-controller; + vdd-supply = <&p3v3>; + ngpios = <16>; + gpio-reserved-ranges = <5 1>; + }; + };
Signature · 1 line
2.35.1
Patrick Rudolph
maintainerPATCH 2/2 pinctrl: Add Cypress cy8c95x0 support
In reply to Patrick RudolphAdd support for cypress I2C GPIO expanders cy8c9520, cy8c9540 and cy8c9560. The GPIO expanders feature a PWM mode, thus add it as pinctrl driver.
The chip features multiple drive modes for each pin when configured as output and multiple bias settings when configured as input.
Tested all three components and verified that all functionality is fully working.
Datasheet: https://www.cypress.com/file/37971/download
--- MAINTAINERS | 6 + drivers/pinctrl/Kconfig | 14 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-cy8c95x0.c | 1388 ++++++++++++++++++++++++++++ 4 files changed, 1409 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-cy8c95x0.c
MAINTAINERS +6 -0
@@ -5389,6 +5389,12 @@ Q: http://patchwork.linuxtv.org/project/linux-media/list/ T: git git://linuxtv.org/anttip/media_tree.git F: drivers/media/common/cypress_firmware* +CYPRESS CY8C95X0 PINCTRL DRIVER +M: Patrick Rudolph <[email protected]> +L: [email protected] +S: Maintained +F: drivers/pinctrl/pinctrl-cy8c95x0.c + CYPRESS CY8CTMA140 TOUCHSCREEN DRIVER M: Linus Walleij <[email protected]> L: [email protected]
drivers/pinctrl/Kconfig +14 -0
@@ -135,6 +135,20 @@ config PINCTRL_BM1880 help Pinctrl driver for Bitmain BM1880 SoC. +config PINCTRL_CY8C95X0 + tristate "Cypress CY8C95X0 I2C pinctrl and GPIO driver" + depends on I2C && OF + select GPIOLIB + select GPIOLIB_IRQCHIP + select PINMUX + select PINCONF + select GENERIC_PINCONF + select REGMAP_I2C + help + Support for 20/40/60 pin Cypress Cy8C95x0 pinctrl/gpio I2C expander. + This driver can also be built as a module. If so, the module will be + called pinctrl-cy8c95x0. + config PINCTRL_DA850_PUPD tristate "TI DA850/OMAP-L138/AM18XX pull-up and pull-down groups" depends on OF && (ARCH_DAVINCI_DA850 || COMPILE_TEST)
drivers/pinctrl/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o obj-$(CONFIG_PINCTRL_AT91PIO4) += pinctrl-at91-pio4.o obj-$(CONFIG_PINCTRL_AXP209) += pinctrl-axp209.o obj-$(CONFIG_PINCTRL_BM1880) += pinctrl-bm1880.o +obj-$(CONFIG_PINCTRL_CY8C95X0) += pinctrl-cy8c95x0.o obj-$(CONFIG_PINCTRL_DA850_PUPD) += pinctrl-da850-pupd.o obj-$(CONFIG_PINCTRL_DA9062) += pinctrl-da9062.o obj-$(CONFIG_PINCTRL_DIGICOLOR) += pinctrl-digicolor.o
drivers/pinctrl/pinctrl-cy8c95x0.c new file +1388 -0
1,388 lines not on this page · raw message
Signature · 1 line
2.35.1
Re: [PATCH 1/2] dt-binding: Add cypress,cy8c95x0 binding
In reply to Patrick RudolphQuoted 3 lines · Patrick Rudolph
Added device tree binding documentation for
Cypress CY8C95x0 I2C pin-controller.
Thank you for your patch. There is something to discuss/improve.
(...)
Quoted 12 lines
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml new file +12
-0+ reg: + maxItems: 1 + + gpio-controller: true + + '#gpio-cells': + description: + The first cell is the pin number and the second cell is used + to specify optional parameters. + const: 2 + + gpio-reserved-ranges: true
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml line 44
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml new file +10
-0+ + interrupts: + maxItems: 1 + + interrupt-controller: true + + '#interrupt-cells': + description: + Specifies the pin number and flags, as defined in + include/dt-bindings/interrupt-controller/irq.h
Skip description, it's obvious.
Quoted 19 lines
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml new file +19
-0+ const: 2 + + ngpios: + minimum: 1 + maximum: 60 + + gpio-line-names: + minItems: 1 + maxItems: 60 + + vdd-supply: + description: + Optional power supply. + +patternProperties: + '-pins$': + type: object + description: + Pinctrl node's client devices use subnodes for desired pin configuration.
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml line 73
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml new file +10
-0+ 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: + oneOf:
Why do you need oneOf here?
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml line 80
Quoted 7 lines
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml new file +7
-0+ - pattern: "^gp([0-7][0-7])$" + minItems: 1 + maxItems: 60 + + function: + enum: [ gpio, pwm ] +
No need for blank line. In other cases you put description before the property constraints, so do it consistently here as well.
Quoted 24 lines
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml new file +24
-0+ description: + Specify the alternative function to be configured for the specified + pins. + + bias-pull-down: true + + bias-pull-up: true + + bias-disable: true + + output-high: true + + output-low: true + + drive-push-pull: true + + drive-open-drain: true + + drive-open-source: true + + required: + - pins + - function +
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml line 114
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml new file +10
-0+ additionalProperties: false + +required: + - compatible + - reg + - interrupts + - interrupt-controller + - '#interrupt-cells' + - gpio-controller + - '#gpio-cells'
no allOf referencing pinctrl.yaml? Include it unless there is some reason not to.
Best regards,
Krzysztof
Re: [PATCH 1/2] dt-binding: Add cypress,cy8c95x0 binding
In reply to Patrick RudolphHi Patrick,
thanks for your patch!
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml line 32
Quoted 10 lines · Patrick Rudolph
Added device tree binding documentation for
Cypress CY8C95x0 I2C pin-controller.Signed-off-by Patrick Rudolph <[email protected]>Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml new file +5
-0+ '#gpio-cells': + description: + The first cell is the pin number and the second cell is used + to specify optional parameters. + const: 2
Maybe specify that the second cell uses the standard GPIO parameters in <dt-bindings/gpio/gpio.h>?
The driver is quite elaborate, you can probably list which parameters you support on this hardware even if the driver don't even implement them yet: it's just a binding after all.
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml line 49
Quoted 3 lines
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml new file +3
-0+ ngpios: + minimum: 1 + maximum: 60
Why? Isn't it obvious from the compatible how many pins the GPIO chip has? Then use that instead.
Write under the compatible as description: for each chip how many gpios it has.
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml line 65
Quoted 7 lines
Documentation/devicetree/bindings/pinctrl/cypress,cy8c95x0.yaml new file +7
-0+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"
This is impressive. It's quite advanced to use the pin config props for elaborate pin config control.
Yours,
LInus Walleij
Re: [PATCH 2/2] pinctrl: Add Cypress cy8c95x0 support
In reply to Patrick RudolphHi Patrick, Naresh,
thanks for your patch! This is a VERY good looking driver so I don't think we will need a lot of iterations before it is finished. (Famous last words, but it looks very good.)
drivers/pinctrl/pinctrl-cy8c95x0.c line 60
Quoted 5 lines · Patrick Rudolph
drivers/pinctrl/pinctrl-cy8c95x0.c new file +5
-0+static const struct i2c_device_id cy8c95x0_id[] = { + {"cy8c9520" ,20 , }, + {"cy8c9540" ,40 , }, + {"cy8c9560" ,60 , }, + { }
So here is the ngpios for each expander.
drivers/pinctrl/pinctrl-cy8c95x0.c line 1296
Quoted 7 lines
drivers/pinctrl/pinctrl-cy8c95x0.c new file +7
-0+ chip->tpin = chip->driver_data &CY8C95X0_GPIO_MASK ; + ngpios =-1 ; +if (client->dev.of_node) +of_property_read_u32 (client->dev.of_node,"ngpios" , &ngpios); + +if (ngpios <0 || ngpios > (chip->driver_data &CY8C95X0_GPIO_MASK )) + ngpios = chip->driver_data &CY8C95X0_GPIO_MASK ;
So why should this be configurable from the device tree at all?
I understand if not all gpios are used, but we usually just expose all GPIOs on an expander.
Yours,
Linus Walleij