Skip to contentSkip to conversation

Add pinctrl support for S32 SoC family

PATCH In review Chester Lin 3 participants 19 messages Feb 20, 2023 – Mar 9, 2023

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

v5 cover Add pinctrl support for S32 SoC family

Hello,

Here I want to introduce a new patch series, which aims to support IOMUX functions provided by SIUL2 [System Integration Unit Lite2] on S32 SoCs, such as S32G2. This series is originally from NXP's implementation on nxp-auto-linux repo[1] and it will be required by upstream kernel for supporting a variety of devices on S32 SoCs which need to config PINMUXs, such as PHYs and MAC controllers.

Thanks,
Chester

Changes in v5:
- dt-bindings: No change
- driver:
- Refactor register r/w access based on REGMAP_MMIO and regmap APIs.
- Tag PM functions with '__maybe_unused'.
- Add mask check while parsing pin ID from a pinmux value.
- Simplify s32_pinconf_mscr_* functions.

Changes in v4:
- Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/T/
- dt-bindings:
- Change the representation of available slew-rate DT values from register values to real frequencies.
- driver:
- Add a mapping table for converting the slew rates to register settings.
- Move driver files into an independent folder drivers/pinctrl/nxp
- Add a MAINTAINER patch.

Changes in v3:
- Link: https://lore.kernel.org/lkml/[email protected]/T/
- dt-bindings:
- Remove the minItems from reg because there's no optional item for

    s32g2.

- List supported properties of pinmux-node and pincfg-node and add more descriptions.
- Adjust the location of "required:".
- Fix descriptions and wordings.
- Rename the yaml file to nxp,s32g2-siul2-pinctrl.yaml.
- Rename pinctrl-s32g.c to pinctrl-s32g2.c
- Adjust Kconfig options [menu-invisible] and names [S32G -> S32G2].
- Add .suppress_bind_attrs
- Drop the .remove callback and replace the module_platform_driver() call with builtin_platform_driver()

Changes in v2:
- Link: https://lore.kernel.org/lkml/[email protected]/T/
- Move the "nxp,pins" ID range information from DT to the driver.
- dt-bindings:
- Fix schema issues.
- Add descriptions for reg entries.
- Revise the example.
- Refine the compatible name from "nxp,s32g-..." to "nxp,s32g2-...".
- Fix the copyright format suggested by NXP.

[1] https://github.com/nxp-auto-linux/linux/tree/bsp35.0-5.15.73-rt

Chester Lin (3):
dt-bindings: pinctrl: add schema for NXP S32 SoCs
pinctrl: add NXP S32 SoC family support
MAINTAINERS: Add NXP S32 pinctrl maintainer and reviewer

 .../pinctrl/nxp,s32g2-siul2-pinctrl.yaml      | 123 +++
 MAINTAINERS                                   |   8 +
 drivers/pinctrl/Kconfig                       |   1 +
 drivers/pinctrl/Makefile                      |   1 +
 drivers/pinctrl/nxp/Kconfig                   |  15 +
 drivers/pinctrl/nxp/Makefile                  |   4 +
 drivers/pinctrl/nxp/pinctrl-s32.h             |  75 ++
 drivers/pinctrl/nxp/pinctrl-s32cc.c           | 945 ++++++++++++++++++
 drivers/pinctrl/nxp/pinctrl-s32g2.c           | 773 ++++++++++++++
 9 files changed, 1945 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/nxp,s32g2-siul2-pinctrl.yaml
 create mode 100644 drivers/pinctrl/nxp/Kconfig
 create mode 100644 drivers/pinctrl/nxp/Makefile
 create mode 100644 drivers/pinctrl/nxp/pinctrl-s32.h
 create mode 100644 drivers/pinctrl/nxp/pinctrl-s32cc.c
 create mode 100644 drivers/pinctrl/nxp/pinctrl-s32g2.c
Signature · 1 line
2.37.3
#1 lore raw

PATCH v5 1/3 dt-bindings: pinctrl: add schema for NXP S32 SoCs

Add DT schema for the pinctrl driver of NXP S32 SoC family.

---

(No change in v5)

Changes in v4:
- Change the representation of available slew-rate DT values from register values to real frequencies.

 .../pinctrl/nxp,s32g2-siul2-pinctrl.yaml      | 123 ++++++++++++++++++
 1 file changed, 123 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/nxp,s32g2-siul2-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/nxp,s32g2-siul2-pinctrl.yaml new file +123 -0
new file mode 100644
index 000000000000..d49aafd8c5f4
@@ -0,0 +1,123 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2022 NXP
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/nxp,s32g2-siul2-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP S32G2 pin controller
+
+maintainers:
+  - Ghennadi Procopciuc <[email protected]>
+  - Chester Lin <[email protected]>
+
+description: |
+  S32G2 pinmux is implemented in SIUL2 (System Integration Unit Lite2),
+  whose memory map is split into two regions:
+    SIUL2_0 @ 0x4009c000
+    SIUL2_1 @ 0x44010000
+
+  Every SIUL2 region has multiple register types, and here only MSCR and
+  IMCR registers need to be revealed for kernel to configure pinmux.
+
+  Please note that some register indexes are reserved in S32G2, such as
+  MSCR102-MSCR111, MSCR123-MSCR143, IMCR84-IMCR118 and IMCR398-IMCR429.
+
+properties:
+  compatible:
+    enum:
+      - nxp,s32g2-siul2-pinctrl
+
+  reg:
+    description: |
+      A list of MSCR/IMCR register regions to be reserved.
+      - MSCR (Multiplexed Signal Configuration Register)
+        An MSCR register can configure the associated pin as either a GPIO pin
+        or a function output pin depends on the selected signal source.
+      - IMCR (Input Multiplexed Signal Configuration Register)
+        An IMCR register can configure the associated pin as function input
+        pin depends on the selected signal source.
+    items:
+      - description: MSCR registers group 0 in SIUL2_0
+      - description: MSCR registers group 1 in SIUL2_1
+      - description: MSCR registers group 2 in SIUL2_1
+      - description: IMCR registers group 0 in SIUL2_0
+      - description: IMCR registers group 1 in SIUL2_1
+      - description: IMCR registers group 2 in SIUL2_1
+
+patternProperties:
+  '-pins$':
+    type: object
+    additionalProperties: false
+
+    patternProperties:
+      '-grp[0-9]$':
+        type: object
+        allOf:
+          - $ref: pinmux-node.yaml#
+          - $ref: pincfg-node.yaml#
+        description: |
+          Pinctrl node's client devices specify pin muxes using subnodes,
+          which in turn use the standard properties below.
+
+        properties:
+          bias-disable: true
+          bias-high-impedance: true
+          bias-pull-up: true
+          bias-pull-down: true
+          drive-open-drain: true
+          input-enable: true
+          output-enable: true
+
+          pinmux:
+            description: |
+              An integer array for representing pinmux configurations of
+              a device. Each integer consists of a PIN_ID and a 4-bit
+              selected signal source(SSS) as IOMUX setting, which is
+              calculated as: pinmux = (PIN_ID << 4 | SSS)
+
+          slew-rate:
+            description: Supported slew rate based on Fmax values (MHz)
+            enum: [83, 133, 150, 166, 208]
+
+        additionalProperties: false
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    pinctrl@4009c240 {
+        compatible = "nxp,s32g2-siul2-pinctrl";
+
+              /* MSCR0-MSCR101 registers on siul2_0 */
+        reg = <0x4009c240 0x198>,
+              /* MSCR112-MSCR122 registers on siul2_1 */
+              <0x44010400 0x2c>,
+              /* MSCR144-MSCR190 registers on siul2_1 */
+              <0x44010480 0xbc>,
+              /* IMCR0-IMCR83 registers on siul2_0 */
+              <0x4009ca40 0x150>,
+              /* IMCR119-IMCR397 registers on siul2_1 */
+              <0x44010c1c 0x45c>,
+              /* IMCR430-IMCR495 registers on siul2_1 */
+              <0x440110f8 0x108>;
+
+        llce-can0-pins {
+            llce-can0-grp0 {
+                pinmux = <0x2b0>;
+                input-enable;
+                slew-rate = <208>;
+            };
+
+            llce-can0-grp1 {
+                pinmux = <0x2c2>;
+                output-enable;
+                slew-rate = <208>;
+            };
+        };
+    };
+...
Signature · 1 line
2.37.3
#2 lore raw

PATCH v5 2/3 pinctrl: add NXP S32 SoC family support

In reply to Chester Lin

Add the pinctrl driver for NXP S32 SoC family. This driver is mainly based on NXP's downstream implementation on nxp-auto-linux repo[1].

[1] https://github.com/nxp-auto-linux/linux/tree/bsp35.0-5.15.73-rt/drivers/pinctrl/freescale

---

Changes in v5:
- Refactor register r/w access based on REGMAP_MMIO and regmap APIs.
- Tag PM functions with '__maybe_unused'.
- Add mask check while parsing pin ID from a pinmux value.
- Simplify s32_pinconf_mscr_* functions.

Changes in v4:
- Add a mapping table for converting the slew rates to register settings.
- Move driver files into an independent folder drivers/pinctrl/nxp

 drivers/pinctrl/Kconfig             |   1 +
 drivers/pinctrl/Makefile            |   1 +
 drivers/pinctrl/nxp/Kconfig         |  15 +
 drivers/pinctrl/nxp/Makefile        |   4 +
 drivers/pinctrl/nxp/pinctrl-s32.h   |  75 +++
 drivers/pinctrl/nxp/pinctrl-s32cc.c | 945 ++++++++++++++++++++++++++++
 drivers/pinctrl/nxp/pinctrl-s32g2.c | 773 +++++++++++++++++++++++
 7 files changed, 1814 insertions(+)
 create mode 100644 drivers/pinctrl/nxp/Kconfig
 create mode 100644 drivers/pinctrl/nxp/Makefile
 create mode 100644 drivers/pinctrl/nxp/pinctrl-s32.h
 create mode 100644 drivers/pinctrl/nxp/pinctrl-s32cc.c
 create mode 100644 drivers/pinctrl/nxp/pinctrl-s32g2.c
drivers/pinctrl/Kconfig +1 -0
index 7d5f5458c72e..2ac142884b98 100644
@@ -535,6 +535,7 @@ source "drivers/pinctrl/meson/Kconfig"
 source "drivers/pinctrl/mvebu/Kconfig"
 source "drivers/pinctrl/nomadik/Kconfig"
 source "drivers/pinctrl/nuvoton/Kconfig"
+source "drivers/pinctrl/nxp/Kconfig"
 source "drivers/pinctrl/pxa/Kconfig"
 source "drivers/pinctrl/qcom/Kconfig"
 source "drivers/pinctrl/ralink/Kconfig"
drivers/pinctrl/Makefile +1 -0
index d5939840bb2a..c40397af024b 100644
@@ -64,6 +64,7 @@ obj-$(CONFIG_PINCTRL_MESON)	+= meson/
 obj-y				+= mvebu/
 obj-y				+= nomadik/
 obj-y				+= nuvoton/
+obj-y				+= nxp/
 obj-$(CONFIG_PINCTRL_PXA)	+= pxa/
 obj-$(CONFIG_ARCH_QCOM)		+= qcom/
 obj-$(CONFIG_PINCTRL_RALINK)	+= ralink/
