From patchwork Mon Mar 20 20:48:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vikas MANOCHA X-Patchwork-Id: 741197 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3vn7xp3HJjz9s2s for ; Tue, 21 Mar 2017 08:14:53 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 176DEC21CD4; Mon, 20 Mar 2017 21:13:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1FE4DC21CA6; Mon, 20 Mar 2017 21:10:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7729BC21CF1; Mon, 20 Mar 2017 21:09:57 +0000 (UTC) Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lists.denx.de (Postfix) with ESMTPS id 4BB63C21CB3 for ; Mon, 20 Mar 2017 21:09:54 +0000 (UTC) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id v2KL9ldG026343; Mon, 20 Mar 2017 22:09:52 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-.pphosted.com with ESMTP id 298vnfshmj-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 20 Mar 2017 22:09:52 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1460B31; Mon, 20 Mar 2017 21:09:52 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag7node3.st.com [10.75.127.21]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id F0E194E4D; Mon, 20 Mar 2017 21:09:51 +0000 (GMT) Received: from localhost (10.75.127.49) by SFHDAG7NODE3.st.com (10.75.127.21) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Mon, 20 Mar 2017 22:09:51 +0100 From: Vikas Manocha To: Date: Mon, 20 Mar 2017 13:48:37 -0700 Message-ID: <1490042927-27450-12-git-send-email-vikas.manocha@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490042927-27450-1-git-send-email-vikas.manocha@st.com> References: <1490042927-27450-1-git-send-email-vikas.manocha@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG3NODE2.st.com (10.75.127.8) To SFHDAG7NODE3.st.com (10.75.127.21) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-20_15:, , signatures=0 Cc: Christophe KERELLO , Hans de Goede , Ian Campbell Subject: [U-Boot] [PATCH 11/18] stm32f746: to switch on user LED1 & read user button X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 cc: Christophe KERELLO --- 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 #include #include +#include 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 */