]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
db820c: stop autoboot when vol- pressed
authorJorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Wed, 10 Jan 2018 10:33:52 +0000 (11:33 +0100)
committerTom Rini <trini@konsulko.com>
Mon, 15 Jan 2018 21:29:02 +0000 (16:29 -0500)
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
arch/arm/dts/dragonboard820c-uboot.dtsi [new file with mode: 0644]
board/qualcomm/dragonboard820c/dragonboard820c.c
include/configs/dragonboard820c.h

diff --git a/arch/arm/dts/dragonboard820c-uboot.dtsi b/arch/arm/dts/dragonboard820c-uboot.dtsi
new file mode 100644 (file)
index 0000000..167e72c
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * U-Boot addition to handle Dragonboard 820c pins
+ *
+ * (C) Copyright 2017 Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+&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 f6307f3a6ec016d8b8a824e0172e52a853fee7d0..6040787cffd670fd7c0b6d2b4939f55798676736 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Board init file for Dragonboard 820C
  *
- * (C) Copyright 2017 Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@gmail.com>
+ * (C) Copyright 2017 Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
  *
  * SPDX-License-Identifier:    GPL-2.0+
  */
@@ -14,6 +14,7 @@
 #include <asm/io.h>
 #include <linux/bitops.h>
 #include <asm/psci.h>
+#include <asm/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -125,3 +126,38 @@ int board_init(void)
 void reset_cpu(ulong addr)
 {
        psci_system_reset();
+}
+
+/* Check for vol- button - if pressed - stop autoboot */
+int misc_init_r(void)
+{
+       struct udevice *pon;
+       struct gpio_desc resin;
+       int node, ret;
+
+       ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8994_pon@800", &pon);
+       if (ret < 0) {
+               printf("Failed to find PMIC pon node. Check device tree\n");
+               return 0;
+       }
+
+       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("bootdelay", "-1");
+               printf("Power button pressed - dropping to console.\n");
+       }
+
+       return 0;
+}
index cb64a5612b5109a5a3f7710434d7efbfe962b97a..010bc44b33556271681c46035b92105855eb400d 100644 (file)
@@ -12,6 +12,8 @@
 #include <linux/sizes.h>
 #include <asm/arch/sysmap-apq8096.h>
 
+#define CONFIG_MISC_INIT_R /* To stop autoboot */
+
 /* Physical Memory Map */
 #define CONFIG_NR_DRAM_BANKS           2