summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorVikas Manocha <vikas.manocha@st.com>2017-04-10 15:03:00 -0700
committerTom Rini <trini@konsulko.com>2017-05-08 11:57:21 -0400
commit2f80a9f72ecf4cfee68279a45e3c155f6516faa1 (patch)
tree20decea52c6dcf8052e6eb8a48cb1596d93f4615 /board
parent280057bd7dd623420b2d8b383fe5bbe26820bc93 (diff)
stm32f746: to switch on user LED1 & read user button
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>
Diffstat (limited to 'board')
-rw-r--r--board/st/stm32f746-disco/stm32f746-disco.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/board/st/stm32f746-disco/stm32f746-disco.c b/board/st/stm32f746-disco/stm32f746-disco.c
index 45a2c47aa2..52c1900ee3 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;