drivers/pinctrl/nxp/Kconfig new file +15 -0
new file mode 100644
index 000000000000..abca7ef97003
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config PINCTRL_S32CC
+	bool
+	depends on ARCH_S32 && OF
+	select GENERIC_PINCTRL_GROUPS
+	select GENERIC_PINMUX_FUNCTIONS
+	select GENERIC_PINCONF
+	select REGMAP_MMIO
+
+config PINCTRL_S32G2
+	depends on ARCH_S32 && OF
+	bool "NXP S32G2 pinctrl driver"
+	select PINCTRL_S32CC
+	help
+	  Say Y here to enable the pinctrl driver for NXP S32G2 family SoCs
drivers/pinctrl/nxp/Makefile new file +4 -0
new file mode 100644
index 000000000000..c1cff4870b02
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+# NXP pin control
+obj-$(CONFIG_PINCTRL_S32CC)	+= pinctrl-s32cc.o
+obj-$(CONFIG_PINCTRL_S32G2)	+= pinctrl-s32g2.o
drivers/pinctrl/nxp/pinctrl-s32.h new file +75 -0

75 lines not on this page · raw message

drivers/pinctrl/nxp/pinctrl-s32cc.c new file +945 -0

945 lines not on this page · raw message

drivers/pinctrl/nxp/pinctrl-s32g2.c new file +773 -0

773 lines not on this page · raw message

Signature · 1 line
2.37.3
#3 lore raw

Re: [PATCH v5 2/3] pinctrl: add NXP S32 SoC family support

Mon, Feb 20, 2023 at 10:33:19AM +0800, Chester Lin kirjoitti:

Quoted 2 lines

Add the pinctrl driver for NXP S32 SoC family. This driver is mainly based on NXP's downstream implementation on nxp-auto-linux repo[1].

Seems Linus already applied this, but still some comments for the future, some for the followups. However, personally I prefer this to be dropped and redone because too many things here and there.

Quoted 1 line

[1] https://github.com/nxp-auto-linux/linux/tree/bsp35.0-5.15.73-rt/drivers/pinctrl/freescale

This can be transformed to Link: tag.

Quoted 8 lines

Is it for real?!
Quite a long chain and none of Co-developed-by.

...

Review

Quoted 1 line
(quoted diff) +1 -0
+	depends on ARCH_S32 && OF

Is OF necessary? Can it be

	depends OF || COMPILE_TEST

?

...

Review

Quoted 1 line
(quoted diff) +1 -0
+	depends on ARCH_S32 && OF

Ditto.

...

drivers/pinctrl/nxp/pinctrl-s32.h line 28

Quoted 13 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +13 -0
+/**
+ * struct s32_pin_group - describes an S32 pin group
+ * @name: the name of this specific pin group
+ * @npins: the number of pins in this group array, i.e. the number of
+ *         elements in pin_ids and pin_sss so we can iterate over that array
+ * @pin_ids: an array of pin IDs in this group
+ * @pin_sss: an array of source signal select configs paired with pin_ids
+ */
+struct s32_pin_group {
+	const char *name;
+	unsigned int npins;
+	unsigned int *pin_ids;
+	unsigned int *pin_sss;

Why didn't you embed struct pingroup?

drivers/pinctrl/nxp/pinctrl-s32.h line 41

Quoted 13 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +13 -0
+};
+
+/**
+ * struct s32_pmx_func - describes S32 pinmux functions
+ * @name: the name of this specific function
+ * @groups: corresponding pin groups
+ * @num_groups: the number of groups
+ */
+struct s32_pmx_func {
+	const char *name;
+	const char **groups;
+	unsigned int num_groups;
+};

struct pinfunction.

...

drivers/pinctrl/nxp/pinctrl-s32.h line 74

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +4 -0
+#ifdef CONFIG_PM_SLEEP
+int __maybe_unused s32_pinctrl_resume(struct device *dev);
+int __maybe_unused s32_pinctrl_suspend(struct device *dev);
+#endif

Please, consider using new PM macros, like pm_ptr().

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 49

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+static u32 get_pin_no(u32 pinmux)
+{
+	return (pinmux & S32_PIN_ID_MASK) >> __ffs(S32_PIN_ID_MASK);

Oh, don't you have MASK to be 2^x - 1? Why to drag this with __ffs()? Just define a complement _SHIFT.

Quoted 1 line

+}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 228

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +4 -0
+	n_pins = of_property_count_elems_of_size(np, "pinmux", sizeof(u32));
+	if (n_pins < 0) {
+		dev_warn(dev, "Unable to find 'pinmux' property in node %s.\n",
+			np->name);

Use %pOFn instead of %s.

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	} else if (!n_pins) {
+		return -EINVAL;
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 320

Quoted 1 line
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +1 -0
+	for (i = 0; i < grp->npins; ++i) {

Why pre-increment?

drivers/pinctrl/nxp/pinctrl-s32cc.c line 328

Quoted 8 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +8 -0
+		if (s32_check_pin(pctldev, grp->pin_ids[i]) != 0) {
+			dev_err(info->dev, "invalid pin: %d in group: %d\n",
+				grp->pin_ids[i], group);
+			return -EINVAL;
+		}
+	}
+
+	for (i = 0, ret = 0; i < grp->npins && !ret; ++i) {

Ditto.

drivers/pinctrl/nxp/pinctrl-s32cc.c line 330

Quoted 2 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +2 -0
+		ret = s32_regmap_update(pctldev, grp->pin_ids[i],
+					S32_MSCR_SSS_MASK, grp->pin_sss[i]);

Traditional pattern is

		if (ret)
			return ret;

This avoids first assignment of the ret.

drivers/pinctrl/nxp/pinctrl-s32cc.c line 236

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	}
+
+	return ret;
	return 0;
Quoted 1 line

+}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 379

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	ret = s32_regmap_read(pctldev, offset, &config);
+	if (ret != 0)
+		return -EINVAL;

Why not

	if (ret)
		return ret;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 390

Quoted 1 line
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +1 -0
+	list_add(&(gpio_pin->list), &(ipctl->gpio_configs));

Too many parentheses.

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 412

