*/
#include <common.h>
+#include <dm.h>
#include <env.h>
#include <mapmem.h>
#include <smbios.h>
#include <version.h>
#ifdef CONFIG_CPU
#include <cpu.h>
-#include <dm.h>
#include <dm/uclass-internal.h>
#endif
*
* @start: string area start address
* @str: string to add
- * @return: string number in the string area
+ * @return: string number in the string area (1 or more)
*/
static int smbios_add_string(char *start, const char *str)
{
return len + 1;
}
-static int smbios_write_type0(ulong *current, int handle)
+static int smbios_write_type0(ulong *current, int handle, ofnode node)
{
struct smbios_type0 *t;
int len = sizeof(struct smbios_type0);
return len;
}
-static int smbios_write_type1(ulong *current, int handle)
+static int smbios_write_type1(ulong *current, int handle, ofnode node)
{
struct smbios_type1 *t;
int len = sizeof(struct smbios_type1);
return len;
}
-static int smbios_write_type2(ulong *current, int handle)
+static int smbios_write_type2(ulong *current, int handle, ofnode node)
{
struct smbios_type2 *t;
int len = sizeof(struct smbios_type2);
return len;
}
-static int smbios_write_type3(ulong *current, int handle)
+static int smbios_write_type3(ulong *current, int handle, ofnode node)
{
struct smbios_type3 *t;
int len = sizeof(struct smbios_type3);
return len;
}
-static void smbios_write_type4_dm(struct smbios_type4 *t)
+static void smbios_write_type4_dm(struct smbios_type4 *t, ofnode node)
{
u16 processor_family = SMBIOS_PROCESSOR_FAMILY_UNKNOWN;
const char *vendor = "Unknown";
#ifdef CONFIG_CPU
char processor_name[49];
char vendor_name[49];
- struct udevice *dev = NULL;
+ struct udevice *cpu = NULL;
- uclass_find_first_device(UCLASS_CPU, &dev);
- if (dev) {
- struct cpu_platdata *plat = dev_get_parent_platdata(dev);
+ uclass_find_first_device(UCLASS_CPU, &cpu);
+ if (cpu) {
+ struct cpu_platdata *plat = dev_get_parent_platdata(cpu);
if (plat->family)
processor_family = plat->family;
t->processor_id[0] = plat->id[0];
t->processor_id[1] = plat->id[1];
- if (!cpu_get_vendor(dev, vendor_name, sizeof(vendor_name)))
+ if (!cpu_get_vendor(cpu, vendor_name, sizeof(vendor_name)))
vendor = vendor_name;
- if (!cpu_get_desc(dev, processor_name, sizeof(processor_name)))
+ if (!cpu_get_desc(cpu, processor_name, sizeof(processor_name)))
name = processor_name;
}
#endif
t->processor_version = smbios_add_string(t->eos, name);
}
-static int smbios_write_type4(ulong *current, int handle)
+static int smbios_write_type4(ulong *current, int handle, ofnode node)
{
struct smbios_type4 *t;
int len = sizeof(struct smbios_type4);
memset(t, 0, sizeof(struct smbios_type4));
fill_smbios_header(t, SMBIOS_PROCESSOR_INFORMATION, len, handle);
t->processor_type = SMBIOS_PROCESSOR_TYPE_CENTRAL;
- smbios_write_type4_dm(t);
+ smbios_write_type4_dm(t, node);
t->status = SMBIOS_PROCESSOR_STATUS_ENABLED;
t->processor_upgrade = SMBIOS_PROCESSOR_UPGRADE_NONE;
t->l1_cache_handle = 0xffff;
return len;
}
-static int smbios_write_type32(ulong *current, int handle)
+static int smbios_write_type32(ulong *current, int handle, ofnode node)
{
struct smbios_type32 *t;
int len = sizeof(struct smbios_type32);
return len;
}
-static int smbios_write_type127(ulong *current, int handle)
+static int smbios_write_type127(ulong *current, int handle, ofnode node)
{
struct smbios_type127 *t;
int len = sizeof(struct smbios_type127);
ulong write_smbios_table(ulong addr)
{
+ ofnode node = ofnode_null();
struct smbios_entry *se;
+ struct udevice *dev;
ulong table_addr;
ulong tables;
int len = 0;
int isize;
int i;
+ if (IS_ENABLED(CONFIG_OF_CONTROL)) {
+ uclass_first_device(UCLASS_SYSINFO, &dev);
+ if (dev)
+ node = dev_read_subnode(dev, "smbios");
+ }
+
/* 16 byte align the table address */
addr = ALIGN(addr, 16);
/* populate minimum required tables */
for (i = 0; i < ARRAY_SIZE(smbios_write_funcs); i++) {
- int tmp = smbios_write_funcs[i]((ulong *)&addr, handle++);
+ int tmp = smbios_write_funcs[i]((ulong *)&addr, handle++, node);
max_struct_size = max(max_struct_size, tmp);
len += tmp;