All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/6] x86: Updates to SMBIOS
@ 2020-10-22  3:08 Simon Glass
  2020-10-22  3:08 ` [PATCH v3 1/6] board: Rename uclass to sysinfo Simon Glass
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Simon Glass @ 2020-10-22  3:08 UTC (permalink / raw
  To: u-boot

At present there are a few Kconfig options which allow SMBIOS fields to
be specified at build time.

Not all fields are supported. Also, defining these at build-time is
limiting since a factory system cannot insert values for particular boards
or models without rebuilding U-Boot.

This series adds a way to set SMBIOS properties using the devicetree.
With this approach, more fields are supported and it is easy to update
values in the devicetree in the factory.

Changes in v3:
- Use a different binding with subnodes for each table type
- Add onto the sysinfo binding

Changes in v2:
- Move dm.h header file to avoid build error on qemu-arm
- Deal with boards that don't use of-control

Simon Glass (6):
  board: Rename uclass to sysinfo
  doc: Add a binding for sysinfo
  x86: Pass an ofnode into each SMBIOS function
  smbios: Allow properties to come from the device tree
  smbios: Add more properties
  smbios: Add documentation and devicetree binding

 arch/powerpc/dts/gdsys/gazerbeam-uboot.dtsi   |   2 +-
 arch/sandbox/dts/test.dts                     |   8 +-
 board/gdsys/common/cmd_ioloop.c               |  12 +-
 board/gdsys/mpc8308/gazerbeam.c               |  47 +++---
 board/google/chromebook_coral/coral.c         |   2 +-
 common/spl/spl_fit.c                          |  15 +-
 configs/chromebook_coral_defconfig            |   2 +-
 configs/gazerbeam_defconfig                   |   4 +-
 configs/sandbox64_defconfig                   |   8 +-
 configs/sandbox_defconfig                     |   8 +-
 configs/sandbox_flattree_defconfig            |   4 +-
 configs/sandbox_spl_defconfig                 |   4 +-
 doc/arch/x86.rst                              |   8 +
 .../gdsys,sysinfo_gazerbeam.txt}              |   8 +-
 doc/device-tree-bindings/sysinfo/smbios.txt   |  77 ++++++++++
 doc/device-tree-bindings/sysinfo/sysinfo.txt  |  18 +++
 drivers/Kconfig                               |   4 +-
 drivers/Makefile                              |   2 +-
 drivers/board/board-uclass.c                  |  71 ---------
 drivers/{board => sysinfo}/Kconfig            |  16 +-
 drivers/{board => sysinfo}/Makefile           |   6 +-
 drivers/{board => sysinfo}/gazerbeam.c        |  74 ++++-----
 drivers/{board => sysinfo}/gazerbeam.h        |   0
 drivers/{board => sysinfo}/sandbox.c          |  50 +++----
 drivers/{board => sysinfo}/sandbox.h          |   0
 drivers/sysinfo/sysinfo-uclass.c              |  71 +++++++++
 drivers/timer/mpc83xx_timer.c                 |  10 +-
 include/dm/uclass-id.h                        |   2 +-
 include/smbios.h                              |   5 +-
 include/{board.h => sysinfo.h}                |  80 +++++-----
 lib/smbios.c                                  | 140 ++++++++++++++----
 test/dm/Makefile                              |   2 +-
 test/dm/board.c                               |  59 --------
 test/dm/sysinfo.c                             |  59 ++++++++
 34 files changed, 533 insertions(+), 345 deletions(-)
 rename doc/device-tree-bindings/{board/gdsys,board_gazerbeam.txt => sysinfo/gdsys,sysinfo_gazerbeam.txt} (90%)
 create mode 100644 doc/device-tree-bindings/sysinfo/smbios.txt
 create mode 100644 doc/device-tree-bindings/sysinfo/sysinfo.txt
 delete mode 100644 drivers/board/board-uclass.c
 rename drivers/{board => sysinfo}/Kconfig (65%)
 rename drivers/{board => sysinfo}/Makefile (50%)
 rename drivers/{board => sysinfo}/gazerbeam.c (69%)
 rename drivers/{board => sysinfo}/gazerbeam.h (100%)
 rename drivers/{board => sysinfo}/sandbox.c (50%)
 rename drivers/{board => sysinfo}/sandbox.h (100%)
 create mode 100644 drivers/sysinfo/sysinfo-uclass.c
 rename include/{board.h => sysinfo.h} (65%)
 delete mode 100644 test/dm/board.c
 create mode 100644 test/dm/sysinfo.c

-- 
2.29.0.rc1.297.gfa9743e501-goog

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v3 1/6] board: Rename uclass to sysinfo
  2020-10-22  3:08 [PATCH v3 0/6] x86: Updates to SMBIOS Simon Glass
@ 2020-10-22  3:08 ` Simon Glass
  2020-10-22  3:08 ` [PATCH v3 2/6] doc: Add a binding for sysinfo Simon Glass
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2020-10-22  3:08 UTC (permalink / raw
  To: u-boot

This uclass is intended to provide a way to obtain information about a
U-Boot board. But the concept of a U-Boot 'board' is the whole system,
not just one circuit board, meaning that 'board' is something of a
misnomer for this uclass.

In addition, the name 'board' is a bit overused in U-Boot and we want to
use the same uclass to provide SMBIOS information.

The obvious name is 'system' but that is so vague as to be meaningless.
Use 'sysinfo' instead, since this uclass is aimed at providing information
on the system.

Rename everything accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/powerpc/dts/gdsys/gazerbeam-uboot.dtsi   |  2 +-
 arch/sandbox/dts/test.dts                     |  8 +-
 board/gdsys/common/cmd_ioloop.c               | 12 +--
 board/gdsys/mpc8308/gazerbeam.c               | 47 ++++++-----
 board/google/chromebook_coral/coral.c         |  2 +-
 common/spl/spl_fit.c                          | 15 ++--
 configs/chromebook_coral_defconfig            |  2 +-
 configs/gazerbeam_defconfig                   |  4 +-
 configs/sandbox64_defconfig                   |  8 +-
 configs/sandbox_defconfig                     |  8 +-
 configs/sandbox_flattree_defconfig            |  4 +-
 configs/sandbox_spl_defconfig                 |  4 +-
 .../gdsys,sysinfo_gazerbeam.txt}              |  8 +-
 drivers/Kconfig                               |  4 +-
 drivers/Makefile                              |  2 +-
 drivers/board/board-uclass.c                  | 71 ----------------
 drivers/{board => sysinfo}/Kconfig            | 16 ++--
 drivers/{board => sysinfo}/Makefile           |  6 +-
 drivers/{board => sysinfo}/gazerbeam.c        | 74 ++++++++---------
 drivers/{board => sysinfo}/gazerbeam.h        |  0
 drivers/{board => sysinfo}/sandbox.c          | 50 ++++++------
 drivers/{board => sysinfo}/sandbox.h          |  0
 drivers/sysinfo/sysinfo-uclass.c              | 71 ++++++++++++++++
 drivers/timer/mpc83xx_timer.c                 | 10 +--
 include/dm/uclass-id.h                        |  2 +-
 include/{board.h => sysinfo.h}                | 80 +++++++++----------
 test/dm/Makefile                              |  2 +-
 test/dm/board.c                               | 59 --------------
 test/dm/sysinfo.c                             | 59 ++++++++++++++
 29 files changed, 318 insertions(+), 312 deletions(-)
 rename doc/device-tree-bindings/{board/gdsys,board_gazerbeam.txt => sysinfo/gdsys,sysinfo_gazerbeam.txt} (90%)
 delete mode 100644 drivers/board/board-uclass.c
 rename drivers/{board => sysinfo}/Kconfig (65%)
 rename drivers/{board => sysinfo}/Makefile (50%)
 rename drivers/{board => sysinfo}/gazerbeam.c (69%)
 rename drivers/{board => sysinfo}/gazerbeam.h (100%)
 rename drivers/{board => sysinfo}/sandbox.c (50%)
 rename drivers/{board => sysinfo}/sandbox.h (100%)
 create mode 100644 drivers/sysinfo/sysinfo-uclass.c
 rename include/{board.h => sysinfo.h} (65%)
 delete mode 100644 test/dm/board.c
 create mode 100644 test/dm/sysinfo.c

diff --git a/arch/powerpc/dts/gdsys/gazerbeam-uboot.dtsi b/arch/powerpc/dts/gdsys/gazerbeam-uboot.dtsi
index 1c4977f20f3..3439737fa3f 100644
--- a/arch/powerpc/dts/gdsys/gazerbeam-uboot.dtsi
+++ b/arch/powerpc/dts/gdsys/gazerbeam-uboot.dtsi
@@ -32,7 +32,7 @@
 	};
 
 	board {
-		compatible = "gdsys,board_gazerbeam";
+		compatible = "gdsys,sysinfo-gazerbeam";
 		csb = <&board_soc>;
 		serdes = <&SERDES>;
 		rxaui0 = <&RXAUI0_0>;
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index fa84b2c10f3..0f0d69da50e 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -1070,10 +1070,6 @@
 		compatible = "sandbox,sandbox_osd";
 	};
 
-	board {
-		compatible = "sandbox,board_sandbox";
-	};
-
 	sandbox_tee {
 		compatible = "sandbox,tee";
 	};
@@ -1209,6 +1205,10 @@
 		reset-names = "valid", "no_mask", "out_of_range";
 	};
 
+	sysinfo {
+		compatible = "sandbox,sysinfo-sandbox";
+	};
+
 	some_regmapped-bus {
 		#address-cells = <0x1>;
 		#size-cells = <0x1>;
diff --git a/board/gdsys/common/cmd_ioloop.c b/board/gdsys/common/cmd_ioloop.c
index 3ea2bec8ebd..658756d9842 100644
--- a/board/gdsys/common/cmd_ioloop.c
+++ b/board/gdsys/common/cmd_ioloop.c
@@ -16,7 +16,7 @@
 #include <dm.h>
 #include <misc.h>
 #include <regmap.h>
-#include <board.h>
+#include <sysinfo.h>
 
 #include "../../../drivers/misc/gdsys_soc.h"
 #include "../../../drivers/misc/gdsys_ioep.h"
@@ -506,11 +506,11 @@ int do_ioloop(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 int do_iodev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
 	struct udevice *ioep = NULL;
-	struct udevice *board;
+	struct udevice *sysinfo;
 	char name[8];
 	int ret;
 
-	if (board_get(&board))
+	if (sysinfo_get(&sysinfo))
 		return CMD_RET_FAILURE;
 
 	if (argc > 1) {
@@ -518,7 +518,8 @@ int do_iodev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 
 		snprintf(name, sizeof(name), "ioep%d", i);
 
-		ret = uclass_get_device_by_phandle(UCLASS_MISC, board, name, &ioep);
+		ret = uclass_get_device_by_phandle(UCLASS_MISC, sysinfo, name,
+						   &ioep);
 
 		if (ret || !ioep) {
 			printf("Invalid IOEP %d\n", i);
@@ -532,7 +533,8 @@ int do_iodev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 		while (1) {
 			snprintf(name, sizeof(name), "ioep%d", i);
 
-			ret = uclass_get_device_by_phandle(UCLASS_MISC, board, name, &ioep);
+			ret = uclass_get_device_by_phandle(UCLASS_MISC, sysinfo,
+							   name, &ioep);
 
 			if (ret || !ioep)
 				break;
diff --git a/board/gdsys/mpc8308/gazerbeam.c b/board/gdsys/mpc8308/gazerbeam.c
index c317260251e..0e7fa1e333e 100644
--- a/board/gdsys/mpc8308/gazerbeam.c
+++ b/board/gdsys/mpc8308/gazerbeam.c
@@ -6,7 +6,6 @@
  */
 
 #include <common.h>
-#include <board.h>
 #include <command.h>
 #include <dm.h>
 #include <env.h>
@@ -15,11 +14,12 @@
 #include <init.h>
 #include <miiphy.h>
 #include <misc.h>
+#include <sysinfo.h>
 #include <tpm-v1.h>
 #include <video_osd.h>
 
 #include "../common/ihs_mdio.h"
-#include "../../../drivers/board/gazerbeam.h"
+#include "../../../drivers/sysinfo/gazerbeam.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -43,22 +43,22 @@ static int get_tpm(struct udevice **devp)
 
 int board_early_init_r(void)
 {
-	struct udevice *board;
+	struct udevice *sysinfo;
 	struct udevice *serdes;
 	int mc = 0;
 	int con = 0;
 
-	if (board_get(&board))
-		puts("Could not find board information device.\n");
+	if (sysinfo_get(&sysinfo))
+		puts("Could not find sysinfo information device.\n");
 
 	/* Initialize serdes */
-	uclass_get_device_by_phandle(UCLASS_MISC, board, "serdes", &serdes);
+	uclass_get_device_by_phandle(UCLASS_MISC, sysinfo, "serdes", &serdes);
 
-	if (board_detect(board))
+	if (sysinfo_detect(sysinfo))
 		puts("Device information detection failed.\n");
 
-	board_get_int(board, BOARD_MULTICHANNEL, &mc);
-	board_get_int(board, BOARD_VARIANT, &con);
+	sysinfo_get_int(sysinfo, BOARD_MULTICHANNEL, &mc);
+	sysinfo_get_int(sysinfo, BOARD_VARIANT, &con);
 
 	if (mc == 2 || mc == 1)
 		dev_disable_by_path("/immr at e0000000/i2c at 3100/pca9698 at 22");
@@ -84,18 +84,18 @@ int board_early_init_r(void)
 	return 0;
 }
 
-int checkboard(void)
+int checksysinfo(void)
 {
-	struct udevice *board;
+	struct udevice *sysinfo;
 	char *s = env_get("serial#");
 	int mc = 0;
 	int con = 0;
 
-	if (board_get(&board))
-		puts("Could not find board information device.\n");
+	if (sysinfo_get(&sysinfo))
+		puts("Could not find sysinfo information device.\n");
 
-	board_get_int(board, BOARD_MULTICHANNEL, &mc);
-	board_get_int(board, BOARD_VARIANT, &con);
+	sysinfo_get_int(sysinfo, BOARD_MULTICHANNEL, &mc);
+	sysinfo_get_int(sysinfo, BOARD_VARIANT, &con);
 
 	puts("Board: Gazerbeam ");
 	printf("%s ", mc == 4 ? "MC4" : mc == 2 ? "MC2" : "SC");
@@ -123,20 +123,22 @@ int last_stage_init(void)
 {
 	int fpga_hw_rev = 0;
 	int i;
-	struct udevice *board;
+	struct udevice *sysinfo;
 	struct udevice *osd;
 	struct video_osd_info osd_info;
 	struct udevice *tpm;
 	int ret;
 
-	if (board_get(&board))
-		puts("Could not find board information device.\n");
+	if (sysinfo_get(&sysinfo))
+		puts("Could not find sysinfo information device.\n");
 
-	if (board) {
-		int res = board_get_int(board, BOARD_HWVERSION, &fpga_hw_rev);
+	if (sysinfo) {
+		int res = sysinfo_get_int(sysinfo, BOARD_HWVERSION,
+					  &fpga_hw_rev);
 
 		if (res)
-			printf("Could not determind FPGA HW revision (res = %d)\n", res);
+			printf("Could not determind FPGA HW revision (res = %d)\n",
+			       res);
 	}
 
 	env_set_ulong("fpga_hw_rev", fpga_hw_rev);
@@ -154,7 +156,8 @@ int last_stage_init(void)
 
 			snprintf(name, sizeof(name), "rxaui%d", i);
 			/* Disable RXAUI polarity inversion */
-			ret = uclass_get_device_by_phandle(UCLASS_MISC, board, name, &rxaui);
+			ret = uclass_get_device_by_phandle(UCLASS_MISC, sysinfo,
+							   name, &rxaui);
 			if (!ret)
 				misc_set_enabled(rxaui, false);
 		}
diff --git a/board/google/chromebook_coral/coral.c b/board/google/chromebook_coral/coral.c
index f5ae48290f4..b8b923c139e 100644
--- a/board/google/chromebook_coral/coral.c
+++ b/board/google/chromebook_coral/coral.c
@@ -150,7 +150,7 @@ static const struct udevice_id coral_ids[] = {
 
 U_BOOT_DRIVER(coral_drv) = {
 	.name		= "coral",
-	.id		= UCLASS_BOARD,
+	.id		= UCLASS_SYSINFO,
 	.of_match	= coral_ids,
 	ACPI_OPS_PTR(&coral_acpi_ops)
 };
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index a90d821c82e..f8f52771352 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -6,13 +6,13 @@
 
 #include <common.h>
 #include <errno.h>
-#include <board.h>
 #include <fpga.h>
 #include <gzip.h>
 #include <image.h>
 #include <log.h>
 #include <malloc.h>
 #include <spl.h>
+#include <sysinfo.h>
 #include <asm/cache.h>
 #include <linux/libfdt.h>
 
@@ -74,7 +74,7 @@ static int spl_fit_get_image_name(const void *fit, int images,
 				  const char *type, int index,
 				  const char **outname)
 {
-	struct udevice *board;
+	struct udevice *sysinfo;
 	const char *name, *str;
 	__maybe_unused int node;
 	int conf_node;
@@ -110,19 +110,20 @@ static int spl_fit_get_image_name(const void *fit, int images,
 		}
 	}
 
-	if (!found && !board_get(&board)) {
+	if (!found && CONFIG_IS_ENABLED(SYSINFO) && !sysinfo_get(&sysinfo)) {
 		int rc;
 		/*
-		 * no string in the property for this index. Check if the board
-		 * level code can supply one.
+		 * no string in the property for this index. Check if the
+		 * sysinfo-level code can supply one.
 		 */
-		rc = board_get_fit_loadable(board, index - i - 1, type, &str);
+		rc = sysinfo_get_fit_loadable(sysinfo, index - i - 1, type,
+					      &str);
 		if (rc && rc != -ENOENT)
 			return rc;
 
 		if (!rc) {
 			/*
-			 * The board provided a name for a loadable.
+			 * The sysinfo provided a name for a loadable.
 			 * Try to match it against the description properties
 			 * first. If no matching node is found, use it as a
 			 * node name.
diff --git a/configs/chromebook_coral_defconfig b/configs/chromebook_coral_defconfig
index 0ec95af75e0..d934eeb8866 100644
--- a/configs/chromebook_coral_defconfig
+++ b/configs/chromebook_coral_defconfig
@@ -77,7 +77,6 @@ CONFIG_SYSCON=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_INTEL_ACPIGEN=y
 CONFIG_CPU=y
-CONFIG_BOARD=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_DW=y
 CONFIG_MISC=y
@@ -98,6 +97,7 @@ CONFIG_SOUND_MAX98357A=y
 CONFIG_SOUND_RT5677=y
 CONFIG_SPI=y
 CONFIG_ICH_SPI=y
+CONFIG_SYSINFO=y
 CONFIG_TPL_SYSRESET=y
 # CONFIG_TPM_V1 is not set
 CONFIG_TPM2_CR50_I2C=y
diff --git a/configs/gazerbeam_defconfig b/configs/gazerbeam_defconfig
index 36c2500bae1..5765ef456be 100644
--- a/configs/gazerbeam_defconfig
+++ b/configs/gazerbeam_defconfig
@@ -157,8 +157,6 @@ CONFIG_CLK=y
 CONFIG_ICS8N3QV01=y
 CONFIG_CPU=y
 CONFIG_CPU_MPC83XX=y
-CONFIG_BOARD=y
-CONFIG_BOARD_GAZERBEAM=y
 CONFIG_DM_PCA953X=y
 CONFIG_MPC8XXX_GPIO=y
 CONFIG_DM_I2C=y
@@ -197,6 +195,8 @@ CONFIG_MPC83XX_SDRAM=y
 CONFIG_DM_RESET=y
 CONFIG_DM_SERIAL=y
 CONFIG_SYS_NS16550=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_GAZERBEAM=y
 CONFIG_SYSRESET=y
 CONFIG_SYSRESET_MPC83XX=y
 CONFIG_TIMER=y
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index e9928d5fc2e..dc993cd13aa 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -69,6 +69,8 @@ CONFIG_CMD_TIME=y
 CONFIG_CMD_TIMER=y
 CONFIG_CMD_SOUND=y
 CONFIG_CMD_QFW=y
+CONFIG_CMD_PSTORE=y
+CONFIG_CMD_PSTORE_MEM_ADDR=0x3000000
 CONFIG_CMD_BOOTSTAGE=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
@@ -80,8 +82,6 @@ CONFIG_CMD_CBFS=y
 CONFIG_CMD_CRAMFS=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_MTDPARTS=y
-CONFIG_CMD_PSTORE=y
-CONFIG_CMD_PSTORE_MEM_ADDR=0x3000000
 CONFIG_MAC_PARTITION=y
 CONFIG_AMIGA_PARTITION=y
 CONFIG_OF_CONTROL=y
@@ -109,8 +109,6 @@ CONFIG_CPU=y
 CONFIG_DM_DEMO=y
 CONFIG_DM_DEMO_SIMPLE=y
 CONFIG_DM_DEMO_SHAPE=y
-CONFIG_BOARD=y
-CONFIG_BOARD_SANDBOX=y
 CONFIG_GPIO_HOG=y
 CONFIG_DM_GPIO_LOOKUP_LABEL=y
 CONFIG_PM8916_GPIO=y
@@ -201,6 +199,8 @@ CONFIG_SOC_DEVICE=y
 CONFIG_SANDBOX_SPI=y
 CONFIG_SPMI=y
 CONFIG_SPMI_SANDBOX=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SANDBOX=y
 CONFIG_SYSRESET=y
 CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index b15b1889e07..5b7cee7889a 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -81,6 +81,8 @@ CONFIG_CMD_TIME=y
 CONFIG_CMD_TIMER=y
 CONFIG_CMD_SOUND=y
 CONFIG_CMD_QFW=y
+CONFIG_CMD_PSTORE=y
+CONFIG_CMD_PSTORE_MEM_ADDR=0x3000000
 CONFIG_CMD_BOOTSTAGE=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
@@ -93,8 +95,6 @@ CONFIG_CMD_CRAMFS=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_SQUASHFS=y
 CONFIG_CMD_MTDPARTS=y
-CONFIG_CMD_PSTORE=y
-CONFIG_CMD_PSTORE_MEM_ADDR=0x3000000
 CONFIG_MAC_PARTITION=y
 CONFIG_AMIGA_PARTITION=y
 CONFIG_OF_CONTROL=y
@@ -130,8 +130,6 @@ CONFIG_CPU=y
 CONFIG_DM_DEMO=y
 CONFIG_DM_DEMO_SIMPLE=y
 CONFIG_DM_DEMO_SHAPE=y
-CONFIG_BOARD=y
-CONFIG_BOARD_SANDBOX=y
 CONFIG_DMA=y
 CONFIG_DMA_CHANNELS=y
 CONFIG_SANDBOX_DMA=y
@@ -235,6 +233,8 @@ CONFIG_SOC_DEVICE=y
 CONFIG_SANDBOX_SPI=y
 CONFIG_SPMI=y
 CONFIG_SPMI_SANDBOX=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SANDBOX=y
 CONFIG_SYSRESET=y
 CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index 6ee23c4a619..1f593eba8fd 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -90,8 +90,6 @@ CONFIG_CPU=y
 CONFIG_DM_DEMO=y
 CONFIG_DM_DEMO_SIMPLE=y
 CONFIG_DM_DEMO_SHAPE=y
-CONFIG_BOARD=y
-CONFIG_BOARD_SANDBOX=y
 CONFIG_GPIO_HOG=y
 CONFIG_DM_GPIO_LOOKUP_LABEL=y
 CONFIG_PM8916_GPIO=y
@@ -177,6 +175,8 @@ CONFIG_SOC_DEVICE=y
 CONFIG_SANDBOX_SPI=y
 CONFIG_SPMI=y
 CONFIG_SPMI_SANDBOX=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SANDBOX=y
 CONFIG_SYSRESET=y
 CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index 1d49e816393..9205f84b86e 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -109,8 +109,6 @@ CONFIG_CPU=y
 CONFIG_DM_DEMO=y
 CONFIG_DM_DEMO_SIMPLE=y
 CONFIG_DM_DEMO_SHAPE=y
-CONFIG_BOARD=y
-CONFIG_BOARD_SANDBOX=y
 CONFIG_SPL_FIRMWARE=y
 CONFIG_GPIO_HOG=y
 CONFIG_PM8916_GPIO=y
@@ -194,6 +192,8 @@ CONFIG_SOC_DEVICE=y
 CONFIG_SANDBOX_SPI=y
 CONFIG_SPMI=y
 CONFIG_SPMI_SANDBOX=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SANDBOX=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
 CONFIG_TIMER=y
diff --git a/doc/device-tree-bindings/board/gdsys,board_gazerbeam.txt b/doc/device-tree-bindings/sysinfo/gdsys,sysinfo_gazerbeam.txt
similarity index 90%
rename from doc/device-tree-bindings/board/gdsys,board_gazerbeam.txt
rename to doc/device-tree-bindings/sysinfo/gdsys,sysinfo_gazerbeam.txt
index 28c1080d904..f70652d3c48 100644
--- a/doc/device-tree-bindings/board/gdsys,board_gazerbeam.txt
+++ b/doc/device-tree-bindings/sysinfo/gdsys,sysinfo_gazerbeam.txt
@@ -1,11 +1,11 @@
-gdsys Gazerbeam board driver
+gdsys Gazerbeam sysinfo driver
 
 This driver provides capabilities to access the gdsys Gazerbeam board's device
 information. Furthermore, phandles to some internal devices are provided for
 the board files.
 
 Required properties:
-- compatible:  should be "gdsys,board_gazerbeam"
+- compatible:  should be "gdsys,sysinfo-gazerbeam"
 - csb:         phandle to the board's coherent system bus (CSB) device node
 - rxaui[0-3]:  phandles to the rxaui control device nodes
 - fpga[0-1]:   phandles to the board's gdsys FPGA device nodes
@@ -17,8 +17,8 @@ Required properties:
 Example:
 
 
-board {
-	compatible = "gdsys,board_gazerbeam";
+sysinfo {
+	compatible = "gdsys,sysinfo-gazerbeam";
 	csb = <&board_soc>;
 	serdes = <&SERDES>;
 	rxaui0 = <&RXAUI0>;
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 613669cb381..37293e8da9d 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -30,8 +30,6 @@ source "drivers/ddr/Kconfig"
 
 source "drivers/demo/Kconfig"
 
-source "drivers/board/Kconfig"
-
 source "drivers/ddr/fsl/Kconfig"
 
 source "drivers/dfu/Kconfig"
@@ -112,6 +110,8 @@ source "drivers/spi/Kconfig"
 
 source "drivers/spmi/Kconfig"
 
+source "drivers/sysinfo/Kconfig"
+
 source "drivers/sysreset/Kconfig"
 
 source "drivers/tee/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index 9eb51453e57..51eec712996 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -26,9 +26,9 @@ obj-$(CONFIG_$(SPL_TPL_)TIMER) += timer/
 obj-$(CONFIG_$(SPL_TPL_)VIRTIO) += virtio/
 obj-$(CONFIG_$(SPL_)DM_MAILBOX) += mailbox/
 obj-$(CONFIG_$(SPL_)REMOTEPROC) += remoteproc/
+obj-$(CONFIG_$(SPL_)SYSINFO) += sysinfo/
 obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
 obj-$(CONFIG_$(SPL_TPL_)ACPI_PMC) += power/acpi_pmc/
-obj-$(CONFIG_$(SPL_)BOARD) += board/
 obj-$(CONFIG_XEN) += xen/
 obj-$(CONFIG_$(SPL_)FPGA) += fpga/
 
diff --git a/drivers/board/board-uclass.c b/drivers/board/board-uclass.c
deleted file mode 100644
index b5485e9895b..00000000000
--- a/drivers/board/board-uclass.c
+++ /dev/null
@@ -1,71 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2017
- * Mario Six,  Guntermann & Drunck GmbH, mario.six at gdsys.cc
- */
-
-#include <common.h>
-#include <dm.h>
-#include <board.h>
-
-int board_get(struct udevice **devp)
-{
-	return uclass_first_device_err(UCLASS_BOARD, devp);
-}
-
-int board_detect(struct udevice *dev)
-{
-	struct board_ops *ops = board_get_ops(dev);
-
-	if (!ops->detect)
-		return -ENOSYS;
-
-	return ops->detect(dev);
-}
-
-int board_get_fit_loadable(struct udevice *dev, int index,
-			   const char *type, const char **strp)
-{
-	struct board_ops *ops = board_get_ops(dev);
-
-	if (!ops->get_fit_loadable)
-		return -ENOSYS;
-
-	return ops->get_fit_loadable(dev, index, type, strp);
-}
-
-int board_get_bool(struct udevice *dev, int id, bool *val)
-{
-	struct board_ops *ops = board_get_ops(dev);
-
-	if (!ops->get_bool)
-		return -ENOSYS;
-
-	return ops->get_bool(dev, id, val);
-}
-
-int board_get_int(struct udevice *dev, int id, int *val)
-{
-	struct board_ops *ops = board_get_ops(dev);
-
-	if (!ops->get_int)
-		return -ENOSYS;
-
-	return ops->get_int(dev, id, val);
-}
-
-int board_get_str(struct udevice *dev, int id, size_t size, char *val)
-{
-	struct board_ops *ops = board_get_ops(dev);
-
-	if (!ops->get_str)
-		return -ENOSYS;
-
-	return ops->get_str(dev, id, size, val);
-}
-
-UCLASS_DRIVER(board) = {
-	.id		= UCLASS_BOARD,
-	.name		= "board",
-	.post_bind	= dm_scan_fdt_dev,
-};
diff --git a/drivers/board/Kconfig b/drivers/sysinfo/Kconfig
similarity index 65%
rename from drivers/board/Kconfig
rename to drivers/sysinfo/Kconfig
index 254f657049d..39141500a05 100644
--- a/drivers/board/Kconfig
+++ b/drivers/sysinfo/Kconfig
@@ -1,24 +1,24 @@
-menuconfig BOARD
-	bool "Device Information"
+menuconfig SYSINFO
+	bool "Device System Information"
 	help
 	  Support methods to query hardware configurations from internal
 	  mechanisms (e.g. reading GPIO values, determining the presence of
 	  devices on busses, etc.). This enables the usage of U-Boot with
 	  modular board architectures.
 
-if BOARD
+if SYSINFO
 
-config SPL_BOARD
+config SPL_SYSINFO
 	depends on SPL_DM
 	bool "Enable board driver support in SPL"
 
-config BOARD_GAZERBEAM
-	bool "Enable board driver for the Gazerbeam board"
+config SYSINFO_GAZERBEAM
+	bool "Enable sysinfo driver for the Gazerbeam board"
 	help
 	  Support querying device information for the gdsys Gazerbeam board.
 
-config BOARD_SANDBOX
-	bool "Enable board driver for the Sandbox board"
+config SYSINFO_SANDBOX
+	bool "Enable sysinfo driver for the Sandbox board"
 	help
 	  Support querying device information for the Sandbox boards.
 
diff --git a/drivers/board/Makefile b/drivers/sysinfo/Makefile
similarity index 50%
rename from drivers/board/Makefile
rename to drivers/sysinfo/Makefile
index cc16361755a..aecf0b0d47c 100644
--- a/drivers/board/Makefile
+++ b/drivers/sysinfo/Makefile
@@ -2,6 +2,6 @@
 #
 # (C) Copyright 2017
 # Mario Six,  Guntermann & Drunck GmbH, mario.six at gdsys.cc
-obj-y += board-uclass.o
-obj-$(CONFIG_BOARD_GAZERBEAM) += gazerbeam.o
-obj-$(CONFIG_BOARD_SANDBOX) += sandbox.o
+obj-y += sysinfo-uclass.o
+obj-$(CONFIG_SYSINFO_GAZERBEAM) += gazerbeam.o
+obj-$(CONFIG_SYSINFO_SANDBOX) += sandbox.o
diff --git a/drivers/board/gazerbeam.c b/drivers/sysinfo/gazerbeam.c
similarity index 69%
rename from drivers/board/gazerbeam.c
rename to drivers/sysinfo/gazerbeam.c
index ed50fc530cb..58012d1dbaa 100644
--- a/drivers/board/gazerbeam.c
+++ b/drivers/sysinfo/gazerbeam.c
@@ -6,7 +6,7 @@
 
 #include <common.h>
 #include <dm.h>
-#include <board.h>
+#include <sysinfo.h>
 #include <i2c.h>
 #include <log.h>
 #include <asm/gpio.h>
@@ -27,16 +27,16 @@ static const int SC_GPIO_NO;
 static const int CON_GPIO_NO = 1;
 
 /**
- * struct board_gazerbeam_priv - Private data structure for the gazerbeam board
- *				 driver.
- * @reset_gpios:  GPIOs for the board's reset GPIOs.
- * @var_gpios:	  GPIOs for the board's hardware variant GPIOs
- * @ver_gpios:	  GPIOs for the board's hardware version GPIOs
- * @variant:	  Container for the board's hardware variant (CON/CPU)
- * @multichannel: Container for the board's multichannel variant (MC4/MC2/SC)
- * @hwversion:	  Container for the board's hardware version
+ * struct sysinfo_gazerbeam_priv - Private data structure for the gazerbeam
+ *	sysinfo driver
+ * @reset_gpios:  GPIOs for the sysinfo's reset GPIOs.
+ * @var_gpios:	  GPIOs for the sysinfo's hardware variant GPIOs
+ * @ver_gpios:	  GPIOs for the sysinfo's hardware version GPIOs
+ * @variant:	  Container for the sysinfo's hardware variant (CON/CPU)
+ * @multichannel: Container for the sysinfo's multichannel variant (MC4/MC2/SC)
+ * @hwversion:	  Container for the sysinfo's hardware version
  */
-struct board_gazerbeam_priv {
+struct sysinfo_gazerbeam_priv {
 	struct gpio_desc reset_gpios[2];
 	struct gpio_desc var_gpios[2];
 	struct gpio_desc ver_gpios[4];
@@ -46,19 +46,19 @@ struct board_gazerbeam_priv {
 };
 
 /**
- * _read_board_variant_data() - Read variant information from the hardware.
- * @dev: The board device for which to determine the multichannel and device
+ * _read_sysinfo_variant_data() - Read variant information from the hardware.
+ * @dev: The sysinfo device for which to determine the multichannel and device
  *	 type information.
  *
- * The data read from the board's hardware (mostly hard-wired GPIOs) is stored
+ * The data read from the sysinfo's hardware (mostly hard-wired GPIOs) is stored
  * in the private data structure of the driver to be used by other driver
  * methods.
  *
  * Return: 0 if OK, -ve on error.
  */
-static int _read_board_variant_data(struct udevice *dev)
+static int _read_sysinfo_variant_data(struct udevice *dev)
 {
-	struct board_gazerbeam_priv *priv = dev_get_priv(dev);
+	struct sysinfo_gazerbeam_priv *priv = dev_get_priv(dev);
 	struct udevice *i2c_bus;
 	struct udevice *dummy;
 	char *listname;
@@ -129,10 +129,10 @@ static int _read_board_variant_data(struct udevice *dev)
 }
 
 /**
- * _read_hwversion() - Read the hardware version from the board.
- * @dev: The board device for which to read the hardware version.
+ * _read_hwversion() - Read the hardware version from the sysinfo.
+ * @dev: The sysinfo device for which to read the hardware version.
  *
- * The hardware version read from the board (from hard-wired GPIOs) is stored
+ * The hardware version read from the sysinfo (from hard-wired GPIOs) is stored
  * in the private data structure of the driver to be used by other driver
  * methods.
  *
@@ -140,7 +140,7 @@ static int _read_board_variant_data(struct udevice *dev)
  */
 static int _read_hwversion(struct udevice *dev)
 {
-	struct board_gazerbeam_priv *priv = dev_get_priv(dev);
+	struct sysinfo_gazerbeam_priv *priv = dev_get_priv(dev);
 	int res;
 
 	res = gpio_request_list_by_name(dev, "ver-gpios", priv->ver_gpios,
@@ -172,11 +172,11 @@ static int _read_hwversion(struct udevice *dev)
 	return 0;
 }
 
-static int board_gazerbeam_detect(struct udevice *dev)
+static int sysinfo_gazerbeam_detect(struct udevice *dev)
 {
 	int res;
 
-	res = _read_board_variant_data(dev);
+	res = _read_sysinfo_variant_data(dev);
 	if (res) {
 		debug("%s: Error reading multichannel variant (err = %d)\n",
 		      dev->name, res);
@@ -193,9 +193,9 @@ static int board_gazerbeam_detect(struct udevice *dev)
 	return 0;
 }
 
-static int board_gazerbeam_get_int(struct udevice *dev, int id, int *val)
+static int sysinfo_gazerbeam_get_int(struct udevice *dev, int id, int *val)
 {
-	struct board_gazerbeam_priv *priv = dev_get_priv(dev);
+	struct sysinfo_gazerbeam_priv *priv = dev_get_priv(dev);
 
 	switch (id) {
 	case BOARD_MULTICHANNEL:
@@ -215,19 +215,19 @@ static int board_gazerbeam_get_int(struct udevice *dev, int id, int *val)
 	return 0;
 }
 
-static const struct udevice_id board_gazerbeam_ids[] = {
-	{ .compatible = "gdsys,board_gazerbeam" },
+static const struct udevice_id sysinfo_gazerbeam_ids[] = {
+	{ .compatible = "gdsys,sysinfo_gazerbeam" },
 	{ /* sentinel */ }
 };
 
-static const struct board_ops board_gazerbeam_ops = {
-	.detect = board_gazerbeam_detect,
-	.get_int = board_gazerbeam_get_int,
+static const struct sysinfo_ops sysinfo_gazerbeam_ops = {
+	.detect = sysinfo_gazerbeam_detect,
+	.get_int = sysinfo_gazerbeam_get_int,
 };
 
-static int board_gazerbeam_probe(struct udevice *dev)
+static int sysinfo_gazerbeam_probe(struct udevice *dev)
 {
-	struct board_gazerbeam_priv *priv = dev_get_priv(dev);
+	struct sysinfo_gazerbeam_priv *priv = dev_get_priv(dev);
 	int gpio_num, i;
 
 	gpio_num = gpio_request_list_by_name(dev, "reset-gpios",
@@ -255,11 +255,11 @@ static int board_gazerbeam_probe(struct udevice *dev)
 	return 0;
 }
 
-U_BOOT_DRIVER(board_gazerbeam) = {
-	.name           = "board_gazerbeam",
-	.id             = UCLASS_BOARD,
-	.of_match       = board_gazerbeam_ids,
-	.ops		= &board_gazerbeam_ops,
-	.priv_auto_alloc_size = sizeof(struct board_gazerbeam_priv),
-	.probe          = board_gazerbeam_probe,
+U_BOOT_DRIVER(sysinfo_gazerbeam) = {
+	.name           = "sysinfo_gazerbeam",
+	.id             = UCLASS_SYSINFO,
+	.of_match       = sysinfo_gazerbeam_ids,
+	.ops		= &sysinfo_gazerbeam_ops,
+	.priv_auto_alloc_size = sizeof(struct sysinfo_gazerbeam_priv),
+	.probe          = sysinfo_gazerbeam_probe,
 };
diff --git a/drivers/board/gazerbeam.h b/drivers/sysinfo/gazerbeam.h
similarity index 100%
rename from drivers/board/gazerbeam.h
rename to drivers/sysinfo/gazerbeam.h
diff --git a/drivers/board/sandbox.c b/drivers/sysinfo/sandbox.c
similarity index 50%
rename from drivers/board/sandbox.c
rename to drivers/sysinfo/sandbox.c
index 50621e47a4f..62a1cb4ac65 100644
--- a/drivers/board/sandbox.c
+++ b/drivers/sysinfo/sandbox.c
@@ -6,11 +6,11 @@
 
 #include <common.h>
 #include <dm.h>
-#include <board.h>
+#include <sysinfo.h>
 
 #include "sandbox.h"
 
-struct board_sandbox_priv {
+struct sysinfo_sandbox_priv {
 	bool called_detect;
 	int test_i1;
 	int test_i2;
@@ -19,9 +19,9 @@ struct board_sandbox_priv {
 char vacation_spots[][64] = {"R'lyeh", "Dreamlands", "Plateau of Leng",
 			     "Carcosa", "Yuggoth", "The Nameless City"};
 
-int board_sandbox_detect(struct udevice *dev)
+int sysinfo_sandbox_detect(struct udevice *dev)
 {
-	struct board_sandbox_priv *priv = dev_get_priv(dev);
+	struct sysinfo_sandbox_priv *priv = dev_get_priv(dev);
 
 	priv->called_detect = true;
 	priv->test_i2 = 100;
@@ -29,9 +29,9 @@ int board_sandbox_detect(struct udevice *dev)
 	return 0;
 }
 
-int board_sandbox_get_bool(struct udevice *dev, int id, bool *val)
+int sysinfo_sandbox_get_bool(struct udevice *dev, int id, bool *val)
 {
-	struct board_sandbox_priv *priv = dev_get_priv(dev);
+	struct sysinfo_sandbox_priv *priv = dev_get_priv(dev);
 
 	switch (id) {
 	case BOOL_CALLED_DETECT:
@@ -43,9 +43,9 @@ int board_sandbox_get_bool(struct udevice *dev, int id, bool *val)
 	return -ENOENT;
 }
 
-int board_sandbox_get_int(struct udevice *dev, int id, int *val)
+int sysinfo_sandbox_get_int(struct udevice *dev, int id, int *val)
 {
-	struct board_sandbox_priv *priv = dev_get_priv(dev);
+	struct sysinfo_sandbox_priv *priv = dev_get_priv(dev);
 
 	switch (id) {
 	case INT_TEST1:
@@ -63,9 +63,9 @@ int board_sandbox_get_int(struct udevice *dev, int id, int *val)
 	return -ENOENT;
 }
 
-int board_sandbox_get_str(struct udevice *dev, int id, size_t size, char *val)
+int sysinfo_sandbox_get_str(struct udevice *dev, int id, size_t size, char *val)
 {
-	struct board_sandbox_priv *priv = dev_get_priv(dev);
+	struct sysinfo_sandbox_priv *priv = dev_get_priv(dev);
 	int i1 = priv->test_i1;
 	int i2 = priv->test_i2;
 	int index = (i1 * i2) % ARRAY_SIZE(vacation_spots);
@@ -80,28 +80,28 @@ int board_sandbox_get_str(struct udevice *dev, int id, size_t size, char *val)
 	return -ENOENT;
 }
 
-static const struct udevice_id board_sandbox_ids[] = {
-	{ .compatible = "sandbox,board_sandbox" },
+static const struct udevice_id sysinfo_sandbox_ids[] = {
+	{ .compatible = "sandbox,sysinfo-sandbox" },
 	{ /* sentinel */ }
 };
 
-static const struct board_ops board_sandbox_ops = {
-	.detect = board_sandbox_detect,
-	.get_bool = board_sandbox_get_bool,
-	.get_int = board_sandbox_get_int,
-	.get_str = board_sandbox_get_str,
+static const struct sysinfo_ops sysinfo_sandbox_ops = {
+	.detect = sysinfo_sandbox_detect,
+	.get_bool = sysinfo_sandbox_get_bool,
+	.get_int = sysinfo_sandbox_get_int,
+	.get_str = sysinfo_sandbox_get_str,
 };
 
-int board_sandbox_probe(struct udevice *dev)
+int sysinfo_sandbox_probe(struct udevice *dev)
 {
 	return 0;
 }
 
-U_BOOT_DRIVER(board_sandbox) = {
-	.name           = "board_sandbox",
-	.id             = UCLASS_BOARD,
-	.of_match       = board_sandbox_ids,
-	.ops		= &board_sandbox_ops,
-	.priv_auto_alloc_size = sizeof(struct board_sandbox_priv),
-	.probe          = board_sandbox_probe,
+U_BOOT_DRIVER(sysinfo_sandbox) = {
+	.name           = "sysinfo_sandbox",
+	.id             = UCLASS_SYSINFO,
+	.of_match       = sysinfo_sandbox_ids,
+	.ops		= &sysinfo_sandbox_ops,
+	.priv_auto_alloc_size = sizeof(struct sysinfo_sandbox_priv),
+	.probe          = sysinfo_sandbox_probe,
 };
diff --git a/drivers/board/sandbox.h b/drivers/sysinfo/sandbox.h
similarity index 100%
rename from drivers/board/sandbox.h
rename to drivers/sysinfo/sandbox.h
diff --git a/drivers/sysinfo/sysinfo-uclass.c b/drivers/sysinfo/sysinfo-uclass.c
new file mode 100644
index 00000000000..6df58fe160b
--- /dev/null
+++ b/drivers/sysinfo/sysinfo-uclass.c
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2017
+ * Mario Six,  Guntermann & Drunck GmbH, mario.six at gdsys.cc
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <sysinfo.h>
+
+int sysinfo_get(struct udevice **devp)
+{
+	return uclass_first_device_err(UCLASS_SYSINFO, devp);
+}
+
+int sysinfo_detect(struct udevice *dev)
+{
+	struct sysinfo_ops *ops = sysinfo_get_ops(dev);
+
+	if (!ops->detect)
+		return -ENOSYS;
+
+	return ops->detect(dev);
+}
+
+int sysinfo_get_fit_loadable(struct udevice *dev, int index, const char *type,
+			     const char **strp)
+{
+	struct sysinfo_ops *ops = sysinfo_get_ops(dev);
+
+	if (!ops->get_fit_loadable)
+		return -ENOSYS;
+
+	return ops->get_fit_loadable(dev, index, type, strp);
+}
+
+int sysinfo_get_bool(struct udevice *dev, int id, bool *val)
+{
+	struct sysinfo_ops *ops = sysinfo_get_ops(dev);
+
+	if (!ops->get_bool)
+		return -ENOSYS;
+
+	return ops->get_bool(dev, id, val);
+}
+
+int sysinfo_get_int(struct udevice *dev, int id, int *val)
+{
+	struct sysinfo_ops *ops = sysinfo_get_ops(dev);
+
+	if (!ops->get_int)
+		return -ENOSYS;
+
+	return ops->get_int(dev, id, val);
+}
+
+int sysinfo_get_str(struct udevice *dev, int id, size_t size, char *val)
+{
+	struct sysinfo_ops *ops = sysinfo_get_ops(dev);
+
+	if (!ops->get_str)
+		return -ENOSYS;
+
+	return ops->get_str(dev, id, size, val);
+}
+
+UCLASS_DRIVER(sysinfo) = {
+	.id		= UCLASS_SYSINFO,
+	.name		= "sysinfo",
+	.post_bind	= dm_scan_fdt_dev,
+};
diff --git a/drivers/timer/mpc83xx_timer.c b/drivers/timer/mpc83xx_timer.c
index ad8bb28e8b3..125056235e7 100644
--- a/drivers/timer/mpc83xx_timer.c
+++ b/drivers/timer/mpc83xx_timer.c
@@ -5,12 +5,12 @@
  */
 
 #include <common.h>
-#include <board.h>
 #include <clk.h>
 #include <dm.h>
 #include <irq_func.h>
 #include <log.h>
 #include <status_led.h>
+#include <sysinfo.h>
 #include <time.h>
 #include <timer.h>
 #include <watchdog.h>
@@ -97,7 +97,7 @@ int interrupt_init(void)
 {
 	immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
 	struct udevice *csb;
-	struct udevice *board;
+	struct udevice *sysinfo;
 	struct udevice *timer;
 	struct mpc83xx_timer_priv *timer_priv;
 	struct clk clock;
@@ -112,12 +112,12 @@ int interrupt_init(void)
 
 	timer_priv = dev_get_priv(timer);
 
-	if (board_get(&board)) {
-		debug("%s: board device could not be fetched.\n", __func__);
+	if (sysinfo_get(&sysinfo)) {
+		debug("%s: sysinfo device could not be fetched.\n", __func__);
 		return -ENOENT;
 	}
 
-	ret = uclass_get_device_by_phandle(UCLASS_SIMPLE_BUS, board,
+	ret = uclass_get_device_by_phandle(UCLASS_SIMPLE_BUS, sysinfo,
 					   "csb", &csb);
 	if (ret) {
 		debug("%s: Could not retrieve CSB device (error: %d)",
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 88f10c46221..e5f942e8a51 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -36,7 +36,6 @@ enum uclass_id {
 	UCLASS_AUDIO_CODEC,	/* Audio codec with control and data path */
 	UCLASS_AXI,		/* AXI bus */
 	UCLASS_BLK,		/* Block device */
-	UCLASS_BOARD,		/* Device information from hardware */
 	UCLASS_BOOTCOUNT,       /* Bootcount backing store */
 	UCLASS_BUTTON,		/* Button */
 	UCLASS_CACHE,		/* Cache controller */
@@ -106,6 +105,7 @@ enum uclass_id {
 	UCLASS_SPI_GENERIC,	/* Generic SPI flash target */
 	UCLASS_SPMI,		/* System Power Management Interface bus */
 	UCLASS_SYSCON,		/* System configuration device */
+	UCLASS_SYSINFO,		/* Device information from hardware */
 	UCLASS_SYSRESET,	/* System reset device */
 	UCLASS_TEE,		/* Trusted Execution Environment device */
 	UCLASS_THERMAL,		/* Thermal sensor */
diff --git a/include/board.h b/include/sysinfo.h
similarity index 65%
rename from include/board.h
rename to include/sysinfo.h
index 678b652b0aa..c045d316b07 100644
--- a/include/board.h
+++ b/include/sysinfo.h
@@ -6,23 +6,23 @@
 
 /*
  * This uclass encapsulates hardware methods to gather information about a
- * board or a specific device such as hard-wired GPIOs on GPIO expanders,
+ * sysinfo or a specific device such as hard-wired GPIOs on GPIO expanders,
  * read-only data in flash ICs, or similar.
  *
  * The interface offers functions to read the usual standard data types (bool,
  * int, string) from the device, each of which is identified by a static
  * numeric ID (which will usually be defined as a enum in a header file).
  *
- * If for example the board had a read-only serial number flash IC, we could
+ * If for example the sysinfo had a read-only serial number flash IC, we could
  * call
  *
- * ret = board_detect(dev);
+ * ret = sysinfo_detect(dev);
  * if (ret) {
- *	debug("board device not found.");
+ *	debug("sysinfo device not found.");
  *	return ret;
  * }
  *
- * ret = board_get_int(dev, ID_SERIAL_NUMBER, &serial);
+ * ret = sysinfo_get_int(dev, ID_SERIAL_NUMBER, &serial);
  * if (ret) {
  *	debug("Error when reading serial number from device.");
  *	return ret;
@@ -31,8 +31,8 @@
  * to read the serial number.
  */
 
-#if CONFIG_IS_ENABLED(BOARD)
-struct board_ops {
+#if CONFIG_IS_ENABLED(SYSINFO)
+struct sysinfo_ops {
 	/**
 	 * detect() - Run the hardware info detection procedure for this
 	 *	      device.
@@ -50,7 +50,7 @@ struct board_ops {
 	/**
 	 * get_bool() - Read a specific bool data value that describes the
 	 *		hardware setup.
-	 * @dev:	The board instance to gather the data.
+	 * @dev:	The sysinfo instance to gather the data.
 	 * @id:		A unique identifier for the bool value to be read.
 	 * @val:	Pointer to a buffer that receives the value read.
 	 *
@@ -61,7 +61,7 @@ struct board_ops {
 	/**
 	 * get_int() - Read a specific int data value that describes the
 	 *	       hardware setup.
-	 * @dev:       The board instance to gather the data.
+	 * @dev:       The sysinfo instance to gather the data.
 	 * @id:        A unique identifier for the int value to be read.
 	 * @val:       Pointer to a buffer that receives the value read.
 	 *
@@ -72,7 +72,7 @@ struct board_ops {
 	/**
 	 * get_str() - Read a specific string data value that describes the
 	 *	       hardware setup.
-	 * @dev:	The board instance to gather the data.
+	 * @dev:	The sysinfo instance to gather the data.
 	 * @id:		A unique identifier for the string value to be read.
 	 * @size:	The size of the buffer to receive the string data.
 	 * @val:	Pointer to a buffer that receives the value read.
@@ -87,7 +87,7 @@ struct board_ops {
 	 * detection. A classic use-case would when DTBOs are used to describe
 	 * additionnal daughter cards.
 	 *
-	 * @dev:	The board instance to gather the data.
+	 * @dev:	The sysinfo instance to gather the data.
 	 * @index:	Index of the image. Starts at 0 and gets incremented
 	 *		after each call to this function.
 	 * @type:	The type of image. For example, "fdt" for DTBs
@@ -100,70 +100,70 @@ struct board_ops {
 				const char *type, const char **strp);
 };
 
-#define board_get_ops(dev)	((struct board_ops *)(dev)->driver->ops)
+#define sysinfo_get_ops(dev)	((struct sysinfo_ops *)(dev)->driver->ops)
 
 /**
- * board_detect() - Run the hardware info detection procedure for this device.
+ * sysinfo_detect() - Run the hardware info detection procedure for this device.
  *
  * @dev:	The device containing the information
  *
  * Return: 0 if OK, -ve on error.
  */
-int board_detect(struct udevice *dev);
+int sysinfo_detect(struct udevice *dev);
 
 /**
- * board_get_bool() - Read a specific bool data value that describes the
+ * sysinfo_get_bool() - Read a specific bool data value that describes the
  *		      hardware setup.
- * @dev:	The board instance to gather the data.
+ * @dev:	The sysinfo instance to gather the data.
  * @id:		A unique identifier for the bool value to be read.
  * @val:	Pointer to a buffer that receives the value read.
  *
  * Return: 0 if OK, -ve on error.
  */
-int board_get_bool(struct udevice *dev, int id, bool *val);
+int sysinfo_get_bool(struct udevice *dev, int id, bool *val);
 
 /**
- * board_get_int() - Read a specific int data value that describes the
+ * sysinfo_get_int() - Read a specific int data value that describes the
  *		     hardware setup.
- * @dev:	The board instance to gather the data.
+ * @dev:	The sysinfo instance to gather the data.
  * @id:		A unique identifier for the int value to be read.
  * @val:	Pointer to a buffer that receives the value read.
  *
  * Return: 0 if OK, -ve on error.
  */
-int board_get_int(struct udevice *dev, int id, int *val);
+int sysinfo_get_int(struct udevice *dev, int id, int *val);
 
 /**
- * board_get_str() - Read a specific string data value that describes the
+ * sysinfo_get_str() - Read a specific string data value that describes the
  *		     hardware setup.
- * @dev:	The board instance to gather the data.
+ * @dev:	The sysinfo instance to gather the data.
  * @id:		A unique identifier for the string value to be read.
  * @size:	The size of the buffer to receive the string data.
  * @val:	Pointer to a buffer that receives the value read.
  *
  * Return: 0 if OK, -ve on error.
  */
-int board_get_str(struct udevice *dev, int id, size_t size, char *val);
+int sysinfo_get_str(struct udevice *dev, int id, size_t size, char *val);
 
 /**
- * board_get() - Return the board device for the board in question.
- * @devp: Pointer to structure to receive the board device.
+ * sysinfo_get() - Return the sysinfo device for the sysinfo in question.
+ * @devp: Pointer to structure to receive the sysinfo device.
  *
- * Since there can only be at most one board instance, the API can supply a
+ * Since there can only be at most one sysinfo instance, the API can supply a
  * function that returns the unique device. This is especially useful for use
- * in board files.
+ * in sysinfo files.
  *
  * Return: 0 if OK, -ve on error.
  */
-int board_get(struct udevice **devp);
+int sysinfo_get(struct udevice **devp);
 
 /**
- * board_get_fit_loadable - Get the name of an image to load from FIT
+ * sysinfo_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
  * detection. A classic use-case would when DTBOs are used to describe
  * additionnal daughter cards.
  *
- * @dev:	The board instance to gather the data.
+ * @dev:	The sysinfo instance to gather the data.
  * @index:	Index of the image. Starts at 0 and gets incremented
  *		after each call to this function.
  * @type:	The type of image. For example, "fdt" for DTBs
@@ -173,39 +173,39 @@ int board_get(struct udevice **devp);
  * Return: 0 if OK, -ENOENT if no loadable is available else -ve on
  * error.
  */
-int board_get_fit_loadable(struct udevice *dev, int index,
-			   const char *type, const char **strp);
+int sysinfo_get_fit_loadable(struct udevice *dev, int index, const char *type,
+			     const char **strp);
 
 #else
 
-static inline int board_detect(struct udevice *dev)
+static inline int sysinfo_detect(struct udevice *dev)
 {
 	return -ENOSYS;
 }
 
-static inline int board_get_bool(struct udevice *dev, int id, bool *val)
+static inline int sysinfo_get_bool(struct udevice *dev, int id, bool *val)
 {
 	return -ENOSYS;
 }
 
-static inline int board_get_int(struct udevice *dev, int id, int *val)
+static inline int sysinfo_get_int(struct udevice *dev, int id, int *val)
 {
 	return -ENOSYS;
 }
 
-static inline int board_get_str(struct udevice *dev, int id, size_t size,
-				char *val)
+static inline int sysinfo_get_str(struct udevice *dev, int id, size_t size,
+				  char *val)
 {
 	return -ENOSYS;
 }
 
-static inline int board_get(struct udevice **devp)
+static inline int sysinfo_get(struct udevice **devp)
 {
 	return -ENOSYS;
 }
 
-static inline int board_get_fit_loadable(struct udevice *dev, int index,
-					 const char *type, const char **strp)
+static inline int sysinfo_get_fit_loadable(struct udevice *dev, int index,
+					   const char *type, const char **strp)
 {
 	return -ENOSYS;
 }
diff --git a/test/dm/Makefile b/test/dm/Makefile
index e2b07983885..0d507791a12 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -18,7 +18,6 @@ obj-$(CONFIG_ACPIGEN) += acpigen.o
 obj-$(CONFIG_ACPIGEN) += acpi_dp.o
 obj-$(CONFIG_SOUND) += audio.o
 obj-$(CONFIG_BLK) += blk.o
-obj-$(CONFIG_BOARD) += board.o
 obj-$(CONFIG_BUTTON) += button.o
 obj-$(CONFIG_DM_BOOTCOUNT) += bootcount.o
 obj-$(CONFIG_CLK) += clk.o clk_ccf.o
@@ -71,6 +70,7 @@ obj-$(CONFIG_DM_SERIAL) += serial.o
 obj-$(CONFIG_CPU) += cpu.o
 obj-$(CONFIG_SOC_DEVICE) += soc.o
 obj-$(CONFIG_SOUND) += sound.o
+obj-$(CONFIG_SYSINFO) += sysinfo.o
 obj-$(CONFIG_TEE) += tee.o
 obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o
 obj-$(CONFIG_DMA) += dma.o
diff --git a/test/dm/board.c b/test/dm/board.c
deleted file mode 100644
index f3e7f63f258..00000000000
--- a/test/dm/board.c
+++ /dev/null
@@ -1,59 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2018
- * Mario Six, Guntermann & Drunck GmbH, mario.six at gdsys.cc
- */
-
-#include <common.h>
-#include <dm.h>
-#include <log.h>
-#include <dm/test.h>
-#include <board.h>
-#include <test/test.h>
-#include <test/ut.h>
-
-#include "../../drivers/board/sandbox.h"
-
-static int dm_test_board(struct unit_test_state *uts)
-{
-	struct udevice *board;
-	bool called_detect;
-	char str[64];
-	int i;
-
-	board_get(&board);
-	ut_assert(board);
-
-	board_get_bool(board, BOOL_CALLED_DETECT, &called_detect);
-	ut_assert(!called_detect);
-
-	board_detect(board);
-
-	board_get_bool(board, BOOL_CALLED_DETECT, &called_detect);
-	ut_assert(called_detect);
-
-	board_get_str(board, STR_VACATIONSPOT, sizeof(str), str);
-	ut_assertok(strcmp(str, "R'lyeh"));
-
-	board_get_int(board, INT_TEST1, &i);
-	ut_asserteq(0, i);
-
-	board_get_int(board, INT_TEST2, &i);
-	ut_asserteq(100, i);
-
-	board_get_str(board, STR_VACATIONSPOT, sizeof(str), str);
-	ut_assertok(strcmp(str, "Carcosa"));
-
-	board_get_int(board, INT_TEST1, &i);
-	ut_asserteq(1, i);
-
-	board_get_int(board, INT_TEST2, &i);
-	ut_asserteq(99, i);
-
-	board_get_str(board, STR_VACATIONSPOT, sizeof(str), str);
-	ut_assertok(strcmp(str, "Yuggoth"));
-
-	return 0;
-}
-
-DM_TEST(dm_test_board, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/sysinfo.c b/test/dm/sysinfo.c
new file mode 100644
index 00000000000..4aaa9e85bce
--- /dev/null
+++ b/test/dm/sysinfo.c
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2018
+ * Mario Six, Guntermann & Drunck GmbH, mario.six at gdsys.cc
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <log.h>
+#include <dm/test.h>
+#include <sysinfo.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+#include "../../drivers/sysinfo/sandbox.h"
+
+static int dm_test_sysinfo(struct unit_test_state *uts)
+{
+	struct udevice *sysinfo;
+	bool called_detect;
+	char str[64];
+	int i;
+
+	ut_assertok(sysinfo_get(&sysinfo));
+	ut_assert(sysinfo);
+
+	sysinfo_get_bool(sysinfo, BOOL_CALLED_DETECT, &called_detect);
+	ut_assert(!called_detect);
+
+	sysinfo_detect(sysinfo);
+
+	sysinfo_get_bool(sysinfo, BOOL_CALLED_DETECT, &called_detect);
+	ut_assert(called_detect);
+
+	sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str), str);
+	ut_assertok(strcmp(str, "R'lyeh"));
+
+	sysinfo_get_int(sysinfo, INT_TEST1, &i);
+	ut_asserteq(0, i);
+
+	sysinfo_get_int(sysinfo, INT_TEST2, &i);
+	ut_asserteq(100, i);
+
+	sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str), str);
+	ut_assertok(strcmp(str, "Carcosa"));
+
+	sysinfo_get_int(sysinfo, INT_TEST1, &i);
+	ut_asserteq(1, i);
+
+	sysinfo_get_int(sysinfo, INT_TEST2, &i);
+	ut_asserteq(99, i);
+
+	sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str), str);
+	ut_assertok(strcmp(str, "Yuggoth"));
+
+	return 0;
+}
+
+DM_TEST(dm_test_sysinfo, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
-- 
2.29.0.rc1.297.gfa9743e501-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 2/6] doc: Add a binding for sysinfo
  2020-10-22  3:08 [PATCH v3 0/6] x86: Updates to SMBIOS Simon Glass
  2020-10-22  3:08 ` [PATCH v3 1/6] board: Rename uclass to sysinfo Simon Glass