Quoted 2 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +2 -0
+	list_for_each_safe(pos, tmp, &ipctl->gpio_configs) {
+		gpio_pin = list_entry(pos, struct gpio_pin_config, list);

Why not list_for_each_entry_safe() ?

Quoted 11 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +11 -0
+		if (gpio_pin->pin_id == offset) {
+			ret = s32_regmap_write(pctldev, gpio_pin->pin_id,
+						 gpio_pin->config);
+			if (ret != 0)
+				goto unlock;
+
+			list_del(pos);
+			kfree(gpio_pin);
+			break;
+		}
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 464

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+static int s32_get_slew_regval(int arg)
+{
+	int i;
	unsigned int i;

+ Blank line.

Quoted 8 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +8 -0
+	/* Translate a real slew rate (MHz) to a register value */
+	for (i = 0; i < ARRAY_SIZE(support_slew); i++) {
+		if (arg == support_slew[i])
+			return i;
+	}
+
+	return -EINVAL;
+}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 513

Quoted 7 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +6 -0
+	case PIN_CONFIG_BIAS_PULL_UP:
+		if (arg)
+			*config |= S32_MSCR_PUS;
+		else
+			*config &= ~S32_MSCR_PUS;
 
+		fallthrough;

It's quite easy to miss this and tell us about how is it supposed to work with PU + PD?

drivers/pinctrl/nxp/pinctrl-s32cc.c line 524

Quoted 11 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +11 -0
+	case PIN_CONFIG_BIAS_PULL_DOWN:
+		if (arg)
+			*config |= S32_MSCR_PUE;
+		else
+			*config &= ~S32_MSCR_PUE;
+		*mask |= S32_MSCR_PUE | S32_MSCR_PUS;
+		break;
+	case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
+		*config &= ~(S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE);
+		*mask |= S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE;
+		fallthrough;

Ditto.

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +4 -0
+	case PIN_CONFIG_BIAS_DISABLE:
+		*config &= ~(S32_MSCR_PUS | S32_MSCR_PUE);
+		*mask |= S32_MSCR_PUS | S32_MSCR_PUE;
+		break;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 545

Quoted 1 line
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +1 -0
+	if (s32_check_pin(pctldev, pin_id) != 0)

Shadowing an error?

Quoted 1 line
(quoted diff) +1 -0
+		return -EINVAL;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 566

Quoted 5 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +5 -0
+	ret = s32_regmap_update(pctldev, pin_id, mask, config);
+
+	dev_dbg(ipctl->dev, "update: pin %d cfg 0x%x\n", pin_id, config);
+
+	return ret;

You are not using ret in between, hence

	return _regmap_update(...);

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 610

Quoted 8 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +8 -0
+static void s32_pinconf_dbg_show(struct pinctrl_dev *pctldev,
+				 struct seq_file *s, unsigned int pin_id)
+{
+	unsigned int config;
+	int ret = s32_regmap_read(pctldev, pin_id, &config);
+
+	if (!ret)
+		seq_printf(s, "0x%x", config);
	int ret;

	ret = s32_regmap_read(pctldev, pin_id, &config);
	if (ret)
		return;

	seq_printf(s, "0x%x", config);
Quoted 1 line

+}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 731

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +2 -0
+	npins = of_property_count_elems_of_size(np, "pinmux", sizeof(u32));
 
+

Unneccessary blank line.

Quoted 9 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +9 -0
+	if (npins < 0) {
+		dev_err(dev, "Failed to read 'pinmux' property in node %s.\n",
+			np->name);
+		return;
+	}
+	if (!npins) {
+		dev_err(dev, "The group %s has no pins.\n", np->name);
+		return;
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 748

Quoted 6 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +5 -0
+	grp->pin_ids = devm_kcalloc(info->dev, grp->npins,
+				    sizeof(unsigned int), GFP_KERNEL);
+	grp->pin_sss = devm_kcalloc(info->dev, grp->npins,
+				    sizeof(unsigned int), GFP_KERNEL);
 
+

Ditto.

drivers/pinctrl/nxp/pinctrl-s32cc.c line 751

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	if (!grp->pin_ids || !grp->pin_sss) {
 
+		dev_err(dev, "Failed to allocate memory for the group %s.\n",
+			np->name);

We do not print ENOMEM error messages.

Quoted 2 lines
(quoted diff) +2 -0
+		return;
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 787

Quoted 2 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +2 -0
+	func->groups = devm_kzalloc(info->dev,
+			func->num_groups * sizeof(char *), GFP_KERNEL);

First of all, this is devm_kcalloc().
Second, where is the error check?

Quoted 6 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +6 -0
+	for_each_child_of_node(np, child) {
+		func->groups[i] = child->name;
+		grp = &info->groups[info->grp_index++];
+		s32_pinctrl_parse_groups(child, grp, info);
+		i++;
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 820

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	ipctl->regions = devm_kzalloc(&pdev->dev,
+				      mem_regions * sizeof(*(ipctl->regions)),
+				      GFP_KERNEL);

devm_kcalloc()

Quoted 2 lines
(quoted diff) +2 -0
+	if (!ipctl->regions)
+		return -ENOMEM;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 856

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	info->functions = devm_kzalloc(&pdev->dev,
+				       nfuncs * sizeof(struct s32_pmx_func),
+				       GFP_KERNEL);

Ditto.

Quoted 2 lines
(quoted diff) +2 -0
+	if (!info->functions)
+		return -ENOMEM;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 865

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	info->groups = devm_kzalloc(&pdev->dev,
+				    info->ngroups * sizeof(struct s32_pin_group),
+				    GFP_KERNEL);

Ditto.

Quoted 2 lines
(quoted diff) +2 -0
+	if (!info->groups)
+		return -ENOMEM;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 926

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	ipctl->pctl = devm_pinctrl_register(&pdev->dev, s32_pinctrl_desc,
+					    ipctl);
 
+

Unneeded blank line.

drivers/pinctrl/nxp/pinctrl-s32cc.c line 929

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	if (IS_ERR(ipctl->pctl)) {
 
+		dev_err(&pdev->dev, "could not register s32 pinctrl driver\n");
+		return PTR_ERR(ipctl->pctl);
	return dev_err_probe(...);
Quoted 1 line
(quoted diff) +1 -0
+	}

...

drivers/pinctrl/nxp/pinctrl-s32g2.c

Quoted 1 line
drivers/pinctrl/nxp/pinctrl-s32g2.c +0 -0

Similar issues has to be addressed, if any.

...

drivers/pinctrl/nxp/pinctrl-s32g2.c line 750

Quoted 2 lines
drivers/pinctrl/nxp/pinctrl-s32g2.c +2 -0
+	return s32_pinctrl_probe
+			(pdev, (struct s32_pinctrl_soc_info *) of_id->data);

Broken indentation.

...

drivers/pinctrl/nxp/pinctrl-s32g2.c line 756

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32g2.c +4 -0
+static const struct dev_pm_ops s32g_pinctrl_pm_ops = {
+	SET_LATE_SYSTEM_SLEEP_PM_OPS(s32_pinctrl_suspend,
+				     s32_pinctrl_resume)
+};

Consider using DEFINE_* PM macros.

...

drivers/pinctrl/nxp/pinctrl-s32g2.c line 761

Quoted 5 lines
drivers/pinctrl/nxp/pinctrl-s32g2.c +4 -0
+static struct platform_driver s32g_pinctrl_driver = {
+	.driver = {
+		.name = "s32g-siul2-pinctrl",
 
+		.owner = THIS_MODULE,

Duplicate assignment.

drivers/pinctrl/nxp/pinctrl-s32g2.c line 768

Quoted 8 lines
drivers/pinctrl/nxp/pinctrl-s32g2.c +7 -0
+		.of_match_table = s32_pinctrl_of_match,
+		.pm = &s32g_pinctrl_pm_ops,
+		.suppress_bind_attrs = true,
+	},
+	.probe = s32g_pinctrl_probe,
+};
 
+

Unnecessary blank line.

Quoted 1 line

+builtin_platform_driver(s32g_pinctrl_driver);

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

Re: [PATCH v5 2/3] pinctrl: add NXP S32 SoC family support

Hi Andy,

Thanks for reviewing this patch!

Quoted 21 lines · On Tue, Mar 07, 2023 at 01:28:09AM +0200, [email protected] wrote:

Mon, Feb 20, 2023 at 10:33:19AM +0800, Chester Lin kirjoitti:

Quoted 2 lines

Add the pinctrl driver for NXP S32 SoC family. This driver is mainly based on NXP's downstream implementation on nxp-auto-linux repo[1].

Seems Linus already applied this, but still some comments for the future, some for the followups. However, personally I prefer this to be dropped and redone because too many things here and there.

Quoted 1 line

[1] https://github.com/nxp-auto-linux/linux/tree/bsp35.0-5.15.73-rt/drivers/pinctrl/freescale

This can be transformed to Link: tag.

Quoted 8 lines
Quoted 3 lines

Is it for real?!
Quite a long chain and none of Co-developed-by.

They are developers who contribute codes and have Signed-off-bys in NXP's downstream version. Since their implementations can still be seen in this upstream one, I prefer to list them all. Indeed a part of them who also actively work with me on upstreaming this driver can be listed as Co-developed-by, but the driver patch has been merged into the maintainer's for-next so I would not change this part unless the driver patch needs to be reverted and re-submitted in the end.

Sorry for the patch header that I mess up anyway.

Quoted 5 lines

...

Review

Quoted 1 line
(quoted diff) +1 -0
+	depends on ARCH_S32 && OF

Is OF necessary? Can it be

I think it's required since the driver file refers to of_* APIs.

Quoted 13 lines
	depends OF || COMPILE_TEST

?

...

Review

Quoted 1 line
(quoted diff) +1 -0
+	depends on ARCH_S32 && OF

Ditto.

...

Quoted 16 lines

drivers/pinctrl/nxp/pinctrl-s32.h line 28

Quoted 13 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +13 -0
+/**
+ * struct s32_pin_group - describes an S32 pin group
+ * @name: the name of this specific pin group
+ * @npins: the number of pins in this group array, i.e. the number of
+ *         elements in pin_ids and pin_sss so we can iterate over that array
+ * @pin_ids: an array of pin IDs in this group
+ * @pin_sss: an array of source signal select configs paired with pin_ids
+ */
+struct s32_pin_group {
+	const char *name;
+	unsigned int npins;
+	unsigned int *pin_ids;
+	unsigned int *pin_sss;

Why didn't you embed struct pingroup?

I did think about that but there's an additional 'pin_sss' which could make code a bit messy. For example:

	s32_regmap_update(pctldev, grp->grp.pins[i],
			  S32_MSCR_SSS_MASK, grp->pin_sss[i]);
Quoted 7 lines
Quoted 7 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +7 -0
+};
+
+/**
+ * struct s32_pmx_func - describes S32 pinmux functions
+ * @name: the name of this specific function
+ * @groups: corresponding pin groups
+ * @num_groups: the number of groups
Quoted 9 lines

drivers/pinctrl/nxp/pinctrl-s32.h line 41

Quoted 6 lines

+ */

drivers/pinctrl/nxp/pinctrl-s32.h new file +5 -0
+struct s32_pmx_func {
+	const char *name;
+	const char **groups;
+	unsigned int num_groups;
+};

struct pinfunction.

Thanks for your information. I was not aware of this new struct since it just got merged recently.

Quoted 9 lines

...

drivers/pinctrl/nxp/pinctrl-s32.h line 74

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +4 -0
+#ifdef CONFIG_PM_SLEEP
+int __maybe_unused s32_pinctrl_resume(struct device *dev);
+int __maybe_unused s32_pinctrl_suspend(struct device *dev);
+#endif

Please, consider using new PM macros, like pm_ptr().

Maybe pm_sleep_ptr() is more accurate?

Quoted 9 lines

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 49

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+static u32 get_pin_no(u32 pinmux)
+{
+	return (pinmux & S32_PIN_ID_MASK) >> __ffs(S32_PIN_ID_MASK);

Oh, don't you have MASK to be 2^x - 1? Why to drag this with __ffs()? Just define a complement _SHIFT.

Will fix it.

Quoted 11 lines
Quoted 1 line

+}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 228

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +4 -0
+	n_pins = of_property_count_elems_of_size(np, "pinmux", sizeof(u32));
+	if (n_pins < 0) {
+		dev_warn(dev, "Unable to find 'pinmux' property in node %s.\n",
+			np->name);

Use %pOFn instead of %s.

Will change it.

Quoted 9 lines
Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	} else if (!n_pins) {
+		return -EINVAL;
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 320

Quoted 1 line
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +1 -0
+	for (i = 0; i < grp->npins; ++i) {

Why pre-increment?

Will change that to keep code style consistency.

Quoted 32 lines

drivers/pinctrl/nxp/pinctrl-s32cc.c line 328

Quoted 9 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +8 -0
+		if (s32_check_pin(pctldev, grp->pin_ids[i]) != 0) {
+			dev_err(info->dev, "invalid pin: %d in group: %d\n",
+				grp->pin_ids[i], group);
+			return -EINVAL;
+		}
+	}
+
+	for (i = 0, ret = 0; i < grp->npins && !ret; ++i) {

Ditto.

drivers/pinctrl/nxp/pinctrl-s32cc.c line 330

Quoted 2 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +2 -0
+		ret = s32_regmap_update(pctldev, grp->pin_ids[i],
+					S32_MSCR_SSS_MASK, grp->pin_sss[i]);

Traditional pattern is

		if (ret)
			return ret;

This avoids first assignment of the ret.

drivers/pinctrl/nxp/pinctrl-s32cc.c line 236

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	}
+
+	return ret;
	return 0;
Quoted 1 line

+}

...

Quoted 9 lines

drivers/pinctrl/nxp/pinctrl-s32cc.c line 379

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	ret = s32_regmap_read(pctldev, offset, &config);
+	if (ret != 0)
+		return -EINVAL;

Why not

	if (ret)
		return ret;

Will fix this and the following error code shadowings, return handlings and blanks.

Thanks for your reminder.

Quoted 6 lines

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 390

Quoted 1 line
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +1 -0
+	list_add(&(gpio_pin->list), &(ipctl->gpio_configs));

Too many parentheses.

Quoted 6 lines

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 412

Quoted 2 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +2 -0
+	list_for_each_safe(pos, tmp, &ipctl->gpio_configs) {
+		gpio_pin = list_entry(pos, struct gpio_pin_config, list);

Why not list_for_each_entry_safe() ?

Will change it.

Quoted 41 lines
Quoted 13 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +11 -0
+		if (gpio_pin->pin_id == offset) {
+			ret = s32_regmap_write(pctldev, gpio_pin->pin_id,
+						 gpio_pin->config);
+			if (ret != 0)
+				goto unlock;
+
+			list_del(pos);
+			kfree(gpio_pin);
+			break;
+		}
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 464

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+static int s32_get_slew_regval(int arg)
+{
+	int i;
	unsigned int i;

+ Blank line.

Quoted 8 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +8 -0
+	/* Translate a real slew rate (MHz) to a register value */
+	for (i = 0; i < ARRAY_SIZE(support_slew); i++) {
+		if (arg == support_slew[i])
+			return i;
+	}
+
+	return -EINVAL;
+}

...

Quoted 5 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +5 -0
+	case PIN_CONFIG_BIAS_PULL_UP:
+		if (arg)
+			*config |= S32_MSCR_PUS;
+		else
+			*config &= ~S32_MSCR_PUS;
Quoted 4 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+		fallthrough;

It's quite easy to miss this and tell us about how is it supposed to work with PU + PD?

I admit that it's ambiguous and should be improved in order to have better readability.

In a S32G2 MSCR register, there are two register bits related to pull up/down functions:

PUE (Pull Enable, MSCR[13]): 0'b: Disabled, 1'b: Enabled PUS (Pull Select, MSCR[12]): 0'b: Pull Down, 1'b: Pull Up

The dt properties could be like these:

1) 'bias-pull-up' or 'bias-pull-up: true' --> arg = 1 In this case both PUE and PUS are set.

2) 'bias-pull-up: false' --> arg = 0
In this case both PUE and PUS are cleared since the pull-up function must be disabled.

Quoted 5 lines
Quoted 5 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +5 -0
+	case PIN_CONFIG_BIAS_PULL_DOWN:
+		if (arg)
+			*config |= S32_MSCR_PUE;
+		else
+			*config &= ~S32_MSCR_PUE;
Quoted 9 lines

drivers/pinctrl/nxp/pinctrl-s32cc.c line 524

Quoted 6 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +6 -0
+		*mask |= S32_MSCR_PUE | S32_MSCR_PUS;
+		break;
+	case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
+		*config &= ~(S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE);
+		*mask |= S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE;
+		fallthrough;

Ditto.

It's similar to the case 'PIN_CONFIG_BIAS_PULL_UP' although the PUS bit is assumed as 0 via the config variable so only the PUE bit needs to be configured, for example:

1) 'bias-pull-down' or 'bias-pull-down: true' --> arg = 1 PUE is set and PUS is cleared.

2) 'bias-pull-down: false' --> arg = 0
In this case both PUE and PUS are cleared since the pull-down function must be disabled.

Quoted 74 lines
Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +4 -0
+	case PIN_CONFIG_BIAS_DISABLE:
+		*config &= ~(S32_MSCR_PUS | S32_MSCR_PUE);
+		*mask |= S32_MSCR_PUS | S32_MSCR_PUE;
+		break;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 545

Quoted 1 line
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +1 -0
+	if (s32_check_pin(pctldev, pin_id) != 0)

Shadowing an error?

Quoted 1 line
(quoted diff) +1 -0
+		return -EINVAL;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 566

Quoted 5 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +5 -0
+	ret = s32_regmap_update(pctldev, pin_id, mask, config);
+
+	dev_dbg(ipctl->dev, "update: pin %d cfg 0x%x\n", pin_id, config);
+
+	return ret;

You are not using ret in between, hence

	return _regmap_update(...);

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 610

Quoted 8 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +8 -0
+static void s32_pinconf_dbg_show(struct pinctrl_dev *pctldev,
+				 struct seq_file *s, unsigned int pin_id)
+{
+	unsigned int config;
+	int ret = s32_regmap_read(pctldev, pin_id, &config);
+
+	if (!ret)
+		seq_printf(s, "0x%x", config);
	int ret;

	ret = s32_regmap_read(pctldev, pin_id, &config);
	if (ret)
		return;

	seq_printf(s, "0x%x", config);
Quoted 1 line

+}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 731

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +2 -0
+	npins = of_property_count_elems_of_size(np, "pinmux", sizeof(u32));
 
+

Unneccessary blank line.

Quoted 9 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +9 -0
+	if (npins < 0) {
+		dev_err(dev, "Failed to read 'pinmux' property in node %s.\n",
+			np->name);
+		return;
+	}
+	if (!npins) {
+		dev_err(dev, "The group %s has no pins.\n", np->name);
+		return;
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 748

Quoted 6 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +5 -0
+	grp->pin_ids = devm_kcalloc(info->dev, grp->npins,
+				    sizeof(unsigned int), GFP_KERNEL);
+	grp->pin_sss = devm_kcalloc(info->dev, grp->npins,
+				    sizeof(unsigned int), GFP_KERNEL);
 
+
Quoted 9 lines

Ditto.

drivers/pinctrl/nxp/pinctrl-s32cc.c line 751

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	if (!grp->pin_ids || !grp->pin_sss) {
 
+		dev_err(dev, "Failed to allocate memory for the group %s.\n",
+			np->name);

We do not print ENOMEM error messages.

Will drop it.

Quoted 11 lines
Quoted 2 lines
(quoted diff) +2 -0
+		return;
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 787

Quoted 2 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +2 -0
+	func->groups = devm_kzalloc(info->dev,
+			func->num_groups * sizeof(char *), GFP_KERNEL);

First of all, this is devm_kcalloc().
Second, where is the error check?

Will fix it.

Quoted 47 lines
Quoted 6 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +6 -0
+	for_each_child_of_node(np, child) {
+		func->groups[i] = child->name;
+		grp = &info->groups[info->grp_index++];
+		s32_pinctrl_parse_groups(child, grp, info);
+		i++;
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 820

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	ipctl->regions = devm_kzalloc(&pdev->dev,
+				      mem_regions * sizeof(*(ipctl->regions)),
+				      GFP_KERNEL);

devm_kcalloc()

Quoted 2 lines
(quoted diff) +2 -0
+	if (!ipctl->regions)
+		return -ENOMEM;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 856

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	info->functions = devm_kzalloc(&pdev->dev,
+				       nfuncs * sizeof(struct s32_pmx_func),
+				       GFP_KERNEL);

Ditto.

Quoted 2 lines
(quoted diff) +2 -0
+	if (!info->functions)
+		return -ENOMEM;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 865

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	info->groups = devm_kzalloc(&pdev->dev,
+				    info->ngroups * sizeof(struct s32_pin_group),
+				    GFP_KERNEL);

Ditto.

Quoted 2 lines
(quoted diff) +2 -0
+	if (!info->groups)
+		return -ENOMEM;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 926

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	ipctl->pctl = devm_pinctrl_register(&pdev->dev, s32_pinctrl_desc,
+					    ipctl);
 
+
Quoted 9 lines

Unneeded blank line.

drivers/pinctrl/nxp/pinctrl-s32cc.c line 929

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	if (IS_ERR(ipctl->pctl)) {
 
+		dev_err(&pdev->dev, "could not register s32 pinctrl driver\n");
+		return PTR_ERR(ipctl->pctl);
	return dev_err_probe(...);

Will change it, thanks!

Quoted 8 lines
Quoted 1 line
(quoted diff) +1 -0
+	}

...

drivers/pinctrl/nxp/pinctrl-s32g2.c

Quoted 1 line
drivers/pinctrl/nxp/pinctrl-s32g2.c +0 -0

Similar issues has to be addressed, if any.

Quoted 9 lines

...

drivers/pinctrl/nxp/pinctrl-s32g2.c line 750

Quoted 2 lines
drivers/pinctrl/nxp/pinctrl-s32g2.c +2 -0
+	return s32_pinctrl_probe
+			(pdev, (struct s32_pinctrl_soc_info *) of_id->data);

Broken indentation.

...

The checkpatch.pl seems not to warn this but I will definitely improve it.

Quoted 7 lines

drivers/pinctrl/nxp/pinctrl-s32g2.c line 756

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32g2.c +4 -0
+static const struct dev_pm_ops s32g_pinctrl_pm_ops = {
+	SET_LATE_SYSTEM_SLEEP_PM_OPS(s32_pinctrl_suspend,
+				     s32_pinctrl_resume)
+};

Consider using DEFINE_* PM macros.

You probably mean DEFINE_SIMPLE_DEV_PM_OPS. Will change it.

Quoted 9 lines

...

drivers/pinctrl/nxp/pinctrl-s32g2.c line 761

Quoted 5 lines
drivers/pinctrl/nxp/pinctrl-s32g2.c +4 -0
+static struct platform_driver s32g_pinctrl_driver = {
+	.driver = {
+		.name = "s32g-siul2-pinctrl",
 
+		.owner = THIS_MODULE,

Duplicate assignment.

Will drop it.

Quoted 19 lines

drivers/pinctrl/nxp/pinctrl-s32g2.c line 768

Quoted 9 lines
drivers/pinctrl/nxp/pinctrl-s32g2.c +7 -0
+		.of_match_table = s32_pinctrl_of_match,
+		.pm = &s32g_pinctrl_pm_ops,
+		.suppress_bind_attrs = true,
+	},
+	.probe = s32g_pinctrl_probe,
+};
 
+

Unnecessary blank line.

Quoted 1 line

+builtin_platform_driver(s32g_pinctrl_driver);

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

Re: [PATCH v5 2/3] pinctrl: add NXP S32 SoC family support

Quoted 266 lines · Chester Lin

Hi Andy,

Thanks for reviewing this patch!

Quoted 21 lines · On Tue, Mar 07, 2023 at 01:28:09AM +0200, [email protected] wrote:

Mon, Feb 20, 2023 at 10:33:19AM +0800, Chester Lin kirjoitti:

Quoted 2 lines

Add the pinctrl driver for NXP S32 SoC family. This driver is mainly based on NXP's downstream implementation on nxp-auto-linux repo[1].

Seems Linus already applied this, but still some comments for the future, some for the followups. However, personally I prefer this to be dropped and redone because too many things here and there.

Quoted 1 line

[1] https://github.com/nxp-auto-linux/linux/tree/bsp35.0-5.15.73-rt/drivers/pinctrl/freescale

This can be transformed to Link: tag.

Quoted 8 lines
Quoted 3 lines

Is it for real?!
Quite a long chain and none of Co-developed-by.

They are developers who contribute codes and have Signed-off-bys in NXP's downstream version. Since their implementations can still be seen in this upstream one, I prefer to list them all. Indeed a part of them who also actively work with me on upstreaming this driver can be listed as Co-developed-by, but the driver patch has been merged into the maintainer's for-next so I would not change this part unless the driver patch needs to be reverted and re-submitted in the end.

Sorry for the patch header that I mess up anyway.

Quoted 5 lines

...

Review

Quoted 1 line
(quoted diff) +1 -0
+	depends on ARCH_S32 && OF

Is OF necessary? Can it be

I think it's required since the driver file refers to of_* APIs.

Quoted 13 lines
	depends OF || COMPILE_TEST

?

...

Review

Quoted 1 line
(quoted diff) +1 -0
+	depends on ARCH_S32 && OF

Ditto.

...

Quoted 16 lines

drivers/pinctrl/nxp/pinctrl-s32.h line 28

Quoted 13 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +13 -0
+/**
+ * struct s32_pin_group - describes an S32 pin group
+ * @name: the name of this specific pin group
+ * @npins: the number of pins in this group array, i.e. the number of
+ *         elements in pin_ids and pin_sss so we can iterate over that array
+ * @pin_ids: an array of pin IDs in this group
+ * @pin_sss: an array of source signal select configs paired with pin_ids
+ */
+struct s32_pin_group {
+	const char *name;
+	unsigned int npins;
+	unsigned int *pin_ids;
+	unsigned int *pin_sss;

Why didn't you embed struct pingroup?

I did think about that but there's an additional 'pin_sss' which could make code a bit messy. For example:

	s32_regmap_update(pctldev, grp->grp.pins[i],
			  S32_MSCR_SSS_MASK, grp->pin_sss[i]);
Quoted 7 lines
Quoted 7 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +7 -0
+};
+
+/**
+ * struct s32_pmx_func - describes S32 pinmux functions
+ * @name: the name of this specific function
+ * @groups: corresponding pin groups
+ * @num_groups: the number of groups
Quoted 9 lines

drivers/pinctrl/nxp/pinctrl-s32.h line 41

Quoted 6 lines

+ */

drivers/pinctrl/nxp/pinctrl-s32.h new file +5 -0
+struct s32_pmx_func {
+	const char *name;
+	const char **groups;
+	unsigned int num_groups;
+};

struct pinfunction.

Thanks for your information. I was not aware of this new struct since it just got merged recently.

Quoted 9 lines

...

drivers/pinctrl/nxp/pinctrl-s32.h line 74

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +4 -0
+#ifdef CONFIG_PM_SLEEP
+int __maybe_unused s32_pinctrl_resume(struct device *dev);
+int __maybe_unused s32_pinctrl_suspend(struct device *dev);
+#endif

Please, consider using new PM macros, like pm_ptr().

Maybe pm_sleep_ptr() is more accurate?

Quoted 9 lines

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 49

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+static u32 get_pin_no(u32 pinmux)
+{
+	return (pinmux & S32_PIN_ID_MASK) >> __ffs(S32_PIN_ID_MASK);

Oh, don't you have MASK to be 2^x - 1? Why to drag this with __ffs()? Just define a complement _SHIFT.

Will fix it.

Quoted 11 lines
Quoted 1 line

+}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 228

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +4 -0
+	n_pins = of_property_count_elems_of_size(np, "pinmux", sizeof(u32));
+	if (n_pins < 0) {
+		dev_warn(dev, "Unable to find 'pinmux' property in node %s.\n",
+			np->name);

Use %pOFn instead of %s.

Will change it.

Quoted 9 lines
Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	} else if (!n_pins) {
+		return -EINVAL;
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 320

Quoted 1 line
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +1 -0
+	for (i = 0; i < grp->npins; ++i) {

Why pre-increment?

Will change that to keep code style consistency.

Quoted 32 lines

drivers/pinctrl/nxp/pinctrl-s32cc.c line 328

Quoted 9 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +8 -0
+		if (s32_check_pin(pctldev, grp->pin_ids[i]) != 0) {
+			dev_err(info->dev, "invalid pin: %d in group: %d\n",
+				grp->pin_ids[i], group);
+			return -EINVAL;
+		}
+	}
+
+	for (i = 0, ret = 0; i < grp->npins && !ret; ++i) {

Ditto.

drivers/pinctrl/nxp/pinctrl-s32cc.c line 330

Quoted 2 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +2 -0
+		ret = s32_regmap_update(pctldev, grp->pin_ids[i],
+					S32_MSCR_SSS_MASK, grp->pin_sss[i]);

Traditional pattern is

		if (ret)
			return ret;

This avoids first assignment of the ret.

drivers/pinctrl/nxp/pinctrl-s32cc.c line 236

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	}
+
+	return ret;
	return 0;
Quoted 1 line

+}

...

Quoted 9 lines

drivers/pinctrl/nxp/pinctrl-s32cc.c line 379

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	ret = s32_regmap_read(pctldev, offset, &config);
+	if (ret != 0)
+		return -EINVAL;

Why not

	if (ret)
		return ret;

Will fix this and the following error code shadowings, return handlings and blanks.

Thanks for your reminder.

Quoted 6 lines

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 390

Quoted 1 line
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +1 -0
+	list_add(&(gpio_pin->list), &(ipctl->gpio_configs));

Too many parentheses.

Quoted 6 lines

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 412

Quoted 2 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +2 -0
+	list_for_each_safe(pos, tmp, &ipctl->gpio_configs) {
+		gpio_pin = list_entry(pos, struct gpio_pin_config, list);

Why not list_for_each_entry_safe() ?

Will change it.

Quoted 41 lines
Quoted 13 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +11 -0
+		if (gpio_pin->pin_id == offset) {
+			ret = s32_regmap_write(pctldev, gpio_pin->pin_id,
+						 gpio_pin->config);
+			if (ret != 0)
+				goto unlock;
+
+			list_del(pos);
+			kfree(gpio_pin);
+			break;
+		}
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 464

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+static int s32_get_slew_regval(int arg)
+{
+	int i;
	unsigned int i;

+ Blank line.

Quoted 8 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +8 -0
+	/* Translate a real slew rate (MHz) to a register value */
+	for (i = 0; i < ARRAY_SIZE(support_slew); i++) {
+		if (arg == support_slew[i])
+			return i;
+	}
+
+	return -EINVAL;
+}

...

Quoted 5 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +5 -0
+	case PIN_CONFIG_BIAS_PULL_UP:
+		if (arg)
+			*config |= S32_MSCR_PUS;
+		else
+			*config &= ~S32_MSCR_PUS;
Quoted 4 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+		fallthrough;

It's quite easy to miss this and tell us about how is it supposed to work with PU + PD?

I admit that it's ambiguous and should be improved in order to have better readability.

In a S32G2 MSCR register, there are two register bits related to pull up/down functions:

PUE (Pull Enable, MSCR[13]): 0'b: Disabled, 1'b: Enabled PUS (Pull Select, MSCR[12]): 0'b: Pull Down, 1'b: Pull Up

Quoted 22 lines

The dt properties could be like these:

1) 'bias-pull-up' or 'bias-pull-up: true' --> arg = 1 In this case both PUE and PUS are set.

2) 'bias-pull-up: false' --> arg = 0
In this case both PUE and PUS are cleared since the pull-up function must be disabled.

Quoted 14 lines

drivers/pinctrl/nxp/pinctrl-s32cc.c line 524

Quoted 11 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +11 -0
+	case PIN_CONFIG_BIAS_PULL_DOWN:
+		if (arg)
+			*config |= S32_MSCR_PUE;
+		else
+			*config &= ~S32_MSCR_PUE;
+		*mask |= S32_MSCR_PUE | S32_MSCR_PUS;
+		break;
+	case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
+		*config &= ~(S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE);
+		*mask |= S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE;
+		fallthrough;

Ditto.

Sorry that I missed the case of PIN_CONFIG_BIAS_HIGH_IMPEDANCE:

As you can see that the pull function must be disabled as well in order to make the pin floating.

Regards,
Chester

Quoted 230 lines

It's similar to the case 'PIN_CONFIG_BIAS_PULL_UP' although the PUS bit is assumed as 0 via the config variable so only the PUE bit needs to be configured, for example:

1) 'bias-pull-down' or 'bias-pull-down: true' --> arg = 1 PUE is set and PUS is cleared.

2) 'bias-pull-down: false' --> arg = 0
In this case both PUE and PUS are cleared since the pull-down function must be disabled.

Quoted 74 lines
Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +4 -0
+	case PIN_CONFIG_BIAS_DISABLE:
+		*config &= ~(S32_MSCR_PUS | S32_MSCR_PUE);
+		*mask |= S32_MSCR_PUS | S32_MSCR_PUE;
+		break;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 545

Quoted 1 line
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +1 -0
+	if (s32_check_pin(pctldev, pin_id) != 0)

Shadowing an error?

Quoted 1 line
(quoted diff) +1 -0
+		return -EINVAL;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 566

Quoted 5 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +5 -0
+	ret = s32_regmap_update(pctldev, pin_id, mask, config);
+
+	dev_dbg(ipctl->dev, "update: pin %d cfg 0x%x\n", pin_id, config);
+
+	return ret;

You are not using ret in between, hence

	return _regmap_update(...);

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 610

Quoted 8 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +8 -0
+static void s32_pinconf_dbg_show(struct pinctrl_dev *pctldev,
+				 struct seq_file *s, unsigned int pin_id)
+{
+	unsigned int config;
+	int ret = s32_regmap_read(pctldev, pin_id, &config);
+
+	if (!ret)
+		seq_printf(s, "0x%x", config);
	int ret;

	ret = s32_regmap_read(pctldev, pin_id, &config);
	if (ret)
		return;

	seq_printf(s, "0x%x", config);
Quoted 1 line

+}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 731

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +2 -0
+	npins = of_property_count_elems_of_size(np, "pinmux", sizeof(u32));
 
+

Unneccessary blank line.

Quoted 9 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +9 -0
+	if (npins < 0) {
+		dev_err(dev, "Failed to read 'pinmux' property in node %s.\n",
+			np->name);
+		return;
+	}
+	if (!npins) {
+		dev_err(dev, "The group %s has no pins.\n", np->name);
+		return;
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 748

Quoted 6 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +5 -0
+	grp->pin_ids = devm_kcalloc(info->dev, grp->npins,
+				    sizeof(unsigned int), GFP_KERNEL);
+	grp->pin_sss = devm_kcalloc(info->dev, grp->npins,
+				    sizeof(unsigned int), GFP_KERNEL);
 
+
Quoted 9 lines

Ditto.

drivers/pinctrl/nxp/pinctrl-s32cc.c line 751

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	if (!grp->pin_ids || !grp->pin_sss) {
 
+		dev_err(dev, "Failed to allocate memory for the group %s.\n",
+			np->name);

We do not print ENOMEM error messages.

Will drop it.

Quoted 11 lines
Quoted 2 lines
(quoted diff) +2 -0
+		return;
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 787

Quoted 2 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +2 -0
+	func->groups = devm_kzalloc(info->dev,
+			func->num_groups * sizeof(char *), GFP_KERNEL);

First of all, this is devm_kcalloc().
Second, where is the error check?

Will fix it.

Quoted 47 lines
Quoted 6 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +6 -0
+	for_each_child_of_node(np, child) {
+		func->groups[i] = child->name;
+		grp = &info->groups[info->grp_index++];
+		s32_pinctrl_parse_groups(child, grp, info);
+		i++;
+	}

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 820

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	ipctl->regions = devm_kzalloc(&pdev->dev,
+				      mem_regions * sizeof(*(ipctl->regions)),
+				      GFP_KERNEL);

devm_kcalloc()

Quoted 2 lines
(quoted diff) +2 -0
+	if (!ipctl->regions)
+		return -ENOMEM;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 856

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	info->functions = devm_kzalloc(&pdev->dev,
+				       nfuncs * sizeof(struct s32_pmx_func),
+				       GFP_KERNEL);

Ditto.

Quoted 2 lines
(quoted diff) +2 -0
+	if (!info->functions)
+		return -ENOMEM;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 865

Quoted 3 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	info->groups = devm_kzalloc(&pdev->dev,
+				    info->ngroups * sizeof(struct s32_pin_group),
+				    GFP_KERNEL);

Ditto.

Quoted 2 lines
(quoted diff) +2 -0
+	if (!info->groups)
+		return -ENOMEM;

...

drivers/pinctrl/nxp/pinctrl-s32cc.c line 926

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	ipctl->pctl = devm_pinctrl_register(&pdev->dev, s32_pinctrl_desc,
+					    ipctl);
 
+
Quoted 9 lines

Unneeded blank line.

drivers/pinctrl/nxp/pinctrl-s32cc.c line 929

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +3 -0
+	if (IS_ERR(ipctl->pctl)) {
 
+		dev_err(&pdev->dev, "could not register s32 pinctrl driver\n");
+		return PTR_ERR(ipctl->pctl);
	return dev_err_probe(...);

Will change it, thanks!

Quoted 8 lines
Quoted 1 line
(quoted diff) +1 -0
+	}

...

drivers/pinctrl/nxp/pinctrl-s32g2.c

Quoted 1 line
drivers/pinctrl/nxp/pinctrl-s32g2.c +0 -0

Similar issues has to be addressed, if any.

Quoted 9 lines

...

drivers/pinctrl/nxp/pinctrl-s32g2.c line 750

Quoted 2 lines
drivers/pinctrl/nxp/pinctrl-s32g2.c +2 -0
+	return s32_pinctrl_probe
+			(pdev, (struct s32_pinctrl_soc_info *) of_id->data);

Broken indentation.

...

The checkpatch.pl seems not to warn this but I will definitely improve it.

Quoted 7 lines

drivers/pinctrl/nxp/pinctrl-s32g2.c line 756

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32g2.c +4 -0
+static const struct dev_pm_ops s32g_pinctrl_pm_ops = {
+	SET_LATE_SYSTEM_SLEEP_PM_OPS(s32_pinctrl_suspend,
+				     s32_pinctrl_resume)
+};

Consider using DEFINE_* PM macros.

You probably mean DEFINE_SIMPLE_DEV_PM_OPS. Will change it.

Quoted 9 lines

...

drivers/pinctrl/nxp/pinctrl-s32g2.c line 761

Quoted 5 lines
drivers/pinctrl/nxp/pinctrl-s32g2.c +4 -0
+static struct platform_driver s32g_pinctrl_driver = {
+	.driver = {
+		.name = "s32g-siul2-pinctrl",
 
+		.owner = THIS_MODULE,

Duplicate assignment.

Will drop it.

Quoted 19 lines

drivers/pinctrl/nxp/pinctrl-s32g2.c line 768

Quoted 9 lines
drivers/pinctrl/nxp/pinctrl-s32g2.c +7 -0
+		.of_match_table = s32_pinctrl_of_match,
+		.pm = &s32g_pinctrl_pm_ops,
+		.suppress_bind_attrs = true,
+	},
+	.probe = s32g_pinctrl_probe,
+};
 
+

Unnecessary blank line.

Quoted 1 line

+builtin_platform_driver(s32g_pinctrl_driver);

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

Re: [PATCH v5 2/3] pinctrl: add NXP S32 SoC family support

In reply to Chester Lin
Quoted 2 lines · Chester Lin
Quoted 1 line · On Tue, Mar 07, 2023 at 01:28:09AM +0200, [email protected] wrote:

Mon, Feb 20, 2023 at 10:33:19AM +0800, Chester Lin kirjoitti:

...

Quoted 3 lines

but the driver patch
has been merged into the maintainer's for-next so I would not change this part unless the driver patch needs to be reverted and re-submitted in the end.

As I said you have to keep it in mind for all your future contributions to the Linux kernel independently on the destiny of this one.

...

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+ depends on ARCH_S32 && OF

Is OF necessary? Can it be

I think it's required since the driver file refers to of_* APIs.

And? Is it functional or compilation dependency? If the latter is the case, what API exactly isn't providing a stub?

Quoted 3 lines
Quoted 3 lines
      depends OF || COMPILE_TEST

?

So?

...

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ depends on ARCH_S32 && OF

Ditto.

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines

+/**
+ * struct s32_pin_group - describes an S32 pin group
+ * @name: the name of this specific pin group
+ * @npins: the number of pins in this group array, i.e. the number of
+ * elements in pin_ids and pin_sss so we can iterate over that array
+ * @pin_ids: an array of pin IDs in this group
+ * @pin_sss: an array of source signal select configs paired with pin_ids

Quoted 8 lines

drivers/pinctrl/nxp/pinctrl-s32.h line 28

Quoted 6 lines

+ */

drivers/pinctrl/nxp/pinctrl-s32.h new file +5 -0
+struct s32_pin_group {
+   const char *name;
+   unsigned int npins;
+   unsigned int *pin_ids;
+   unsigned int *pin_sss;

Why didn't you embed struct pingroup?

Quoted 5 lines

I did think about that but there's an additional 'pin_sss' which could make code a bit messy. For example:

        s32_regmap_update(pctldev, grp->grp.pins[i],
                          S32_MSCR_SSS_MASK, grp->pin_sss[i]);

We specifically provide those data types to separate generic things with custom ones. I don't think about the code getting longer, the access to the proper data seems reasonable to me. Look into other drivers that utilise these data types.

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +7 -0
+};
+
+/**
+ * struct s32_pmx_func - describes S32 pinmux functions
+ * @name: the name of this specific function
+ * @groups: corresponding pin groups
+ * @num_groups: the number of groups
Quoted 8 lines

drivers/pinctrl/nxp/pinctrl-s32.h line 41

Quoted 6 lines

+ */

drivers/pinctrl/nxp/pinctrl-s32.h new file +5 -0
+struct s32_pmx_func {
+   const char *name;
+   const char **groups;
+   unsigned int num_groups;
+};

struct pinfunction.

Quoted 2 lines

Thanks for your information. I was not aware of this new struct since it just got merged recently.

That's why the rule is to keep an eye on the subsystem development by regular rebasing on top of its tip (pinctrl tree, devel branch in this case).

...

Quoted 8 lines
Quoted 6 lines

drivers/pinctrl/nxp/pinctrl-s32.h line 74

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +4 -0
+#ifdef CONFIG_PM_SLEEP
+int __maybe_unused s32_pinctrl_resume(struct device *dev);
+int __maybe_unused s32_pinctrl_suspend(struct device *dev);
+#endif

Please, consider using new PM macros, like pm_ptr().

Maybe pm_sleep_ptr() is more accurate?

You are the author, choose what you think fits the best!

...

Quoted 17 lines
Quoted 10 lines

drivers/pinctrl/nxp/pinctrl-s32cc.c line 513

Quoted 7 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +6 -0
+   case PIN_CONFIG_BIAS_PULL_UP:
+           if (arg)
+                   *config |= S32_MSCR_PUS;
+           else
+                   *config &= ~S32_MSCR_PUS;
 
+           fallthrough;

It's quite easy to miss this and tell us about how is it supposed to work with PU + PD?

I admit that it's ambiguous and should be improved in order to have better readability.

In a S32G2 MSCR register, there are two register bits related to pull up/down functions:

PUE (Pull Enable, MSCR[13]): 0'b: Disabled, 1'b: Enabled PUS (Pull Select, MSCR[12]): 0'b: Pull Down, 1'b: Pull Up

Quoted 7 lines

The dt properties could be like these:

1) 'bias-pull-up' or 'bias-pull-up: true' --> arg = 1 In this case both PUE and PUS are set.

2) 'bias-pull-up: false' --> arg = 0
In this case both PUE and PUS are cleared since the pull-up function must be disabled.

So, split it to a separate function where you do the enabling only once. I can point to drivers/pinctrl/intel/pinctrl-intel.c for the idea to take from.

Quoted 15 lines
Quoted 12 lines

drivers/pinctrl/nxp/pinctrl-s32cc.c line 524

Quoted 11 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +11 -0
+   case PIN_CONFIG_BIAS_PULL_DOWN:
+           if (arg)
+                   *config |= S32_MSCR_PUE;
+           else
+                   *config &= ~S32_MSCR_PUE;
+           *mask |= S32_MSCR_PUE | S32_MSCR_PUS;
+           break;
+   case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
+           *config &= ~(S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE);
+           *mask |= S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE;
+           fallthrough;
Quoted 2 lines

Ditto.

Quoted 13 lines

It's similar to the case 'PIN_CONFIG_BIAS_PULL_UP' although the PUS bit is assumed as 0 via the config variable so only the PUE bit needs to be configured, for example:

1) 'bias-pull-down' or 'bias-pull-down: true' --> arg = 1 PUE is set and PUS is cleared.

