Skip to contentSkip to conversation

Add gpio configuration support for Qualcomm Snapdragon platform

PATCH Superseded Petr Hodina 2 participants 4 messages Jun 1

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Add gpio configuration support for Qualcomm Snapdragon platform

This patch series adds the gpio configuration as input along with pull-up/down/disable and drive strength for output.

Remove the reconfiguration from the set_direction.

This enables on mainline Linux phones to use volume-up in menu.

---
Petr Hodina (2):
gpio: qcom_pmic_gpio: implement standard pinconf parameters
gpio: qcom_pmic_gpio: don't reset pull on direction change

 drivers/gpio/qcom_pmic_gpio.c | 41 ++++++++++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 9 deletions(-)

---
base-commit: 1f89ddd61cd8c27a3dc1fc7edbeccb55d424eb72
change-id: 20260601-qcom-gpio-98e85ab22647

Best regards,

Signature · 1 line
Petr Hodina <[email protected]>
#1 lore raw

PATCH 1/2 gpio: qcom_pmic_gpio: implement standard pinconf parameters

Set bias-pull-up/down/disable, input-enable and the vendor qcom,drive-strength properties in pinconf_params.

---
 drivers/gpio/qcom_pmic_gpio.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)
drivers/gpio/qcom_pmic_gpio.c +32 -3
index 4458c55cd3d..71cc76fef2f 100644
@@ -56,6 +56,8 @@
 #define REG_DIG_VIN_VIN0       0
 
 #define REG_DIG_PULL_CTL       0x42
+#define REG_DIG_PULL_UP_30K    0x0
+#define REG_DIG_PULL_DN        0x4
 #define REG_DIG_PULL_NO_PU     0x5
 
 #define REG_LV_MV_OUTPUT_CTL	0x44
@@ -365,6 +367,11 @@ U_BOOT_DRIVER(qcom_pmic_gpio) = {
 static const struct pinconf_param qcom_pmic_pinctrl_conf_params[] = {
 	{ "output-high", PIN_CONFIG_OUTPUT_ENABLE, 1 },
 	{ "output-low", PIN_CONFIG_OUTPUT, 0 },
+	{ "input-enable", PIN_CONFIG_INPUT_ENABLE, 1 },
+	{ "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 },
+	{ "bias-pull-up", PIN_CONFIG_BIAS_PULL_UP, 0 },
+	{ "bias-pull-down", PIN_CONFIG_BIAS_PULL_DOWN, 0 },
+	{ "qcom,drive-strength", PIN_CONFIG_DRIVE_STRENGTH, 0 },
 };
 
 static int qcom_pmic_pinctrl_get_pins_count(struct udevice *dev)
@@ -387,9 +394,31 @@ static const char *qcom_pmic_pinctrl_get_pin_name(struct udevice *dev, unsigned
 static int qcom_pmic_pinctrl_pinconf_set(struct udevice *dev, unsigned int selector,
 					 unsigned int param, unsigned int arg)
 {
-	/* We only support configuring the pin as an output, either low or high */
-	return _qcom_gpio_set_direction(dev, selector, false,
-					param == PIN_CONFIG_OUTPUT_ENABLE);
+	struct qcom_pmic_gpio_data *plat = dev_get_plat(dev);
+	u32 gpio_base = plat->pid + REG_OFFSET(selector);
+
+	switch (param) {
+	case PIN_CONFIG_OUTPUT_ENABLE:
+	case PIN_CONFIG_OUTPUT:
+		return qcom_gpio_set_direction(dev, selector, false,
+					       param == PIN_CONFIG_OUTPUT_ENABLE);
+	case PIN_CONFIG_INPUT_ENABLE:
+		return qcom_gpio_set_direction(dev, selector, true, 0);
+	case PIN_CONFIG_BIAS_PULL_UP:
+		return pmic_reg_write(plat->pmic, gpio_base + REG_DIG_PULL_CTL,
+				      REG_DIG_PULL_UP_30K);
+	case PIN_CONFIG_BIAS_PULL_DOWN:
+		return pmic_reg_write(plat->pmic, gpio_base + REG_DIG_PULL_CTL,
+				      REG_DIG_PULL_DN);
+	case PIN_CONFIG_BIAS_DISABLE:
+		return pmic_reg_write(plat->pmic, gpio_base + REG_DIG_PULL_CTL,
+				      REG_DIG_PULL_NO_PU);
+	case PIN_CONFIG_DRIVE_STRENGTH:
+		return pmic_reg_write(plat->pmic, gpio_base + REG_DIG_OUT_CTL,
+				      REG_DIG_OUT_CTL_CMOS | (arg & 0x3));
+	default:
+		return -EOPNOTSUPP;
+	}
 }
 
 static const char *qcom_pmic_pinctrl_get_function_name(struct udevice *dev, unsigned int selector)
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/2 gpio: qcom_pmic_gpio: don't reset pull on direction change

In reply to Petr Hodina

Fix for pull-up/pull-down/disable as that's independent of the direction.

---
 drivers/gpio/qcom_pmic_gpio.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/gpio/qcom_pmic_gpio.c +0 -6
index 71cc76fef2f..e67e138ede2 100644
@@ -129,12 +129,6 @@ static int qcom_gpio_set_direction(struct udevice *dev, unsigned int offset,
 
 	_qcom_gpio_set_direction(dev, offset, input, value);
 
-	/* Set the right pull (no pull) */
-	ret = pmic_reg_write(plat->pmic, gpio_base + REG_DIG_PULL_CTL,
-			     REG_DIG_PULL_NO_PU);
-	if (ret < 0)
-		return ret;
-
 	/* Configure output pin drivers if needed */
 	if (!input) {
 		/* Select the VIN - VIN0, pin is input so it doesn't matter */
Signature · 1 line
2.53.0
#3 lore raw
In reply to Petr Hodina
Quoted 7 lines · On 6/1/26 13:52, Petr Hodina via B4 Relay wrote:

This patch series adds the gpio configuration as input along with pull-up/down/disable and drive strength for output.

Remove the reconfiguration from the set_direction.

This enables on mainline Linux phones to use volume-up in menu.

Quoted 7 lines

---
Petr Hodina (2):
gpio: qcom_pmic_gpio: implement standard pinconf parameters
gpio: qcom_pmic_gpio: don't reset pull on direction change

  drivers/gpio/qcom_pmic_gpio.c | 41 ++++++++++++++++++++++++++++++++---------

Please switch to drivers/gpio/qcom_spmi_gpio.c instead, this driver is deprecated and should be removed once it's tested on all SoCs referenced.

Thanks,
Neil

Quoted 10 lines
  1 file changed, 32 insertions(+), 9 deletions(-)

---
base-commit: 1f89ddd61cd8c27a3dc1fc7edbeccb55d424eb72
change-id: 20260601-qcom-gpio-98e85ab22647

Best regards,
--
Petr Hodina <[email protected]>