mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-18 10:54:37 +00:00
Merge patch series "boards: siemens: iot2050: SM variant, sysinfo support, fixes & cleanups"
Baocheng Su <baocheng.su@siemens.com> says: This introduces a sysinfo driver which also permits SMBIOS support. The first 10 patches of v2 have already been applied. The remaining is solely the sysinfo driver. To maintain consistency and ease of searching through the history, the series title remains unchanged. Link: https://lore.kernel.org/r/20250218023614.52574-1-baocheng.su@siemens.com
This commit is contained in:
commit
962217d218
10 changed files with 425 additions and 63 deletions
|
@ -14,6 +14,24 @@
|
|||
spi0 = &ospi0;
|
||||
};
|
||||
|
||||
sysinfo {
|
||||
compatible = "siemens,sysinfo-iot2050";
|
||||
/* TI_SRAM_SCRATCH_BOARD_EEPROM_START */
|
||||
offset = <0x40280000>;
|
||||
bootph-all;
|
||||
|
||||
smbios {
|
||||
system {
|
||||
manufacturer = "SIEMENS AG";
|
||||
product = "SIMATIC IOT2050";
|
||||
};
|
||||
|
||||
baseboard {
|
||||
manufacturer = "SIEMENS AG";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
leds {
|
||||
bootph-all;
|
||||
status-led-red {
|
||||
|
|
|
@ -35,6 +35,8 @@ config TARGET_IOT2050_A53
|
|||
select BOARD_LATE_INIT
|
||||
select SYS_DISABLE_DCACHE_OPS
|
||||
select BINMAN
|
||||
select SYSINFO
|
||||
select SPL_SYSINFO if SPL
|
||||
help
|
||||
This builds U-Boot for the IOT2050 devices.
|
||||
|
||||
|
|
|
@ -25,28 +25,7 @@
|
|||
#include <asm/gpio.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#define IOT2050_INFO_MAGIC 0x20502050
|
||||
|
||||
struct iot2050_info {
|
||||
u32 magic;
|
||||
u16 size;
|
||||
char name[20 + 1];
|
||||
char serial[16 + 1];
|
||||
char mlfb[18 + 1];
|
||||
char uuid[32 + 1];
|
||||
char a5e[18 + 1];
|
||||
u8 mac_addr_cnt;
|
||||
u8 mac_addr[8][ARP_HLEN];
|
||||
char seboot_version[40 + 1];
|
||||
u8 padding[3];
|
||||
u32 ddr_size_mb;
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* Scratch SRAM (available before DDR RAM) contains extracted EEPROM data.
|
||||
*/
|
||||
#define IOT2050_INFO_DATA ((struct iot2050_info *) \
|
||||
TI_SRAM_SCRATCH_BOARD_EEPROM_START)
|
||||
#include "../../../../drivers/sysinfo/iot2050.h"
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
|
@ -117,6 +96,8 @@ static const char *m2_connector_mode_name[] = {
|
|||
|
||||
static enum m2_connector_mode connector_mode;
|
||||
|
||||
static char iot2050_board_name[21];
|
||||
|
||||
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
|
||||
static void *connector_overlay;
|
||||
static u32 connector_overlay_size;
|
||||
|
@ -149,37 +130,57 @@ static void set_pinvalue(const char *gpio_name, const char *label, int value)
|
|||
dm_gpio_set_value(&gpio, value);
|
||||
}
|
||||
|
||||
static bool setup_sysinfo(struct udevice **sysinfo_ptr)
|
||||
{
|
||||
if (sysinfo_get(sysinfo_ptr)) {
|
||||
pr_err("Could not find sysinfo device.\n");
|
||||
return false;
|
||||
}
|
||||
if (sysinfo_detect(*sysinfo_ptr)) {
|
||||
pr_err("Board info parsing error\n");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void get_board_name(void)
|
||||
{
|
||||
struct udevice *sysinfo;
|
||||
|
||||
if (iot2050_board_name[0] != 0)
|
||||
return;
|
||||
|
||||
if (!setup_sysinfo(&sysinfo))
|
||||
return;
|
||||
|
||||
sysinfo_get_str(sysinfo, BOARD_NAME, sizeof(iot2050_board_name),
|
||||
iot2050_board_name);
|
||||
}
|
||||
|
||||
static bool board_is_advanced(void)
|
||||
{
|
||||
struct iot2050_info *info = IOT2050_INFO_DATA;
|
||||
|
||||
return info->magic == IOT2050_INFO_MAGIC &&
|
||||
strstr((char *)info->name, "IOT2050-ADVANCED") != NULL;
|
||||
get_board_name();
|
||||
return strstr(iot2050_board_name, "IOT2050-ADVANCED") != NULL;
|
||||
}
|
||||
|
||||
static bool board_is_pg1(void)
|
||||
{
|
||||
struct iot2050_info *info = IOT2050_INFO_DATA;
|
||||
|
||||
return info->magic == IOT2050_INFO_MAGIC &&
|
||||
(strcmp((char *)info->name, "IOT2050-BASIC") == 0 ||
|
||||
strcmp((char *)info->name, "IOT2050-ADVANCED") == 0);
|
||||
get_board_name();
|
||||
return strcmp(iot2050_board_name, "IOT2050-BASIC") == 0 ||
|
||||
strcmp(iot2050_board_name, "IOT2050-ADVANCED") == 0;
|
||||
}
|
||||
|
||||
static bool board_is_m2(void)
|
||||
{
|
||||
struct iot2050_info *info = IOT2050_INFO_DATA;
|
||||
|
||||
return info->magic == IOT2050_INFO_MAGIC &&
|
||||
strcmp((char *)info->name, "IOT2050-ADVANCED-M2") == 0;
|
||||
get_board_name();
|
||||
return strcmp(iot2050_board_name, "IOT2050-ADVANCED-M2") == 0;
|
||||
}
|
||||
|
||||
static bool board_is_sm(void)
|
||||
{
|
||||
struct iot2050_info *info = IOT2050_INFO_DATA;
|
||||
|
||||
return info->magic == IOT2050_INFO_MAGIC &&
|
||||
strcmp((char *)info->name, "IOT2050-ADVANCED-SM") == 0;
|
||||
get_board_name();
|
||||
return strcmp(iot2050_board_name, "IOT2050-ADVANCED-SM") == 0;
|
||||
}
|
||||
|
||||
static void remove_mmc1_target(void)
|
||||
|
@ -206,33 +207,43 @@ static void enable_pcie_connector_power(void)
|
|||
|
||||
void set_board_info_env(void)
|
||||
{
|
||||
struct iot2050_info *info = IOT2050_INFO_DATA;
|
||||
u8 __maybe_unused mac_cnt;
|
||||
struct udevice *sysinfo;
|
||||
const char *fdtfile;
|
||||
|
||||
if (info->magic != IOT2050_INFO_MAGIC) {
|
||||
pr_err("IOT2050: Board info parsing error!\n");
|
||||
return;
|
||||
}
|
||||
char buf[41];
|
||||
|
||||
if (env_get("board_uuid"))
|
||||
return;
|
||||
|
||||
env_set("board_name", info->name);
|
||||
env_set("board_serial", info->serial);
|
||||
env_set("mlfb", info->mlfb);
|
||||
env_set("board_uuid", info->uuid);
|
||||
env_set("board_a5e", info->a5e);
|
||||
if (!setup_sysinfo(&sysinfo))
|
||||
return;
|
||||
|
||||
if (sysinfo_get_str(sysinfo, BOARD_NAME, sizeof(buf), buf) == 0)
|
||||
env_set("board_name", buf);
|
||||
if (sysinfo_get_str(sysinfo, SYSID_SM_SYSTEM_SERIAL, sizeof(buf), buf) == 0)
|
||||
env_set("board_serial", buf);
|
||||
if (sysinfo_get_str(sysinfo, BOARD_MLFB, sizeof(buf), buf) == 0)
|
||||
env_set("mlfb", buf);
|
||||
if (sysinfo_get_str(sysinfo, BOARD_UUID, sizeof(buf), buf) == 0)
|
||||
env_set("board_uuid", buf);
|
||||
if (sysinfo_get_str(sysinfo, BOARD_A5E, sizeof(buf), buf) == 0)
|
||||
env_set("board_a5e", buf);
|
||||
if (sysinfo_get_str(sysinfo, BOARD_SEBOOT_VER, sizeof(buf), buf) == 0)
|
||||
env_set("seboot_version", buf);
|
||||
env_set("fw_version", PLAIN_VERSION);
|
||||
env_set("seboot_version", info->seboot_version);
|
||||
|
||||
if (IS_ENABLED(CONFIG_NET)) {
|
||||
int mac_cnt;
|
||||
|
||||
mac_cnt = sysinfo_get_item_count(sysinfo, SYSID_BOARD_MAC_ADDR);
|
||||
/* set MAC addresses to ensure forwarding to the OS */
|
||||
for (mac_cnt = 0; mac_cnt < info->mac_addr_cnt; mac_cnt++) {
|
||||
if (is_valid_ethaddr(info->mac_addr[mac_cnt]))
|
||||
eth_env_set_enetaddr_by_index("eth",
|
||||
mac_cnt + 1,
|
||||
info->mac_addr[mac_cnt]);
|
||||
for (int i = 0; i < mac_cnt; i++) {
|
||||
u8 *mac = NULL;
|
||||
size_t bytes = 0;
|
||||
|
||||
sysinfo_get_data_by_index(sysinfo, SYSID_BOARD_MAC_ADDR,
|
||||
i, (void **)&mac, &bytes);
|
||||
if (bytes == ARP_HLEN && is_valid_ethaddr(mac))
|
||||
eth_env_set_enetaddr_by_index("eth", i + 1, mac);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,7 +299,7 @@ static void do_overlay_prepare(const char *overlay_path)
|
|||
return;
|
||||
|
||||
fit_error:
|
||||
pr_err("M.2 device tree overlay %s not available,\n", overlay_path);
|
||||
pr_err("M.2 device tree overlay %s not available.\n", overlay_path);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -362,8 +373,15 @@ int board_init(void)
|
|||
|
||||
int dram_init(void)
|
||||
{
|
||||
struct iot2050_info *info = IOT2050_INFO_DATA;
|
||||
gd->ram_size = ((phys_size_t)(info->ddr_size_mb)) << 20;
|
||||
struct udevice *sysinfo;
|
||||
u32 ddr_size_mb;
|
||||
|
||||
if (!setup_sysinfo(&sysinfo))
|
||||
return -ENODEV;
|
||||
|
||||
sysinfo_get_int(sysinfo, SYSID_BOARD_RAM_SIZE_MB, &ddr_size_mb);
|
||||
|
||||
gd->ram_size = ((phys_size_t)(ddr_size_mb)) << 20;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -405,18 +423,18 @@ int dram_init_banksize(void)
|
|||
#ifdef CONFIG_SPL_LOAD_FIT
|
||||
int board_fit_config_name_match(const char *name)
|
||||
{
|
||||
struct iot2050_info *info = IOT2050_INFO_DATA;
|
||||
char upper_name[32];
|
||||
|
||||
get_board_name();
|
||||
|
||||
/* skip the prefix "ti/k3-am65x8-" */
|
||||
name += 13;
|
||||
|
||||
if (info->magic != IOT2050_INFO_MAGIC ||
|
||||
strlen(name) >= sizeof(upper_name))
|
||||
if (strlen(name) >= sizeof(upper_name))
|
||||
return -1;
|
||||
|
||||
str_to_upper(name, upper_name, sizeof(upper_name));
|
||||
if (!strcmp(upper_name, (char *)info->name))
|
||||
if (!strcmp(upper_name, iot2050_board_name))
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
|
|
|
@ -31,6 +31,13 @@ config SYSINFO_RCAR3
|
|||
help
|
||||
Support querying SoC version information for Renesas R-Car Gen3.
|
||||
|
||||
config SYSINFO_IOT2050
|
||||
bool "Enable sysinfo driver for the Siemens IOT2050"
|
||||
depends on TARGET_IOT2050_A53
|
||||
default y if TARGET_IOT2050_A53
|
||||
help
|
||||
Support querying device information for Siemens IOT2050.
|
||||
|
||||
config SYSINFO_SANDBOX
|
||||
bool "Enable sysinfo driver for the Sandbox board"
|
||||
help
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
obj-y += sysinfo-uclass.o
|
||||
obj-$(CONFIG_SYSINFO_GAZERBEAM) += gazerbeam.o
|
||||
obj-$(CONFIG_SYSINFO_GPIO) += gpio.o
|
||||
obj-$(CONFIG_SYSINFO_IOT2050) += iot2050.o
|
||||
obj-$(CONFIG_SYSINFO_RCAR3) += rcar3.o
|
||||
obj-$(CONFIG_SYSINFO_SANDBOX) += sandbox.o
|
||||
obj-$(CONFIG_SYSINFO_SMBIOS) += smbios.o
|
||||
|
|
202
drivers/sysinfo/iot2050.c
Normal file
202
drivers/sysinfo/iot2050.c
Normal file
|
@ -0,0 +1,202 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (c) Siemens AG, 2025
|
||||
*/
|
||||
|
||||
#include <dm.h>
|
||||
#include <sysinfo.h>
|
||||
#include <net.h>
|
||||
#include <u-boot/uuid.h>
|
||||
#include <asm/arch/hardware.h>
|
||||
|
||||
#include "iot2050.h"
|
||||
|
||||
#define IOT2050_INFO_MAGIC 0x20502050
|
||||
|
||||
#define IOT2050_UUID_STR_LEN (32)
|
||||
|
||||
struct iot2050_info {
|
||||
u32 magic;
|
||||
u16 size;
|
||||
char name[20 + 1];
|
||||
char serial[16 + 1];
|
||||
char mlfb[18 + 1];
|
||||
char uuid[IOT2050_UUID_STR_LEN + 1];
|
||||
char a5e[18 + 1];
|
||||
u8 mac_addr_cnt;
|
||||
u8 mac_addr[8][ARP_HLEN];
|
||||
char seboot_version[40 + 1];
|
||||
u8 padding[3];
|
||||
u32 ddr_size_mb;
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* struct sysinfo_iot2050_priv - sysinfo private data
|
||||
* @info: iot2050 board info
|
||||
*/
|
||||
struct sysinfo_iot2050_priv {
|
||||
struct iot2050_info *info;
|
||||
u8 uuid_smbios[16];
|
||||
};
|
||||
|
||||
static int sysinfo_iot2050_detect(struct udevice *dev)
|
||||
{
|
||||
struct sysinfo_iot2050_priv *priv = dev_get_priv(dev);
|
||||
|
||||
if (!priv->info || priv->info->magic != IOT2050_INFO_MAGIC)
|
||||
return -EFAULT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sysinfo_iot2050_get_str(struct udevice *dev, int id, size_t size,
|
||||
char *val)
|
||||
{
|
||||
struct sysinfo_iot2050_priv *priv = dev_get_priv(dev);
|
||||
|
||||
switch (id) {
|
||||
case BOARD_NAME:
|
||||
case SYSID_SM_BASEBOARD_VERSION:
|
||||
strlcpy(val, priv->info->name, size);
|
||||
break;
|
||||
case SYSID_SM_SYSTEM_SERIAL:
|
||||
strlcpy(val, priv->info->serial, size);
|
||||
break;
|
||||
case BOARD_MLFB:
|
||||
case SYSID_SM_SYSTEM_VERSION:
|
||||
strlcpy(val, priv->info->mlfb, size);
|
||||
break;
|
||||
case BOARD_UUID:
|
||||
strlcpy(val, priv->info->uuid, size);
|
||||
break;
|
||||
case BOARD_A5E:
|
||||
case SYSID_SM_BASEBOARD_PRODUCT:
|
||||
strlcpy(val, priv->info->a5e, size);
|
||||
break;
|
||||
case BOARD_SEBOOT_VER:
|
||||
case SYSID_PRIOR_STAGE_VERSION:
|
||||
strlcpy(val, priv->info->seboot_version, size);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
};
|
||||
|
||||
val[size - 1] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sysinfo_iot2050_get_int(struct udevice *dev, int id, int *val)
|
||||
{
|
||||
struct sysinfo_iot2050_priv *priv = dev_get_priv(dev);
|
||||
|
||||
switch (id) {
|
||||
case SYSID_BOARD_RAM_SIZE_MB:
|
||||
*val = priv->info->ddr_size_mb;
|
||||
return 0;
|
||||
default:
|
||||
return -EINVAL;
|
||||
};
|
||||
}
|
||||
|
||||
static int sysinfo_iot2050_get_data(struct udevice *dev, int id, void **data,
|
||||
size_t *size)
|
||||
{
|
||||
struct sysinfo_iot2050_priv *priv = dev_get_priv(dev);
|
||||
|
||||
switch (id) {
|
||||
case SYSID_SM_SYSTEM_UUID:
|
||||
*data = priv->uuid_smbios;
|
||||
*size = 16;
|
||||
return 0;
|
||||
default:
|
||||
return -EINVAL;
|
||||
};
|
||||
}
|
||||
|
||||
static int sysinfo_iot2050_get_item_count(struct udevice *dev, int id)
|
||||
{
|
||||
struct sysinfo_iot2050_priv *priv = dev_get_priv(dev);
|
||||
|
||||
switch (id) {
|
||||
case SYSID_BOARD_MAC_ADDR:
|
||||
return priv->info->mac_addr_cnt;
|
||||
default:
|
||||
return -EINVAL;
|
||||
};
|
||||
}
|
||||
|
||||
static int sysinfo_iot2050_get_data_by_index(struct udevice *dev, int id,
|
||||
int index, void **data,
|
||||
size_t *size)
|
||||
{
|
||||
struct sysinfo_iot2050_priv *priv = dev_get_priv(dev);
|
||||
|
||||
switch (id) {
|
||||
case SYSID_BOARD_MAC_ADDR:
|
||||
if (index >= priv->info->mac_addr_cnt)
|
||||
return -EINVAL;
|
||||
*data = priv->info->mac_addr[index];
|
||||
*size = ARP_HLEN;
|
||||
return 0;
|
||||
default:
|
||||
return -EINVAL;
|
||||
};
|
||||
}
|
||||
|
||||
static const struct sysinfo_ops sysinfo_iot2050_ops = {
|
||||
.detect = sysinfo_iot2050_detect,
|
||||
.get_str = sysinfo_iot2050_get_str,
|
||||
.get_int = sysinfo_iot2050_get_int,
|
||||
.get_data = sysinfo_iot2050_get_data,
|
||||
.get_item_count = sysinfo_iot2050_get_item_count,
|
||||
.get_data_by_index = sysinfo_iot2050_get_data_by_index,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Convert the IOT2050 UUID string to the SMBIOS format
|
||||
*
|
||||
* @param uuid_raw The IOT2050 UUID string parsed from the eeprom
|
||||
* @param uuid_smbios The buffer to hold the SMBIOS formatted UUID
|
||||
*/
|
||||
static void sysinfo_iot2050_convert_uuid(const char *uuid_iot2050,
|
||||
u8 *uuid_smbios)
|
||||
{
|
||||
char uuid_rfc4122_str[IOT2050_UUID_STR_LEN + 4 + 1] = {0};
|
||||
char *tmp = uuid_rfc4122_str;
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
memcpy(tmp, uuid_iot2050 + i * 2, 2);
|
||||
tmp += 2;
|
||||
if (i == 3 || i == 5 || i == 7 || i == 9)
|
||||
*tmp++ = '-';
|
||||
}
|
||||
uuid_str_to_bin(uuid_rfc4122_str, uuid_smbios, UUID_STR_FORMAT_GUID);
|
||||
}
|
||||
|
||||
static int sysinfo_iot2050_probe(struct udevice *dev)
|
||||
{
|
||||
struct sysinfo_iot2050_priv *priv = dev_get_priv(dev);
|
||||
unsigned long offset;
|
||||
|
||||
offset = dev_read_u32_default(dev, "offset",
|
||||
TI_SRAM_SCRATCH_BOARD_EEPROM_START);
|
||||
priv->info = (struct iot2050_info *)offset;
|
||||
|
||||
sysinfo_iot2050_convert_uuid(priv->info->uuid, priv->uuid_smbios);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct udevice_id sysinfo_iot2050_ids[] = {
|
||||
{ .compatible = "siemens,sysinfo-iot2050" },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(sysinfo_iot2050) = {
|
||||
.name = "sysinfo_iot2050",
|
||||
.id = UCLASS_SYSINFO,
|
||||
.of_match = sysinfo_iot2050_ids,
|
||||
.ops = &sysinfo_iot2050_ops,
|
||||
.priv_auto = sizeof(struct sysinfo_iot2050_priv),
|
||||
.probe = sysinfo_iot2050_probe,
|
||||
};
|
14
drivers/sysinfo/iot2050.h
Normal file
14
drivers/sysinfo/iot2050.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) Siemens AG, 2025
|
||||
*/
|
||||
|
||||
#include <sysinfo.h>
|
||||
|
||||
enum sysinfo_id_iot2050 {
|
||||
BOARD_MLFB = SYSID_USER,
|
||||
BOARD_A5E,
|
||||
BOARD_NAME,
|
||||
BOARD_UUID,
|
||||
BOARD_SEBOOT_VER,
|
||||
};
|
|
@ -119,6 +119,35 @@ int sysinfo_get_data(struct udevice *dev, int id, void **data, size_t *size)
|
|||
return ops->get_data(dev, id, data, size);
|
||||
}
|
||||
|
||||
int sysinfo_get_item_count(struct udevice *dev, int id)
|
||||
{
|
||||
struct sysinfo_priv *priv = dev_get_uclass_priv(dev);
|
||||
struct sysinfo_ops *ops = sysinfo_get_ops(dev);
|
||||
|
||||
if (!priv->detected)
|
||||
return -EPERM;
|
||||
|
||||
if (!ops->get_item_count)
|
||||
return -ENOSYS;
|
||||
|
||||
return ops->get_item_count(dev, id);
|
||||
}
|
||||
|
||||
int sysinfo_get_data_by_index(struct udevice *dev, int id, int index,
|
||||
void **data, size_t *size)
|
||||
{
|
||||
struct sysinfo_priv *priv = dev_get_uclass_priv(dev);
|
||||
struct sysinfo_ops *ops = sysinfo_get_ops(dev);
|
||||
|
||||
if (!priv->detected)
|
||||
return -EPERM;
|
||||
|
||||
if (!ops->get_data_by_index)
|
||||
return -ENOSYS;
|
||||
|
||||
return ops->get_data_by_index(dev, id, index, data, size);
|
||||
}
|
||||
|
||||
UCLASS_DRIVER(sysinfo) = {
|
||||
.id = UCLASS_SYSINFO,
|
||||
.name = "sysinfo",
|
||||
|
|
|
@ -57,6 +57,7 @@ enum sysinfo_id {
|
|||
SYSID_SM_SYSTEM_WAKEUP,
|
||||
SYSID_SM_SYSTEM_SKU,
|
||||
SYSID_SM_SYSTEM_FAMILY,
|
||||
SYSID_SM_SYSTEM_UUID,
|
||||
|
||||
/* Baseboard (or Module) Information (Type 2) */
|
||||
SYSID_SM_BASEBOARD_MANUFACTURER,
|
||||
|
@ -151,6 +152,8 @@ enum sysinfo_id {
|
|||
/* For show_board_info() */
|
||||
SYSID_BOARD_MODEL,
|
||||
SYSID_BOARD_MANUFACTURER,
|
||||
SYSID_BOARD_MAC_ADDR,
|
||||
SYSID_BOARD_RAM_SIZE_MB,
|
||||
SYSID_PRIOR_STAGE_VERSION,
|
||||
SYSID_PRIOR_STAGE_DATE,
|
||||
|
||||
|
@ -220,6 +223,30 @@ struct sysinfo_ops {
|
|||
*/
|
||||
int (*get_data)(struct udevice *dev, int id, void **data, size_t *size);
|
||||
|
||||
/**
|
||||
* get_item_count() - Get the item count of the specific data area that
|
||||
* describes the hardware setup.
|
||||
* @dev: The sysinfo instance to gather the data.
|
||||
* @id: A unique identifier for the data area to be get.
|
||||
*
|
||||
* Return: non-negative item count if OK, -ve on error.
|
||||
*/
|
||||
int (*get_item_count)(struct udevice *dev, int id);
|
||||
|
||||
/**
|
||||
* get_data_by_index() - Get a data value by index from the platform.
|
||||
*
|
||||
* @dev: The sysinfo instance to gather the data.
|
||||
* @id: A unique identifier for the data area to be get.
|
||||
* @index: The item index, starting from 0.
|
||||
* @data: Pointer to the address of the data area.
|
||||
* @size: Pointer to the size of the data area.
|
||||
*
|
||||
* Return: 0 if OK, -ve on error.
|
||||
*/
|
||||
int (*get_data_by_index)(struct udevice *dev, int id, int index,
|
||||
void **data, size_t *size);
|
||||
|
||||
/**
|
||||
* get_fit_loadable - Get the name of an image to load from FIT
|
||||
* This function can be used to provide the image names based on runtime
|
||||
|
@ -303,6 +330,32 @@ int sysinfo_get_str(struct udevice *dev, int id, size_t size, char *val);
|
|||
*/
|
||||
int sysinfo_get_data(struct udevice *dev, int id, void **data, size_t *size);
|
||||
|
||||
/**
|
||||
* sysinfo_get_item_count() - Get the item count of the specific data area that
|
||||
* describes the hardware setup.
|
||||
* @dev: The sysinfo instance to gather the data.
|
||||
* @id: A unique identifier for the data area to be get.
|
||||
*
|
||||
* Return: non-negative item count if OK, -EPERM if called before
|
||||
* sysinfo_detect(), else -ve on error.
|
||||
*/
|
||||
int sysinfo_get_item_count(struct udevice *dev, int id);
|
||||
|
||||
/**
|
||||
* sysinfo_get_data_by_index() - Get a data value by index from the platform.
|
||||
*
|
||||
* @dev: The sysinfo instance to gather the data.
|
||||
* @id: A unique identifier for the data area to be get.
|
||||
* @index: The item index, starting from 0.
|
||||
* @data: Pointer to the address of the data area.
|
||||
* @size: Pointer to the size of the data area.
|
||||
*
|
||||
* Return: 0 if OK, -EPERM if called before sysinfo_detect(), else -ve on
|
||||
* error.
|
||||
*/
|
||||
int sysinfo_get_data_by_index(struct udevice *dev, int id, int index,
|
||||
void **data, size_t *size);
|
||||
|
||||
/**
|
||||
* sysinfo_get() - Return the sysinfo device for the sysinfo in question.
|
||||
* @devp: Pointer to structure to receive the sysinfo device.
|
||||
|
@ -364,6 +417,18 @@ static inline int sysinfo_get_data(struct udevice *dev, int id, void **data,
|
|||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int sysinfo_get_item_count(struct udevice *dev, int id)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int sysinfo_get_data_by_index(struct udevice *dev, int id,
|
||||
int index, void **data,
|
||||
size_t *size)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int sysinfo_get(struct udevice **devp)
|
||||
{
|
||||
return -ENOSYS;
|
||||
|
|
|
@ -429,6 +429,8 @@ static int smbios_write_type1(ulong *current, int handle,
|
|||
struct smbios_type1 *t;
|
||||
int len = sizeof(*t);
|
||||
char *serial_str = env_get("serial#");
|
||||
size_t uuid_len;
|
||||
void *uuid;
|
||||
|
||||
t = map_sysmem(*current, len);
|
||||
memset(t, 0, len);
|
||||
|
@ -450,6 +452,10 @@ static int smbios_write_type1(ulong *current, int handle,
|
|||
SYSID_SM_SYSTEM_SERIAL,
|
||||
NULL);
|
||||
}
|
||||
if (!sysinfo_get_data(ctx->dev, SYSID_SM_SYSTEM_UUID, &uuid,
|
||||
&uuid_len) &&
|
||||
uuid_len == sizeof(t->uuid))
|
||||
memcpy(t->uuid, uuid, sizeof(t->uuid));
|
||||
t->wakeup_type = smbios_get_val_si(ctx, "wakeup-type",
|
||||
SYSID_SM_SYSTEM_WAKEUP,
|
||||
SMBIOS_WAKEUP_TYPE_UNKNOWN);
|
||||
|
|
Loading…
Add table
Reference in a new issue