2) 'bias-pull-down: false' --> arg = 0
In this case both PUE and PUS are cleared since the pull-down function must be disabled.

Quoted 4 lines
Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +4 -0
+   case PIN_CONFIG_BIAS_DISABLE:
+           *config &= ~(S32_MSCR_PUS | S32_MSCR_PUE);
+           *mask |= S32_MSCR_PUS | S32_MSCR_PUE;
+           break;

Ditto.

...

I assume that non-commented is equal to silent agreement and will be addressed accordingly. If it's not the case, reply again with your objections.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw

Re: [PATCH v5 2/3] pinctrl: add NXP S32 SoC family support

Hi Andy,

Quoted 16 lines · Andy Shevchenko
Quoted 2 lines · Chester Lin
Quoted 1 line · On Tue, Mar 07, 2023 at 01:28:09AM +0200, [email protected] wrote:

Mon, Feb 20, 2023 at 10:33:19AM +0800, Chester Lin kirjoitti:

...

Quoted 3 lines

but the driver patch
has been merged into the maintainer's for-next so I would not change this part unless the driver patch needs to be reverted and re-submitted in the end.

As I said you have to keep it in mind for all your future contributions to the Linux kernel independently on the destiny of this one.

...

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+ depends on ARCH_S32 && OF

Is OF necessary? Can it be

