]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mach-snapdragon: switch to PMIC button driver
authorCaleb Connolly <caleb.connolly@linaro.org>
Tue, 5 Dec 2023 13:46:48 +0000 (13:46 +0000)
committerCaleb Connolly <caleb.connolly@linaro.org>
Tue, 16 Jan 2024 12:26:53 +0000 (12:26 +0000)
The PMIC button driver is a much better representation of the hardware
here, adjust the boards to use upstream DT and the PMIC button driver
instead of exposing the buttons as GPIOs and relying on the GPIO-button
driver.

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Tested-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
13 files changed:
arch/arm/dts/dragonboard410c-uboot.dtsi
arch/arm/dts/dragonboard410c.dts
arch/arm/dts/dragonboard820c-uboot.dtsi
arch/arm/dts/dragonboard820c.dts
arch/arm/dts/dragonboard845c-uboot.dtsi
arch/arm/dts/dragonboard845c.dts
arch/arm/dts/sdm845.dtsi
arch/arm/dts/starqltechn-uboot.dtsi
arch/arm/dts/starqltechn.dts
arch/arm/mach-snapdragon/Kconfig
arch/arm/mach-snapdragon/init_sdm845.c
board/qualcomm/dragonboard410c/dragonboard410c.c
board/qualcomm/dragonboard820c/dragonboard820c.c

index 3b0bd0ed0a1b13c875989910dedb2ac65c8b9234..cec64bf80f99b38a89caa415158e4fbde32ae743 100644 (file)
                gpios = <&pm8916_gpios 3 0>;
        };
 };
-
-
-&pm8916_pon {
-       key_vol_down {
-               gpios = <&pm8916_pon 1 0>;
-       };
-
-       key_power {
-               gpios = <&pm8916_pon 0 0>;
-       };
-};
index 9230dd3fd96c821e8c5db7d2581827082e9b9fac..c41fee977813ce30764b057375b28f9ce0ae4477 100644 (file)
                                #address-cells = <0x1>;
                                #size-cells = <0x1>;
 
-                               pm8916_pon: pm8916_pon@800 {
-                                       compatible = "qcom,pm8916-pwrkey";
-                                       reg = <0x800 0x96>;
-                                       #gpio-cells = <2>;
-                                       gpio-controller;
+                               pon@800 {
+                                       compatible = "qcom,pm8916-pon";
+                                       reg = <0x800 0x100>;
+                                       mode-bootloader = <0x2>;
+                                       mode-recovery = <0x1>;
+
+                                       pwrkey {
+                                               compatible = "qcom,pm8941-pwrkey";
+                                               debounce = <15625>;
+                                               bias-pull-up;
+                                       };
+
+                                       pm8916_resin: resin {
+                                               compatible = "qcom,pm8941-resin";
+                                               debounce = <15625>;
+                                               bias-pull-up;
+                                       };
                                };
 
                                pm8916_gpios: pm8916_gpios@c000 {
index 457728a43ecb5f88abdda2d4e62d5115c778eee6..d93c7c1fbdee25d01c083842cd68831b4dd50a2e 100644 (file)
                };
        };
 };
-
-&pm8994_pon {
-       key_vol_down {
-               gpios = <&pm8994_pon 1 0>;
-               label = "key_vol_down";
-       };
-
-       key_power {
-               gpios = <&pm8994_pon 0 0>;
-               label = "key_power";
-       };
-};
index ad201d48749c4da6f517a60630dbf716a1e1f31b..0d9c9f7a4922dbecc5e823f55bbb8b7c6b2acc49 100644 (file)
                                #address-cells = <0x1>;
                                #size-cells = <0x1>;
 
-                               pm8994_pon: pm8994_pon@800 {
-                                       compatible = "qcom,pm8994-pwrkey";
-                                       reg = <0x800 0x96>;
-                                       #gpio-cells = <2>;
-                                       gpio-controller;
-                                       gpio-bank-name="pm8994_key.";
+                               pm8994_pon: pon@800 {
+                                       compatible = "qcom,pm8916-pon";
+                                       reg = <0x800 0x100>;
+                                       mode-bootloader = <0x2>;
+                                       mode-recovery = <0x1>;
+
+                                       pwrkey {
+                                               compatible = "qcom,pm8941-pwrkey";
+                                               debounce = <15625>;
+                                               bias-pull-up;
+                                       };
+
+                                       pm8994_resin: resin {
+                                               compatible = "qcom,pm8941-resin";
+                                               debounce = <15625>;
+                                               bias-pull-up;
+                                       };
                                };
 
                                pm8994_gpios: pm8994_gpios@c000 {
index 7728f4f4a3e5a61d27e31b7f77cab1c7750c13a6..775f45c0149fc72e8d5e5aecab85253ee08ca276 100644 (file)
                };
        };
 };
