Skip to contentSkip to conversation

pinctrl: meson: a4: Add input enable pin configuration

PATCH In review Xianwei Zhao 3 participants 3 messages Aug 12 – Aug 14

Subsystems (4)
lore
Share & tools
lore

Xianwei Zhao

author maintainer
#0 lore raw

PATCH 1/1 pinctrl: meson: a4: Add input enable pin configuration

Add support for PIN_CONFIG_INPUT_ENABLE in the Amlogic A4 pinctrl driver.

Use the existing output enable control to configure the input enable state, since the hardware uses the same control with inverse semantics.

Also update PIN_CONFIG_OUTPUT_ENABLE handling to return the actual output enable state instead of treating any non-zero value as enabled.

---
 drivers/pinctrl/meson/pinctrl-amlogic-a4.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/pinctrl/meson/pinctrl-amlogic-a4.c +12 -2
index 420f7915c010..39eb8cc7fc0d 100644
@@ -469,9 +469,15 @@ static int aml_pinconf_get(struct pinctrl_dev *pcdev, unsigned int pin,
 		break;
 	case PIN_CONFIG_OUTPUT_ENABLE:
 		ret = aml_pinconf_get_output(info, pin);
-		if (ret <= 0)
+		if (ret < 0)
+			return -EINVAL;
+		arg = ret;
+		break;
+	case PIN_CONFIG_INPUT_ENABLE:
+		ret = aml_pinconf_get_output(info, pin);
+		if (ret < 0)
 			return -EINVAL;
-		arg = 1;
+		arg = !ret;
 		break;
 	case PIN_CONFIG_LEVEL:
 		ret = aml_pinconf_get_output(info, pin);
@@ -619,6 +625,7 @@ static int aml_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,
 		switch (param) {
 		case PIN_CONFIG_DRIVE_STRENGTH_UA:
 		case PIN_CONFIG_OUTPUT_ENABLE:
+		case PIN_CONFIG_INPUT_ENABLE:
 		case PIN_CONFIG_LEVEL:
 			arg = pinconf_to_config_argument(configs[i]);
 			break;
@@ -643,6 +650,9 @@ static int aml_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,
 		case PIN_CONFIG_OUTPUT_ENABLE:
 			ret = aml_pinconf_set_output(info, pin, arg);
 			break;
+		case PIN_CONFIG_INPUT_ENABLE:
+			ret = aml_pinconf_set_output(info, pin, !arg);
+			break;
 		case PIN_CONFIG_LEVEL:
 			ret = aml_pinconf_set_output_drive(info, pin, arg);
 			break;

---
base-commit: 761af93c9f1a100b8d9f71aa744b8f9abbbbbfb2
change-id: 20260812-input-enable-51166b444697

Best regards,

Signature · 1 line
Xianwei Zhao <[email protected]>
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] aml_pinconf_get() violates the pinctrl subsystem contract by returning 0 (success) instead of…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] aml_pinconf_get() violates the pinctrl subsystem contract by returning 0 (success) instead of -EINVAL when boolean configurations PIN_CONFIG_OUTPUT_ENABLE and PIN_CONFIG_INPUT_ENABLE are disabled, breaking pinctrl debugfs reporting. --

--- Patch [1]: [PATCH] pinctrl: meson: a4: Add input enable pin configuration --- commit c1c005b3aefd6b68087e4e331448ad3792ca002d
Author: Xianwei Zhao <[email protected]>

pinctrl: meson: a4: Add input enable pin configuration

This commit adds support for PIN_CONFIG_INPUT_ENABLE in the Amlogic A4 pinctrl driver. It uses the existing output enable control to configure the input enable state, and updates PIN_CONFIG_OUTPUT_ENABLE handling.

Quoted 9 lines
drivers/pinctrl/meson/pinctrl-amlogic-a4.c +1 -1
@@ -469,9 +469,15 @@ static int aml_pinconf_get(struct pinctrl_dev *pcdev, unsigned int pin,
 		break;
 	case PIN_CONFIG_OUTPUT_ENABLE:
 		ret = aml_pinconf_get_output(info, pin);
-		if (ret <= 0)
+		if (ret < 0)

drivers/pinctrl/meson/pinctrl-amlogic-a4.c static int aml_pinconf_get(struct pinctrl_dev *pcdev, unsigned int pin, · line 481

Quoted 10 lines
drivers/pinctrl/meson/pinctrl-amlogic-a4.c +7 -1
+			return -EINVAL;
+		arg = ret;
+		break;
+	case PIN_CONFIG_INPUT_ENABLE:
+		ret = aml_pinconf_get_output(info, pin);
+		if (ret < 0)
 			return -EINVAL;
-		arg = 1;
+		arg = !ret;
 		break;

[Severity: Medium]
Does returning 0 instead of -EINVAL when these boolean configurations are disabled violate the pinctrl subsystem contract in aml_pinconf_get?

The generic pinctrl subsystem relies on the -EINVAL return code to omit disabled boolean features. Because boolean features ignore the returned argument value, returning 0 with arg = 0 when the feature is disabled will cause debugfs (such as /sys/kernel/debug/pinctrl/.../pinconf-pins) to falsely report both 'output enabled' and 'input enabled' as active for every pin.

Should the check for PIN_CONFIG_OUTPUT_ENABLE remain ret <= 0, and should PIN_CONFIG_INPUT_ENABLE also return -EINVAL when input is not enabled?

Signature · 6 lines
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
maintainer
#2 lore raw
In reply to Xianwei Zhao
Quoted 5 lines · On Wed, Aug 12, 2026 at 12:18 PM Xianwei Zhao via B4 Relay…

From: Xianwei Zhao <[email protected]>

Add support for PIN_CONFIG_INPUT_ENABLE in the Amlogic A4 pinctrl driver.

Quoted 7 lines

Use the existing output enable control to configure the input enable state, since the hardware uses the same control with inverse semantics.

Also update PIN_CONFIG_OUTPUT_ENABLE handling to return the actual output enable state instead of treating any non-zero value as enabled.

I just applied this because we are close to the merge window and it seems important and looks good to me.

I can always pull it out if the maintainers object.

Yours,
Linus Walleij