diff mbox series

button: qcom-pmic: allow to specify code in devicetree

Message ID 20250424014811.3809818-1-alexeymin@minlexx.ru
State Accepted
Delegated to: Casey Connolly
Headers show
Series button: qcom-pmic: allow to specify code in devicetree | expand

Commit Message

Alexey Minnekhanov April 24, 2025, 1:48 a.m. UTC
From: Alexey Minnekhanov <alexeymin@postmarketos.org>

Most device vendors put "Volume Down" button onto PMIC RESIN.
But Sony is special: see
dts/upstream/src/arm64/qcom/sdm630-sony-xperia-nile.dtsi or [1].
They put "Volume Down" on PMIC GPIO 7 where others usually put
"Volume Up", and KEY_VOLUMEUP is inside &pon_resin.

Currently if you boot U-Boot on such Sony device, you end up
with 2 "Volume Down" buttons, and no "Volume Up", which makes
navigating menu problematic.

Support reading devicetree "linux,code" property and override
statically defined button code & label based on that.

[1] https://elixir.bootlin.com/linux/v6.15-rc3/source/arch/
arm64/boot/dts/qcom/sdm630-sony-xperia-nile.dtsi#L263

Signed-off-by: Alexey Minnekhanov <alexeymin@postmarketos.org>
Signed-off-by: Alexey Minnekhanov <alexeymin@minlexx.ru>
---
 drivers/button/button-qcom-pmic.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Casey Connolly May 9, 2025, 9:24 p.m. UTC | #1
On 4/24/25 03:48, Alexey Minnekhanov wrote:
> From: Alexey Minnekhanov <alexeymin@postmarketos.org>
> 
> Most device vendors put "Volume Down" button onto PMIC RESIN.
> But Sony is special: see
> dts/upstream/src/arm64/qcom/sdm630-sony-xperia-nile.dtsi or [1].
> They put "Volume Down" on PMIC GPIO 7 where others usually put
> "Volume Up", and KEY_VOLUMEUP is inside &pon_resin.
> 
> Currently if you boot U-Boot on such Sony device, you end up
> with 2 "Volume Down" buttons, and no "Volume Up", which makes
> navigating menu problematic.
> 
> Support reading devicetree "linux,code" property and override
> statically defined button code & label based on that.
> 
> [1] https://elixir.bootlin.com/linux/v6.15-rc3/source/arch/
> arm64/boot/dts/qcom/sdm630-sony-xperia-nile.dtsi#L263
> 
> Signed-off-by: Alexey Minnekhanov <alexeymin@postmarketos.org>
> Signed-off-by: Alexey Minnekhanov <alexeymin@minlexx.ru>

Reviewed-by: Casey Connolly <casey.connolly@linaro.org>

Thanks!

> ---
>   drivers/button/button-qcom-pmic.c | 15 +++++++++++++++
>   1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/button/button-qcom-pmic.c b/drivers/button/button-qcom-pmic.c
> index e3bb9bd758a..85addfe32a2 100644
> --- a/drivers/button/button-qcom-pmic.c
> +++ b/drivers/button/button-qcom-pmic.c
> @@ -143,6 +143,21 @@ static int qcom_pwrkey_probe(struct udevice *dev)
>   
>   	priv->base = base;
>   
> +	ret = dev_read_u32(dev, "linux,code", &priv->code);
> +	if (ret == 0) {
> +		/* convert key, if read OK */
> +		switch (priv->code) {
> +		case KEY_VOLUMEDOWN:
> +			priv->code = KEY_DOWN;
> +			uc_plat->label = "Volume Down";
> +			break;
> +		case KEY_VOLUMEUP:
> +			priv->code = KEY_UP;
> +			uc_plat->label = "Volume Up";
> +			break;
> +		}
> +	}
> +
>   	/* Do a sanity check */
>   	ret = pmic_reg_read(priv->pmic, priv->base + REG_TYPE);
>   	if (ret != 0x1 && ret != 0xb) {
Casey Connolly June 3, 2025, 3 p.m. UTC | #2
On Thu, 24 Apr 2025 04:48:11 +0300, Alexey Minnekhanov wrote:
> Most device vendors put "Volume Down" button onto PMIC RESIN.
> But Sony is special: see
> dts/upstream/src/arm64/qcom/sdm630-sony-xperia-nile.dtsi or [1].
> They put "Volume Down" on PMIC GPIO 7 where others usually put
> "Volume Up", and KEY_VOLUMEUP is inside &pon_resin.
> 
> Currently if you boot U-Boot on such Sony device, you end up
> with 2 "Volume Down" buttons, and no "Volume Up", which makes
> navigating menu problematic.
> 
> [...]

Applied, thanks!

[1/1] button: qcom-pmic: allow to specify code in devicetree
      https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/c92bf21e731a

Best regards,
diff mbox series

Patch

diff --git a/drivers/button/button-qcom-pmic.c b/drivers/button/button-qcom-pmic.c
index e3bb9bd758a..85addfe32a2 100644
--- a/drivers/button/button-qcom-pmic.c
+++ b/drivers/button/button-qcom-pmic.c
@@ -143,6 +143,21 @@  static int qcom_pwrkey_probe(struct udevice *dev)
 
 	priv->base = base;
 
+	ret = dev_read_u32(dev, "linux,code", &priv->code);
+	if (ret == 0) {
+		/* convert key, if read OK */
+		switch (priv->code) {
+		case KEY_VOLUMEDOWN:
+			priv->code = KEY_DOWN;
+			uc_plat->label = "Volume Down";
+			break;
+		case KEY_VOLUMEUP:
+			priv->code = KEY_UP;
+			uc_plat->label = "Volume Up";
+			break;
+		}
+	}
+
 	/* Do a sanity check */
 	ret = pmic_reg_read(priv->pmic, priv->base + REG_TYPE);
 	if (ret != 0x1 && ret != 0xb) {