-
-&pm8998_pon {
-       key_vol_down {
-               gpios = <&pm8998_pon 1 0>;
-               label = "key_vol_down";
-       };
-       key_power {
-               gpios = <&pm8998_pon 0 0>;
-               label = "key_power";
-       };
-};
index b4f057ac6537859bcf0ab8a4e991e8059047fae2..054f253eb32aa597029618266339961455404bde 100644 (file)
@@ -41,4 +41,8 @@
        };
 };
 
+&pm8998_resin {
+       status = "okay";
+};
+
 #include "dragonboard845c-uboot.dtsi"
index 4798ace0ff8b11ec5dc836e6fe7f4db051bc958a..cd5d890e9a459740c26cb33b2052ee0ab45fdbd6 100644 (file)
                                #address-cells = <0x1>;
                                #size-cells = <0x1>;
 
-                               pm8998_pon: pm8998_pon@800 {
-                                       compatible = "qcom,pm8998-pwrkey";
+                               pm8998_pon: pon@800 {
+                                       compatible = "qcom,pm8998-pon";
+
                                        reg = <0x800 0x100>;
-                                       #gpio-cells = <2>;
-                                       gpio-controller;
-                                       gpio-bank-name = "pm8998_key.";
+                                       mode-bootloader = <0x2>;
+                                       mode-recovery = <0x1>;
+
+                                       pm8998_pwrkey: pwrkey {
+                                               compatible = "qcom,pm8941-pwrkey";
+                                               debounce = <15625>;
+                                               bias-pull-up;
+                                       };
+
+                                       pm8998_resin: resin {
+                                               compatible = "qcom,pm8941-resin";
+                                               debounce = <15625>;
+                                               bias-pull-up;
+                                               status = "disabled";
+                                       };
                                };
 
                                pm8998_gpios: pm8998_gpios@c000 {
index 034d5c1c07edcba48a7b7c960d380209f7b1b48b..55c6d18412ba87ba88a2e6d3519e5fc02b795c7e 100644 (file)
        };
 };
 
-&pm8998_pon {
-       key_vol_down {
-               gpios = <&pm8998_pon 1 0>;
-               label = "key_vol_down";
-       };
-       key_power {
-               gpios = <&pm8998_pon 0 0>;
-               label = "key_power";
-       };
-};
index 5b6372bee79afb991c74e475ea25f9d80ebaf304..0842e19adb604bdd7980de9c0d600a384254dcbd 100644 (file)
                format = "a8r8g8b8";
        };
 
-       gpio-keys {
-               compatible = "gpio-keys";
-
-               key-pwr {
-                       label = "Power";
-                       linux,code = <KEY_ENTER>;
-                       gpios = <&pm8998_pon 0 GPIO_ACTIVE_LOW>;
-               };
-
-               key-vol-down {
-                       label = "Volume Down";
-                       linux,code = <KEY_DOWN>;
-                       gpios = <&pm8998_pon 1 GPIO_ACTIVE_LOW>;
-               };
-       };
-
        soc: soc {
                serial@a84000 {
                        status = "okay";
        };
 };
 