@ 2020-10-22  3:08 ` Simon Glass
  2020-10-22  5:40   ` Heinrich Schuchardt
  2020-10-22  3:08 ` [PATCH v3 3/6] x86: Pass an ofnode into each SMBIOS function Simon Glass
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Simon Glass @ 2020-10-22  3:08 UTC (permalink / raw
  To: u-boot

Add a simple binding file for this, so that it is clear what this binding
directory is for.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 doc/device-tree-bindings/sysinfo/sysinfo.txt | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 doc/device-tree-bindings/sysinfo/sysinfo.txt

diff --git a/doc/device-tree-bindings/sysinfo/sysinfo.txt b/doc/device-tree-bindings/sysinfo/sysinfo.txt
new file mode 100644
index 00000000000..ed8830b8284
--- /dev/null
+++ b/doc/device-tree-bindings/sysinfo/sysinfo.txt
@@ -0,0 +1,18 @@
+Sysinfo
+=======
+
+This provides capabilities to access information about a board/system, for
+use by drivers.
+
+Required properties:
+
+  - compatible: any suitable string where the driver is in the UCLASS_SYSINFO
+      class
+
+See also smbios.txt
+
+
+Example
+
+sysinfo {
+	compatible = "sandbox,sysinfo";
-- 
2.29.0.rc1.297.gfa9743e501-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 3/6] x86: Pass an ofnode into each SMBIOS function
  2020-10-22  3:08 [PATCH v3 0/6] x86: Updates to SMBIOS Simon Glass
  2020-10-22  3:08 ` [PATCH v3 1/6] board: Rename uclass to sysinfo Simon Glass
  2020-10-22  3:08 ` [PATCH v3 2/6] doc: Add a binding for sysinfo Simon Glass
@ 2020-10-22  3:08 ` Simon Glass
  2020-10-22  3:08 ` [PATCH v3 4/6] smbios: Allow properties to come from the device tree Simon Glass
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2020-10-22  3:08 UTC (permalink / raw
  To: u-boot

As a first step to obtaining SMBIOS information from the devicetree, add
an ofnode parameter to the writing functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v2)

Changes in v2:
- Move dm.h header file to avoid build error on qemu-arm
- Deal with boards that don't use of-control

 include/smbios.h |  5 ++++-
 lib/smbios.c     | 44 ++++++++++++++++++++++++++------------------
 2 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/include/smbios.h b/include/smbios.h
index 97b9ddce237..c19afbe16c7 100644
--- a/include/smbios.h
+++ b/include/smbios.h
@@ -8,6 +8,8 @@
 #ifndef _SMBIOS_H_
 #define _SMBIOS_H_
 
+#include <dm/ofnode.h>
+
 /* SMBIOS spec version implemented */
 #define SMBIOS_MAJOR_VER	3
 #define SMBIOS_MINOR_VER	0
@@ -222,9 +224,10 @@ static inline void fill_smbios_header(void *table, int type,
  *
  * @addr:	start address to write the structure
  * @handle:	the structure's handle, a unique 16-bit number
+ * @node:	node containing the information to write (ofnode_null() if none)
  * @return:	size of the structure
  */
-typedef int (*smbios_write_type)(ulong *addr, int handle);
+typedef int (*smbios_write_type)(ulong *addr, int handle, ofnode node);
 
 /**
  * write_smbios_table() - Write SMBIOS table
diff --git a/lib/smbios.c b/lib/smbios.c
index 11790443e1a..4bb3bac56b4 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <env.h>
 #include <mapmem.h>
 #include <smbios.h>
@@ -13,7 +14,6 @@
 #include <version.h>
 #ifdef CONFIG_CPU
 #include <cpu.h>
-#include <dm.h>
 #include <dm/uclass-internal.h>
 #endif
 
@@ -25,7 +25,7 @@
  *
  * @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)
 {
@@ -74,7 +74,7 @@ static int smbios_string_table_len(char *start)
 	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);
@@ -111,7 +111,7 @@ static int smbios_write_type0(ulong *current, int handle)
 	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);
@@ -134,7 +134,7 @@ static int smbios_write_type1(ulong *current, int handle)
 	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);
@@ -154,7 +154,7 @@ static int smbios_write_type2(ulong *current, int handle)
 	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);
@@ -176,7 +176,7 @@ static int smbios_write_type3(ulong *current, int handle)
 	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";
@@ -185,20 +185,20 @@ static void smbios_write_type4_dm(struct smbios_type4 *t)
 #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
@@ -208,7 +208,7 @@ static void smbios_write_type4_dm(struct smbios_type4 *t)
 	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);
@@ -217,7 +217,7 @@ static int smbios_write_type4(ulong *current, int handle)
 	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;
@@ -232,7 +232,7 @@ static int smbios_write_type4(ulong *current, int handle)
 	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);
@@ -247,7 +247,7 @@ static int smbios_write_type32(ulong *current, int handle)
 	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);
@@ -274,7 +274,9 @@ static smbios_write_type smbios_write_funcs[] = {
 
 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;
@@ -284,6 +286,12 @@ ulong write_smbios_table(ulong addr)
 	int isize;
 	int i;
 
+	if (IS_ENABLED(CONFIG_OF_CONTROL)) {
+		uclass_first_device(UCLASS_BOARD, &dev);
+		if (dev)
+			node = dev_read_subnode(dev, "smbios");
+	}
+
 	/* 16 byte align the table address */
 	addr = ALIGN(addr, 16);
 
@@ -296,7 +304,7 @@ ulong write_smbios_table(ulong addr)
 
 	/* 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;
-- 
2.29.0.rc1.297.gfa9743e501-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 4/6] smbios: Allow properties to come from the device tree
  2020-10-22  3:08 [PATCH v3 0/6] x86: Updates to SMBIOS Simon Glass
                   ` (2 preceding siblings ...)
  2020-10-22  3:08 ` [PATCH v3 3/6] x86: Pass an ofnode into each SMBIOS function Simon Glass
@ 2020-10-22  3:08 ` Simon Glass
  2020-10-22  5:49   ` Heinrich Schuchardt
  2020-10-22  3:08 ` [PATCH v3 5/6] smbios: Add more properties Simon Glass
  2020-10-22  3:08 ` [PATCH v3 6/6] smbios: Add documentation and devicetree binding Simon Glass
  5 siblings, 1 reply; 13+ messages in thread
From: Simon Glass @ 2020-10-22  3:08 UTC (permalink / raw
  To: u-boot

Support a way to put SMBIOS properties in the device tree. These can be
placed in a 'board' device in an 'smbios' subnode.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3:
- Use a different binding with subnodes for each table type

 lib/smbios.c | 100 +++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 82 insertions(+), 18 deletions(-)

diff --git a/lib/smbios.c b/lib/smbios.c
index 4bb3bac56b4..6d3c20a48ee 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -17,6 +17,18 @@
 #include <dm/uclass-internal.h>
 #endif
 
+/**
+ * struct smbios_write_method - Informaiton about a table-writing function
+ *
+ * @write: Function to call
+ * @subnode_name: Name of subnode which has the information for this function,
+ *	NULL if none
+ */
+struct smbios_write_method {
+	smbios_write_type write;
+	const char *subnode_name;
+};
+
 /**
  * smbios_add_string() - add a string to the string area
  *
@@ -52,6 +64,43 @@ static int smbios_add_string(char *start, const char *str)
 	}
 }
 
+/**
+ * smbios_add_prop_default() - Add a property from the device tree or default
+ *
+ * @start:	string area start address
+ * @node:	node containing the information to write (ofnode_null() if none)
+ * @prop:	property to write
+ * @def:	default string if the node has no such property
+ * @return 0 if not found, else SMBIOS string number (1 or more)
+ */
+static int smbios_add_prop_default(char *start, ofnode node, const char *prop,
+				   const char *def)
+{
+	const char *str = NULL;
+
+	if (IS_ENABLED(CONFIG_OF_CONTROL))
+		str = ofnode_read_string(node, prop);
+	if (str)
+		return smbios_add_string(start, str);
+	else if (def)
+		return smbios_add_string(start, def);
+
+	return 0;
+}
+
+/**
+ * smbios_add_prop() - Add a property from the device tree
+ *
+ * @start:	string area start address
+ * @node:	node containing the information to write (ofnode_null() if none)
+ * @prop:	property to write
+ * @return 0 if not found, else SMBIOS string number (1 or more)
+ */
+static int smbios_add_prop(char *start, ofnode node, const char *prop)
+{
+	return smbios_add_prop_default(start, node, prop, NULL);
+}
+
 /**
  * smbios_string_table_len() - compute the string area size
  *
@@ -120,11 +169,15 @@ static int smbios_write_type1(ulong *current, int handle, ofnode node)
 	t = map_sysmem(*current, len);
 	memset(t, 0, sizeof(struct smbios_type1));
 	fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle);
-	t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
-	t->product_name = smbios_add_string(t->eos, CONFIG_SMBIOS_PRODUCT_NAME);
+	t->manufacturer = smbios_add_prop_default(t->eos, node, "manufactuer",
+						  CONFIG_SMBIOS_MANUFACTURER);
+	t->product_name = smbios_add_prop_default(t->eos, node, "product",
+						  CONFIG_SMBIOS_PRODUCT_NAME);
 	if (serial_str) {
-		strncpy((char *)t->uuid, serial_str, sizeof(t->uuid));
 		t->serial_number = smbios_add_string(t->eos, serial_str);
+		strncpy((char *)t->uuid, serial_str, sizeof(t->uuid));
+	} else {
+		t->serial_number = smbios_add_prop(t->eos, node, "serial");
 	}
 
 	len = t->length + smbios_string_table_len(t->eos);
@@ -142,8 +195,10 @@ static int smbios_write_type2(ulong *current, int handle, ofnode node)
 	t = map_sysmem(*current, len);
 	memset(t, 0, sizeof(struct smbios_type2));
 	fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle);
-	t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
-	t->product_name = smbios_add_string(t->eos, CONFIG_SMBIOS_PRODUCT_NAME);
+	t->manufacturer = smbios_add_prop_default(t->eos, node, "manufactuer",
+						  CONFIG_SMBIOS_MANUFACTURER);
+	t->product_name = smbios_add_prop_default(t->eos, node, "product",
+						  CONFIG_SMBIOS_PRODUCT_NAME);
 	t->feature_flags = SMBIOS_BOARD_FEATURE_HOSTING;
 	t->board_type = SMBIOS_BOARD_MOTHERBOARD;
 
@@ -162,7 +217,8 @@ static int smbios_write_type3(ulong *current, int handle, ofnode node)
 	t = map_sysmem(*current, len);
 	memset(t, 0, sizeof(struct smbios_type3));
 	fill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, handle);
-	t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
+	t->manufacturer = smbios_add_prop_default(t->eos, node, "manufactuer",
+						  CONFIG_SMBIOS_MANUFACTURER);
 	t->chassis_type = SMBIOS_ENCLOSURE_DESKTOP;
 	t->bootup_state = SMBIOS_STATE_SAFE;
 	t->power_supply_state = SMBIOS_STATE_SAFE;
@@ -262,19 +318,19 @@ static int smbios_write_type127(ulong *current, int handle, ofnode node)
 	return len;
 }
 
-static smbios_write_type smbios_write_funcs[] = {
-	smbios_write_type0,
-	smbios_write_type1,
-	smbios_write_type2,
-	smbios_write_type3,
-	smbios_write_type4,
-	smbios_write_type32,
-	smbios_write_type127
+static struct smbios_write_method smbios_write_funcs[] = {
+	{ smbios_write_type0, },
+	{ smbios_write_type1, "system", },
+	{ smbios_write_type2, "baseboard", },
+	{ smbios_write_type3, "chassis", },
+	{ smbios_write_type4, },
+	{ smbios_write_type32, },
+	{ smbios_write_type127 },
 };
 
 ulong write_smbios_table(ulong addr)
 {
-	ofnode node = ofnode_null();
+	ofnode parent_node = ofnode_null();
 	struct smbios_entry *se;
 	struct udevice *dev;
 	ulong table_addr;
@@ -287,9 +343,9 @@ ulong write_smbios_table(ulong addr)
 	int i;
 
 	if (IS_ENABLED(CONFIG_OF_CONTROL)) {
-		uclass_first_device(UCLASS_BOARD, &dev);
+		uclass_first_device(UCLASS_SYSINFO, &dev);
 		if (dev)
-			node = dev_read_subnode(dev, "smbios");
+			parent_node = dev_read_subnode(dev, "smbios");
 	}
 
 	/* 16 byte align the table address */
@@ -304,7 +360,15 @@ ulong write_smbios_table(ulong addr)
 
 	/* populate minimum required tables */
 	for (i = 0; i < ARRAY_SIZE(smbios_write_funcs); i++) {
-		int tmp = smbios_write_funcs[i]((ulong *)&addr, handle++, node);
+		const struct smbios_write_method *method;
+		ofnode node = ofnode_null();
+		int tmp;
+
+		method = &smbios_write_funcs[i];
+		if (method->subnode_name)
+			node = ofnode_find_subnode(parent_node,
+						   method->subnode_name);
+		tmp = method->write((ulong *)&addr, handle++, node);
 
 		max_struct_size = max(max_struct_size, tmp);
 		len += tmp;
-- 
2.29.0.rc1.297.gfa9743e501-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 5/6] smbios: Add more properties
  2020-10-22  3:08 [PATCH v3 0/6] x86: Updates to SMBIOS Simon Glass
                   ` (3 preceding siblings ...)
  2020-10-22  3:08 ` [PATCH v3 4/6] smbios: Allow properties to come from the device tree Simon Glass
@ 2020-10-22  3:08 ` Simon Glass
  2020-10-22  3:08 ` [PATCH v3 6/6] smbios: Add documentation and devicetree binding Simon Glass
  5 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2020-10-22  3:08 UTC (permalink / raw
  To: u-boot

The current tables only support a subset of the available fields defined
by the SMBIOS spec. Add a few more.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 lib/smbios.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/smbios.c b/lib/smbios.c
index 6d3c20a48ee..e97a3bfe6f3 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -173,12 +173,15 @@ static int smbios_write_type1(ulong *current, int handle, ofnode node)
 						  CONFIG_SMBIOS_MANUFACTURER);
 	t->product_name = smbios_add_prop_default(t->eos, node, "product",
 						  CONFIG_SMBIOS_PRODUCT_NAME);
+	t->version = smbios_add_prop(t->eos, node, "version");
 	if (serial_str) {
 		t->serial_number = smbios_add_string(t->eos, serial_str);
 		strncpy((char *)t->uuid, serial_str, sizeof(t->uuid));
 	} else {
 		t->serial_number = smbios_add_prop(t->eos, node, "serial");
 	}
+	t->sku_number = smbios_add_prop(t->eos, node, "sku");
+	t->family = smbios_add_prop(t->eos, node, "family");
 
 	len = t->length + smbios_string_table_len(t->eos);
 	*current += len;
@@ -199,6 +202,7 @@ static int smbios_write_type2(ulong *current, int handle, ofnode node)
 						  CONFIG_SMBIOS_MANUFACTURER);
 	t->product_name = smbios_add_prop_default(t->eos, node, "product",
 						  CONFIG_SMBIOS_PRODUCT_NAME);
+	t->asset_tag_number = smbios_add_prop(t->eos, node, "asset-tag");
 	t->feature_flags = SMBIOS_BOARD_FEATURE_HOSTING;
 	t->board_type = SMBIOS_BOARD_MOTHERBOARD;
 
-- 
2.29.0.rc1.297.gfa9743e501-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 6/6] smbios: Add documentation and devicetree binding
  2020-10-22  3:08 [PATCH v3 0/6] x86: Updates to SMBIOS Simon Glass
                   ` (4 preceding siblings ...)
  2020-10-22  3:08 ` [PATCH v3 5/6] smbios: Add more properties Simon Glass
@ 2020-10-22  3:08 ` Simon Glass
  2020-10-22  5:51   ` Heinrich Schuchardt
  5 siblings, 1 reply; 13+ messages in thread
From: Simon Glass @ 2020-10-22  3:08 UTC (permalink / raw
  To: u-boot

Add information about how to set SMBIOS properties using the devicetree.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3:
- Add onto the sysinfo binding

 doc/arch/x86.rst                            |  8 +++
 doc/device-tree-bindings/sysinfo/smbios.txt | 77 +++++++++++++++++++++
 2 files changed, 85 insertions(+)
 create mode 100644 doc/device-tree-bindings/sysinfo/smbios.txt

diff --git a/doc/arch/x86.rst b/doc/arch/x86.rst
index c6b70ce61a3..cc307aa8d5e 100644
--- a/doc/arch/x86.rst
+++ b/doc/arch/x86.rst
@@ -740,6 +740,14 @@ Note that this is a development feature only. It is not intended for use in
 production environments. Also it is not currently part of the automated tests
 so may break in the future.
 
+SMBIOS tables
+-------------
+
+To generate SMBIOS tables in U-Boot, for use by the OS, enable the
+CONFIG_GENERATE_SMBIOS_TABLE option. The easiest way to provide the values to
+use is via the device tree. For details see
+device-tree-bindings/sysinfo/smbios.txt
+
 TODO List
 ---------
 - Audio
diff --git a/doc/device-tree-bindings/sysinfo/smbios.txt b/doc/device-tree-bindings/sysinfo/smbios.txt
new file mode 100644
index 00000000000..b5223228025
--- /dev/null
+++ b/doc/device-tree-bindings/sysinfo/smbios.txt
@@ -0,0 +1,77 @@
+SMBIOS sysinfo information
+==========================
+
+This binding allows the values for the SMBIOS tables to be specified in the
+devicetree, as below.
+
+Required properties:
+
+  - compatible: "u-boot,smbios" or any other string depending on your board
+
+This driver allows providing board-specific features such as power control
+GPIOs. In addition, the SMBIOS values can be specified in the device tree,
+as below:
+
+An optional 'smbios' subnode can be used to provide these properties. Within
+that, the properties are broken down by table type, as in the System Management
+BIOS (Basic Input/Output System) Specification.
+
+Available subnodes for each table type are:
+
+  - 1 : system
+  - 2 : baseboard
+  - 3 : chassis
+
+Within each subnode the following tables are recognised:
+
+"system" subnode optional properties:
+
+  - manufacturer: Product manufacturer for system
+  - product:      Product name
+  - version:      Product version string
+  - serial:       Serial number for system (note that this can be overridden by
+                      the serial# environment variable)
+  - sku:          Product SKU (Stock-Keeping Unit)
+  - family:       Product family
+
+"baseboard" subnode optional properties:
+
+  - manufacturer: Product manufacturer for baseboard
+  - product:      Product name
+  - asset-tag:    Asset tag for the motherboard, sometimes used in organisations
+                      to track devices
+
+"chassis" subnode optional properties:
+
+  - manufacturer: Product manufacturer for chassis
+
+
+Example:
+
+sysinfo {
+	compatible = "sandbox,sysinfo-sandbox";
+
+	smbios {
+		/* Type 1 table */
+		system {
+			manufacturer = "Google";
+			product = "Coral";
+			version = "rev2";
+			serial = "123456789";
+			sku = "sku3";
+			family = "Google_Coral";
+		};
+
+		/* Type 2 table */
+		baseboard {
+			manufacturer = "Google";
+			product = "Coral";
+			asset-tag = "ABC123";
+		};
+
+		/* Type 3 table */
+		chassis {
+			manufacturer = "Google";
+		};
+	};
+};
-- 
2.29.0.rc1.297.gfa9743e501-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 2/6] doc: Add a binding for sysinfo
  2020-10-22  3:08 ` [PATCH v3 2/6] doc: Add a binding for sysinfo Simon Glass
@ 2020-10-22  5:40   ` Heinrich Schuchardt
  2020-10-22 12:29     ` Simon Glass
  0 siblings, 1 reply; 13+ messages in thread
From: Heinrich Schuchardt @ 2020-10-22  5:40 UTC (permalink / raw
  To: u-boot

On 10/22/20 5:08 AM, Simon Glass wrote:
> Add a simple binding file for this, so that it is clear what this binding
> directory is for.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> (no changes since v1)
>
>  doc/device-tree-bindings/sysinfo/sysinfo.txt | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>  create mode 100644 doc/device-tree-bindings/sysinfo/sysinfo.txt
>
> diff --git a/doc/device-tree-bindings/sysinfo/sysinfo.txt b/doc/device-tree-bindings/sysinfo/sysinfo.txt
> new file mode 100644
> index 00000000000..ed8830b8284
> --- /dev/null
> +++ b/doc/device-tree-bindings/sysinfo/sysinfo.txt
> @@ -0,0 +1,18 @@
> +Sysinfo
> +=======
> +
> +This provides capabilities to access information about a board/system, for
> +use by drivers.
> +
> +Required properties:
> +
> +  - compatible: any suitable string where the driver is in the UCLASS_SYSINFO
> +      class
> +
> +See also smbios.txt
> +
> +
> +Example
> +
> +sysinfo {
> +	compatible = "sandbox,sysinfo";
>

Most boards use don't use ACPI but device-trees for calling
the operating system.
We try to keep our device-trees in sync with Linux.
The device-tree available under $fdtcontroladdr should be
usable to boot the OS.
We should avoid anything that could lead now or in the future
to a conflict with the the OS usage of the device tree nodes.

Please, use in the example a compatibility string that is
unique to U-Boot.

How about: "uboot,sandbox-sysinfo"?

Best regards

Heinrich

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v3 4/6] smbios: Allow properties to come from the device tree
  2020-10-22  3:08 ` [PATCH v3 4/6] smbios: Allow properties to come from the device tree Simon Glass
@ 2020-10-22  5:49   ` Heinrich Schuchardt
  2020-10-22 12:29     ` Simon Glass
  0 siblings, 1 reply; 13+ messages in thread
From: Heinrich Schuchardt @ 2020-10-22  5:49 UTC (permalink / raw
  To: u-boot

On 10/22/20 5:08 AM, Simon Glass wrote:
> Support a way to put SMBIOS properties in the device tree. These can be
> placed in a 'board' device in an 'smbios' subnode.

For me it is fine if you want to specify the SMBIOS properties via the
device tree. But it makes no sense to have multiple ways of
specification and thereby increase code size.

So if you move to SMBIOS properties to the device-tree, please,
eliminate the Kconfig symbols.

Best regards

Heinrich

>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3:
> - Use a different binding with subnodes for each table type
>
>  lib/smbios.c | 100 +++++++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 82 insertions(+), 18 deletions(-)
>
> diff --git a/lib/smbios.c b/lib/smbios.c
> index 4bb3bac56b4..6d3c20a48ee 100644
> --- a/lib/smbios.c
> +++ b/lib/smbios.c
> @@ -17,6 +17,18 @@
>  #include <dm/uclass-internal.h>
>  #endif
>
> +/**
> + * struct smbios_write_method - Informaiton about a table-writing function
> + *
> + * @write: Function to call
> + * @subnode_name: Name of subnode which has the information for this function,
> + *	NULL if none
> + */
> +struct smbios_write_method {
> +	smbios_write_type write;
> +	const char *subnode_name;
> +};
> +
>  /**
>   * smbios_add_string() - add a string to the string area
>   *
> @@ -52,6 +64,43 @@ static int smbios_add_string(char *start, const char *str)
>  	}
>  }
>
> +/**
> + * smbios_add_prop_default() - Add a property from the device tree or default
> + *
> + * @start:	string area start address
> + * @node:	node containing the information to write (ofnode_null() if none)
> + * @prop:	property to write
> + * @def:	default string if the node has no such property
> + * @return 0 if not found, else SMBIOS string number (1 or more)
> + */
> +static int smbios_add_prop_default(char *start, ofnode node, const char *prop,
> +				   const char *def)
> +{
> +	const char *str = NULL;
> +
> +	if (IS_ENABLED(CONFIG_OF_CONTROL))
> +		str = ofnode_read_string(node, prop);
> +	if (str)
> +		return smbios_add_string(start, str);
> +	else if (def)
> +		return smbios_add_string(start, def);
> +
> +	return 0;
> +}
> +
> +/**
> + * smbios_add_prop() - Add a property from the device tree
> + *
> + * @start:	string area start address
> + * @node:	node containing the information to write (ofnode_null() if none)
> + * @prop:	property to write
> + * @return 0 if not found, else SMBIOS string number (1 or more)
> + */
> +static int smbios_add_prop(char *start, ofnode node, const char *prop)
> +{
> +	return smbios_add_prop_default(start, node, prop, NULL);
> +}
> +
>  /**
>   * smbios_string_table_len() - compute the string area size
>   *
> @@ -120,11 +169,15 @@ static int smbios_write_type1(ulong *current, int handle, ofnode node)
>  	t = map_sysmem(*current, len);
>  	memset(t, 0, sizeof(struct smbios_type1));
>  	fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle);
> -	t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
> -	t->product_name = smbios_add_string(t->eos, CONFIG_SMBIOS_PRODUCT_NAME);
> +	t->manufacturer = smbios_add_prop_default(t->eos, node, "manufactuer",
> +						  CONFIG_SMBIOS_MANUFACTURER);
> +	t->product_name = smbios_add_prop_default(t->eos, node, "product",
> +						  CONFIG_SMBIOS_PRODUCT_NAME);
>  	if (serial_str) {
> -		strncpy((char *)t->uuid, serial_str, sizeof(t->uuid));
>  		t->serial_number = smbios_add_string(t->eos, serial_str);
> +		strncpy((char *)t->uuid, serial_str, sizeof(t->uuid));
> +	} else {
> +		t->serial_number = smbios_add_prop(t->eos, node, "serial");
>  	}
>
>  	len = t->length + smbios_string_table_len(t->eos);
> @@ -142,8 +195,10 @@ static int smbios_write_type2(ulong *current, int handle, ofnode node)
>  	t = map_sysmem(*current, len);
>  	memset(t, 0, sizeof(struct smbios_type2));
>  	fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle);
> -	t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
> -	t->product_name = smbios_add_string(t->eos, CONFIG_SMBIOS_PRODUCT_NAME);
> +	t->manufacturer = smbios_add_prop_default(t->eos, node, "manufactuer",
> +						  CONFIG_SMBIOS_MANUFACTURER);
> +	t->product_name = smbios_add_prop_default(t->eos, node, "product",
> +						  CONFIG_SMBIOS_PRODUCT_NAME);
>  	t->feature_flags = SMBIOS_BOARD_FEATURE_HOSTING;
>  	t->board_type = SMBIOS_BOARD_MOTHERBOARD;
>
> @@ -162,7 +217,8 @@ static int smbios_write_type3(ulong *current, int handle, ofnode node)
>  	t = map_sysmem(*current, len);
>  	memset(t, 0, sizeof(struct smbios_type3));
>  	fill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, handle);
> -	t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
> +	t->manufacturer = smbios_add_prop_default(t->eos, node, "manufactuer",
> +						  CONFIG_SMBIOS_MANUFACTURER);
>  	t->chassis_type = SMBIOS_ENCLOSURE_DESKTOP;
>  	t->bootup_state = SMBIOS_STATE_SAFE;
>  	t->power_supply_state = SMBIOS_STATE_SAFE;
> @@ -262,19 +318,19 @@ static int smbios_write_type127(ulong *current, int handle, ofnode node)
>  	return len;
>  }
>
> -static smbios_write_type smbios_write_funcs[] = {
> -	smbios_write_type0,
> -	smbios_write_type1,
> -	smbios_write_type2,
> -	smbios_write_type3,
> -	smbios_write_type4,
> -	smbios_write_type32,
> -	smbios_write_type127
> +static struct smbios_write_method smbios_write_funcs[] = {
> +	{ smbios_write_type0, },
> +	{ smbios_write_type1, "system", },
> +	{ smbios_write_type2, "baseboard", },
> +	{ smbios_write_type3, "chassis", },
> +	{ smbios_write_type4, },
> +	{ smbios_write_type32, },
> +	{ smbios_write_type127 },
>  };
>
>  ulong write_smbios_table(ulong addr)
>  {
> -	ofnode node = ofnode_null();
> +	ofnode parent_node = ofnode_null();
>  	struct smbios_entry *se;
>  	struct udevice *dev;
>  	ulong table_addr;
> @@ -287,9 +343,9 @@ ulong write_smbios_table(ulong addr)
>  	int i;
>
>  	if (IS_ENABLED(CONFIG_OF_CONTROL)) {
> -		uclass_first_device(UCLASS_BOARD, &dev);
> +		uclass_first_device(UCLASS_SYSINFO, &dev);
>  		if (dev)
> -			node = dev_read_subnode(dev, "smbios");
> +			parent_node = dev_read_subnode(dev, "smbios");
>  	}
>
>  	/* 16 byte align the table address */
> @@ -304,7 +360,15 @@ ulong write_smbios_table(ulong addr)
>
>  	/* populate minimum required tables */
>  	for (i = 0; i < ARRAY_SIZE(smbios_write_funcs); i++) {
> -		int tmp = smbios_write_funcs[i]((ulong *)&addr, handle++, node);
> +		const struct smbios_write_method *method;
> +		ofnode node = ofnode_null();
> +		int tmp;
> +
> +		method = &smbios_write_funcs[i];
> +		if (method->subnode_name)
> +			node = ofnode_find_subnode(parent_node,
> +						   method->subnode_name);
> +		tmp = method->write((ulong *)&addr, handle++, node);
>
>  		max_struct_size = max(max_struct_size, tmp);
>  		len += tmp;
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v3 6/6] smbios: Add documentation and devicetree binding
  2020-10-22  3:08 ` [PATCH v3 6/6] smbios: Add documentation and devicetree binding Simon Glass
@ 2020-10-22  5:51   ` Heinrich Schuchardt
  2020-10-22 12:29     ` Simon Glass
  0 siblings, 1 reply; 13+ messages in thread
From: Heinrich Schuchardt @ 2020-10-22  5:51 UTC (permalink / raw
  To: u-boot

On 10/22/20 5:08 AM, Simon Glass wrote:
> Add information about how to set SMBIOS properties using the devicetree.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3:
> - Add onto the sysinfo binding
>
>  doc/arch/x86.rst                            |  8 +++
>  doc/device-tree-bindings/sysinfo/smbios.txt | 77 +++++++++++++++++++++
>  2 files changed, 85 insertions(+)
>  create mode 100644 doc/device-tree-bindings/sysinfo/smbios.txt
>
> diff --git a/doc/arch/x86.rst b/doc/arch/x86.rst
> index c6b70ce61a3..cc307aa8d5e 100644
> --- a/doc/arch/x86.rst
> +++ b/doc/arch/x86.rst
> @@ -740,6 +740,14 @@ Note that this is a development feature only. It is not intended for use in
>  production environments. Also it is not currently part of the automated tests
>  so may break in the future.
>
> +SMBIOS tables
> +-------------
> +
> +To generate SMBIOS tables in U-Boot, for use by the OS, enable the
> +CONFIG_GENERATE_SMBIOS_TABLE option. The easiest way to provide the values to
> +use is via the device tree. For details see
> +device-tree-bindings/sysinfo/smbios.txt
> +
>  TODO List
>  ---------
>  - Audio
> diff --git a/doc/device-tree-bindings/sysinfo/smbios.txt b/doc/device-tree-bindings/sysinfo/smbios.txt
> new file mode 100644
> index 00000000000..b5223228025
> --- /dev/null
> +++ b/doc/device-tree-bindings/sysinfo/smbios.txt
> @@ -0,0 +1,77 @@
> +SMBIOS sysinfo information
> +==========================
> +
> +This binding allows the values for the SMBIOS tables to be specified in the
> +devicetree, as below.
> +
> +Required properties:
> +
> +  - compatible: "u-boot,smbios" or any other string depending on your board
> +
> +This driver allows providing board-specific features such as power control
> +GPIOs. In addition, the SMBIOS values can be specified in the device tree,
> +as below:
> +
> +An optional 'smbios' subnode can be used to provide these properties. Within
> +that, the properties are broken down by table type, as in the System Management
> +BIOS (Basic Input/Output System) Specification.
> +
> +Available subnodes for each table type are:
> +
> +  - 1 : system
> +  - 2 : baseboard
> +  - 3 : chassis
> +
> +Within each subnode the following tables are recognised:
> +
> +"system" subnode optional properties:
> +
> +  - manufacturer: Product manufacturer for system
> +  - product:      Product name
> +  - version:      Product version string
> +  - serial:       Serial number for system (note that this can be overridden by
> +                      the serial# environment variable)
> +  - sku:          Product SKU (Stock-Keeping Unit)
> +  - family:       Product family
> +
> +"baseboard" subnode optional properties:
> +
> +  - manufacturer: Product manufacturer for baseboard
> +  - product:      Product name
> +  - asset-tag:    Asset tag for the motherboard, sometimes used in organisations
> +                      to track devices
> +
> +"chassis" subnode optional properties:
> +
> +  - manufacturer: Product manufacturer for chassis
> +
> +
> +Example:
> +
> +sysinfo {
> +	compatible = "sandbox,sysinfo-sandbox";

Most boards use don't use ACPI but device-trees for calling
the operating system.
We try to keep our device-trees in sync with Linux.
The device-tree available under $fdtcontroladdr should be
usable to boot the OS.
We should avoid anything that could lead now or in the future
to a conflict with the the OS usage of the device tree nodes.

Please, use in the example a compatibility string that is
unique to U-Boot.

How about: "uboot,sandbox-sysinfo"?

Best regards

Heinrich

> +
> +	smbios {
> +		/* Type 1 table */
> +		system {
> +			manufacturer = "Google";
> +			product = "Coral";
> +			version = "rev2";
> +			serial = "123456789";
> +			sku = "sku3";
> +			family = "Google_Coral";
> +		};
> +
> +		/* Type 2 table */
> +		baseboard {
> +			manufacturer = "Google";
> +			product = "Coral";
> +			asset-tag = "ABC123";
> +		};
> +
> +		/* Type 3 table */
> +		chassis {
> +			manufacturer = "Google";
> +		};
> +	};
> +};
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v3 2/6] doc: Add a binding for sysinfo
  2020-10-22  5:40   ` Heinrich Schuchardt
@ 2020-10-22 12:29     ` Simon Glass
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2020-10-22 12:29 UTC (permalink / raw
  To: u-boot

Hi Heinrich,

On Wed, 21 Oct 2020 at 23:41, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 10/22/20 5:08 AM, Simon Glass wrote:
> > Add a simple binding file for this, so that it is clear what this binding
> > directory is for.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > (no changes since v1)
> >
> >  doc/device-tree-bindings/sysinfo/sysinfo.txt | 18 ++++++++++++++++++
> >  1 file changed, 18 insertions(+)
> >  create mode 100644 doc/device-tree-bindings/sysinfo/sysinfo.txt
> >
> > diff --git a/doc/device-tree-bindings/sysinfo/sysinfo.txt b/doc/device-tree-bindings/sysinfo/sysinfo.txt
> > new file mode 100644
> > index 00000000000..ed8830b8284
> > --- /dev/null
> > +++ b/doc/device-tree-bindings/sysinfo/sysinfo.txt
> > @@ -0,0 +1,18 @@
> > +Sysinfo
> > +=======
> > +
> > +This provides capabilities to access information about a board/system, for
> > +use by drivers.
> > +
> > +Required properties:
> > +
> > +  - compatible: any suitable string where the driver is in the UCLASS_SYSINFO
> > +      class
> > +
> > +See also smbios.txt
> > +
> > +
> > +Example
> > +
> > +sysinfo {
> > +     compatible = "sandbox,sysinfo";
> >
>
> Most boards use don't use ACPI but device-trees for calling
> the operating system.
> We try to keep our device-trees in sync with Linux.
> The device-tree available under $fdtcontroladdr should be
> usable to boot the OS.
> We should avoid anything that could lead now or in the future
> to a conflict with the the OS usage of the device tree nodes.
>
> Please, use in the example a compatibility string that is
> unique to U-Boot.
>
> How about: "uboot,sandbox-sysinfo"?

We use "sandbox" as the vendor throughout U-Boot so I don't feel we
should change now. Perhaps as part of an effort to send our bindings
upstream?

Regards,
Simon

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v3 6/6] smbios: Add documentation and devicetree binding
  2020-10-22  5:51   ` Heinrich Schuchardt
@ 2020-10-22 12:29     ` Simon Glass
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2020-10-22 12:29 UTC (permalink / raw
  To: u-boot

Hi Heinrich,

On Wed, 21 Oct 2020 at 23:51, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 10/22/20 5:08 AM, Simon Glass wrote:
> > Add information about how to set SMBIOS properties using the devicetree.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > Changes in v3:
> > - Add onto the sysinfo binding
> >
> >  doc/arch/x86.rst                            |  8 +++
> >  doc/device-tree-bindings/sysinfo/smbios.txt | 77 +++++++++++++++++++++
> >  2 files changed, 85 insertions(+)
> >  create mode 100644 doc/device-tree-bindings/sysinfo/smbios.txt
> >
> > diff --git a/doc/arch/x86.rst b/doc/arch/x86.rst
> > index c6b70ce61a3..cc307aa8d5e 100644
> > --- a/doc/arch/x86.rst
> > +++ b/doc/arch/x86.rst
> > @@ -740,6 +740,14 @@ Note that this is a development feature only. It is not intended for use in
> >  production environments. Also it is not currently part of the automated tests
> >  so may break in the future.
> >
> > +SMBIOS tables
> > +-------------
> > +
> > +To generate SMBIOS tables in U-Boot, for use by the OS, enable the
> > +CONFIG_GENERATE_SMBIOS_TABLE option. The easiest way to provide the values to
> > +use is via the device tree. For details see
> > +device-tree-bindings/sysinfo/smbios.txt
> > +
> >  TODO List
> >  ---------
> >  - Audio
> > diff --git a/doc/device-tree-bindings/sysinfo/smbios.txt b/doc/device-tree-bindings/sysinfo/smbios.txt
> > new file mode 100644
> > index 00000000000..b5223228025
> > --- /dev/null
> > +++ b/doc/device-tree-bindings/sysinfo/smbios.txt
> > @@ -0,0 +1,77 @@
> > +SMBIOS sysinfo information
> > +==========================
> > +
> > +This binding allows the values for the SMBIOS tables to be specified in the
> > +devicetree, as below.
> > +
> > +Required properties:
> > +
> > +  - compatible: "u-boot,smbios" or any other string depending on your board
> > +
> > +This driver allows providing board-specific features such as power control
> > +GPIOs. In addition, the SMBIOS values can be specified in the device tree,
> > +as below:
> > +
> > +An optional 'smbios' subnode can be used to provide these properties. Within
> > +that, the properties are broken down by table type, as in the System Management
> > +BIOS (Basic Input/Output System) Specification.
> > +
> > +Available subnodes for each table type are:
> > +
> > +  - 1 : system
> > +  - 2 : baseboard
> > +  - 3 : chassis
> > +
> > +Within each subnode the following tables are recognised:
> > +
> > +"system" subnode optional properties:
> > +
> > +  - manufacturer: Product manufacturer for system
> > +  - product:      Product name
> > +  - version:      Product version string
> > +  - serial:       Serial number for system (note that this can be overridden by
> > +                      the serial# environment variable)
> > +  - sku:          Product SKU (Stock-Keeping Unit)
> > +  - family:       Product family
> > +
> > +"baseboard" subnode optional properties:
> > +
> > +  - manufacturer: Product manufacturer for baseboard
> > +  - product:      Product name
> > +  - asset-tag:    Asset tag for the motherboard, sometimes used in organisations
> > +                      to track devices
> > +
> > +"chassis" subnode optional properties:
> > +
> > +  - manufacturer: Product manufacturer for chassis
> > +
> > +
> > +Example:
> > +
> > +sysinfo {
> > +     compatible = "sandbox,sysinfo-sandbox";
>
> Most boards use don't use ACPI but device-trees for calling
> the operating system.
> We try to keep our device-trees in sync with Linux.
> The device-tree available under $fdtcontroladdr should be
> usable to boot the OS.
> We should avoid anything that could lead now or in the future
> to a conflict with the the OS usage of the device tree nodes.
>
> Please, use in the example a compatibility string that is
> unique to U-Boot.
>
> How about: "uboot,sandbox-sysinfo"?
>

See my other note on the same comment.

BTW the compatible string depends on the board vendor. We don't define
it in this binding file.

In any case, as I say, this binding does not set the compatible
string. It can be whatever the board wants.

I'd really like to send our bindings up to Linux. So far they have
shown little interest in accepting these, although I don't think
anyone has tried in years. It came up on the call last week.

Regards,
Simon

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v3 4/6] smbios: Allow properties to come from the device tree
  2020-10-22  5:49   ` Heinrich Schuchardt
@ 2020-10-22 12:29     ` Simon Glass
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Glass @ 2020-10-22 12:29 UTC (permalink / raw
  To: u-boot

Hi Heinrich,

On Wed, 21 Oct 2020 at 23:50, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 10/22/20 5:08 AM, Simon Glass wrote:
> > Support a way to put SMBIOS properties in the device tree. These can be
> > placed in a 'board' device in an 'smbios' subnode.
>
> For me it is fine if you want to specify the SMBIOS properties via the
> device tree. But it makes no sense to have multiple ways of
> specification and thereby increase code size.
>
> So if you move to SMBIOS properties to the device-tree, please,
> eliminate the Kconfig symbols.

I was thinking about that. There is one board that doesn't even use
devicetree, but perhaps we should just remove the CONFIG or the board.

I will take a look.

Regards,
Simon

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-10-22 12:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-22  3:08 [PATCH v3 0/6] x86: Updates to SMBIOS Simon Glass
2020-10-22  3:08 ` [PATCH v3 1/6] board: Rename uclass to sysinfo Simon Glass
2020-10-22  3:08 ` [PATCH v3 2/6] doc: Add a binding for sysinfo Simon Glass
2020-10-22  5:40   ` Heinrich Schuchardt
2020-10-22 12:29     ` Simon Glass
2020-10-22  3:08 ` [PATCH v3 3/6] x86: Pass an ofnode into each SMBIOS function Simon Glass
2020-10-22  3:08 ` [PATCH v3 4/6] smbios: Allow properties to come from the device tree Simon Glass
2020-10-22  5:49   ` Heinrich Schuchardt
2020-10-22 12:29     ` Simon Glass
2020-10-22  3:08 ` [PATCH v3 5/6] smbios: Add more properties Simon Glass
2020-10-22  3:08 ` [PATCH v3 6/6] smbios: Add documentation and devicetree binding Simon Glass
2020-10-22  5:51   ` Heinrich Schuchardt
2020-10-22 12:29     ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.