* [PATCH v3 0/4] gpio: siul2-s32g2: add initial GPIO driver
@ 2024-09-19 13:47 Andrei Stefanescu
2024-09-19 13:47 ` [PATCH v3 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() Andrei Stefanescu
` (3 more replies)
0 siblings, 4 replies; 19+ messages in thread
From: Andrei Stefanescu @ 2024-09-19 13:47 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.
v3 -> v2
- fix dt-bindings schema id
- add maxItems to gpio-ranges
- removed gpio label from dt-bindings example
- added changelog for the MAINTAINERS commit and
added separate entry for the SIUL2 GPIO driver
- added guard(raw_spinlock_irqsave) in
'siul2_gpio_set_direction'
- updated the description for
'devm_platform_get_and_ioremap_resource_byname'
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 | 107 ++++
MAINTAINERS | 7 +
drivers/base/platform.c | 27 +
drivers/gpio/Kconfig | 10 +
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-siul2-s32g2.c | 576 ++++++++++++++++++
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] 19+ messages in thread
* [PATCH v3 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname()
2024-09-19 13:47 [PATCH v3 0/4] gpio: siul2-s32g2: add initial GPIO driver Andrei Stefanescu
@ 2024-09-19 13:47 ` Andrei Stefanescu
2024-09-19 13:47 ` [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs Andrei Stefanescu
` (2 subsequent siblings)
3 siblings, 0 replies; 19+ messages in thread
From: Andrei Stefanescu @ 2024-09-19 13:47 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>
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com>
---
drivers/base/platform.c | 27 +++++++++++++++++++++++++++
include/linux/platform_device.h | 13 +++++++++++++
2 files changed, 40 insertions(+)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 4c3ee6521ba5..da6827f9462a 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -108,6 +108,33 @@ 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
+ *
+ * @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] 19+ messages in thread
* [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs
2024-09-19 13:47 [PATCH v3 0/4] gpio: siul2-s32g2: add initial GPIO driver Andrei Stefanescu
2024-09-19 13:47 ` [PATCH v3 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() Andrei Stefanescu
@ 2024-09-19 13:47 ` Andrei Stefanescu
2024-09-20 12:46 ` Conor Dooley
2024-09-22 21:04 ` Krzysztof Kozlowski
2024-09-19 13:47 ` [PATCH v3 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support Andrei Stefanescu
2024-09-19 13:47 ` [PATCH v3 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver Andrei Stefanescu
3 siblings, 2 replies; 19+ messages in thread
From: Andrei Stefanescu @ 2024-09-19 13:47 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 | 107 ++++++++++++++++++
1 file changed, 107 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..0548028e6745
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml
@@ -0,0 +1,107 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
+# Copyright 2024 NXP
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpio/nxp,s32g2-siul2-gpio.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
+ maxItems: 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@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] 19+ messages in thread
* [PATCH v3 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support
2024-09-19 13:47 [PATCH v3 0/4] gpio: siul2-s32g2: add initial GPIO driver Andrei Stefanescu
2024-09-19 13:47 ` [PATCH v3 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() Andrei Stefanescu
2024-09-19 13:47 ` [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs Andrei Stefanescu
@ 2024-09-19 13:47 ` Andrei Stefanescu
2024-09-22 14:35 ` kernel test robot
2024-09-22 21:47 ` Amit Singh Tomar
2024-09-19 13:47 ` [PATCH v3 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver Andrei Stefanescu
3 siblings, 2 replies; 19+ messages in thread
From: Andrei Stefanescu @ 2024-09-19 13:47 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 | 576 ++++++++++++++++++++++++++++++++
3 files changed, 587 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..a69cbb3bcfaf
--- /dev/null
+++ b/drivers/gpio/gpio-siul2-s32g2.c
@@ -0,0 +1,576 @@
+// 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)
+{
+ guard(raw_spinlock_irqsave)(&dev->lock);
+
+ if (dir == GPIO_LINE_DIRECTION_IN)
+ __clear_bit(gpio, dev->pin_dir_bitmap);
+ else
+ __set_bit(gpio, dev->pin_dir_bitmap);
+}
+
+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] 19+ messages in thread
* [PATCH v3 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver
2024-09-19 13:47 [PATCH v3 0/4] gpio: siul2-s32g2: add initial GPIO driver Andrei Stefanescu
` (2 preceding siblings ...)
2024-09-19 13:47 ` [PATCH v3 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support Andrei Stefanescu
@ 2024-09-19 13:47 ` Andrei Stefanescu
3 siblings, 0 replies; 19+ messages in thread
From: Andrei Stefanescu @ 2024-09-19 13:47 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 myself as a maintainer for the S32G2 SIUL2 GPIO driver and
the NXP S32 mailing list for reviews.
Signed-off-by: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com>
---
MAINTAINERS | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 42d2d950877c..f47bdcb2c1c7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16585,6 +16585,13 @@ S: Maintained
F: Documentation/devicetree/bindings/sound/fsl,sgtl5000.yaml
F: sound/soc/codecs/sgtl5000*
+NXP SIUL2 GPIO DRIVER
+M: Andrei Stefanescu <andrei.stefanescu@oss.nxp.com>
+L: NXP S32 Linux Team <s32@nxp.com>
+S: Maintained
+F: Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml
+F: drivers/gpio/gpio-siul2-s32g2.c
+
NXP SJA1105 ETHERNET SWITCH DRIVER
M: Vladimir Oltean <olteanv@gmail.com>
L: linux-kernel@vger.kernel.org
--
2.45.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs
2024-09-19 13:47 ` [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs Andrei Stefanescu
@ 2024-09-20 12:46 ` Conor Dooley
2024-09-20 13:33 ` Andrei Stefanescu
2024-09-22 21:04 ` Krzysztof Kozlowski
1 sibling, 1 reply; 19+ messages in thread
From: Conor Dooley @ 2024-09-20 12:46 UTC (permalink / raw)
To: Andrei Stefanescu
Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring,
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
[-- Attachment #1: Type: text/plain, Size: 1761 bytes --]
On Thu, Sep 19, 2024 at 04:47:22PM +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 | 107 ++++++++++++++++++
> 1 file changed, 107 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..0548028e6745
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml
> @@ -0,0 +1,107 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
> +# Copyright 2024 NXP
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/gpio/nxp,s32g2-siul2-gpio.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
Commit message and binding description say s32g2 and s32g3, but there's
only a compatible here for g2.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs
2024-09-20 12:46 ` Conor Dooley
@ 2024-09-20 13:33 ` Andrei Stefanescu
2024-09-20 13:40 ` Krzysztof Kozlowski
0 siblings, 1 reply; 19+ messages in thread
From: Andrei Stefanescu @ 2024-09-20 13:33 UTC (permalink / raw)
To: Conor Dooley
Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring,
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 Conor,
Thank you for your review!
On 20/09/2024 15:46, Conor Dooley wrote:
> On Thu, Sep 19, 2024 at 04:47:22PM +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 | 107 ++++++++++++++++++
>> 1 file changed, 107 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..0548028e6745
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml
>> @@ -0,0 +1,107 @@
>> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
>> +# Copyright 2024 NXP
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/gpio/nxp,s32g2-siul2-gpio.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
>
> Commit message and binding description say s32g2 and s32g3, but there's
> only a compatible here for g2.
Yes, the SIUL2 GPIO hardware is the same for both S32G2 and S32G3 SoCs. I plan
to reuse the same compatible when I add the SIUL2 GPIO device tree node for
the S32G3 boards. Would that be ok?
Best regards,
Andrei
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs
2024-09-20 13:33 ` Andrei Stefanescu
@ 2024-09-20 13:40 ` Krzysztof Kozlowski
2024-09-21 21:58 ` Conor Dooley
0 siblings, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2024-09-20 13:40 UTC (permalink / raw)
To: Andrei Stefanescu, Conor Dooley
Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring,
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 20/09/2024 15:33, Andrei Stefanescu wrote:
> Hi Conor,
>
> Thank you for your review!
>
> On 20/09/2024 15:46, Conor Dooley wrote:
>> On Thu, Sep 19, 2024 at 04:47:22PM +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 | 107 ++++++++++++++++++
>>> 1 file changed, 107 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..0548028e6745
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml
>>> @@ -0,0 +1,107 @@
>>> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
>>> +# Copyright 2024 NXP
>>> +%YAML 1.2
>>> +---
>>> +$id: http://devicetree.org/schemas/gpio/nxp,s32g2-siul2-gpio.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
>>
>> Commit message and binding description say s32g2 and s32g3, but there's
>> only a compatible here for g2.
>
> Yes, the SIUL2 GPIO hardware is the same for both S32G2 and S32G3 SoCs. I plan
> to reuse the same compatible when I add the SIUL2 GPIO device tree node for
> the S32G3 boards. Would that be ok?
There are only few exceptions where re-using compatible is allowed. Was
S32G on them? Please consult existing practice/maintainers and past reviews.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs
2024-09-20 13:40 ` Krzysztof Kozlowski
@ 2024-09-21 21:58 ` Conor Dooley
2024-09-22 21:04 ` Krzysztof Kozlowski
0 siblings, 1 reply; 19+ messages in thread
From: Conor Dooley @ 2024-09-21 21:58 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Andrei Stefanescu, Linus Walleij, Bartosz Golaszewski,
Rob Herring, 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
[-- Attachment #1: Type: text/plain, Size: 2841 bytes --]
On Fri, Sep 20, 2024 at 03:40:31PM +0200, Krzysztof Kozlowski wrote:
> On 20/09/2024 15:33, Andrei Stefanescu wrote:
> > Hi Conor,
> >
> > Thank you for your review!
> >
> > On 20/09/2024 15:46, Conor Dooley wrote:
> >> On Thu, Sep 19, 2024 at 04:47:22PM +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 | 107 ++++++++++++++++++
> >>> 1 file changed, 107 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..0548028e6745
> >>> --- /dev/null
> >>> +++ b/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml
> >>> @@ -0,0 +1,107 @@
> >>> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
> >>> +# Copyright 2024 NXP
> >>> +%YAML 1.2
> >>> +---
> >>> +$id: http://devicetree.org/schemas/gpio/nxp,s32g2-siul2-gpio.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
> >>
> >> Commit message and binding description say s32g2 and s32g3, but there's
> >> only a compatible here for g2.
> >
> > Yes, the SIUL2 GPIO hardware is the same for both S32G2 and S32G3 SoCs. I plan
> > to reuse the same compatible when I add the SIUL2 GPIO device tree node for
> > the S32G3 boards. Would that be ok?
>
> There are only few exceptions where re-using compatible is allowed. Was
> S32G on them? Please consult existing practice/maintainers and past reviews.
Pretty sure I had a similar conversation about another peripheral on
these devices, and it was established that these are not different fusings
etc, but rather are independent SoCs that reuse an IP core. Given that,
I'd expect to see a fallback compatible used here, as is the norm.
Cheers,
Conor.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support
2024-09-19 13:47 ` [PATCH v3 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support Andrei Stefanescu
@ 2024-09-22 14:35 ` kernel test robot
2024-09-22 21:47 ` Amit Singh Tomar
1 sibling, 0 replies; 19+ messages in thread
From: kernel test robot @ 2024-09-22 14:35 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: oe-kbuild-all, linux-gpio, devicetree, linux-kernel,
linux-arm-kernel, NXP S32 Linux Team, Andrei Stefanescu
Hi Andrei,
kernel test robot noticed the following build errors:
[auto build test ERROR on brgl/gpio/for-next]
[also build test ERROR on driver-core/driver-core-testing driver-core/driver-core-next driver-core/driver-core-linus robh/for-next linus/master v6.11 next-20240920]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andrei-Stefanescu/drivers-provide-devm_platform_get_and_ioremap_resource_byname/20240919-215018
base: https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link: https://lore.kernel.org/r/20240919134732.2626144-4-andrei.stefanescu%40oss.nxp.com
patch subject: [PATCH v3 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support
config: powerpc-randconfig-r133-20240921 (https://download.01.org/0day-ci/archive/20240922/202409222107.1XGvOBqS-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 14.1.0
reproduce: (https://download.01.org/0day-ci/archive/20240922/202409222107.1XGvOBqS-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409222107.1XGvOBqS-lkp@intel.com/
All errors (new ones prefixed by >>, old ones prefixed by <<):
WARNING: modpost: missing MODULE_DESCRIPTION() in mm/kasan/kasan_test_module.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/usb/serial/usb-serial-simple.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_userspace.o
>> ERROR: modpost: "__udivdi3" [drivers/gpio/gpio-siul2-s32g2.ko] undefined!
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs
2024-09-21 21:58 ` Conor Dooley
@ 2024-09-22 21:04 ` Krzysztof Kozlowski
2024-09-22 21:07 ` Conor Dooley
0 siblings, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2024-09-22 21:04 UTC (permalink / raw)
To: Conor Dooley
Cc: Andrei Stefanescu, Linus Walleij, Bartosz Golaszewski,
Rob Herring, 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 Sat, Sep 21, 2024 at 10:58:46PM +0100, Conor Dooley wrote:
> On Fri, Sep 20, 2024 at 03:40:31PM +0200, Krzysztof Kozlowski wrote:
> > On 20/09/2024 15:33, Andrei Stefanescu wrote:
> > > Hi Conor,
> > >
> > > Thank you for your review!
> > >
> > > On 20/09/2024 15:46, Conor Dooley wrote:
> > >> On Thu, Sep 19, 2024 at 04:47:22PM +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 | 107 ++++++++++++++++++
> > >>> 1 file changed, 107 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..0548028e6745
> > >>> --- /dev/null
> > >>> +++ b/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml
> > >>> @@ -0,0 +1,107 @@
> > >>> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
> > >>> +# Copyright 2024 NXP
> > >>> +%YAML 1.2
> > >>> +---
> > >>> +$id: http://devicetree.org/schemas/gpio/nxp,s32g2-siul2-gpio.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
> > >>
> > >> Commit message and binding description say s32g2 and s32g3, but there's
> > >> only a compatible here for g2.
> > >
> > > Yes, the SIUL2 GPIO hardware is the same for both S32G2 and S32G3 SoCs. I plan
> > > to reuse the same compatible when I add the SIUL2 GPIO device tree node for
> > > the S32G3 boards. Would that be ok?
> >
> > There are only few exceptions where re-using compatible is allowed. Was
> > S32G on them? Please consult existing practice/maintainers and past reviews.
Just in case this was not clear - comment "please consult existing..."
was towards Andrei, not you Conor.
>
> Pretty sure I had a similar conversation about another peripheral on
> these devices, and it was established that these are not different fusings
> etc, but rather are independent SoCs that reuse an IP core. Given that,
> I'd expect to see a fallback compatible used here, as is the norm.
Yep.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs
2024-09-19 13:47 ` [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs Andrei Stefanescu
2024-09-20 12:46 ` Conor Dooley
@ 2024-09-22 21:04 ` Krzysztof Kozlowski
2024-09-23 15:05 ` Andrei Stefanescu
1 sibling, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2024-09-22 21:04 UTC (permalink / raw)
To: Andrei Stefanescu
Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring,
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 Thu, Sep 19, 2024 at 04:47:22PM +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 | 107 ++++++++++++++++++
> 1 file changed, 107 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..0548028e6745
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml
> @@ -0,0 +1,107 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
Different license - see checkpatch.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs
2024-09-22 21:04 ` Krzysztof Kozlowski
@ 2024-09-22 21:07 ` Conor Dooley
2024-09-23 10:47 ` Andrei Stefanescu
0 siblings, 1 reply; 19+ messages in thread
From: Conor Dooley @ 2024-09-22 21:07 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Andrei Stefanescu, Linus Walleij, Bartosz Golaszewski,
Rob Herring, 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
[-- Attachment #1: Type: text/plain, Size: 1518 bytes --]
On Sun, Sep 22, 2024 at 11:04:22PM +0200, Krzysztof Kozlowski wrote:
> On Sat, Sep 21, 2024 at 10:58:46PM +0100, Conor Dooley wrote:
> > On Fri, Sep 20, 2024 at 03:40:31PM +0200, Krzysztof Kozlowski wrote:
> > > On 20/09/2024 15:33, Andrei Stefanescu wrote:
> > > >>> +properties:
> > > >>> + compatible:
> > > >>> + items:
> > > >>> + - const: nxp,s32g2-siul2-gpio
> > > >>
> > > >> Commit message and binding description say s32g2 and s32g3, but there's
> > > >> only a compatible here for g2.
> > > >
> > > > Yes, the SIUL2 GPIO hardware is the same for both S32G2 and S32G3 SoCs. I plan
> > > > to reuse the same compatible when I add the SIUL2 GPIO device tree node for
> > > > the S32G3 boards. Would that be ok?
> > >
> > > There are only few exceptions where re-using compatible is allowed. Was
> > > S32G on them? Please consult existing practice/maintainers and past reviews.
>
> Just in case this was not clear - comment "please consult existing..."
> was towards Andrei, not you Conor.
Oh I know, I was just passing through and figured I may as well leave a
comment repeating what I said on the other devices :)
> > Pretty sure I had a similar conversation about another peripheral on
> > these devices, and it was established that these are not different fusings
> > etc, but rather are independent SoCs that reuse an IP core. Given that,
> > I'd expect to see a fallback compatible used here, as is the norm.
>
> Yep.
>
> Best regards,
> Krzysztof
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support
2024-09-19 13:47 ` [PATCH v3 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support Andrei Stefanescu
2024-09-22 14:35 ` kernel test robot
@ 2024-09-22 21:47 ` Amit Singh Tomar
2024-09-23 10:57 ` Andrei Stefanescu
1 sibling, 1 reply; 19+ messages in thread
From: Amit Singh Tomar @ 2024-09-22 21:47 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
Hi,
>
> 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 | 576 ++++++++++++++++++++++++++++++++
> 3 files changed, 587 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..a69cbb3bcfaf
> --- /dev/null
> +++ b/drivers/gpio/gpio-siul2-s32g2.c
> @@ -0,0 +1,576 @@
> +// 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)
nit: Parentheses are not required here, please remove it.
> +
> +#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)
> +{
> + guard(raw_spinlock_irqsave)(&dev->lock);
> +
> + if (dir == GPIO_LINE_DIRECTION_IN)
> + __clear_bit(gpio, dev->pin_dir_bitmap);
> + else
> + __set_bit(gpio, dev->pin_dir_bitmap);
> +}
> +
> +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 [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs
2024-09-22 21:07 ` Conor Dooley
@ 2024-09-23 10:47 ` Andrei Stefanescu
2024-09-23 21:34 ` Conor Dooley
0 siblings, 1 reply; 19+ messages in thread
From: Andrei Stefanescu @ 2024-09-23 10:47 UTC (permalink / raw)
To: Conor Dooley, Krzysztof Kozlowski
Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring,
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,
On 23/09/2024 00:07, Conor Dooley wrote:
> On Sun, Sep 22, 2024 at 11:04:22PM +0200, Krzysztof Kozlowski wrote:
>> On Sat, Sep 21, 2024 at 10:58:46PM +0100, Conor Dooley wrote:
>>> On Fri, Sep 20, 2024 at 03:40:31PM +0200, Krzysztof Kozlowski wrote:
>>>> On 20/09/2024 15:33, Andrei Stefanescu wrote:
>
>>>>>>> +properties:
>>>>>>> + compatible:
>>>>>>> + items:
>>>>>>> + - const: nxp,s32g2-siul2-gpio
>>>>>>
>>>>>> Commit message and binding description say s32g2 and s32g3, but there's
>>>>>> only a compatible here for g2.
>>>>>
>>>>> Yes, the SIUL2 GPIO hardware is the same for both S32G2 and S32G3 SoCs. I plan
>>>>> to reuse the same compatible when I add the SIUL2 GPIO device tree node for
>>>>> the S32G3 boards. Would that be ok?
>>>>
>>>> There are only few exceptions where re-using compatible is allowed. Was
>>>> S32G on them? Please consult existing practice/maintainers and past reviews.
I will add another compatible: "nxp,s32g3-siul2-gpio" for the S32G3 SoC. We currently
also have the SIUL2 pinctrl driver in upstream with only one compatible:
"nxp,s32g2-siul2-pinctrl". Should I also send a separate patch to add an S32G3 compatible
to it?
>>
>> Just in case this was not clear - comment "please consult existing..."
>> was towards Andrei, not you Conor.
>
> Oh I know, I was just passing through and figured I may as well leave a
> comment repeating what I said on the other devices :)
>
>>> Pretty sure I had a similar conversation about another peripheral on
>>> these devices, and it was established that these are not different fusings
>>> etc, but rather are independent SoCs that reuse an IP core. Given that,
>>> I'd expect to see a fallback compatible used here, as is the norm.
>>
>> Yep.
>>
>> Best regards,
>> Krzysztof
>>
Best regards,
Andrei
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support
2024-09-22 21:47 ` Amit Singh Tomar
@ 2024-09-23 10:57 ` Andrei Stefanescu
0 siblings, 0 replies; 19+ messages in thread
From: Andrei Stefanescu @ 2024-09-23 10:57 UTC (permalink / raw)
To: Amit Singh Tomar, 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,
>> +#define SIUL2_PGPDO(N) (((N) ^ 1) * 2)
>> +#define S32G2_SIUL2_NUM 2
>> +#define S32G2_PADS_DTS_TAG_LEN (7)
> nit: Parentheses are not required here, please remove it.
Thank you for the review! I will remove the parentheses
from "S32G2_PADS_DTS_TAG_LEN" in v4.
Best regards,
Andrei
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs
2024-09-22 21:04 ` Krzysztof Kozlowski
@ 2024-09-23 15:05 ` Andrei Stefanescu
0 siblings, 0 replies; 19+ messages in thread
From: Andrei Stefanescu @ 2024-09-23 15:05 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring,
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 Krzysztof,
On 23/09/2024 00:04, Krzysztof Kozlowski wrote:
> On Thu, Sep 19, 2024 at 04:47:22PM +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 | 107 ++++++++++++++++++
>> 1 file changed, 107 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..0548028e6745
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/gpio/nxp,s32g2-siul2-gpio.yaml
>> @@ -0,0 +1,107 @@
>> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
>
> Different license - see checkpatch.
>
Thank you for pointing it out! I will fix it in v4.
> Best regards,
> Krzysztof
Best regards,
Andrei
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs
2024-09-23 10:47 ` Andrei Stefanescu
@ 2024-09-23 21:34 ` Conor Dooley
2024-09-23 21:35 ` Conor Dooley
0 siblings, 1 reply; 19+ messages in thread
From: Conor Dooley @ 2024-09-23 21:34 UTC (permalink / raw)
To: Andrei Stefanescu
Cc: Krzysztof Kozlowski, Linus Walleij, Bartosz Golaszewski,
Rob Herring, 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
[-- Attachment #1: Type: text/plain, Size: 1363 bytes --]
On Mon, Sep 23, 2024 at 01:47:25PM +0300, Andrei Stefanescu wrote:
> Hi,
>
> On 23/09/2024 00:07, Conor Dooley wrote:
> > On Sun, Sep 22, 2024 at 11:04:22PM +0200, Krzysztof Kozlowski wrote:
> >> On Sat, Sep 21, 2024 at 10:58:46PM +0100, Conor Dooley wrote:
> >>> On Fri, Sep 20, 2024 at 03:40:31PM +0200, Krzysztof Kozlowski wrote:
> >>>> On 20/09/2024 15:33, Andrei Stefanescu wrote:
> >
> >>>>>>> +properties:
> >>>>>>> + compatible:
> >>>>>>> + items:
> >>>>>>> + - const: nxp,s32g2-siul2-gpio
> >>>>>>
> >>>>>> Commit message and binding description say s32g2 and s32g3, but there's
> >>>>>> only a compatible here for g2.
> >>>>>
> >>>>> Yes, the SIUL2 GPIO hardware is the same for both S32G2 and S32G3 SoCs. I plan
> >>>>> to reuse the same compatible when I add the SIUL2 GPIO device tree node for
> >>>>> the S32G3 boards. Would that be ok?
> >>>>
> >>>> There are only few exceptions where re-using compatible is allowed. Was
> >>>> S32G on them? Please consult existing practice/maintainers and past reviews.
>
> I will add another compatible: "nxp,s32g3-siul2-gpio" for the S32G3 SoC. We currently
> also have the SIUL2 pinctrl driver in upstream with only one compatible:
> "nxp,s32g2-siul2-pinctrl". Should I also send a separate patch to add an S32G3 compatible
> to it?
>
That would be great, thanks.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs
2024-09-23 21:34 ` Conor Dooley
@ 2024-09-23 21:35 ` Conor Dooley
0 siblings, 0 replies; 19+ messages in thread
From: Conor Dooley @ 2024-09-23 21:35 UTC (permalink / raw)
To: Andrei Stefanescu
Cc: Krzysztof Kozlowski, Linus Walleij, Bartosz Golaszewski,
Rob Herring, 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
[-- Attachment #1: Type: text/plain, Size: 1656 bytes --]
On Mon, Sep 23, 2024 at 10:34:05PM +0100, Conor Dooley wrote:
> On Mon, Sep 23, 2024 at 01:47:25PM +0300, Andrei Stefanescu wrote:
> > Hi,
> >
> > On 23/09/2024 00:07, Conor Dooley wrote:
> > > On Sun, Sep 22, 2024 at 11:04:22PM +0200, Krzysztof Kozlowski wrote:
> > >> On Sat, Sep 21, 2024 at 10:58:46PM +0100, Conor Dooley wrote:
> > >>> On Fri, Sep 20, 2024 at 03:40:31PM +0200, Krzysztof Kozlowski wrote:
> > >>>> On 20/09/2024 15:33, Andrei Stefanescu wrote:
> > >
> > >>>>>>> +properties:
> > >>>>>>> + compatible:
> > >>>>>>> + items:
> > >>>>>>> + - const: nxp,s32g2-siul2-gpio
> > >>>>>>
> > >>>>>> Commit message and binding description say s32g2 and s32g3, but there's
> > >>>>>> only a compatible here for g2.
> > >>>>>
> > >>>>> Yes, the SIUL2 GPIO hardware is the same for both S32G2 and S32G3 SoCs. I plan
> > >>>>> to reuse the same compatible when I add the SIUL2 GPIO device tree node for
> > >>>>> the S32G3 boards. Would that be ok?
> > >>>>
> > >>>> There are only few exceptions where re-using compatible is allowed. Was
> > >>>> S32G on them? Please consult existing practice/maintainers and past reviews.
> >
> > I will add another compatible: "nxp,s32g3-siul2-gpio" for the S32G3 SoC. We currently
> > also have the SIUL2 pinctrl driver in upstream with only one compatible:
> > "nxp,s32g2-siul2-pinctrl". Should I also send a separate patch to add an S32G3 compatible
> > to it?
> >
>
> That would be great, thanks.
Wait, the driver doesn't need to have 2 compatibles, only the binding
does. Make the g3 compatible fall back to the g2 one, and the driver
doesn't need to change.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2024-09-23 21:35 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-19 13:47 [PATCH v3 0/4] gpio: siul2-s32g2: add initial GPIO driver Andrei Stefanescu
2024-09-19 13:47 ` [PATCH v3 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() Andrei Stefanescu
2024-09-19 13:47 ` [PATCH v3 2/4] dt-bindings: gpio: add support for NXP S32G2/S32G3 SoCs Andrei Stefanescu
2024-09-20 12:46 ` Conor Dooley
2024-09-20 13:33 ` Andrei Stefanescu
2024-09-20 13:40 ` Krzysztof Kozlowski
2024-09-21 21:58 ` Conor Dooley
2024-09-22 21:04 ` Krzysztof Kozlowski
2024-09-22 21:07 ` Conor Dooley
2024-09-23 10:47 ` Andrei Stefanescu
2024-09-23 21:34 ` Conor Dooley
2024-09-23 21:35 ` Conor Dooley
2024-09-22 21:04 ` Krzysztof Kozlowski
2024-09-23 15:05 ` Andrei Stefanescu
2024-09-19 13:47 ` [PATCH v3 3/4] gpio: siul2-s32g2: add NXP S32G2/S32G3 SoCs support Andrei Stefanescu
2024-09-22 14:35 ` kernel test robot
2024-09-22 21:47 ` Amit Singh Tomar
2024-09-23 10:57 ` Andrei Stefanescu
2024-09-19 13:47 ` [PATCH v3 4/4] MAINTAINERS: add MAINTAINER for S32G2 SIUL2 GPIO driver 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 read-only IMAP folder(s) and NNTP newsgroup(s).