I think it's required since the driver file refers to of_* APIs.

And? Is it functional or compilation dependency? If the latter is the case, what API exactly isn't providing a stub?

I was wrong. Looks like the ARM64 arch Kconfig always select OF so it's not really necessary to have OF here.

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
      depends OF || COMPILE_TEST

?

So?

Since the OF dependency is not really necessary here, to fulfill the compile test purpose, the possible dependency might be (ARCH_S32 || COMPILE_TEST), but it could meet a compiling failure on the reference of pinconf_generic_parse_dt_config() for those architectures which do not select OF by default since there's no stub for this function. [pinconf_generic_parse_dt_config() is called in pinctrl-s32cc.c]

Quoted 6 lines

...

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ depends on ARCH_S32 && OF

Ditto.

Based on the previous assumption [OF is not needed and PINCTRL_S32CC doesn't depend on COMPILE_TEST], selecting PINCTRL_S32G2 wouldn't work if it simply depends on (ARCH_S32 || COMPILE_TEST), for example:

WARNING: unmet direct dependencies detected for PINCTRL_S32CC
Depends on [n]: PINCTRL [=y] && ARCH_S32
Selected by [y]:
- PINCTRL_S32G2 [=y] && PINCTRL [=y] && (ARCH_S32 || COMPILE_TEST [=y])

So the better solutions is to still have OF in PINCTRL_S32CC, such as:

config PINCTRL_S32CC

	bool
	depends on ARCH_S32 || (OF && COMPILE_TEST)
	.....

config PINCTRL_S32G2

	depends on ARCH_S32 || COMPILE_TEST
	.....

Regards,
Chester

Quoted 19 lines
Quoted 19 lines
Quoted 7 lines
Quoted 7 lines

+/**
+ * struct s32_pin_group - describes an S32 pin group
+ * @name: the name of this specific pin group
+ * @npins: the number of pins in this group array, i.e. the number of
+ * elements in pin_ids and pin_sss so we can iterate over that array
+ * @pin_ids: an array of pin IDs in this group
+ * @pin_sss: an array of source signal select configs paired with pin_ids

Quoted 8 lines

drivers/pinctrl/nxp/pinctrl-s32.h line 28

Quoted 6 lines

+ */

drivers/pinctrl/nxp/pinctrl-s32.h new file +5 -0
+struct s32_pin_group {
+   const char *name;
+   unsigned int npins;
+   unsigned int *pin_ids;
+   unsigned int *pin_sss;

Why didn't you embed struct pingroup?

I did think about that but there's an additional 'pin_sss' which could make code a bit messy. For example:

Quoted 8 lines
Quoted 2 lines
        s32_regmap_update(pctldev, grp->grp.pins[i],
                          S32_MSCR_SSS_MASK, grp->pin_sss[i]);

We specifically provide those data types to separate generic things with custom ones. I don't think about the code getting longer, the access to the proper data seems reasonable to me. Look into other drivers that utilise these data types.

Will change it, thanks for your suggestions.

Quoted 58 lines
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +7 -0
+};
+
+/**
+ * struct s32_pmx_func - describes S32 pinmux functions
+ * @name: the name of this specific function
+ * @groups: corresponding pin groups
+ * @num_groups: the number of groups
Quoted 8 lines

drivers/pinctrl/nxp/pinctrl-s32.h line 41

Quoted 6 lines

+ */

drivers/pinctrl/nxp/pinctrl-s32.h new file +5 -0
+struct s32_pmx_func {
+   const char *name;
+   const char **groups;
+   unsigned int num_groups;
+};

struct pinfunction.

Quoted 2 lines

Thanks for your information. I was not aware of this new struct since it just got merged recently.

That's why the rule is to keep an eye on the subsystem development by regular rebasing on top of its tip (pinctrl tree, devel branch in this case).

...

Quoted 8 lines
Quoted 6 lines

drivers/pinctrl/nxp/pinctrl-s32.h line 74

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +4 -0
+#ifdef CONFIG_PM_SLEEP
+int __maybe_unused s32_pinctrl_resume(struct device *dev);
+int __maybe_unused s32_pinctrl_suspend(struct device *dev);
+#endif

Please, consider using new PM macros, like pm_ptr().

Maybe pm_sleep_ptr() is more accurate?

You are the author, choose what you think fits the best!

...

Quoted 19 lines
Quoted 10 lines

drivers/pinctrl/nxp/pinctrl-s32cc.c line 513

Quoted 7 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +6 -0
+   case PIN_CONFIG_BIAS_PULL_UP:
+           if (arg)
+                   *config |= S32_MSCR_PUS;
+           else
+                   *config &= ~S32_MSCR_PUS;
 
+           fallthrough;

It's quite easy to miss this and tell us about how is it supposed to work with PU + PD?

I admit that it's ambiguous and should be improved in order to have better readability.

In a S32G2 MSCR register, there are two register bits related to pull up/down functions:

PUE (Pull Enable, MSCR[13]): 0'b: Disabled, 1'b: Enabled PUS (Pull Select, MSCR[12]): 0'b: Pull Down, 1'b: Pull Up

The dt properties could be like these:

Quoted 9 lines
Quoted 5 lines

1) 'bias-pull-up' or 'bias-pull-up: true' --> arg = 1 In this case both PUE and PUS are set.

