All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vikas Manocha <vikas.manocha@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 11/18] stm32f746: to switch on user LED1 & read user button
Date: Tue, 4 Apr 2017 14:45:13 -0700	[thread overview]
Message-ID: <1491342324-5820-12-git-send-email-vikas.manocha@st.com> (raw)
In-Reply-To: <1491342324-5820-1-git-send-email-vikas.manocha@st.com>

All discovery boards have one user button & one user LED. Here we are
just reading the button status & switching ON the user LED.

Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
cc: Christophe KERELLO <christophe.kerello@st.com>
---
Changed in v2: None

 arch/arm/dts/stm32f746-disco.dts           | 10 ++++++++
 board/st/stm32f746-disco/stm32f746-disco.c | 37 ++++++++++++++++++++++++++++++
 include/configs/stm32f746-disco.h          |  1 +
 3 files changed, 48 insertions(+)

diff --git a/arch/arm/dts/stm32f746-disco.dts b/arch/arm/dts/stm32f746-disco.dts
index f830aa9..8e4576b 100644
--- a/arch/arm/dts/stm32f746-disco.dts
+++ b/arch/arm/dts/stm32f746-disco.dts
@@ -78,6 +78,16 @@
 		gpio9 = &gpioj;
 		gpio10 = &gpiok;
 	};
+
+	led1 {
+		compatible = "st,led1";
+		led-gpio = <&gpioi 1 0>;
+	};
+
+	button1 {
+		compatible = "st,button1";
+		button-gpio = <&gpioi 11 0>;
+	};
 };
 
 &clk_hse {
diff --git a/board/st/stm32f746-disco/stm32f746-disco.c b/board/st/stm32f746-disco/stm32f746-disco.c
index 45a2c47..52c1900 100644
--- a/board/st/stm32f746-disco/stm32f746-disco.c
+++ b/board/st/stm32f746-disco/stm32f746-disco.c
@@ -17,6 +17,7 @@
 #include <asm/arch/stm32_periph.h>
 #include <asm/arch/stm32_defs.h>
 #include <asm/arch/syscfg.h>
+#include <asm/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -72,6 +73,42 @@ u32 get_board_rev(void)
 	return 0;
 }
 
+int board_late_init(void)
+{
+	struct gpio_desc gpio = {};
+	int node;
+
+	node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,led1");
+	if (node < 0)
+		return -1;
+
+	gpio_request_by_name_nodev(gd->fdt_blob, node, "led-gpio", 0, &gpio,
+				   GPIOD_IS_OUT);
+
+	if (dm_gpio_is_valid(&gpio)) {
+		dm_gpio_set_value(&gpio, 0);
+		mdelay(10);
+		dm_gpio_set_value(&gpio, 1);
+	}
+
+	/* read button 1*/
+	node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,button1");
+	if (node < 0)
+		return -1;
+
+	gpio_request_by_name_nodev(gd->fdt_blob, node, "button-gpio", 0, &gpio,
+				   GPIOD_IS_IN);
+
+	if (dm_gpio_is_valid(&gpio)) {
+		if (dm_gpio_get_value(&gpio))
+			puts("usr button is at HIGH LEVEL\n");
+		else
+			puts("usr button is at LOW LEVEL\n");
+	}
+
+	return 0;
+}
+
 int board_init(void)
 {
 	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
diff --git a/include/configs/stm32f746-disco.h b/include/configs/stm32f746-disco.h
index fe3ac34..f5f9f0b 100644
--- a/include/configs/stm32f746-disco.h
+++ b/include/configs/stm32f746-disco.h
@@ -81,4 +81,5 @@
 #define CONFIG_CMDLINE_EDITING
 
 #define CONFIG_CMD_MEM
+#define CONFIG_BOARD_LATE_INIT
 #endif /* __CONFIG_H */
-- 
1.9.1

  parent reply	other threads:[~2017-04-04 21:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 21:45 [U-Boot] [PATCH v2 00/18] stm32f7: add sdram & gpio drivers Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 01/18] stm32f7: use clock driver to enable qspi controller clock Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 02/18] stm32f7: sdram: move sdram driver code to ram drivers area Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 03/18] stm32f7: dm: add driver model support for sdram Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 04/18] ARM: DT: stm32f7: add sdram pin contol node Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 05/18] stm32f7: use driver model for sdram initialization Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 06/18] stm32f7: use clock driver to enable sdram controller clock Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 07/18] stm32f7: sdram: use sdram device tree node to configure sdram controller Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 08/18] dm: gpio: Add driver for stm32f7 gpio controller Vikas Manocha
2017-04-09 19:27   ` Simon Glass
2017-04-10 16:25     ` Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 09/18] ARM: DT: stm32f7: add gpio device tree nodes Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 10/18] stm32f7: use stm32f7 gpio driver supporting driver model Vikas Manocha
2017-04-04 21:45 ` Vikas Manocha [this message]
2017-04-04 21:45 ` [U-Boot] [PATCH v2 12/18] stm32f7: stm32f746-disco: read memory info from device tree Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 13/18] stm32f7: enable board info read " Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 14/18] stm32f7: sdram: correct sdram configuration as per micron sdram Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 15/18] stm32f7: increase the max no of pin configuration to 70 Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 16/18] stm32f7: move board specific pin muxing to dts Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 17/18] stm32f7: add support for stm32f769 disco board Vikas Manocha
2017-04-04 21:45 ` [U-Boot] [PATCH v2 18/18] stm32f7: remove not needed configuration from board config Vikas Manocha

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=1491342324-5820-12-git-send-email-vikas.manocha@st.com \
    --to=vikas.manocha@st.com \
    --cc=u-boot@lists.denx.de \
    --subject='Re: [U-Boot] [PATCH v2 11/18] stm32f746: to switch on user LED1 & read user button' \
    /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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.