1From 8098310be5887bd5e80830f105b63ed59dc10421 Mon Sep 17 00:00:00 2001 2From: Alexander Filippov <a.filippov@yadro.com> 3Date: Fri, 22 May 2020 11:45:31 +0300 4Subject: [PATCH] aspeed: add bmc position support 5 6There are two Nicoles in one chassis in the Tatlin hardware. 7The position is encoded by a pin, read by an MCU, and then translated 8to the BMC via GPIO pin GPIOE1. 9 10This reads the GPIO pin state and put is as a bootargs item. 11 12Signed-off-by: Alexander Filippov <a.filippov@yadro.com> 13--- 14 arch/arm/mach-aspeed/ast-late-init.c | 21 +++++++++++++++++++++ 15 1 file changed, 21 insertions(+) 16 17diff --git a/arch/arm/mach-aspeed/ast-late-init.c b/arch/arm/mach-aspeed/ast-late-init.c 18index 5646c0e882..7d36dc0d8a 100644 19--- a/arch/arm/mach-aspeed/ast-late-init.c 20+++ b/arch/arm/mach-aspeed/ast-late-init.c 21@@ -7,6 +7,7 @@ 22 23 #include <asm/arch/ast_scu.h> 24 #include <asm/arch/regs-scu.h> 25+#include <asm/gpio.h> 26 #include <malloc.h> 27 28 static void update_bootargs_cmd(const char *key, const char *value) 29@@ -106,9 +107,29 @@ static void set_reset_reason(void) 30 } 31 } 32 33+static void set_bmc_position(void) 34+{ 35+ unsigned gpio = ASPEED_GPIO(E, 1); 36+ 37+ /* Init GPIO */ 38+ if (gpio_request(gpio, "bmcposition") == 0 && 39+ gpio_direction_input(gpio) == 0) 40+ { 41+ int position = gpio_get_value(gpio); 42+ if (position >= 0) 43+ { 44+ printf("BMC Position: %d\n", position); 45+ update_bootargs_cmd("bmcposition", position ? "1" : "0"); 46+ } 47+ } 48+ 49+ gpio_free(gpio); 50+} 51+ 52 int board_late_init(void) 53 { 54 set_reset_reason(); 55+ set_bmc_position(); 56 57 return 0; 58 } 59-- 602.25.4 61 62