2) 'bias-pull-up: false' --> arg = 0
In this case both PUE and PUS are cleared since the pull-up function must be disabled.

So, split it to a separate function where you do the enabling only once. I can point to drivers/pinctrl/intel/pinctrl-intel.c for the idea to take from.

Will do.

Quoted 40 lines
Quoted 15 lines
Quoted 12 lines

drivers/pinctrl/nxp/pinctrl-s32cc.c line 524

Quoted 11 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +11 -0
+   case PIN_CONFIG_BIAS_PULL_DOWN:
+           if (arg)
+                   *config |= S32_MSCR_PUE;
+           else
+                   *config &= ~S32_MSCR_PUE;
+           *mask |= S32_MSCR_PUE | S32_MSCR_PUS;
+           break;
+   case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
+           *config &= ~(S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE);
+           *mask |= S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE;
+           fallthrough;
Quoted 2 lines

Ditto.

Quoted 13 lines

It's similar to the case 'PIN_CONFIG_BIAS_PULL_UP' although the PUS bit is assumed as 0 via the config variable so only the PUE bit needs to be configured, for example:

1) 'bias-pull-down' or 'bias-pull-down: true' --> arg = 1 PUE is set and PUS is cleared.

2) 'bias-pull-down: false' --> arg = 0
In this case both PUE and PUS are cleared since the pull-down function must be disabled.

