1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2017-2020 ABB
9 #include "../common/common.h"
12 * For FU1, the MAC address associated with the mgmt port should
13 * be the base address (as read from the IVM) + 4, and for FU2 it
16 #define MAC_ADDRESS_OFFSET_FU1 4
17 #define MAC_ADDRESS_OFFSET_FU2 10
20 * This function reads the state of GPIO40 and returns true (non-zero)
21 * if it is '1' and false(0) otherwise.
23 * This pin is routed to a pull-up on FU2 and a pull-down on
25 #define GPIO_FU_DETECTION 40
27 int secu1_is_fu2(void)
30 int ret = gpio_request(GPIO_FU_DETECTION, "secu");
33 printf("gpio: failed to request pin for FU detection\n");
36 gpio_direction_input(GPIO_FU_DETECTION);
37 value = gpio_get_value(GPIO_FU_DETECTION);
40 printf("FU2 detected\n");
42 printf("FU1 detected\n");
47 static uchar ivm_content[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
49 #if defined(CONFIG_HUSH_INIT_VAR)
50 int hush_init_var(void)
52 ivm_analyze_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
60 ivm_read_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN,
61 MAC_ADDRESS_OFFSET_FU2);
63 ivm_read_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN,
64 MAC_ADDRESS_OFFSET_FU1);