]> git.sur5r.net Git - u-boot/commitdiff
stm32f746: to switch on user LED1 & read user button
authorVikas Manocha <vikas.manocha@st.com>
Mon, 10 Apr 2017 22:03:00 +0000 (15:03 -0700)
committerTom Rini <trini@konsulko.com>
Mon, 8 May 2017 15:57:21 +0000 (11:57 -0400)
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>

arch/arm/dts/stm32f746-disco.dts
board/st/stm32f746-disco/stm32f746-disco.c
include/configs/stm32f746-disco.h

index f830aa90efd91eddcad9373a8cb2dfa20653c9ba..8e4576bdc1fb9e90d670459d94b7e9e556ad0152 100644 (file)
                gpio9 = &gpioj;
                gpio10 = &gpiok;
        };
+
+       led1 {
+               compatible = "st,led1";
+               led-gpio = <&gpioi 1 0>;
+       };
+
+       button1 {
+               compatible = "st,button1";
+               button-gpio = <&gpioi 11 0>;
+       };
 };
 
 &clk_hse {
index 45a2c47aa281964f3321723dd4186cc0afc7325d..52c1900ee3402da09ee99ac45b86231ecc90567e 100644 (file)
@@ -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;
index e917ba9162fb1d1261851957f329d69ea2ec384a..48ac4413e026c2a8bff90818c37dea54ee22cfb0 100644 (file)
@@ -75,4 +75,5 @@
 
 #define CONFIG_CMD_MEM
 #define CONFIG_CMD_CACHE
+#define CONFIG_BOARD_LATE_INIT
 #endif /* __CONFIG_H */