Quoted 4 lines
Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +4 -0
+   case PIN_CONFIG_BIAS_DISABLE:
+           *config &= ~(S32_MSCR_PUS | S32_MSCR_PUE);
+           *mask |= S32_MSCR_PUS | S32_MSCR_PUE;
+           break;

Ditto.

...

I assume that non-commented is equal to silent agreement and will be addressed accordingly. If it's not the case, reply again with your objections.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw

Re: [PATCH v5 2/3] pinctrl: add NXP S32 SoC family support

Quoted 63 lines · Chester Lin

Hi Andy,

Quoted 16 lines · Andy Shevchenko
Quoted 2 lines · Chester Lin
Quoted 1 line · On Tue, Mar 07, 2023 at 01:28:09AM +0200, [email protected] wrote:

Mon, Feb 20, 2023 at 10:33:19AM +0800, Chester Lin kirjoitti:

...

Quoted 3 lines

but the driver patch
has been merged into the maintainer's for-next so I would not change this part unless the driver patch needs to be reverted and re-submitted in the end.

As I said you have to keep it in mind for all your future contributions to the Linux kernel independently on the destiny of this one.

...

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+ depends on ARCH_S32 && OF

Is OF necessary? Can it be

I think it's required since the driver file refers to of_* APIs.

And? Is it functional or compilation dependency? If the latter is the case, what API exactly isn't providing a stub?

I was wrong. Looks like the ARM64 arch Kconfig always select OF so it's not really necessary to have OF here.

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
      depends OF || COMPILE_TEST

?

So?

Since the OF dependency is not really necessary here, to fulfill the compile test purpose, the possible dependency might be (ARCH_S32 || COMPILE_TEST), but it could meet a compiling failure on the reference of pinconf_generic_parse_dt_config() for those architectures which do not select OF by default since there's no stub for this function. [pinconf_generic_parse_dt_config() is called in pinctrl-s32cc.c]

Quoted 6 lines

...

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ depends on ARCH_S32 && OF

Ditto.

Based on the previous assumption [OF is not needed and PINCTRL_S32CC doesn't depend on COMPILE_TEST], selecting PINCTRL_S32G2 wouldn't work if it simply depends on (ARCH_S32 || COMPILE_TEST), for example:

WARNING: unmet direct dependencies detected for PINCTRL_S32CC
Depends on [n]: PINCTRL [=y] && ARCH_S32
Selected by [y]:
- PINCTRL_S32G2 [=y] && PINCTRL [=y] && (ARCH_S32 || COMPILE_TEST [=y])

So the better solutions is to still have OF in PINCTRL_S32CC, such as:

Quoted 7 lines

config PINCTRL_S32CC

	bool
	depends on ARCH_S32 || (OF && COMPILE_TEST)
	.....

config PINCTRL_S32G2

	depends on ARCH_S32 || COMPILE_TEST

Fix the dependency here, it should be:

config PINCTRL_S32G2

	depends on ARCH_S32 || (OF && COMPILE_TEST)
        .....

Just in case if OF is not set but COMPILE_TEST is set.

Quoted 145 lines
	.....

Regards,
Chester

Quoted 19 lines
Quoted 19 lines
Quoted 7 lines
Quoted 7 lines

+/**
+ * struct s32_pin_group - describes an S32 pin group
+ * @name: the name of this specific pin group
+ * @npins: the number of pins in this group array, i.e. the number of
+ * elements in pin_ids and pin_sss so we can iterate over that array
+ * @pin_ids: an array of pin IDs in this group
+ * @pin_sss: an array of source signal select configs paired with pin_ids

Quoted 8 lines

drivers/pinctrl/nxp/pinctrl-s32.h line 28

Quoted 6 lines

+ */

drivers/pinctrl/nxp/pinctrl-s32.h new file +5 -0
+struct s32_pin_group {
+   const char *name;
+   unsigned int npins;
+   unsigned int *pin_ids;
+   unsigned int *pin_sss;

Why didn't you embed struct pingroup?

I did think about that but there's an additional 'pin_sss' which could make code a bit messy. For example:

Quoted 8 lines
Quoted 2 lines
        s32_regmap_update(pctldev, grp->grp.pins[i],
                          S32_MSCR_SSS_MASK, grp->pin_sss[i]);

We specifically provide those data types to separate generic things with custom ones. I don't think about the code getting longer, the access to the proper data seems reasonable to me. Look into other drivers that utilise these data types.

Will change it, thanks for your suggestions.

Quoted 58 lines
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +7 -0
+};
+
+/**
+ * struct s32_pmx_func - describes S32 pinmux functions
+ * @name: the name of this specific function
+ * @groups: corresponding pin groups
+ * @num_groups: the number of groups
Quoted 8 lines

drivers/pinctrl/nxp/pinctrl-s32.h line 41

Quoted 6 lines

+ */

drivers/pinctrl/nxp/pinctrl-s32.h new file +5 -0
+struct s32_pmx_func {
+   const char *name;
+   const char **groups;
+   unsigned int num_groups;
+};

struct pinfunction.

Quoted 2 lines

Thanks for your information. I was not aware of this new struct since it just got merged recently.

That's why the rule is to keep an eye on the subsystem development by regular rebasing on top of its tip (pinctrl tree, devel branch in this case).

...

Quoted 8 lines
Quoted 6 lines

drivers/pinctrl/nxp/pinctrl-s32.h line 74

Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32.h new file +4 -0
+#ifdef CONFIG_PM_SLEEP
+int __maybe_unused s32_pinctrl_resume(struct device *dev);
+int __maybe_unused s32_pinctrl_suspend(struct device *dev);
+#endif

Please, consider using new PM macros, like pm_ptr().

Maybe pm_sleep_ptr() is more accurate?

You are the author, choose what you think fits the best!

...

Quoted 19 lines
Quoted 10 lines

drivers/pinctrl/nxp/pinctrl-s32cc.c line 513

Quoted 7 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +6 -0
+   case PIN_CONFIG_BIAS_PULL_UP:
+           if (arg)
+                   *config |= S32_MSCR_PUS;
+           else
+                   *config &= ~S32_MSCR_PUS;
 
+           fallthrough;

It's quite easy to miss this and tell us about how is it supposed to work with PU + PD?

I admit that it's ambiguous and should be improved in order to have better readability.

In a S32G2 MSCR register, there are two register bits related to pull up/down functions:

PUE (Pull Enable, MSCR[13]): 0'b: Disabled, 1'b: Enabled PUS (Pull Select, MSCR[12]): 0'b: Pull Down, 1'b: Pull Up

The dt properties could be like these:

Quoted 9 lines
Quoted 5 lines

1) 'bias-pull-up' or 'bias-pull-up: true' --> arg = 1 In this case both PUE and PUS are set.

2) 'bias-pull-up: false' --> arg = 0
In this case both PUE and PUS are cleared since the pull-up function must be disabled.

So, split it to a separate function where you do the enabling only once. I can point to drivers/pinctrl/intel/pinctrl-intel.c for the idea to take from.

Will do.

Quoted 40 lines
Quoted 15 lines
Quoted 12 lines

drivers/pinctrl/nxp/pinctrl-s32cc.c line 524

Quoted 11 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +11 -0
+   case PIN_CONFIG_BIAS_PULL_DOWN:
+           if (arg)
+                   *config |= S32_MSCR_PUE;
+           else
+                   *config &= ~S32_MSCR_PUE;
+           *mask |= S32_MSCR_PUE | S32_MSCR_PUS;
+           break;
+   case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
+           *config &= ~(S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE);
+           *mask |= S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE;
+           fallthrough;
Quoted 2 lines

Ditto.

Quoted 13 lines

It's similar to the case 'PIN_CONFIG_BIAS_PULL_UP' although the PUS bit is assumed as 0 via the config variable so only the PUE bit needs to be configured, for example:

1) 'bias-pull-down' or 'bias-pull-down: true' --> arg = 1 PUE is set and PUS is cleared.

2) 'bias-pull-down: false' --> arg = 0
In this case both PUE and PUS are cleared since the pull-down function must be disabled.

Quoted 4 lines
Quoted 4 lines
drivers/pinctrl/nxp/pinctrl-s32cc.c new file +4 -0
+   case PIN_CONFIG_BIAS_DISABLE:
+           *config &= ~(S32_MSCR_PUS | S32_MSCR_PUE);
+           *mask |= S32_MSCR_PUS | S32_MSCR_PUE;
+           break;

Ditto.

...

I assume that non-commented is equal to silent agreement and will be addressed accordingly. If it's not the case, reply again with your objections.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw

Re: [PATCH v5 2/3] pinctrl: add NXP S32 SoC family support

Quoted 5 lines · Chester Lin
Quoted 4 lines · Chester Lin
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Chester Lin
Quoted 1 line · On Tue, Mar 07, 2023 at 01:28:09AM +0200, [email protected] wrote:

Mon, Feb 20, 2023 at 10:33:19AM +0800, Chester Lin kirjoitti:

...

Quoted 16 lines
Quoted 16 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+ depends on ARCH_S32 && OF

Is OF necessary? Can it be

I think it's required since the driver file refers to of_* APIs.

And? Is it functional or compilation dependency? If the latter is the case, what API exactly isn't providing a stub?

I was wrong. Looks like the ARM64 arch Kconfig always select OF so it's not really necessary to have OF here.

Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
      depends OF || COMPILE_TEST

?

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

So?

Since the OF dependency is not really necessary here, to fulfill the compile test purpose, the possible dependency might be (ARCH_S32 || COMPILE_TEST), but it could meet a compiling failure on the reference of pinconf_generic_parse_dt_config() for those architectures which do not select OF by default since there's no stub for this function. [pinconf_generic_parse_dt_config() is called in pinctrl-s32cc.c]

So. your driver needs to select the proper module and since there is no stub it probably needs to be added.

Linus, why do we have no stubs in the first place?

...

Quoted 20 lines
Quoted 20 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ depends on ARCH_S32 && OF

Ditto.

Based on the previous assumption [OF is not needed and PINCTRL_S32CC doesn't depend on COMPILE_TEST], selecting PINCTRL_S32G2 wouldn't work if it simply depends on (ARCH_S32 || COMPILE_TEST), for example:

WARNING: unmet direct dependencies detected for PINCTRL_S32CC
Depends on [n]: PINCTRL [=y] && ARCH_S32
Selected by [y]:
- PINCTRL_S32G2 [=y] && PINCTRL [=y] && (ARCH_S32 || COMPILE_TEST [=y])

So the better solutions is to still have OF in PINCTRL_S32CC, such as:

config PINCTRL_S32CC

      bool
      depends on ARCH_S32 || (OF && COMPILE_TEST)
      .....
Quoted 4 lines
Quoted 2 lines

config PINCTRL_S32G2

      depends on ARCH_S32 || COMPILE_TEST

Fix the dependency here, it should be:

Nope, this is definitely wrong.

Quoted 5 lines

config PINCTRL_S32G2

        depends on ARCH_S32 || (OF && COMPILE_TEST)
        .....

Just in case if OF is not set but COMPILE_TEST is set.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#10 lore raw

PATCH v5 3/3 MAINTAINERS: Add NXP S32 pinctrl maintainer and reviewer

In reply to Chester Lin

Add myself as a maintainer and add NXP S32 Linux Team as a review group for S32 pinctrl patches.

---

(No change in v5)

Changes in v4:
- The initial version in this series.

 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
index 39ff1a717625..e427d7af88fb 100644
@@ -16562,6 +16562,14 @@ S:	Supported
 F:	drivers/gpio/gpio-sama5d2-piobu.c
 F:	drivers/pinctrl/pinctrl-at91*
 
+PIN CONTROLLER - NXP S32
+M:	Chester Lin <[email protected]>
+R:	NXP S32 Linux Team <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/pinctrl/nxp,s32*
+F:	drivers/pinctrl/nxp/
+
 PIN CONTROLLER - QUALCOMM
 M:	Bjorn Andersson <[email protected]>
 L:	[email protected]
Signature · 1 line
2.37.3
#11 lore raw
In reply to Chester Lin
Quoted 10 lines · Chester Lin

Here I want to introduce a new patch series, which aims to support IOMUX functions provided by SIUL2 [System Integration Unit Lite2] on S32 SoCs, such as S32G2. This series is originally from NXP's implementation on nxp-auto-linux repo[1] and it will be required by upstream kernel for supporting a variety of devices on S32 SoCs which need to config PINMUXs, such as PHYs and MAC controllers.

Thanks,
Chester

Quoted 7 lines

Changes in v5:
- dt-bindings: No change
- driver:
- Refactor register r/w access based on REGMAP_MMIO and regmap APIs.
- Tag PM functions with '__maybe_unused'.
- Add mask check while parsing pin ID from a pinmux value.
- Simplify s32_pinconf_mscr_* functions.

This looks really good any no more comments arrived, so patches are applied for v6.4!

Thanks for your work on this so far Chester! (I suppose there will be maintenance
for this family going forward.)

Yours,
Linus Walleij

#12 lore raw

Mon, Mar 06, 2023 at 02:28:56PM +0100, Linus Walleij kirjoitti:

Quoted 20 lines · Chester Lin
Quoted 11 lines

Here I want to introduce a new patch series, which aims to support IOMUX functions provided by SIUL2 [System Integration Unit Lite2] on S32 SoCs, such as S32G2. This series is originally from NXP's implementation on nxp-auto-linux repo[1] and it will be required by upstream kernel for supporting a variety of devices on S32 SoCs which need to config PINMUXs, such as PHYs and MAC controllers.

Thanks,
Chester

Quoted 7 lines

Changes in v5:
- dt-bindings: No change
- driver:
- Refactor register r/w access based on REGMAP_MMIO and regmap APIs.
- Tag PM functions with '__maybe_unused'.
- Add mask check while parsing pin ID from a pinmux value.
- Simplify s32_pinconf_mscr_* functions.

Quoted 6 lines

This looks really good any no more comments arrived, so patches are applied for v6.4!

Thanks for your work on this so far Chester! (I suppose there will be maintenance
for this family going forward.)

Can you unpull this?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#13 lore raw
Quoted 21 lines · On Tue, Mar 7, 2023 at 12:28 AM <[email protected]> wrote:

Mon, Mar 06, 2023 at 02:28:56PM +0100, Linus Walleij kirjoitti:

Quoted 20 lines · Chester Lin
Quoted 18 lines

Here I want to introduce a new patch series, which aims to support IOMUX functions provided by SIUL2 [System Integration Unit Lite2] on S32 SoCs, such as S32G2. This series is originally from NXP's implementation on nxp-auto-linux repo[1] and it will be required by upstream kernel for supporting a variety of devices on S32 SoCs which need to config PINMUXs, such as PHYs and MAC controllers.

Thanks,
Chester

Changes in v5:
- dt-bindings: No change
- driver:
- Refactor register r/w access based on REGMAP_MMIO and regmap APIs.
- Tag PM functions with '__maybe_unused'.
- Add mask check while parsing pin ID from a pinmux value.
- Simplify s32_pinconf_mscr_* functions.

Quoted 8 lines
Quoted 6 lines

This looks really good any no more comments arrived, so patches are applied for v6.4!

Thanks for your work on this so far Chester! (I suppose there will be maintenance
for this family going forward.)

Can you unpull this?

If need be.

Are there serious issues with the patch set such that they cannot be fixed by add-on patches?

Yours,
Linus Walleij

#14 lore raw
Quoted 1 line · Linus Walleij

On Tue, Mar 7, 2023 at 12:28 AM <[email protected]> wrote:

...

Quoted 6 lines
Quoted 1 line

Can you unpull this?

If need be.

Are there serious issues with the patch set such that they cannot be fixed by add-on patches?

There are a few absent error checks, some error code shadowing, etc. I can't tell if these all are serious, but the amount of them is like a dozen.

I reviewed the patch, so you can look into that yourself and decide.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#15 lore raw
Quoted 9 lines · Andy Shevchenko
Quoted 1 line · Linus Walleij

On Tue, Mar 7, 2023 at 12:28 AM <[email protected]> wrote:

...

Quoted 4 lines
Quoted 1 line

Can you unpull this?

If need be.

Quoted 7 lines
Quoted 2 lines

Are there serious issues with the patch set such that they cannot be fixed by add-on patches?

There are a few absent error checks, some error code shadowing, etc. I can't tell if these all are serious, but the amount of them is like a dozen.

I reviewed the patch, so you can look into that yourself and decide.

I looked at it and some of the comments are pretty serious and need addressing ASAP.

However it only affects this hardware so it's not like it's breaking the world. I generally prefer in-tree development over too many big patch iterations, it gets more focused.

I think if Chester can follow up with a patch or several addressing the comments in the next week or two that's fine.

However if we get closer to -rc6 and nothing has happened I would not be so happy and then I might just revert the driver patch.

Yours,
Linus Walleij

#16 lore raw

Hi Linus and Andy,

Quoted 14 lines · Linus Walleij
Quoted 12 lines · Andy Shevchenko
Quoted 1 line · Linus Walleij

On Tue, Mar 7, 2023 at 12:28 AM <[email protected]> wrote:

...

Quoted 6 lines
Quoted 1 line

Can you unpull this?

If need be.

Are there serious issues with the patch set such that they cannot be fixed by add-on patches?

Quoted 8 lines
Quoted 4 lines

There are a few absent error checks, some error code shadowing, etc. I can't tell if these all are serious, but the amount of them is like a dozen.

I reviewed the patch, so you can look into that yourself and decide.

I looked at it and some of the comments are pretty serious and need addressing ASAP.

Thanks for reviewing the patch.

Please kindly leave review comments if it doesn't take too much time for you. I just want to ensure that I won't miss anything.

Quoted 7 lines

However it only affects this hardware so it's not like it's breaking the world. I generally prefer in-tree development over too many big patch iterations, it gets more focused.

I think if Chester can follow up with a patch or several addressing the comments in the next week or two that's fine.

I will do my best to solve it.

Thanks,
Chester

Quoted 5 lines

However if we get closer to -rc6 and nothing has happened I would not be so happy and then I might just revert the driver patch.

Yours,
Linus Walleij

#17 lore raw
Quoted 22 lines · Chester Lin

Hi Linus and Andy,

Quoted 19 lines · Linus Walleij
Quoted 16 lines · Andy Shevchenko
Quoted 1 line · Linus Walleij

On Tue, Mar 7, 2023 at 12:28 AM <[email protected]> wrote:

...

Quoted 6 lines
Quoted 1 line

Can you unpull this?

If need be.

Are there serious issues with the patch set such that they cannot be fixed by add-on patches?

There are a few absent error checks, some error code shadowing, etc. I can't tell if these all are serious, but the amount of them is like a dozen.

I reviewed the patch, so you can look into that yourself and decide.

Quoted 9 lines
Quoted 3 lines

I looked at it and some of the comments are pretty serious and need addressing ASAP.

Thanks for reviewing the patch.

Please kindly leave review comments if it doesn't take too much time for you. I just want to ensure that I won't miss anything.

Sorry that I just found that my mailbox didn't receive Andy's mail [comments on v5 2/3]. I will try answering it and come up with a patch ASAP.

Thanks for your patience,
Chester

Quoted 18 lines
Quoted 7 lines

However it only affects this hardware so it's not like it's breaking the world. I generally prefer in-tree development over too many big patch iterations, it gets more focused.

I think if Chester can follow up with a patch or several addressing the comments in the next week or two that's fine.

I will do my best to solve it.

Thanks,
Chester

Quoted 5 lines

However if we get closer to -rc6 and nothing has happened I would not be so happy and then I might just revert the driver patch.

Yours,
Linus Walleij

#18 lore raw

On Tue, Mar 7, 2023 at 4:53 PM Chester Lin <[email protected]> wrote:

...

Quoted 2 lines

Sorry that I just found that my mailbox didn't receive Andy's mail [comments on v5 2/3]. I will try answering it and come up with a patch ASAP.

The thread is available here:
https://lore.kernel.org/all/[email protected]/

You can even download it using the b4 tool (available in your distro quite likely).

Signature · 7 lines
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel