* [PATCH v2 0/4] gpio: siul2-s32g2: add initial GPIO driver
@ 2024-09-13 8:29 Andrei Stefanescu
2024-09-13 8:29 ` [PATCH v2 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() Andrei Stefanescu
` (3 more replies)
0 siblings, 4 replies; 18+ messages in thread
From: Andrei Stefanescu @ 2024-09-13 8:29 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Chester Lin, Matthias Brugger,
Greg Kroah-Hartman, Rafael J. Wysocki
Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
NXP S32 Linux Team, Andrei Stefanescu
This patch series adds support for basic GPIO
operations(set, get, direction_output/input, set_config).
There are two SIUL2 hardware modules: SIUL2_0 and SIUL2_1.
However, this driver exports both as a single GPIO driver.
This is because the interrupt registers are located only
in SIUL2_1, even for GPIOs that are part of SIUL2_0.
There are two gaps in the GPIO ranges:
- 102-111(inclusive) are invalid
- 123-143(inclusive) are invalid
These will be excluded via the `gpio-reserved-ranges`
property.
Writing and reading GPIO values is done via the PGPDO/PGPDI
registers(Parallel GPIO Pad Data Output/Input) which are
16 bit registers, each bit corresponding to a GPIO.
Note that the PGPDO order is similar to a big-endian grouping
of two registers:
PGPDO1, PGPDO0, PGPDO3, PGPDO2, PGPDO5, PGPDO4, gap, PGPDO6.
I have other patches for this driver:
- interrupt support
- power management callbacks
which I plan to upstream after this series gets merged
in order to simplify the review process.
v2 -> v1
dt-bindings:
- changed filename to match compatible
- fixed commit messages
- removed dt-bindings unnecessary properties descriptions
- added minItems for the interrupts property
driver:
- added depends on ARCH_S32 || COMPILE_TEST to Kconfig
- added select REGMAP_MMIO to Kconfig
- remove unnecessary include
- add of_node_put after `siul2_get_gpio_pinspec`
- removed inline from function definitions
- removed match data and moved the previous platdata
definition to the top of the file to be visible
- replace bitmap_set/clear with __clear_bit/set_bit
and devm_bitmap_zalloc with devm_kzalloc
- switched to gpiochip_generic_request/free/config
- fixed dev_err format for size_t reported by
kernel test robot
- add platform_get_and_ioremap_resource_byname wrapper
Andrei Stefanescu (4):
drivers: provide devm_platform_get_and_ioremap_resource_byname()
dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs
gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support
MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver
.../bindings/gpio/nxp,s32g2-siul2-gpio.yaml | 106 ++++
MAINTAINERS | 2 +
drivers/base/platform.c | 28 +
drivers/gpio/Kconfig | 10 +
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-siul2-s32g2.c | 581 ++++++++++++++++++
include/linux/platform_device.h | 13 +
7 files changed, 741 insertions(+)
create mode 100644 Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml
create mode 100644 drivers/gpio/gpio-siul2-s32g2.c
--
2.45.2
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH v2 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() 2024-09-13 8:29 [PATCH v2 0/4] gpio: siul2-s32g2: add initial GPIO driver Andrei Stefanescu @ 2024-09-13 8:29 ` Andrei Stefanescu 2024-09-18 7:52 ` Matthias Brugger 2024-09-13 8:29 ` [PATCH v2 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs Andrei Stefanescu ` (2 subsequent siblings) 3 siblings, 1 reply; 18+ messages in thread From: Andrei Stefanescu @ 2024-09-13 8:29 UTC (permalink / raw) To: Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chester Lin, Matthias Brugger, Greg Kroah-Hartman, Rafael J. Wysocki Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel, NXP S32 Linux Team, Andrei Stefanescu, Krzysztof Kozlowski Similar to commit 890cc39a879906b63912482dfc41944579df2dc6 ("drivers: provide devm_platform_get_and_ioremap_resource()") add a wrapper for "platform_get_resource_byname" and "devm_ioremap_resource". This new wrapper also returns the resource, if any, via a pointer. Suggested-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> --- drivers/base/platform.c | 28 ++++++++++++++++++++++++++++ include/linux/platform_device.h | 13 +++++++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 4c3ee6521ba5..ab48c02fcb2c 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -108,6 +108,34 @@ devm_platform_get_and_ioremap_resource(struct platform_device *pdev, } EXPORT_SYMBOL_GPL(devm_platform_get_and_ioremap_resource); +/** + * devm_platform_get_and_ioremap_resource_byname - call devm_ioremap_resource() + * for a platform device and get + * a resource by its name instead + * of the index + * + * @pdev: platform device to use both for memory resource lookup as well as + * resource management + * @name: resource name + * @res: optional output parameter to store a pointer to the obtained resource. + * + * Return: a pointer to the remapped memory or an ERR_PTR() encoded error code + * on failure. + */ +void __iomem * +devm_platform_get_and_ioremap_resource_byname(struct platform_device *pdev, + const char *name, + struct resource **res) +{ + struct resource *r; + + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); + if (res) + *res = r; + return devm_ioremap_resource(&pdev->dev, r); +} +EXPORT_SYMBOL_GPL(devm_platform_get_and_ioremap_resource_byname); + /** * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform * device diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index d422db6eec63..ab7f33f3c426 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -68,6 +68,12 @@ platform_find_device_by_driver(struct device *start, extern void __iomem * devm_platform_get_and_ioremap_resource(struct platform_device *pdev, unsigned int index, struct resource **res); + +extern void __iomem * +devm_platform_get_and_ioremap_resource_byname(struct platform_device *pdev, + const char *name, + struct resource **res); + extern void __iomem * devm_platform_ioremap_resource(struct platform_device *pdev, unsigned int index); @@ -83,6 +89,13 @@ devm_platform_get_and_ioremap_resource(struct platform_device *pdev, return ERR_PTR(-EINVAL); } +static inline void __iomem * +devm_platform_get_and_ioremap_resource_byname(struct platform_device *pdev, + const char *name, + struct resource **res) +{ + return ERR_PTR(-EINVAL); +} static inline void __iomem * devm_platform_ioremap_resource(struct platform_device *pdev, -- 2.45.2 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() 2024-09-13 8:29 ` [PATCH v2 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() Andrei Stefanescu @ 2024-09-18 7:52 ` Matthias Brugger 0 siblings, 0 replies; 18+ messages in thread From: Matthias Brugger @ 2024-09-18 7:52 UTC (permalink / raw) To: Andrei Stefanescu, Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chester Lin, Greg Kroah-Hartman, Rafael J. Wysocki Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel, NXP S32 Linux Team, Krzysztof Kozlowski On 13/09/2024 10:29, Andrei Stefanescu wrote: > Similar to commit 890cc39a879906b63912482dfc41944579df2dc6 > ("drivers: provide devm_platform_get_and_ioremap_resource()") > add a wrapper for "platform_get_resource_byname" and > "devm_ioremap_resource". This new wrapper also returns the resource, if > any, via a pointer. > > Suggested-by: Krzysztof Kozlowski <krzk@kernel.org> > Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> > --- > drivers/base/platform.c | 28 ++++++++++++++++++++++++++++ > include/linux/platform_device.h | 13 +++++++++++++ > 2 files changed, 41 insertions(+) > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > index 4c3ee6521ba5..ab48c02fcb2c 100644 > --- a/drivers/base/platform.c > +++ b/drivers/base/platform.c > @@ -108,6 +108,34 @@ devm_platform_get_and_ioremap_resource(struct platform_device *pdev, > } > EXPORT_SYMBOL_GPL(devm_platform_get_and_ioremap_resource); > > +/** > + * devm_platform_get_and_ioremap_resource_byname - call devm_ioremap_resource() > + * for a platform device and get > + * a resource by its name instead > + * of the index I think we don't need to describe what the function does not do. With that: Reviewed-by: Matthias Brugger <mbrugger@suse.com> > + * > + * @pdev: platform device to use both for memory resource lookup as well as > + * resource management > + * @name: resource name > + * @res: optional output parameter to store a pointer to the obtained resource. > + * > + * Return: a pointer to the remapped memory or an ERR_PTR() encoded error code > + * on failure. > + */ > +void __iomem * > +devm_platform_get_and_ioremap_resource_byname(struct platform_device *pdev, > + const char *name, > + struct resource **res) > +{ > + struct resource *r; > + > + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); > + if (res) > + *res = r; > + return devm_ioremap_resource(&pdev->dev, r); > +} > +EXPORT_SYMBOL_GPL(devm_platform_get_and_ioremap_resource_byname); > + > /** > * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform > * device > diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h > index d422db6eec63..ab7f33f3c426 100644 > --- a/include/linux/platform_device.h > +++ b/include/linux/platform_device.h > @@ -68,6 +68,12 @@ platform_find_device_by_driver(struct device *start, > extern void __iomem * > devm_platform_get_and_ioremap_resource(struct platform_device *pdev, > unsigned int index, struct resource **res); > + > +extern void __iomem * > +devm_platform_get_and_ioremap_resource_byname(struct platform_device *pdev, > + const char *name, > + struct resource **res); > + > extern void __iomem * > devm_platform_ioremap_resource(struct platform_device *pdev, > unsigned int index); > @@ -83,6 +89,13 @@ devm_platform_get_and_ioremap_resource(struct platform_device *pdev, > return ERR_PTR(-EINVAL); > } > > +static inline void __iomem * > +devm_platform_get_and_ioremap_resource_byname(struct platform_device *pdev, > + const char *name, > + struct resource **res) > +{ > + return ERR_PTR(-EINVAL); > +} > > static inline void __iomem * > devm_platform_ioremap_resource(struct platform_device *pdev, ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs 2024-09-13 8:29 [PATCH v2 0/4] gpio: siul2-s32g2: add initial GPIO driver Andrei Stefanescu 2024-09-13 8:29 ` [PATCH v2 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() Andrei Stefanescu @ 2024-09-13 8:29 ` Andrei Stefanescu 2024-09-13 9:35 ` Rob Herring (Arm) 2024-09-13 14:13 ` Rob Herring 2024-09-13 8:29 ` [PATCH v2 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support Andrei Stefanescu 2024-09-13 8:29 ` [PATCH v2 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver Andrei Stefanescu 3 siblings, 2 replies; 18+ messages in thread From: Andrei Stefanescu @ 2024-09-13 8:29 UTC (permalink / raw) To: Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chester Lin, Matthias Brugger, Greg Kroah-Hartman, Rafael J. Wysocki Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel, NXP S32 Linux Team, Andrei Stefanescu Add support for the GPIO driver of the NXP S32G2/S32G3 SoCs. Signed-off-by: Phu Luu An <phu.luuan@nxp.com> Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com> Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> --- .../bindings/gpio/nxp,s32g2-siul2-gpio.yaml | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml diff --git a/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml b/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml new file mode 100644 index 000000000000..8be8eb3a971d --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml @@ -0,0 +1,106 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause +# Copyright 2024 NXP +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/nxp,gpio-siul2-s32g2.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP S32G2 SIUL2 GPIO controller + +maintainers: + - Ghennadi Procopciuc <Ghennadi.Procopciuc@nxp.com> + - Larisa Grigore <larisa.grigore@nxp.com> + - Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> + +description: + Support for the SIUL2 GPIOs found on the S32G2 and S32G3 + chips. It includes an IRQ controller for all pins which have + an EIRQ associated. + +properties: + compatible: + items: + - const: nxp,s32g2-siul2-gpio + + reg: + items: + - description: PGPDO (output value) registers for SIUL2_0 + - description: PGPDO (output value) registers for SIUL2_1 + - description: PGPDI (input value) registers for SIUL2_0 + - description: PGPDI (input value) registers for SIUL2_1 + - description: EIRQ (interrupt) configuration registers from SIUL2_1 + - description: EIRQ IMCR registers for interrupt muxing between pads + + reg-names: + items: + - const: opads0 + - const: opads1 + - const: ipads0 + - const: ipads1 + - const: eirqs + - const: eirq-imcrs + + gpio-controller: true + + '#gpio-cells': + const: 2 + + interrupts: + maxItems: 1 + + interrupt-controller: true + + "#interrupt-cells": + const: 2 + + gpio-ranges: + minItems: 2 + + gpio-reserved-ranges: + minItems: 2 + +patternProperties: + "-hog(-[0-9]+)?$": + required: + - gpio-hog + +required: + - compatible + - reg + - reg-names + - gpio-controller + - "#gpio-cells" + - gpio-ranges + - gpio-reserved-ranges + - interrupts + - interrupt-controller + - "#interrupt-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + + gpio: siul2-gpio@4009d700 { + compatible = "nxp,s32g2-siul2-gpio"; + reg = <0x4009d700 0x10>, + <0x44011700 0x18>, + <0x4009d740 0x10>, + <0x44011740 0x18>, + <0x44010010 0xb4>, + <0x44011078 0x80>; + reg-names = "opads0", "opads1", "ipads0", + "ipads1", "eirqs", "eirq-imcrs"; + gpio-controller; + #gpio-cells = <2>; + /* GPIO 0-101 */ + gpio-ranges = <&pinctrl 0 0 102>, + /* GPIO 112-190 */ + <&pinctrl 112 112 79>; + gpio-reserved-ranges = <102 10>, <123 21>; + interrupts = <GIC_SPI 210 IRQ_TYPE_LEVEL_HIGH>; + interrupt-controller; + #interrupt-cells = <2>; + }; -- 2.45.2 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs 2024-09-13 8:29 ` [PATCH v2 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs Andrei Stefanescu @ 2024-09-13 9:35 ` Rob Herring (Arm) 2024-09-13 9:55 ` Andrei Stefanescu 2024-09-13 14:13 ` Rob Herring 1 sibling, 1 reply; 18+ messages in thread From: Rob Herring (Arm) @ 2024-09-13 9:35 UTC (permalink / raw) To: Andrei Stefanescu Cc: Conor Dooley, Rafael J. Wysocki, linux-kernel, NXP S32 Linux Team, linux-gpio, Bartosz Golaszewski, devicetree, Krzysztof Kozlowski, Chester Lin, Greg Kroah-Hartman, Linus Walleij, Matthias Brugger, linux-arm-kernel On Fri, 13 Sep 2024 11:29:33 +0300, Andrei Stefanescu wrote: > Add support for the GPIO driver of the NXP S32G2/S32G3 SoCs. > > Signed-off-by: Phu Luu An <phu.luuan@nxp.com> > Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com> > Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> > Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> > --- > .../bindings/gpio/nxp,s32g2-siul2-gpio.yaml | 106 ++++++++++++++++++ > 1 file changed, 106 insertions(+) > create mode 100644 Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml > My bot found errors running 'make dt_binding_check' on your patch: yamllint warnings/errors: dtschema/dtc warnings/errors: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml: $id: Cannot determine base path from $id, relative path/filename doesn't match actual path or filename $id: http://devicetree.org/schemas/gpio/nxp,gpio-siul2-s32g2.yaml file: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml doc reference errors (make refcheckdocs): See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20240913082937.444367-3-andrei.stefanescu@oss.nxp.com 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. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs 2024-09-13 9:35 ` Rob Herring (Arm) @ 2024-09-13 9:55 ` Andrei Stefanescu 0 siblings, 0 replies; 18+ messages in thread From: Andrei Stefanescu @ 2024-09-13 9:55 UTC (permalink / raw) To: Rob Herring (Arm) Cc: Conor Dooley, Rafael J. Wysocki, linux-kernel, NXP S32 Linux Team, linux-gpio, Bartosz Golaszewski, devicetree, Krzysztof Kozlowski, Chester Lin, Greg Kroah-Hartman, Linus Walleij, Matthias Brugger, linux-arm-kernel Hi, On 13/09/2024 12:35, Rob Herring (Arm) wrote: > > On Fri, 13 Sep 2024 11:29:33 +0300, Andrei Stefanescu wrote: >> Add support for the GPIO driver of the NXP S32G2/S32G3 SoCs. >> >> Signed-off-by: Phu Luu An <phu.luuan@nxp.com> >> Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com> >> Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> >> Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> >> --- >> .../bindings/gpio/nxp,s32g2-siul2-gpio.yaml | 106 ++++++++++++++++++ >> 1 file changed, 106 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml >> > > My bot found errors running 'make dt_binding_check' on your patch: > > yamllint warnings/errors: > > dtschema/dtc warnings/errors: > /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml: $id: Cannot determine base path from $id, relative path/filename doesn't match actual path or filename > $id: http://devicetree.org/schemas/gpio/nxp,gpio-siul2-s32g2.yaml > file: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml > > doc reference errors (make refcheckdocs): > I am sorry for this, I forgot to run the 'dt_binding_check' on this version. I will wait a bit for other comments and I will fix in v3. Best regards, Andrei ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs 2024-09-13 8:29 ` [PATCH v2 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs Andrei Stefanescu 2024-09-13 9:35 ` Rob Herring (Arm) @ 2024-09-13 14:13 ` Rob Herring 2024-09-16 6:01 ` Andrei Stefanescu 1 sibling, 1 reply; 18+ messages in thread From: Rob Herring @ 2024-09-13 14:13 UTC (permalink / raw) To: Andrei Stefanescu Cc: Linus Walleij, Bartosz Golaszewski, Krzysztof Kozlowski, Conor Dooley, Chester Lin, Matthias Brugger, Greg Kroah-Hartman, Rafael J. Wysocki, linux-gpio, devicetree, linux-kernel, linux-arm-kernel, NXP S32 Linux Team On Fri, Sep 13, 2024 at 11:29:33AM +0300, Andrei Stefanescu wrote: > Add support for the GPIO driver of the NXP S32G2/S32G3 SoCs. > > Signed-off-by: Phu Luu An <phu.luuan@nxp.com> > Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com> > Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> > Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> > --- > .../bindings/gpio/nxp,s32g2-siul2-gpio.yaml | 106 ++++++++++++++++++ > 1 file changed, 106 insertions(+) > create mode 100644 Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml > > diff --git a/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml b/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml > new file mode 100644 > index 000000000000..8be8eb3a971d > --- /dev/null > +++ b/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml > @@ -0,0 +1,106 @@ > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause > +# Copyright 2024 NXP > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/gpio/nxp,gpio-siul2-s32g2.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: NXP S32G2 SIUL2 GPIO controller > + > +maintainers: > + - Ghennadi Procopciuc <Ghennadi.Procopciuc@nxp.com> > + - Larisa Grigore <larisa.grigore@nxp.com> > + - Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> > + > +description: > + Support for the SIUL2 GPIOs found on the S32G2 and S32G3 > + chips. It includes an IRQ controller for all pins which have > + an EIRQ associated. > + > +properties: > + compatible: > + items: > + - const: nxp,s32g2-siul2-gpio > + > + reg: > + items: > + - description: PGPDO (output value) registers for SIUL2_0 > + - description: PGPDO (output value) registers for SIUL2_1 > + - description: PGPDI (input value) registers for SIUL2_0 > + - description: PGPDI (input value) registers for SIUL2_1 > + - description: EIRQ (interrupt) configuration registers from SIUL2_1 > + - description: EIRQ IMCR registers for interrupt muxing between pads > + > + reg-names: > + items: > + - const: opads0 > + - const: opads1 > + - const: ipads0 > + - const: ipads1 > + - const: eirqs > + - const: eirq-imcrs > + > + gpio-controller: true > + > + '#gpio-cells': > + const: 2 > + > + interrupts: > + maxItems: 1 > + > + interrupt-controller: true > + > + "#interrupt-cells": > + const: 2 > + > + gpio-ranges: > + minItems: 2 This gets expanded to 'maxItems: 2'. Is that what you want? If not, maxItems should be explicit. > + > + gpio-reserved-ranges: > + minItems: 2 > + > +patternProperties: > + "-hog(-[0-9]+)?$": > + required: > + - gpio-hog > + > +required: > + - compatible > + - reg > + - reg-names > + - gpio-controller > + - "#gpio-cells" > + - gpio-ranges > + - gpio-reserved-ranges > + - interrupts > + - interrupt-controller > + - "#interrupt-cells" > + > +additionalProperties: false > + > +examples: > + - | > + #include <dt-bindings/interrupt-controller/arm-gic.h> > + #include <dt-bindings/interrupt-controller/irq.h> > + > + gpio: siul2-gpio@4009d700 { gpio@... Drop unused label. > + compatible = "nxp,s32g2-siul2-gpio"; > + reg = <0x4009d700 0x10>, > + <0x44011700 0x18>, > + <0x4009d740 0x10>, > + <0x44011740 0x18>, > + <0x44010010 0xb4>, > + <0x44011078 0x80>; > + reg-names = "opads0", "opads1", "ipads0", > + "ipads1", "eirqs", "eirq-imcrs"; > + gpio-controller; > + #gpio-cells = <2>; > + /* GPIO 0-101 */ > + gpio-ranges = <&pinctrl 0 0 102>, > + /* GPIO 112-190 */ > + <&pinctrl 112 112 79>; > + gpio-reserved-ranges = <102 10>, <123 21>; > + interrupts = <GIC_SPI 210 IRQ_TYPE_LEVEL_HIGH>; > + interrupt-controller; > + #interrupt-cells = <2>; > + }; > -- > 2.45.2 > ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs 2024-09-13 14:13 ` Rob Herring @ 2024-09-16 6:01 ` Andrei Stefanescu 0 siblings, 0 replies; 18+ messages in thread From: Andrei Stefanescu @ 2024-09-16 6:01 UTC (permalink / raw) To: Rob Herring Cc: Linus Walleij, Bartosz Golaszewski, Krzysztof Kozlowski, Conor Dooley, Chester Lin, Matthias Brugger, Greg Kroah-Hartman, Rafael J. Wysocki, linux-gpio, devicetree, linux-kernel, linux-arm-kernel, NXP S32 Linux Team Hi Rob, Thank you very much for the review! >> + >> + gpio-ranges: >> + minItems: 2 > > This gets expanded to 'maxItems: 2'. Is that what you want? If not, > maxItems should be explicit. Yes, 'maxItems: 2' is what I want but I can also add 'maxItems: 2' in v3 to be explicit/more clear about it. >> + - | >> + #include <dt-bindings/interrupt-controller/arm-gic.h> >> + #include <dt-bindings/interrupt-controller/irq.h> >> + >> + gpio: siul2-gpio@4009d700 { > > gpio@... > > Drop unused label. I will fix in v3. Best regards, Andrei ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support 2024-09-13 8:29 [PATCH v2 0/4] gpio: siul2-s32g2: add initial GPIO driver Andrei Stefanescu 2024-09-13 8:29 ` [PATCH v2 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() Andrei Stefanescu 2024-09-13 8:29 ` [PATCH v2 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs Andrei Stefanescu @ 2024-09-13 8:29 ` Andrei Stefanescu 2024-09-14 16:40 ` Markus Elfring 2024-09-13 8:29 ` [PATCH v2 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver Andrei Stefanescu 3 siblings, 1 reply; 18+ messages in thread From: Andrei Stefanescu @ 2024-09-13 8:29 UTC (permalink / raw) To: Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chester Lin, Matthias Brugger, Greg Kroah-Hartman, Rafael J. Wysocki Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel, NXP S32 Linux Team, Andrei Stefanescu Add the GPIO driver for S32G2/S32G3 SoCs. This driver uses the SIUL2 (System Integration Unit Lite2) hardware module. There are two SIUL2 hardware modules present, SIUL2_0(controlling GPIOs 0-101) and SIUL2_1 for the rest. The GPIOs are not fully contiguous, there are some gaps: - GPIO102 up to GPIO111(inclusive) are invalid - GPIO123 up to GPIO143(inclusive) are invalid Some GPIOs are input only(i.e. GPI182) though this restriction is not yet enforced in code. This patch adds basic GPIO functionality(no interrupts, no suspend/resume functions). Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com> Signed-off-by: Phu Luu An <phu.luuan@nxp.com> Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> --- drivers/gpio/Kconfig | 10 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-siul2-s32g2.c | 581 ++++++++++++++++++++++++++++++++ 3 files changed, 592 insertions(+) create mode 100644 drivers/gpio/gpio-siul2-s32g2.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 58f43bcced7c..75a6ca60ebc7 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -643,6 +643,16 @@ config GPIO_SIOX Say yes here to support SIOX I/O devices. These are units connected via a SIOX bus and have a number of fixed-direction I/O lines. +config GPIO_SIUL2_S32G2 + tristate "GPIO driver for S32G2/S32G3" + depends on ARCH_S32 || COMPILE_TEST + depends on OF_GPIO + select REGMAP_MMIO + help + This enables support for the SIUL2 GPIOs found on the S32G2/S32G3 + chips. Say yes here to enable the SIUL2 to be used as an GPIO + controller for S32G2/S32G3 platforms. + config GPIO_SNPS_CREG bool "Synopsys GPIO via CREG (Control REGisters) driver" depends on ARC || COMPILE_TEST diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 64dd6d9d730d..fb6e770a64b9 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -149,6 +149,7 @@ obj-$(CONFIG_GPIO_SCH) += gpio-sch.o obj-$(CONFIG_GPIO_SIFIVE) += gpio-sifive.o obj-$(CONFIG_GPIO_SIM) += gpio-sim.o obj-$(CONFIG_GPIO_SIOX) += gpio-siox.o +obj-$(CONFIG_GPIO_SIUL2_S32G2) += gpio-siul2-s32g2.o obj-$(CONFIG_GPIO_SL28CPLD) += gpio-sl28cpld.o obj-$(CONFIG_GPIO_SLOPPY_LOGIC_ANALYZER) += gpio-sloppy-logic-analyzer.o obj-$(CONFIG_GPIO_SODAVILLE) += gpio-sodaville.o diff --git a/drivers/gpio/gpio-siul2-s32g2.c b/drivers/gpio/gpio-siul2-s32g2.c new file mode 100644 index 000000000000..205a1a4d216d --- /dev/null +++ b/drivers/gpio/gpio-siul2-s32g2.c @@ -0,0 +1,581 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * SIUL2 GPIO support. + * + * Copyright (c) 2016 Freescale Semiconductor, Inc. + * Copyright 2018-2024 NXP + */ + +#include <linux/err.h> +#include <linux/init.h> +#include <linux/io.h> +#include <linux/platform_device.h> +#include <linux/module.h> +#include <linux/gpio/driver.h> +#include <linux/pinctrl/consumer.h> +#include <linux/regmap.h> +#include <linux/types.h> + +/* PGPDOs are 16bit registers that come in big endian + * order if they are grouped in pairs of two. + * + * For example, the order is PGPDO1, PGPDO0, PGPDO3, PGPDO2... + */ +#define SIUL2_PGPDO(N) (((N) ^ 1) * 2) +#define S32G2_SIUL2_NUM 2 +#define S32G2_PADS_DTS_TAG_LEN (7) + +#define SIUL2_GPIO_16_PAD_SIZE 16 + +/** + * struct siul2_device_data - platform data attached to the compatible. + * @pad_access: access table for I/O pads, consists of S32G2_SIUL2_NUM tables. + * @reset_cnt: reset the pin name counter to zero when switching to SIUL2_1. + */ +struct siul2_device_data { + const struct regmap_access_table **pad_access; + const bool reset_cnt; +}; + +/** + * struct siul2_desc - describes a SIUL2 hw module. + * @pad_access: array of valid I/O pads. + * @opadmap: the regmap of the Parallel GPIO Pad Data Out Register. + * @ipadmap: the regmap of the Parallel GPIO Pad Data In Register. + * @gpio_base: the first GPIO pin. + * @gpio_num: the number of GPIO pins. + */ +struct siul2_desc { + const struct regmap_access_table *pad_access; + struct regmap *opadmap; + struct regmap *ipadmap; + u32 gpio_base; + u32 gpio_num; +}; + +/** + * struct siul2_gpio_dev - describes a group of GPIO pins. + * @platdata: the platform data. + * @siul2: SIUL2_0 and SIUL2_1 modules information. + * @pin_dir_bitmap: the bitmap with pin directions. + * @gc: the GPIO chip. + * @lock: mutual access to bitmaps. + */ +struct siul2_gpio_dev { + const struct siul2_device_data *platdata; + struct siul2_desc siul2[S32G2_SIUL2_NUM]; + unsigned long *pin_dir_bitmap; + struct gpio_chip gc; + raw_spinlock_t lock; +}; + +static const struct regmap_range s32g2_siul20_pad_yes_ranges[] = { + regmap_reg_range(SIUL2_PGPDO(0), SIUL2_PGPDO(0)), + regmap_reg_range(SIUL2_PGPDO(1), SIUL2_PGPDO(1)), + regmap_reg_range(SIUL2_PGPDO(2), SIUL2_PGPDO(2)), + regmap_reg_range(SIUL2_PGPDO(3), SIUL2_PGPDO(3)), + regmap_reg_range(SIUL2_PGPDO(4), SIUL2_PGPDO(4)), + regmap_reg_range(SIUL2_PGPDO(5), SIUL2_PGPDO(5)), + regmap_reg_range(SIUL2_PGPDO(6), SIUL2_PGPDO(6)), +}; + +static const struct regmap_access_table s32g2_siul20_pad_access_table = { + .yes_ranges = s32g2_siul20_pad_yes_ranges, + .n_yes_ranges = ARRAY_SIZE(s32g2_siul20_pad_yes_ranges), +}; + +static const struct regmap_range s32g2_siul21_pad_yes_ranges[] = { + regmap_reg_range(SIUL2_PGPDO(7), SIUL2_PGPDO(7)), + regmap_reg_range(SIUL2_PGPDO(9), SIUL2_PGPDO(9)), + regmap_reg_range(SIUL2_PGPDO(10), SIUL2_PGPDO(10)), + regmap_reg_range(SIUL2_PGPDO(11), SIUL2_PGPDO(11)), +}; + +static const struct regmap_access_table s32g2_siul21_pad_access_table = { + .yes_ranges = s32g2_siul21_pad_yes_ranges, + .n_yes_ranges = ARRAY_SIZE(s32g2_siul21_pad_yes_ranges), +}; + +static const struct regmap_access_table *s32g2_pad_access_table[] = { + &s32g2_siul20_pad_access_table, + &s32g2_siul21_pad_access_table +}; + +static_assert(ARRAY_SIZE(s32g2_pad_access_table) == S32G2_SIUL2_NUM); + +static const struct siul2_device_data s32g2_device_data = { + .pad_access = s32g2_pad_access_table, + .reset_cnt = true, +}; + +static int siul2_get_gpio_pinspec(struct platform_device *pdev, + struct of_phandle_args *pinspec, + unsigned int range_index) +{ + struct device_node *np = pdev->dev.of_node; + + return of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, + range_index, pinspec); +} + +static struct regmap *siul2_offset_to_regmap(struct siul2_gpio_dev *dev, + unsigned int offset, + bool input) +{ + struct siul2_desc *siul2; + size_t i; + + for (i = 0; i < ARRAY_SIZE(dev->siul2); i++) { + siul2 = &dev->siul2[i]; + if (offset >= siul2->gpio_base && + offset - siul2->gpio_base < siul2->gpio_num) + return input ? siul2->ipadmap : siul2->opadmap; + } + + return NULL; +} + +static void siul2_gpio_set_direction(struct siul2_gpio_dev *dev, + unsigned int gpio, int dir) +{ + unsigned long flags; + + raw_spin_lock_irqsave(&dev->lock, flags); + + if (dir == GPIO_LINE_DIRECTION_IN) + __clear_bit(gpio, dev->pin_dir_bitmap); + else + __set_bit(gpio, dev->pin_dir_bitmap); + + raw_spin_unlock_irqrestore(&dev->lock, flags); +} + + +static int siul2_get_direction(struct siul2_gpio_dev *dev, + unsigned int gpio) +{ + return test_bit(gpio, dev->pin_dir_bitmap) ? GPIO_LINE_DIRECTION_OUT : + GPIO_LINE_DIRECTION_IN; +} + +static struct siul2_gpio_dev *to_siul2_gpio_dev(struct gpio_chip *chip) +{ + return container_of(chip, struct siul2_gpio_dev, gc); +} + +static int siul2_gpio_dir_in(struct gpio_chip *chip, unsigned int gpio) +{ + struct siul2_gpio_dev *gpio_dev; + int ret = 0; + + ret = pinctrl_gpio_direction_input(chip, gpio); + if (ret) + return ret; + + gpio_dev = to_siul2_gpio_dev(chip); + siul2_gpio_set_direction(gpio_dev, gpio, GPIO_LINE_DIRECTION_IN); + + return 0; +} + +static int siul2_gpio_get_dir(struct gpio_chip *chip, unsigned int gpio) +{ + return siul2_get_direction(to_siul2_gpio_dev(chip), gpio); +} + +static unsigned int siul2_pin2pad(unsigned int pin) +{ + return pin / SIUL2_GPIO_16_PAD_SIZE; +} + +static u16 siul2_pin2mask(unsigned int pin) +{ + /** + * From Reference manual : + * PGPDOx[PPDOy] = GPDO(x × 16) + (15 - y)[PDO_(x × 16) + (15 - y)] + */ + return BIT(SIUL2_GPIO_16_PAD_SIZE - 1 - pin % SIUL2_GPIO_16_PAD_SIZE); +} + +static void siul2_gpio_set_val(struct gpio_chip *chip, unsigned int offset, + int value) +{ + struct siul2_gpio_dev *gpio_dev = to_siul2_gpio_dev(chip); + unsigned int pad, reg_offset; + struct regmap *regmap; + u16 mask; + + mask = siul2_pin2mask(offset); + pad = siul2_pin2pad(offset); + + reg_offset = SIUL2_PGPDO(pad); + regmap = siul2_offset_to_regmap(gpio_dev, offset, false); + if (!regmap) + return; + + value = value ? mask : 0; + + regmap_update_bits(regmap, reg_offset, mask, value); +} + +static int siul2_gpio_dir_out(struct gpio_chip *chip, unsigned int gpio, + int val) +{ + struct siul2_gpio_dev *gpio_dev; + int ret = 0; + + gpio_dev = to_siul2_gpio_dev(chip); + siul2_gpio_set_val(chip, gpio, val); + + ret = pinctrl_gpio_direction_output(chip, gpio); + if (ret) + return ret; + + siul2_gpio_set_direction(gpio_dev, gpio, GPIO_LINE_DIRECTION_OUT); + + return 0; +} + +static void siul2_gpio_set(struct gpio_chip *chip, unsigned int offset, + int value) +{ + struct siul2_gpio_dev *gpio_dev = to_siul2_gpio_dev(chip); + + if (!gpio_dev) + return; + + if (siul2_get_direction(gpio_dev, offset) == GPIO_LINE_DIRECTION_IN) + return; + + siul2_gpio_set_val(chip, offset, value); +} + +static int siul2_gpio_get(struct gpio_chip *chip, unsigned int offset) +{ + struct siul2_gpio_dev *gpio_dev = to_siul2_gpio_dev(chip); + unsigned int mask, pad, reg_offset, data = 0; + struct regmap *regmap; + + mask = siul2_pin2mask(offset); + pad = siul2_pin2pad(offset); + + reg_offset = SIUL2_PGPDO(pad); + regmap = siul2_offset_to_regmap(gpio_dev, offset, true); + if (!regmap) + return -EINVAL; + + regmap_read(regmap, reg_offset, &data); + + return !!(data & mask); +} + +static const struct regmap_config siul2_regmap_conf = { + .val_bits = 32, + .reg_bits = 32, + .reg_stride = 4, + .cache_type = REGCACHE_FLAT, +}; + +static struct regmap *common_regmap_init(struct platform_device *pdev, + struct regmap_config *conf, + const char *name) +{ + struct device *dev = &pdev->dev; + struct resource *res; + resource_size_t size; + void __iomem *base; + + base = devm_platform_get_and_ioremap_resource_byname(pdev, name, &res); + if (IS_ERR(base)) { + dev_err(&pdev->dev, "Failed to get MEM resource: %s\n", name); + return ERR_PTR(-EINVAL); + } + + size = resource_size(res); + conf->val_bits = conf->reg_stride * 8; + conf->max_register = size - conf->reg_stride; + conf->name = name; + conf->use_raw_spinlock = true; + + if (conf->cache_type != REGCACHE_NONE) + conf->num_reg_defaults_raw = size / conf->reg_stride; + + return devm_regmap_init_mmio(dev, base, conf); +} + +static bool not_writable(__always_unused struct device *dev, + __always_unused unsigned int reg) +{ + return false; +} + +static struct regmap *init_padregmap(struct platform_device *pdev, + struct siul2_gpio_dev *gpio_dev, + int selector, bool input) +{ + const struct siul2_device_data *platdata = gpio_dev->platdata; + struct regmap_config regmap_conf = siul2_regmap_conf; + char dts_tag[S32G2_PADS_DTS_TAG_LEN]; + int err; + + regmap_conf.reg_stride = 2; + + if (selector != 0 && selector != 1) + return ERR_PTR(-EINVAL); + + regmap_conf.rd_table = platdata->pad_access[selector]; + + err = snprintf(dts_tag, ARRAY_SIZE(dts_tag), "%cpads%d", + input ? 'i' : 'o', selector); + if (err < 0) + return ERR_PTR(-EINVAL); + + if (input) { + regmap_conf.writeable_reg = not_writable; + regmap_conf.cache_type = REGCACHE_NONE; + } else { + regmap_conf.wr_table = platdata->pad_access[selector]; + } + + return common_regmap_init(pdev, ®map_conf, dts_tag); +} + +static int siul2_gpio_pads_init(struct platform_device *pdev, + struct siul2_gpio_dev *gpio_dev) +{ + struct device *dev = &pdev->dev; + size_t i; + + for (i = 0; i < ARRAY_SIZE(gpio_dev->siul2); i++) { + gpio_dev->siul2[i].opadmap = init_padregmap(pdev, gpio_dev, i, + false); + if (IS_ERR(gpio_dev->siul2[i].opadmap)) { + dev_err(dev, + "Failed to initialize opad2%zu regmap config\n", + i); + return PTR_ERR(gpio_dev->siul2[i].opadmap); + } + + gpio_dev->siul2[i].ipadmap = init_padregmap(pdev, gpio_dev, i, + true); + if (IS_ERR(gpio_dev->siul2[i].ipadmap)) { + dev_err(dev, + "Failed to initialize ipad2%zu regmap config\n", + i); + return PTR_ERR(gpio_dev->siul2[i].ipadmap); + } + } + + return 0; +} + +static int siul2_gen_names(struct device *dev, unsigned int cnt, char **names, + char *ch_index, unsigned int *num_index) +{ + unsigned int i; + + for (i = 0; i < cnt; i++) { + if (i != 0 && !(*num_index % 16)) + (*ch_index)++; + + names[i] = devm_kasprintf(dev, GFP_KERNEL, "P%c_%02d", + *ch_index, 0xFU & (*num_index)++); + if (!names[i]) + return -ENOMEM; + } + + return 0; +} + +static int siul2_gpio_remove_reserved_names(struct device *dev, + struct siul2_gpio_dev *gpio_dev, + char **names) +{ + struct device_node *np = dev->of_node; + int num_ranges, i, j, ret; + u32 base_gpio, num_gpio; + + /* Parse the gpio-reserved-ranges to know which GPIOs to exclude. */ + + num_ranges = of_property_count_u32_elems(dev->of_node, + "gpio-reserved-ranges"); + + /* The "gpio-reserved-ranges" is optional. */ + if (num_ranges < 0) + return 0; + num_ranges /= 2; + + for (i = 0; i < num_ranges; i++) { + ret = of_property_read_u32_index(np, "gpio-reserved-ranges", + i * 2, &base_gpio); + if (ret) { + dev_err(dev, "Could not parse the start GPIO: %d\n", + ret); + return ret; + } + + ret = of_property_read_u32_index(np, "gpio-reserved-ranges", + i * 2 + 1, &num_gpio); + if (ret) { + dev_err(dev, "Could not parse num. GPIOs: %d\n", ret); + return ret; + } + + if (base_gpio + num_gpio > gpio_dev->gc.ngpio) { + dev_err(dev, "Reserved GPIOs outside of GPIO range\n"); + return -EINVAL; + } + + /* Remove names set for reserved GPIOs. */ + for (j = base_gpio; j < base_gpio + num_gpio; j++) { + devm_kfree(dev, names[j]); + names[j] = NULL; + } + } + + return 0; +} + +static int siul2_gpio_populate_names(struct device *dev, + struct siul2_gpio_dev *gpio_dev) +{ + unsigned int num_index = 0; + char ch_index = 'A'; + char **names; + int i, ret; + + names = devm_kcalloc(dev, gpio_dev->gc.ngpio, sizeof(*names), + GFP_KERNEL); + if (!names) + return -ENOMEM; + + for (i = 0; i < S32G2_SIUL2_NUM; i++) { + ret = siul2_gen_names(dev, gpio_dev->siul2[i].gpio_num, + names + gpio_dev->siul2[i].gpio_base, + &ch_index, &num_index); + if (ret) { + dev_err(dev, "Could not set names for SIUL2_%d GPIOs\n", + i); + return ret; + } + + if (gpio_dev->platdata->reset_cnt) + num_index = 0; + + ch_index++; + } + + ret = siul2_gpio_remove_reserved_names(dev, gpio_dev, names); + if (ret) + return ret; + + gpio_dev->gc.names = (const char *const *)names; + + return 0; +} + +static int siul2_gpio_probe(struct platform_device *pdev) +{ + struct siul2_gpio_dev *gpio_dev; + struct device *dev = &pdev->dev; + struct of_phandle_args pinspec; + size_t i, bitmap_size; + struct gpio_chip *gc; + int ret = 0; + + gpio_dev = devm_kzalloc(dev, sizeof(*gpio_dev), GFP_KERNEL); + if (!gpio_dev) + return -ENOMEM; + + gpio_dev->platdata = &s32g2_device_data; + + for (i = 0; i < S32G2_SIUL2_NUM; i++) + gpio_dev->siul2[i].pad_access = + gpio_dev->platdata->pad_access[i]; + + ret = siul2_gpio_pads_init(pdev, gpio_dev); + if (ret) + return ret; + + gc = &gpio_dev->gc; + + platform_set_drvdata(pdev, gpio_dev); + + raw_spin_lock_init(&gpio_dev->lock); + + for (i = 0; i < ARRAY_SIZE(gpio_dev->siul2); i++) { + ret = siul2_get_gpio_pinspec(pdev, &pinspec, i); + if (ret) { + dev_err(dev, + "unable to get pinspec %zu from device tree\n", + i); + return -EINVAL; + } + + of_node_put(pinspec.np); + + if (pinspec.args_count != 3) { + dev_err(dev, "Invalid pinspec count: %d\n", + pinspec.args_count); + return -EINVAL; + } + + gpio_dev->siul2[i].gpio_base = pinspec.args[1]; + gpio_dev->siul2[i].gpio_num = pinspec.args[2]; + } + + gc->base = -1; + + /* In some cases, there is a gap between the SIUL GPIOs. */ + gc->ngpio = gpio_dev->siul2[S32G2_SIUL2_NUM - 1].gpio_base + + gpio_dev->siul2[S32G2_SIUL2_NUM - 1].gpio_num; + + ret = siul2_gpio_populate_names(&pdev->dev, gpio_dev); + if (ret) + return ret; + + bitmap_size = BITS_TO_LONGS(gc->ngpio) * + sizeof(*gpio_dev->pin_dir_bitmap); + gpio_dev->pin_dir_bitmap = devm_kzalloc(dev, bitmap_size, GFP_KERNEL); + if (!gpio_dev->pin_dir_bitmap) + return -ENOMEM; + + gc->parent = dev; + gc->label = dev_name(dev); + + gc->set = siul2_gpio_set; + gc->get = siul2_gpio_get; + gc->set_config = gpiochip_generic_config; + gc->request = gpiochip_generic_request; + gc->free = gpiochip_generic_free; + gc->direction_output = siul2_gpio_dir_out; + gc->direction_input = siul2_gpio_dir_in; + gc->get_direction = siul2_gpio_get_dir; + gc->owner = THIS_MODULE; + + ret = devm_gpiochip_add_data(dev, gc, gpio_dev); + if (ret) + return dev_err_probe(dev, ret, "unable to add gpiochip\n"); + + return 0; +} + +static const struct of_device_id siul2_gpio_dt_ids[] = { + { .compatible = "nxp,s32g2-siul2-gpio" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, siul2_gpio_dt_ids); + +static struct platform_driver siul2_gpio_driver = { + .driver = { + .name = "s32g2-siul2-gpio", + .of_match_table = siul2_gpio_dt_ids, + }, + .probe = siul2_gpio_probe, +}; + +module_platform_driver(siul2_gpio_driver); + +MODULE_AUTHOR("NXP"); +MODULE_DESCRIPTION("NXP SIUL2 GPIO"); +MODULE_LICENSE("GPL"); -- 2.45.2 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support 2024-09-13 8:29 ` [PATCH v2 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support Andrei Stefanescu @ 2024-09-14 16:40 ` Markus Elfring 2024-09-16 8:14 ` Andrei Stefanescu 0 siblings, 1 reply; 18+ messages in thread From: Markus Elfring @ 2024-09-14 16:40 UTC (permalink / raw) To: Andrei Stefanescu, Ghennadi Procopciuc, Larisa Grigore, Phu Luu An, linux-gpio, devicetree, linux-arm-kernel, Bartosz Golaszewski, Chester Lin, Conor Dooley, Greg Kroah-Hartman, Krzysztof Kozlowski, Linus Walleij, Matthias Brugger, Rafael J. Wysocki, Rob Herring Cc: LKML, s32 … > +++ b/drivers/gpio/gpio-siul2-s32g2.c > @@ -0,0 +1,581 @@ … > +static void siul2_gpio_set_direction(struct siul2_gpio_dev *dev, > + unsigned int gpio, int dir) > +{ > + unsigned long flags; > + > + raw_spin_lock_irqsave(&dev->lock, flags); … > + raw_spin_unlock_irqrestore(&dev->lock, flags); > +} … Under which circumstances would you become interested to apply a statement like “guard(raw_spinlock_irqsave)(&dev->lock);”? https://elixir.bootlin.com/linux/v6.11-rc7/source/include/linux/spinlock.h#L551 Regards, Markus ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support 2024-09-14 16:40 ` Markus Elfring @ 2024-09-16 8:14 ` Andrei Stefanescu 0 siblings, 0 replies; 18+ messages in thread From: Andrei Stefanescu @ 2024-09-16 8:14 UTC (permalink / raw) To: Markus Elfring, Ghennadi Procopciuc, Larisa Grigore, Phu Luu An, linux-gpio, devicetree, linux-arm-kernel, Bartosz Golaszewski, Chester Lin, Conor Dooley, Greg Kroah-Hartman, Krzysztof Kozlowski, Linus Walleij, Matthias Brugger, Rafael J. Wysocki, Rob Herring Cc: LKML, s32 Hi Markus, On 14/09/2024 19:40, Markus Elfring wrote: > … >> +++ b/drivers/gpio/gpio-siul2-s32g2.c >> @@ -0,0 +1,581 @@ > … >> +static void siul2_gpio_set_direction(struct siul2_gpio_dev *dev, >> + unsigned int gpio, int dir) >> +{ >> + unsigned long flags; >> + >> + raw_spin_lock_irqsave(&dev->lock, flags); > … >> + raw_spin_unlock_irqrestore(&dev->lock, flags); >> +} > … > > Under which circumstances would you become interested to apply a statement > like “guard(raw_spinlock_irqsave)(&dev->lock);”? > https://elixir.bootlin.com/linux/v6.11-rc7/source/include/linux/spinlock.h#L551 Thank you very much for the suggestion! I will add it in v3. > > Regards, > Markus Best regards, Andrei ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver 2024-09-13 8:29 [PATCH v2 0/4] gpio: siul2-s32g2: add initial GPIO driver Andrei Stefanescu ` (2 preceding siblings ...) 2024-09-13 8:29 ` [PATCH v2 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support Andrei Stefanescu @ 2024-09-13 8:29 ` Andrei Stefanescu 2024-09-13 11:05 ` Greg Kroah-Hartman 2024-09-17 17:44 ` Krzysztof Kozlowski 3 siblings, 2 replies; 18+ messages in thread From: Andrei Stefanescu @ 2024-09-13 8:29 UTC (permalink / raw) To: Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chester Lin, Matthias Brugger, Greg Kroah-Hartman, Rafael J. Wysocki Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel, NXP S32 Linux Team, Andrei Stefanescu Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 10430778c998..e23c4369b6e1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2689,10 +2689,12 @@ ARM/NXP S32G ARCHITECTURE R: Chester Lin <chester62515@gmail.com> R: Matthias Brugger <mbrugger@suse.com> R: Ghennadi Procopciuc <ghennadi.procopciuc@oss.nxp.com> +R: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> L: NXP S32 Linux Team <s32@nxp.com> L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Maintained F: arch/arm64/boot/dts/freescale/s32g*.dts* +F: drivers/gpio/gpio-siul2-s32g2.c F: drivers/pinctrl/nxp/ ARM/Orion SoC/Technologic Systems TS-78xx platform support -- 2.45.2 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver 2024-09-13 8:29 ` [PATCH v2 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver Andrei Stefanescu @ 2024-09-13 11:05 ` Greg Kroah-Hartman 2024-09-13 12:33 ` Andrei Stefanescu 2024-09-17 17:44 ` Krzysztof Kozlowski 1 sibling, 1 reply; 18+ messages in thread From: Greg Kroah-Hartman @ 2024-09-13 11:05 UTC (permalink / raw) To: Andrei Stefanescu Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chester Lin, Matthias Brugger, Rafael J. Wysocki, linux-gpio, devicetree, linux-kernel, linux-arm-kernel, NXP S32 Linux Team On Fri, Sep 13, 2024 at 11:29:35AM +0300, Andrei Stefanescu wrote: > Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> For obvious reasons, we can't take patches without any changelog text, even for simple stuff. thanks, greg k-h ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver 2024-09-13 11:05 ` Greg Kroah-Hartman @ 2024-09-13 12:33 ` Andrei Stefanescu 0 siblings, 0 replies; 18+ messages in thread From: Andrei Stefanescu @ 2024-09-13 12:33 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chester Lin, Matthias Brugger, Rafael J. Wysocki, linux-gpio, devicetree, linux-kernel, linux-arm-kernel, NXP S32 Linux Team Hi Greg, On 13/09/2024 14:05, Greg Kroah-Hartman wrote: > On Fri, Sep 13, 2024 at 11:29:35AM +0300, Andrei Stefanescu wrote: >> Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> > > For obvious reasons, we can't take patches without any changelog text, > even for simple stuff. > > thanks, > > greg k-h Thank you! I will fix it in v3. Best regards, Andrei ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver 2024-09-13 8:29 ` [PATCH v2 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver Andrei Stefanescu 2024-09-13 11:05 ` Greg Kroah-Hartman @ 2024-09-17 17:44 ` Krzysztof Kozlowski 2024-09-18 7:57 ` Andrei Stefanescu 1 sibling, 1 reply; 18+ messages in thread From: Krzysztof Kozlowski @ 2024-09-17 17:44 UTC (permalink / raw) To: Andrei Stefanescu, Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chester Lin, Matthias Brugger, Greg Kroah-Hartman, Rafael J. Wysocki Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel, NXP S32 Linux Team On 13/09/2024 10:29, Andrei Stefanescu wrote: > Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> > --- > MAINTAINERS | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/MAINTAINERS b/MAINTAINERS > index 10430778c998..e23c4369b6e1 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -2689,10 +2689,12 @@ ARM/NXP S32G ARCHITECTURE > R: Chester Lin <chester62515@gmail.com> > R: Matthias Brugger <mbrugger@suse.com> > R: Ghennadi Procopciuc <ghennadi.procopciuc@oss.nxp.com> > +R: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> That's another patch where NXP adds silently themself as platform maintainer without explanation. Although here at least existing maintainers are Cced. This looks like some pattern, so maybe clarifications are needed. You wanted to be maintainer of this driver alone, right? So separate entry. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver 2024-09-17 17:44 ` Krzysztof Kozlowski @ 2024-09-18 7:57 ` Andrei Stefanescu 2024-09-18 8:13 ` Krzysztof Kozlowski 0 siblings, 1 reply; 18+ messages in thread From: Andrei Stefanescu @ 2024-09-18 7:57 UTC (permalink / raw) To: Krzysztof Kozlowski, Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chester Lin, Matthias Brugger, Greg Kroah-Hartman, Rafael J. Wysocki Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel, NXP S32 Linux Team Hi Krzysztof, On 17/09/2024 20:44, Krzysztof Kozlowski wrote: > On 13/09/2024 10:29, Andrei Stefanescu wrote: >> Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> >> --- >> MAINTAINERS | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/MAINTAINERS b/MAINTAINERS >> index 10430778c998..e23c4369b6e1 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -2689,10 +2689,12 @@ ARM/NXP S32G ARCHITECTURE >> R: Chester Lin <chester62515@gmail.com> >> R: Matthias Brugger <mbrugger@suse.com> >> R: Ghennadi Procopciuc <ghennadi.procopciuc@oss.nxp.com> >> +R: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> > > That's another patch where NXP adds silently themself as platform > maintainer without explanation. Although here at least existing > maintainers are Cced. > > This looks like some pattern, so maybe clarifications are needed. > > You wanted to be maintainer of this driver alone, right? So separate entry. I would actually want to become a maintainer for the platform. I have already added changes to the pinctrl driver and the s32g2.dtsi/s32g3.dtsi files. I intend to submit more patches to these files and I would like to review changes to them. However, if you or any of the existing maintainers consider that I should only add myself as a maintainer for the SIUL2 GPIO driver, I can fix this in v3. > > Best regards, > Krzysztof > Best regards, Andrei ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver 2024-09-18 7:57 ` Andrei Stefanescu @ 2024-09-18 8:13 ` Krzysztof Kozlowski 2024-09-18 9:01 ` Andrei Stefanescu 0 siblings, 1 reply; 18+ messages in thread From: Krzysztof Kozlowski @ 2024-09-18 8:13 UTC (permalink / raw) To: Andrei Stefanescu, Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chester Lin, Matthias Brugger, Greg Kroah-Hartman, Rafael J. Wysocki Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel, NXP S32 Linux Team On 18/09/2024 09:57, Andrei Stefanescu wrote: > Hi Krzysztof, > > On 17/09/2024 20:44, Krzysztof Kozlowski wrote: >> On 13/09/2024 10:29, Andrei Stefanescu wrote: >>> Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> >>> --- >>> MAINTAINERS | 2 ++ >>> 1 file changed, 2 insertions(+) >>> >>> diff --git a/MAINTAINERS b/MAINTAINERS >>> index 10430778c998..e23c4369b6e1 100644 >>> --- a/MAINTAINERS >>> +++ b/MAINTAINERS >>> @@ -2689,10 +2689,12 @@ ARM/NXP S32G ARCHITECTURE >>> R: Chester Lin <chester62515@gmail.com> >>> R: Matthias Brugger <mbrugger@suse.com> >>> R: Ghennadi Procopciuc <ghennadi.procopciuc@oss.nxp.com> >>> +R: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> >> >> That's another patch where NXP adds silently themself as platform >> maintainer without explanation. Although here at least existing >> maintainers are Cced. >> >> This looks like some pattern, so maybe clarifications are needed. >> >> You wanted to be maintainer of this driver alone, right? So separate entry. > > I would actually want to become a maintainer for the platform. I have > already added changes to the pinctrl driver and the s32g2.dtsi/s32g3.dtsi files. > I intend to submit more patches to these files and I would like to review > changes to them. That's fine, so please provide some sort of message in the commit, describing your intention, document the commitment. > > However, if you or any of the existing maintainers consider that I should > only add myself as a maintainer for the SIUL2 GPIO driver, I can fix this in v3. I assume you proposed this after consulting them? It is unusual to add yourself to maintainers without first talking to existing folks... Best regards, Krzysztof ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver 2024-09-18 8:13 ` Krzysztof Kozlowski @ 2024-09-18 9:01 ` Andrei Stefanescu 0 siblings, 0 replies; 18+ messages in thread From: Andrei Stefanescu @ 2024-09-18 9:01 UTC (permalink / raw) To: Krzysztof Kozlowski, Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chester Lin, Matthias Brugger, Greg Kroah-Hartman, Rafael J. Wysocki Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel, NXP S32 Linux Team On 18/09/2024 11:13, Krzysztof Kozlowski wrote: > On 18/09/2024 09:57, Andrei Stefanescu wrote: >> Hi Krzysztof, >> >> On 17/09/2024 20:44, Krzysztof Kozlowski wrote: >>> On 13/09/2024 10:29, Andrei Stefanescu wrote: >>>> Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> >>>> --- >>>> MAINTAINERS | 2 ++ >>>> 1 file changed, 2 insertions(+) >>>> >>>> diff --git a/MAINTAINERS b/MAINTAINERS >>>> index 10430778c998..e23c4369b6e1 100644 >>>> --- a/MAINTAINERS >>>> +++ b/MAINTAINERS >>>> @@ -2689,10 +2689,12 @@ ARM/NXP S32G ARCHITECTURE >>>> R: Chester Lin <chester62515@gmail.com> >>>> R: Matthias Brugger <mbrugger@suse.com> >>>> R: Ghennadi Procopciuc <ghennadi.procopciuc@oss.nxp.com> >>>> +R: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com> >>> >>> That's another patch where NXP adds silently themself as platform >>> maintainer without explanation. Although here at least existing >>> maintainers are Cced. >>> >>> This looks like some pattern, so maybe clarifications are needed. >>> >>> You wanted to be maintainer of this driver alone, right? So separate entry. >> >> I would actually want to become a maintainer for the platform. I have >> already added changes to the pinctrl driver and the s32g2.dtsi/s32g3.dtsi files. >> I intend to submit more patches to these files and I would like to review >> changes to them. > > That's fine, so please provide some sort of message in the commit, > describing your intention, document the commitment. > >> >> However, if you or any of the existing maintainers consider that I should >> only add myself as a maintainer for the SIUL2 GPIO driver, I can fix this in v3. > > I assume you proposed this after consulting them? It is unusual to add > yourself to maintainers without first talking to existing folks... No, unfortunately I haven't consulted with them before proposing it here. I am sorry for that! I will add myself as a reviewer only for the SIUL2 GPIO driver in v3. > > > Best regards, > Krzysztof > Best regards, Andrei ^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2024-09-18 9:01 UTC | newest] Thread overview: 18+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-09-13 8:29 [PATCH v2 0/4] gpio: siul2-s32g2: add initial GPIO driver Andrei Stefanescu 2024-09-13 8:29 ` [PATCH v2 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() Andrei Stefanescu 2024-09-18 7:52 ` Matthias Brugger 2024-09-13 8:29 ` [PATCH v2 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs Andrei Stefanescu 2024-09-13 9:35 ` Rob Herring (Arm) 2024-09-13 9:55 ` Andrei Stefanescu 2024-09-13 14:13 ` Rob Herring 2024-09-16 6:01 ` Andrei Stefanescu 2024-09-13 8:29 ` [PATCH v2 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support Andrei Stefanescu 2024-09-14 16:40 ` Markus Elfring 2024-09-16 8:14 ` Andrei Stefanescu 2024-09-13 8:29 ` [PATCH v2 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver Andrei Stefanescu 2024-09-13 11:05 ` Greg Kroah-Hartman 2024-09-13 12:33 ` Andrei Stefanescu 2024-09-17 17:44 ` Krzysztof Kozlowski 2024-09-18 7:57 ` Andrei Stefanescu 2024-09-18 8:13 ` Krzysztof Kozlowski 2024-09-18 9:01 ` Andrei Stefanescu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).