public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jorge Ramirez-Ortiz <jorge.ramirez.ortiz@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 05/05] db820c: stop autoboot when vol- pressed
Date: Wed, 10 Jan 2018 11:33:52 +0100	[thread overview]
Message-ID: <1515580432-25985-5-git-send-email-jorge.ramirez.ortiz@gmail.com> (raw)
In-Reply-To: <1515580432-25985-1-git-send-email-jorge.ramirez.ortiz@gmail.com>

From: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>

Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
---
 arch/arm/dts/dragonboard820c-uboot.dtsi          | 19 ++++++++++++
 board/qualcomm/dragonboard820c/dragonboard820c.c | 37 +++++++++++++++++++++++-
 include/configs/dragonboard820c.h                |  2 ++
 3 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/dragonboard820c-uboot.dtsi

diff --git a/arch/arm/dts/dragonboard820c-uboot.dtsi b/arch/arm/dts/dragonboard820c-uboot.dtsi
new file mode 100644
index 0000000..167e72c
--- /dev/null
+++ b/arch/arm/dts/dragonboard820c-uboot.dtsi
@@ -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";
+	};
+};
diff --git a/board/qualcomm/dragonboard820c/dragonboard820c.c b/board/qualcomm/dragonboard820c/dragonboard820c.c
index 8f40ba4..d4a20d2 100644
--- a/board/qualcomm/dragonboard820c/dragonboard820c.c
+++ b/board/qualcomm/dragonboard820c/dragonboard820c.c
@@ -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;
 
@@ -126,3 +127,37 @@ 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 at 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;
+}
diff --git a/include/configs/dragonboard820c.h b/include/configs/dragonboard820c.h
index 76bcaf8..e0c3c0c 100644
--- a/include/configs/dragonboard820c.h
+++ b/include/configs/dragonboard820c.h
@@ -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
 
-- 
2.7.4

  parent reply	other threads:[~2018-01-10 10:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10 10:33 [U-Boot] [PATCH v1 01/05] env: enable accessing the environment in an EXT4 partition Jorge Ramirez-Ortiz
2018-01-10 10:33 ` [U-Boot] [PATCH v1 02/05] arm: mach-snapdragon: refactor clock driver Jorge Ramirez-Ortiz
2018-01-15 21:43   ` [U-Boot] [U-Boot, v1, " Tom Rini
2018-01-10 10:33 ` [U-Boot] [PATCH v1 03/05] db820c: add qualcomm dragonboard 820C support Jorge Ramirez-Ortiz
2018-01-12 11:19   ` Jorge Ramirez
2018-01-15  9:27   ` Jorge Ramirez
2018-01-15 21:43   ` [U-Boot] [U-Boot, v1, " Tom Rini
2018-01-10 10:33 ` [U-Boot] [PATCH v1 04/05] db820c: enable pmic gpios for pm8994 Jorge Ramirez-Ortiz
2018-01-15 21:43   ` [U-Boot] [U-Boot, v1, " Tom Rini
2018-01-10 10:33 ` Jorge Ramirez-Ortiz [this message]
2018-01-15 21:43   ` [U-Boot] [U-Boot, v1, 05/05] db820c: stop autoboot when vol- pressed Tom Rini
2018-01-15 21:43 ` [U-Boot] [U-Boot, v1, 01/05] env: enable accessing the environment in an EXT4 partition Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1515580432-25985-5-git-send-email-jorge.ramirez.ortiz@gmail.com \
    --to=jorge.ramirez.ortiz@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox