mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-22 19:23:07 +00:00
5d57dfad3f
As the ownership is now Hitachi Power Grids, change the license string and adapt the compatible string in DTS files. For kmeter1.dts we change it to "keymile,KMETER1" for now, as this is then compliant with what is submitted to the linux kernel. All other boards don't have a upstreamed version in linux mainline. Signed-off-by: Holger Brunck <holger.brunck@hitachi-powergrids.com> CC: Valentin Longchamp <valentin.longchamp@hitachi-powergrids.com> CC: Heiko Schocher <hs@denx.de> CC: Marek Vasut <marex@denx.de> CC: Tom Rini <trini@konsulko.com> Reviewed-by: Tom Rini <trini@konsulko.com>
67 lines
1.4 KiB
C
67 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2017-2020 Hitachi Power Grids
|
|
*/
|
|
#include <common.h>
|
|
#include <i2c.h>
|
|
#include <asm/gpio.h>
|
|
|
|
#include "../common/common.h"
|
|
|
|
/*
|
|
* For FU1, the MAC address associated with the mgmt port should
|
|
* be the base address (as read from the IVM) + 4, and for FU2 it
|
|
* is + 10
|
|
*/
|
|
#define MAC_ADDRESS_OFFSET_FU1 4
|
|
#define MAC_ADDRESS_OFFSET_FU2 10
|
|
|
|
/*
|
|
* This function reads the state of GPIO40 and returns true (non-zero)
|
|
* if it is '1' and false(0) otherwise.
|
|
*
|
|
* This pin is routed to a pull-up on FU2 and a pull-down on
|
|
*/
|
|
#define GPIO_FU_DETECTION 40
|
|
|
|
int secu1_is_fu2(void)
|
|
{
|
|
int value;
|
|
int ret = gpio_request(GPIO_FU_DETECTION, "secu");
|
|
|
|
if (ret) {
|
|
printf("gpio: failed to request pin for FU detection\n");
|
|
return 1;
|
|
}
|
|
gpio_direction_input(GPIO_FU_DETECTION);
|
|
value = gpio_get_value(GPIO_FU_DETECTION);
|
|
|
|
if (value == 1)
|
|
printf("FU2 detected\n");
|
|
else
|
|
printf("FU1 detected\n");
|
|
|
|
return value;
|
|
}
|
|
|
|
static uchar ivm_content[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
|
|
|
|
#if defined(CONFIG_HUSH_INIT_VAR)
|
|
int hush_init_var(void)
|
|
{
|
|
ivm_analyze_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
int misc_init_r(void)
|
|
{
|
|
if (secu1_is_fu2())
|
|
ivm_read_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN,
|
|
MAC_ADDRESS_OFFSET_FU2);
|
|
else
|
|
ivm_read_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN,
|
|
MAC_ADDRESS_OFFSET_FU1);
|
|
|
|
return 0;
|
|
}
|