+&pm8998_resin {
+       status = "okay";
+};
+
 &tlmm {
        muic_i2c: muic-i2c-n {
                pins = "GPIO_33", "GPIO_34";
index 3c9f3bee3f1890a589c9475bf8aefab84dfa6794..ad667108191024db5b616a03cb1d503e4165d6ab 100644 (file)
@@ -17,6 +17,7 @@ config SDM845
        select LINUX_KERNEL_IMAGE_HEADER
        imply CLK_QCOM_SDM845
        imply PINCTRL_QCOM_SDM845
+       imply BUTTON_QCOM_PMIC
 
 config LNX_KRNL_IMG_TEXT_OFFSET_BASE
        default 0x80000000
@@ -30,6 +31,7 @@ config TARGET_DRAGONBOARD410C
        select ENABLE_ARM_SOC_BOOT0_HOOK
        imply CLK_QCOM_APQ8016
        imply PINCTRL_QCOM_APQ8016
+       imply BUTTON_QCOM_PMIC
        help
          Support for 96Boards Dragonboard 410C. This board complies with
          96Board Open Platform Specifications. Features:
@@ -45,6 +47,7 @@ config TARGET_DRAGONBOARD820C
        bool "96Boards Dragonboard 820C"
        imply CLK_QCOM_APQ8096
        imply PINCTRL_QCOM_APQ8096
+       imply BUTTON_QCOM_PMIC
        help
          Support for 96Boards Dragonboard 820C. This board complies with
          96Board Open Platform Specifications. Features:
index 1f8850239437f7f37f0a62b1d64f9441befae496..067acc9a6f440d0193b2e1605b3d60ecfccdf9a4 100644 (file)
@@ -5,6 +5,7 @@
  * (C) Copyright 2021 Dzmitry Sankouski <dsankouski@gmail.com>
  */
 
+#include <button.h>
 #include <init.h>
 #include <env.h>
 #include <common.h>
@@ -32,46 +33,18 @@ __weak int board_init(void)
 /* Check for vol- and power buttons */
 __weak int misc_init_r(void)
 {
-       struct udevice *pon;
-       struct gpio_desc resin;
-       int node, ret;
+       struct udevice *btn;
+       int ret;
+       enum button_state_t state;
 
-       ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8998_pon@800", &pon);
+       ret = button_get_by_label("pwrkey", &btn);
        if (ret < 0) {
-               printf("Failed to find PMIC pon node. Check device tree\n");
-               return 0;
+               printf("Couldn't find power button!\n");
+               return ret;
        }
 
-       node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
-                                 "key_vol_down");
-       if (node < 0) {
-               printf("Failed to find key_vol_down node. Check device tree\n");
-               return 0;
-       }
-       if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
-                                      &resin, 0)) {
-               printf("Failed to request key_vol_down button.\n");
-               return 0;
-       }
-       if (dm_gpio_get_value(&resin)) {
-               env_set("key_vol_down", "1");
-               printf("Volume down button pressed\n");
-       } else {
-               env_set("key_vol_down", "0");
-       }
-
-       node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
-                                 "key_power");
-       if (node < 0) {
-               printf("Failed to find key_power node. Check device tree\n");
-               return 0;
-       }
-       if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
-                                      &resin, 0)) {
-               printf("Failed to request key_power button.\n");
-               return 0;
-       }
-       if (dm_gpio_get_value(&resin)) {
+       state = button_get_state(btn);
+       if (state == BUTTON_ON) {
                env_set("key_power", "1");
                printf("Power button pressed\n");
        } else {
index 371b3262f8c591f7732d61510838a17a2c1c2132..350e0e9e20aad4e8098ed609e6da363ddec6e3d6 100644 (file)
@@ -5,6 +5,7 @@
  * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
  */
 
+#include <button.h>
 #include <common.h>
 #include <cpu_func.h>
 #include <dm.h>
@@ -108,32 +109,20 @@ int board_usb_init(int index, enum usb_init_type init)
 /* Check for vol- button - if pressed - stop autoboot */
 int misc_init_r(void)
 {
-       struct udevice *pon;
-       struct gpio_desc resin;
-       int node, ret;
+       struct udevice *btn;
+       int ret;
+       enum button_state_t state;
 
-       ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8916_pon@800", &pon);
+       ret = button_get_by_label("vol_down", &btn);
        if (ret < 0) {
-               printf("Failed to find PMIC pon node. Check device tree\n");
-               return 0;
+               printf("Couldn't find power button!\n");
+               return ret;
        }
 
-       node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
-                                 "key_vol_down");
-       if (node < 0) {
-               printf("Failed to find key_vol_down node. Check device tree\n");
-               return 0;
-       }
-
-       if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
-                                      &resin, 0)) {
-               printf("Failed to request key_vol_down button.\n");
-               return 0;
-       }
-
-       if (dm_gpio_get_value(&resin)) {
+       state = button_get_state(btn);
+       if (state == BUTTON_ON) {
                env_set("preboot", "setenv preboot; fastboot 0");
-               printf("key_vol_down pressed - Starting fastboot.\n");
+               printf("vol_down pressed - Starting fastboot.\n");
        }
 
        return 0;
index 6785bf58e9496c98e179d9cb95423472d44f6257..2f0db628368b18d5c2a6f9df3cb765bae926e27d 100644 (file)
@@ -5,6 +5,7 @@
  * (C) Copyright 2017 Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
  */
 
+#include <button.h>
 #include <cpu_func.h>
 #include <init.h>
 #include <env.h>
@@ -139,30 +140,18 @@ void reset_cpu(void)
 /* Check for vol- button - if pressed - stop autoboot */
 int misc_init_r(void)
 {
-       struct udevice *pon;
-       struct gpio_desc resin;
-       int node, ret;
+       struct udevice *btn;
+       int ret;
+       enum button_state_t state;
 
-       ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8994_pon@800", &pon);
+       ret = button_get_by_label("pwrkey", &btn);
        if (ret < 0) {
-               printf("Failed to find PMIC pon node. Check device tree\n");
-               return 0;
+               printf("Couldn't find power button!\n");
+               return ret;
        }
 
-       node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
-                                 "key_vol_down");
-       if (node < 0) {
-               printf("Failed to find key_vol_down node. Check device tree\n");
-               return 0;
-       }
-
-       if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
-                                      &resin, 0)) {
-               printf("Failed to request key_vol_down button.\n");
-               return 0;
-       }
-
-       if (dm_gpio_get_value(&resin)) {
+       state = button_get_state(btn);
+       if (state == BUTTON_ON) {
                env_set("bootdelay", "-1");
                printf("Power button pressed - dropping to console.\n");
        }