};
board {
- compatible = "gdsys,board_gazerbeam";
+ compatible = "gdsys,sysinfo-gazerbeam";
csb = <&board_soc>;
serdes = <&SERDES>;
rxaui0 = <&RXAUI0_0>;
compatible = "sandbox,sandbox_osd";
};
- board {
- compatible = "sandbox,board_sandbox";
- };
-
sandbox_tee {
compatible = "sandbox,tee";
};
reset-names = "valid", "no_mask", "out_of_range";
};
+ sysinfo {
+ compatible = "sandbox,sysinfo-sandbox";
+ };
+
some_regmapped-bus {
#address-cells = <0x1>;
#size-cells = <0x1>;
#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"
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) {
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);
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;
*/
#include <common.h>
-#include <board.h>
#include <command.h>
#include <dm.h>
#include <env.h>
#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;
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@e0000000/i2c@3100/pca9698@22");
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");
{
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);
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);
}
U_BOOT_DRIVER(coral_drv) = {
.name = "coral",
- .id = UCLASS_BOARD,
+ .id = UCLASS_SYSINFO,
.of_match = coral_ids,
ACPI_OPS_PTR(&coral_acpi_ops)
};
#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>
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;
}
}
- 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.
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
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
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
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
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
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
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
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
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
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
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
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
+++ /dev/null
-gdsys Gazerbeam board 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"
-- 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
-- ioep[0-1]: phandles to the board's IO endpoint device nodes
-- ver-gpios: GPIO list to read the hardware version from
-- var-gpios: GPIO list to read the hardware variant information from
-- reset-gpios: GPIO list for the board's reset GPIOs
-
-Example:
-
-
-board {
- compatible = "gdsys,board_gazerbeam";
- csb = <&board_soc>;
- serdes = <&SERDES>;
- rxaui0 = <&RXAUI0>;
- rxaui1 = <&RXAUI1>;
- rxaui2 = <&RXAUI2>;
- rxaui3 = <&RXAUI3>;
- fpga0 = <&FPGA0>;
- fpga1 = <&FPGA1>;
- ioep0 = <&IOEP0>;
- ioep1 = <&IOEP1>;
-
- ver-gpios = <&PPCPCA 12 0
- &PPCPCA 13 0
- &PPCPCA 14 0
- &PPCPCA 15 0>;
-
- /* MC2/SC-Board */
- var-gpios-mc2 = <&GPIO_VB0 0 0 /* VAR-MC_SC */
- &GPIO_VB0 11 0>; /* VAR-CON */
- /* MC4-Board */
- var-gpios-mc4 = <&GPIO_VB1 0 0 /* VAR-MC_SC */
- &GPIO_VB1 11 0>; /* VAR-CON */
-
- reset-gpios = <&gpio0 1 0 &gpio0 2 1>;
-};
--- /dev/null
+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,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
+- ioep[0-1]: phandles to the board's IO endpoint device nodes
+- ver-gpios: GPIO list to read the hardware version from
+- var-gpios: GPIO list to read the hardware variant information from
+- reset-gpios: GPIO list for the board's reset GPIOs
+
+Example:
+
+
+sysinfo {
+ compatible = "gdsys,sysinfo-gazerbeam";
+ csb = <&board_soc>;
+ serdes = <&SERDES>;
+ rxaui0 = <&RXAUI0>;
+ rxaui1 = <&RXAUI1>;
+ rxaui2 = <&RXAUI2>;
+ rxaui3 = <&RXAUI3>;
+ fpga0 = <&FPGA0>;
+ fpga1 = <&FPGA1>;
+ ioep0 = <&IOEP0>;
+ ioep1 = <&IOEP1>;
+
+ ver-gpios = <&PPCPCA 12 0
+ &PPCPCA 13 0
+ &PPCPCA 14 0
+ &PPCPCA 15 0>;
+
+ /* MC2/SC-Board */
+ var-gpios-mc2 = <&GPIO_VB0 0 0 /* VAR-MC_SC */
+ &GPIO_VB0 11 0>; /* VAR-CON */
+ /* MC4-Board */
+ var-gpios-mc4 = <&GPIO_VB1 0 0 /* VAR-MC_SC */
+ &GPIO_VB1 11 0>; /* VAR-CON */
+
+ reset-gpios = <&gpio0 1 0 &gpio0 2 1>;
+};
source "drivers/demo/Kconfig"
-source "drivers/board/Kconfig"
-
source "drivers/ddr/fsl/Kconfig"
source "drivers/dfu/Kconfig"
source "drivers/spmi/Kconfig"
+source "drivers/sysinfo/Kconfig"
+
source "drivers/sysreset/Kconfig"
source "drivers/tee/Kconfig"
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/
+++ /dev/null
-menuconfig BOARD
- bool "Device 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
-
-config SPL_BOARD
- depends on SPL_DM
- bool "Enable board driver support in SPL"
-
-config BOARD_GAZERBEAM
- bool "Enable board 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"
- help
- Support querying device information for the Sandbox boards.
-
-endif
+++ /dev/null
-# SPDX-License-Identifier: GPL-2.0+
-#
-# (C) Copyright 2017
-obj-y += board-uclass.o
-obj-$(CONFIG_BOARD_GAZERBEAM) += gazerbeam.o
-obj-$(CONFIG_BOARD_SANDBOX) += sandbox.o
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2017
- */
-
-#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,
-};
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2017
- */
-
-#include <common.h>
-#include <dm.h>
-#include <board.h>
-#include <i2c.h>
-#include <log.h>
-#include <asm/gpio.h>
-
-#include "gazerbeam.h"
-
-/* Sequence number of I2C bus that holds the GPIO expanders */
-static const int I2C_BUS_SEQ_NO = 1;
-
-/* I2C address of SC/MC2 expander */
-static const int MC2_EXPANDER_ADDR = 0x20;
-/* I2C address of MC4 expander */
-static const int MC4_EXPANDER_ADDR = 0x22;
-
-/* Number of the GPIO to read the SC data from */
-static const int SC_GPIO_NO;
-/* Number of the GPIO to read the CON data from */
-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 board_gazerbeam_priv {
- struct gpio_desc reset_gpios[2];
- struct gpio_desc var_gpios[2];
- struct gpio_desc ver_gpios[4];
- int variant;
- int multichannel;
- int hwversion;
-};
-
-/**
- * _read_board_variant_data() - Read variant information from the hardware.
- * @dev: The board 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
- * 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)
-{
- struct board_gazerbeam_priv *priv = dev_get_priv(dev);
- struct udevice *i2c_bus;
- struct udevice *dummy;
- char *listname;
- int mc4, mc2, sc, mc2_sc, con;
- int gpio_num;
- int res;
-
- res = uclass_get_device_by_seq(UCLASS_I2C, I2C_BUS_SEQ_NO, &i2c_bus);
- if (res) {
- debug("%s: Could not get I2C bus %d (err = %d)\n",
- dev->name, I2C_BUS_SEQ_NO, res);
- return res;
- }
-
- if (!i2c_bus) {
- debug("%s: Could not get I2C bus %d\n",
- dev->name, I2C_BUS_SEQ_NO);
- return -EIO;
- }
-
- mc2_sc = !dm_i2c_probe(i2c_bus, MC2_EXPANDER_ADDR, 0, &dummy);
- mc4 = !dm_i2c_probe(i2c_bus, MC4_EXPANDER_ADDR, 0, &dummy);
-
- if (mc2_sc && mc4) {
- debug("%s: Board hardware configuration inconsistent.\n",
- dev->name);
- return -EINVAL;
- }
-
- listname = mc2_sc ? "var-gpios-mc2" : "var-gpios-mc4";
-
- gpio_num = gpio_request_list_by_name(dev, listname, priv->var_gpios,
- ARRAY_SIZE(priv->var_gpios),
- GPIOD_IS_IN);
- if (gpio_num < 0) {
- debug("%s: Requesting gpio list %s failed (err = %d).\n",
- dev->name, listname, gpio_num);
- return gpio_num;
- }
-
- sc = dm_gpio_get_value(&priv->var_gpios[SC_GPIO_NO]);
- if (sc < 0) {
- debug("%s: Error while reading 'sc' GPIO (err = %d)",
- dev->name, sc);
- return sc;
- }
-
- mc2 = mc2_sc ? (sc ? 0 : 1) : 0;
-
- if ((sc && mc2) || (sc && mc4) || (!sc && !mc2 && !mc4)) {
- debug("%s: Board hardware configuration inconsistent.\n",
- dev->name);
- return -EINVAL;
- }
-
- con = dm_gpio_get_value(&priv->var_gpios[CON_GPIO_NO]);
- if (con < 0) {
- debug("%s: Error while reading 'con' GPIO (err = %d)",
- dev->name, con);
- return con;
- }
-
- priv->variant = con ? VAR_CON : VAR_CPU;
-
- priv->multichannel = mc4 ? 4 : (mc2 ? 2 : (sc ? 1 : 0));
-
- return 0;
-}
-
-/**
- * _read_hwversion() - Read the hardware version from the board.
- * @dev: The board device for which to read the hardware version.
- *
- * The hardware version read from the board (from 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_hwversion(struct udevice *dev)
-{
- struct board_gazerbeam_priv *priv = dev_get_priv(dev);
- int res;
-
- res = gpio_request_list_by_name(dev, "ver-gpios", priv->ver_gpios,
- ARRAY_SIZE(priv->ver_gpios),
- GPIOD_IS_IN);
- if (res < 0) {
- debug("%s: Error getting GPIO list 'ver-gpios' (err = %d)\n",
- dev->name, res);
- return -ENODEV;
- }
-
- res = dm_gpio_get_values_as_int(priv->ver_gpios,
- ARRAY_SIZE(priv->ver_gpios));
- if (res < 0) {
- debug("%s: Error reading HW version from expander (err = %d)\n",
- dev->name, res);
- return res;
- }
-
- priv->hwversion = res;
-
- res = gpio_free_list(dev, priv->ver_gpios, ARRAY_SIZE(priv->ver_gpios));
- if (res < 0) {
- debug("%s: Error freeing HW version GPIO list (err = %d)\n",
- dev->name, res);
- return res;
- }
-
- return 0;
-}
-
-static int board_gazerbeam_detect(struct udevice *dev)
-{
- int res;
-
- res = _read_board_variant_data(dev);
- if (res) {
- debug("%s: Error reading multichannel variant (err = %d)\n",
- dev->name, res);
- return res;
- }
-
- res = _read_hwversion(dev);
- if (res) {
- debug("%s: Error reading hardware version (err = %d)\n",
- dev->name, res);
- return res;
- }
-
- return 0;
-}
-
-static int board_gazerbeam_get_int(struct udevice *dev, int id, int *val)
-{
- struct board_gazerbeam_priv *priv = dev_get_priv(dev);
-
- switch (id) {
- case BOARD_MULTICHANNEL:
- *val = priv->multichannel;
- break;
- case BOARD_VARIANT:
- *val = priv->variant;
- break;
- case BOARD_HWVERSION:
- *val = priv->hwversion;
- break;
- default:
- debug("%s: Integer value %d unknown\n", dev->name, id);
- return -EINVAL;
- }
-
- return 0;
-}
-
-static const struct udevice_id board_gazerbeam_ids[] = {
- { .compatible = "gdsys,board_gazerbeam" },
- { /* sentinel */ }
-};
-
-static const struct board_ops board_gazerbeam_ops = {
- .detect = board_gazerbeam_detect,
- .get_int = board_gazerbeam_get_int,
-};
-
-static int board_gazerbeam_probe(struct udevice *dev)
-{
- struct board_gazerbeam_priv *priv = dev_get_priv(dev);
- int gpio_num, i;
-
- gpio_num = gpio_request_list_by_name(dev, "reset-gpios",
- priv->reset_gpios,
- ARRAY_SIZE(priv->reset_gpios),
- GPIOD_IS_OUT);
-
- if (gpio_num < 0) {
- debug("%s: Error getting GPIO list 'reset-gpios' (err = %d)\n",
- dev->name, gpio_num);
- return gpio_num;
- }
-
- /* Set startup-finished GPIOs */
- for (i = 0; i < ARRAY_SIZE(priv->reset_gpios); i++) {
- int res = dm_gpio_set_value(&priv->reset_gpios[i], 0);
-
- if (res) {
- debug("%s: Error while setting GPIO %d (err = %d)\n",
- dev->name, i, res);
- return res;
- }
- }
-
- 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,
-};
+++ /dev/null
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * (C) Copyright 2017
- *
- */
-
-enum {
- BOARD_MULTICHANNEL,
- BOARD_VARIANT,
- BOARD_HWVERSION,
-};
-
-enum {
- VAR_CON,
- VAR_CPU,
-};
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2018
- */
-
-#include <common.h>
-#include <dm.h>
-#include <board.h>
-
-#include "sandbox.h"
-
-struct board_sandbox_priv {
- bool called_detect;
- int test_i1;
- int test_i2;
-};
-
-char vacation_spots[][64] = {"R'lyeh", "Dreamlands", "Plateau of Leng",
- "Carcosa", "Yuggoth", "The Nameless City"};
-
-int board_sandbox_detect(struct udevice *dev)
-{
- struct board_sandbox_priv *priv = dev_get_priv(dev);
-
- priv->called_detect = true;
- priv->test_i2 = 100;
-
- return 0;
-}
-
-int board_sandbox_get_bool(struct udevice *dev, int id, bool *val)
-{
- struct board_sandbox_priv *priv = dev_get_priv(dev);
-
- switch (id) {
- case BOOL_CALLED_DETECT:
- /* Checks if the dectect method has been called */
- *val = priv->called_detect;
- return 0;
- }
-
- return -ENOENT;
-}
-
-int board_sandbox_get_int(struct udevice *dev, int id, int *val)
-{
- struct board_sandbox_priv *priv = dev_get_priv(dev);
-
- switch (id) {
- case INT_TEST1:
- *val = priv->test_i1;
- /* Increments with every call */
- priv->test_i1++;
- return 0;
- case INT_TEST2:
- *val = priv->test_i2;
- /* Decrements with every call */
- priv->test_i2--;
- return 0;
- }
-
- return -ENOENT;
-}
-
-int board_sandbox_get_str(struct udevice *dev, int id, size_t size, char *val)
-{
- struct board_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);
-
- switch (id) {
- case STR_VACATIONSPOT:
- /* Picks a vacation spot depending on i1 and i2 */
- snprintf(val, size, vacation_spots[index]);
- return 0;
- }
-
- return -ENOENT;
-}
-
-static const struct udevice_id board_sandbox_ids[] = {
- { .compatible = "sandbox,board_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,
-};
-
-int board_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,
-};
+++ /dev/null
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * (C) Copyright 2018
- */
-
-enum {
- BOOL_CALLED_DETECT,
- INT_TEST1,
- INT_TEST2,
- STR_VACATIONSPOT,
-};
--- /dev/null
+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 SYSINFO
+
+config SPL_SYSINFO
+ depends on SPL_DM
+ bool "Enable board driver support in SPL"
+
+config SYSINFO_GAZERBEAM
+ bool "Enable sysinfo driver for the Gazerbeam board"
+ help
+ Support querying device information for the gdsys Gazerbeam board.
+
+config SYSINFO_SANDBOX
+ bool "Enable sysinfo driver for the Sandbox board"
+ help
+ Support querying device information for the Sandbox boards.
+
+endif
--- /dev/null
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2017
+obj-y += sysinfo-uclass.o
+obj-$(CONFIG_SYSINFO_GAZERBEAM) += gazerbeam.o
+obj-$(CONFIG_SYSINFO_SANDBOX) += sandbox.o
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2017
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <sysinfo.h>
+#include <i2c.h>
+#include <log.h>
+#include <asm/gpio.h>
+
+#include "gazerbeam.h"
+
+/* Sequence number of I2C bus that holds the GPIO expanders */
+static const int I2C_BUS_SEQ_NO = 1;
+
+/* I2C address of SC/MC2 expander */
+static const int MC2_EXPANDER_ADDR = 0x20;
+/* I2C address of MC4 expander */
+static const int MC4_EXPANDER_ADDR = 0x22;
+
+/* Number of the GPIO to read the SC data from */
+static const int SC_GPIO_NO;
+/* Number of the GPIO to read the CON data from */
+static const int CON_GPIO_NO = 1;
+
+/**
+ * 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 sysinfo_gazerbeam_priv {
+ struct gpio_desc reset_gpios[2];
+ struct gpio_desc var_gpios[2];
+ struct gpio_desc ver_gpios[4];
+ int variant;
+ int multichannel;
+ int hwversion;
+};
+
+/**
+ * _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 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_sysinfo_variant_data(struct udevice *dev)
+{
+ struct sysinfo_gazerbeam_priv *priv = dev_get_priv(dev);
+ struct udevice *i2c_bus;
+ struct udevice *dummy;
+ char *listname;
+ int mc4, mc2, sc, mc2_sc, con;
+ int gpio_num;
+ int res;
+
+ res = uclass_get_device_by_seq(UCLASS_I2C, I2C_BUS_SEQ_NO, &i2c_bus);
+ if (res) {
+ debug("%s: Could not get I2C bus %d (err = %d)\n",
+ dev->name, I2C_BUS_SEQ_NO, res);
+ return res;
+ }
+
+ if (!i2c_bus) {
+ debug("%s: Could not get I2C bus %d\n",
+ dev->name, I2C_BUS_SEQ_NO);
+ return -EIO;
+ }
+
+ mc2_sc = !dm_i2c_probe(i2c_bus, MC2_EXPANDER_ADDR, 0, &dummy);
+ mc4 = !dm_i2c_probe(i2c_bus, MC4_EXPANDER_ADDR, 0, &dummy);
+
+ if (mc2_sc && mc4) {
+ debug("%s: Board hardware configuration inconsistent.\n",
+ dev->name);
+ return -EINVAL;
+ }
+
+ listname = mc2_sc ? "var-gpios-mc2" : "var-gpios-mc4";
+
+ gpio_num = gpio_request_list_by_name(dev, listname, priv->var_gpios,
+ ARRAY_SIZE(priv->var_gpios),
+ GPIOD_IS_IN);
+ if (gpio_num < 0) {
+ debug("%s: Requesting gpio list %s failed (err = %d).\n",
+ dev->name, listname, gpio_num);
+ return gpio_num;
+ }
+
+ sc = dm_gpio_get_value(&priv->var_gpios[SC_GPIO_NO]);
+ if (sc < 0) {
+ debug("%s: Error while reading 'sc' GPIO (err = %d)",
+ dev->name, sc);
+ return sc;
+ }
+
+ mc2 = mc2_sc ? (sc ? 0 : 1) : 0;
+
+ if ((sc && mc2) || (sc && mc4) || (!sc && !mc2 && !mc4)) {
+ debug("%s: Board hardware configuration inconsistent.\n",
+ dev->name);
+ return -EINVAL;
+ }
+
+ con = dm_gpio_get_value(&priv->var_gpios[CON_GPIO_NO]);
+ if (con < 0) {
+ debug("%s: Error while reading 'con' GPIO (err = %d)",
+ dev->name, con);
+ return con;
+ }
+
+ priv->variant = con ? VAR_CON : VAR_CPU;
+
+ priv->multichannel = mc4 ? 4 : (mc2 ? 2 : (sc ? 1 : 0));
+
+ return 0;
+}
+
+/**
+ * _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 sysinfo (from 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_hwversion(struct udevice *dev)
+{
+ struct sysinfo_gazerbeam_priv *priv = dev_get_priv(dev);
+ int res;
+
+ res = gpio_request_list_by_name(dev, "ver-gpios", priv->ver_gpios,
+ ARRAY_SIZE(priv->ver_gpios),
+ GPIOD_IS_IN);
+ if (res < 0) {
+ debug("%s: Error getting GPIO list 'ver-gpios' (err = %d)\n",
+ dev->name, res);
+ return -ENODEV;
+ }
+
+ res = dm_gpio_get_values_as_int(priv->ver_gpios,
+ ARRAY_SIZE(priv->ver_gpios));
+ if (res < 0) {
+ debug("%s: Error reading HW version from expander (err = %d)\n",
+ dev->name, res);
+ return res;
+ }
+
+ priv->hwversion = res;
+
+ res = gpio_free_list(dev, priv->ver_gpios, ARRAY_SIZE(priv->ver_gpios));
+ if (res < 0) {
+ debug("%s: Error freeing HW version GPIO list (err = %d)\n",
+ dev->name, res);
+ return res;
+ }
+
+ return 0;
+}
+
+static int sysinfo_gazerbeam_detect(struct udevice *dev)
+{
+ int res;
+
+ res = _read_sysinfo_variant_data(dev);
+ if (res) {
+ debug("%s: Error reading multichannel variant (err = %d)\n",
+ dev->name, res);
+ return res;
+ }
+
+ res = _read_hwversion(dev);
+ if (res) {
+ debug("%s: Error reading hardware version (err = %d)\n",
+ dev->name, res);
+ return res;
+ }
+
+ return 0;
+}
+
+static int sysinfo_gazerbeam_get_int(struct udevice *dev, int id, int *val)
+{
+ struct sysinfo_gazerbeam_priv *priv = dev_get_priv(dev);
+
+ switch (id) {
+ case BOARD_MULTICHANNEL:
+ *val = priv->multichannel;
+ break;
+ case BOARD_VARIANT:
+ *val = priv->variant;
+ break;
+ case BOARD_HWVERSION:
+ *val = priv->hwversion;
+ break;
+ default:
+ debug("%s: Integer value %d unknown\n", dev->name, id);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static const struct udevice_id sysinfo_gazerbeam_ids[] = {
+ { .compatible = "gdsys,sysinfo-gazerbeam" },
+ { /* sentinel */ }
+};
+
+static const struct sysinfo_ops sysinfo_gazerbeam_ops = {
+ .detect = sysinfo_gazerbeam_detect,
+ .get_int = sysinfo_gazerbeam_get_int,
+};
+
+static int sysinfo_gazerbeam_probe(struct udevice *dev)
+{
+ struct sysinfo_gazerbeam_priv *priv = dev_get_priv(dev);
+ int gpio_num, i;
+
+ gpio_num = gpio_request_list_by_name(dev, "reset-gpios",
+ priv->reset_gpios,
+ ARRAY_SIZE(priv->reset_gpios),
+ GPIOD_IS_OUT);
+
+ if (gpio_num < 0) {
+ debug("%s: Error getting GPIO list 'reset-gpios' (err = %d)\n",
+ dev->name, gpio_num);
+ return gpio_num;
+ }
+
+ /* Set startup-finished GPIOs */
+ for (i = 0; i < ARRAY_SIZE(priv->reset_gpios); i++) {
+ int res = dm_gpio_set_value(&priv->reset_gpios[i], 0);
+
+ if (res) {
+ debug("%s: Error while setting GPIO %d (err = %d)\n",
+ dev->name, i, res);
+ return res;
+ }
+ }
+
+ return 0;
+}
+
+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,
+};
--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2017
+ *
+ */
+
+enum {
+ BOARD_MULTICHANNEL,
+ BOARD_VARIANT,
+ BOARD_HWVERSION,
+};
+
+enum {
+ VAR_CON,
+ VAR_CPU,
+};
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2018
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <sysinfo.h>
+
+#include "sandbox.h"
+
+struct sysinfo_sandbox_priv {
+ bool called_detect;
+ int test_i1;
+ int test_i2;
+};
+
+char vacation_spots[][64] = {"R'lyeh", "Dreamlands", "Plateau of Leng",
+ "Carcosa", "Yuggoth", "The Nameless City"};
+
+int sysinfo_sandbox_detect(struct udevice *dev)
+{
+ struct sysinfo_sandbox_priv *priv = dev_get_priv(dev);
+
+ priv->called_detect = true;
+ priv->test_i2 = 100;
+
+ return 0;
+}
+
+int sysinfo_sandbox_get_bool(struct udevice *dev, int id, bool *val)
+{
+ struct sysinfo_sandbox_priv *priv = dev_get_priv(dev);
+
+ switch (id) {
+ case BOOL_CALLED_DETECT:
+ /* Checks if the dectect method has been called */
+ *val = priv->called_detect;
+ return 0;
+ }
+
+ return -ENOENT;
+}
+
+int sysinfo_sandbox_get_int(struct udevice *dev, int id, int *val)
+{
+ struct sysinfo_sandbox_priv *priv = dev_get_priv(dev);
+
+ switch (id) {
+ case INT_TEST1:
+ *val = priv->test_i1;
+ /* Increments with every call */
+ priv->test_i1++;
+ return 0;
+ case INT_TEST2:
+ *val = priv->test_i2;
+ /* Decrements with every call */
+ priv->test_i2--;
+ return 0;
+ }
+
+ return -ENOENT;
+}
+
+int sysinfo_sandbox_get_str(struct udevice *dev, int id, size_t size, char *val)
+{
+ 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);
+
+ switch (id) {
+ case STR_VACATIONSPOT:
+ /* Picks a vacation spot depending on i1 and i2 */
+ snprintf(val, size, vacation_spots[index]);
+ return 0;
+ }
+
+ return -ENOENT;
+}
+
+static const struct udevice_id sysinfo_sandbox_ids[] = {
+ { .compatible = "sandbox,sysinfo-sandbox" },
+ { /* sentinel */ }
+};
+
+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 sysinfo_sandbox_probe(struct udevice *dev)
+{
+ return 0;
+}
+
+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,
+};
--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2018
+ */
+
+enum {
+ BOOL_CALLED_DETECT,
+ INT_TEST1,
+ INT_TEST2,
+ STR_VACATIONSPOT,
+};
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2017
+ */
+
+#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,
+};
*/
#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>
{
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;
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)",
+++ /dev/null
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * (C) Copyright 2017
- */
-
-/*
- * This uclass encapsulates hardware methods to gather information about a
- * board 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
- * call
- *
- * ret = board_detect(dev);
- * if (ret) {
- * debug("board device not found.");
- * return ret;
- * }
- *
- * ret = board_get_int(dev, ID_SERIAL_NUMBER, &serial);
- * if (ret) {
- * debug("Error when reading serial number from device.");
- * return ret;
- * }
- *
- * to read the serial number.
- */
-
-#if CONFIG_IS_ENABLED(BOARD)
-struct board_ops {
- /**
- * detect() - Run the hardware info detection procedure for this
- * device.
- * @dev: The device containing the information
- *
- * This operation might take a long time (e.g. read from EEPROM,
- * check the presence of a device on a bus etc.), hence this is not
- * done in the probe() method, but later during operation in this
- * dedicated method.
- *
- * Return: 0 if OK, -ve on error.
- */
- int (*detect)(struct udevice *dev);
-
- /**
- * get_bool() - Read a specific bool data value that describes the
- * hardware setup.
- * @dev: The board 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 (*get_bool)(struct udevice *dev, int id, bool *val);
-
- /**
- * get_int() - Read a specific int data value that describes the
- * hardware setup.
- * @dev: The board 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 (*get_int)(struct udevice *dev, int id, int *val);
-
- /**
- * get_str() - Read a specific string data value that describes the
- * hardware setup.
- * @dev: The board 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 (*get_str)(struct udevice *dev, int id, size_t size, char *val);
-
- /**
- * 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.
- * @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
- * @strp: A pointer to string. Untouched if the function fails
- *
- * Return: 0 if OK, -ENOENT if no loadable is available else -ve on
- * error.
- */
- int (*get_fit_loadable)(struct udevice *dev, int index,
- const char *type, const char **strp);
-};
-
-#define board_get_ops(dev) ((struct board_ops *)(dev)->driver->ops)
-
-/**
- * board_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);
-
-/**
- * board_get_bool() - Read a specific bool data value that describes the
- * hardware setup.
- * @dev: The board 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);
-
-/**
- * board_get_int() - Read a specific int data value that describes the
- * hardware setup.
- * @dev: The board 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);
-
-/**
- * board_get_str() - Read a specific string data value that describes the
- * hardware setup.
- * @dev: The board 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);
-
-/**
- * board_get() - Return the board device for the board in question.
- * @devp: Pointer to structure to receive the board device.
- *
- * Since there can only be at most one board instance, the API can supply a
- * function that returns the unique device. This is especially useful for use
- * in board files.
- *
- * Return: 0 if OK, -ve on error.
- */
-int board_get(struct udevice **devp);
-
-/**
- * board_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.
- * @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
- * @strp: A pointer to string. Untouched if the function fails
- *
- *
- * 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);
-
-#else
-
-static inline int board_detect(struct udevice *dev)
-{
- return -ENOSYS;
-}
-
-static inline int board_get_bool(struct udevice *dev, int id, bool *val)
-{
- return -ENOSYS;
-}
-
-static inline int board_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)
-{
- return -ENOSYS;
-}
-
-static inline int board_get(struct udevice **devp)
-{
- return -ENOSYS;
-}
-
-static inline int board_get_fit_loadable(struct udevice *dev, int index,
- const char *type, const char **strp)
-{
- return -ENOSYS;
-}
-
-#endif
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 */
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 */
--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2017
+ */
+
+/*
+ * This uclass encapsulates hardware methods to gather information about a
+ * 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 sysinfo had a read-only serial number flash IC, we could
+ * call
+ *
+ * ret = sysinfo_detect(dev);
+ * if (ret) {
+ * debug("sysinfo device not found.");
+ * return ret;
+ * }
+ *
+ * ret = sysinfo_get_int(dev, ID_SERIAL_NUMBER, &serial);
+ * if (ret) {
+ * debug("Error when reading serial number from device.");
+ * return ret;
+ * }
+ *
+ * to read the serial number.
+ */
+
+#if CONFIG_IS_ENABLED(SYSINFO)
+struct sysinfo_ops {
+ /**
+ * detect() - Run the hardware info detection procedure for this
+ * device.
+ * @dev: The device containing the information
+ *
+ * This operation might take a long time (e.g. read from EEPROM,
+ * check the presence of a device on a bus etc.), hence this is not
+ * done in the probe() method, but later during operation in this
+ * dedicated method.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+ int (*detect)(struct udevice *dev);
+
+ /**
+ * get_bool() - Read a specific bool data value that describes the
+ * hardware setup.
+ * @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 (*get_bool)(struct udevice *dev, int id, bool *val);
+
+ /**
+ * get_int() - Read a specific int data value that describes the
+ * hardware setup.
+ * @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 (*get_int)(struct udevice *dev, int id, int *val);
+
+ /**
+ * get_str() - Read a specific string data value that describes the
+ * hardware setup.
+ * @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 (*get_str)(struct udevice *dev, int id, size_t size, char *val);
+
+ /**
+ * 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 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
+ * @strp: A pointer to string. Untouched if the function fails
+ *
+ * Return: 0 if OK, -ENOENT if no loadable is available else -ve on
+ * error.
+ */
+ int (*get_fit_loadable)(struct udevice *dev, int index,
+ const char *type, const char **strp);
+};
+
+#define sysinfo_get_ops(dev) ((struct sysinfo_ops *)(dev)->driver->ops)
+
+/**
+ * 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 sysinfo_detect(struct udevice *dev);
+
+/**
+ * sysinfo_get_bool() - Read a specific bool data value that describes the
+ * hardware setup.
+ * @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 sysinfo_get_bool(struct udevice *dev, int id, bool *val);
+
+/**
+ * sysinfo_get_int() - Read a specific int data value that describes the
+ * hardware setup.
+ * @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 sysinfo_get_int(struct udevice *dev, int id, int *val);
+
+/**
+ * sysinfo_get_str() - Read a specific string data value that describes the
+ * hardware setup.
+ * @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 sysinfo_get_str(struct udevice *dev, int id, size_t size, char *val);
+
+/**
+ * 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 sysinfo instance, the API can supply a
+ * function that returns the unique device. This is especially useful for use
+ * in sysinfo files.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+int sysinfo_get(struct udevice **devp);
+
+/**
+ * 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 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
+ * @strp: A pointer to string. Untouched if the function fails
+ *
+ *
+ * Return: 0 if OK, -ENOENT if no loadable is available else -ve on
+ * error.
+ */
+int sysinfo_get_fit_loadable(struct udevice *dev, int index, const char *type,
+ const char **strp);
+
+#else
+
+static inline int sysinfo_detect(struct udevice *dev)
+{
+ return -ENOSYS;
+}
+
+static inline int sysinfo_get_bool(struct udevice *dev, int id, bool *val)
+{
+ return -ENOSYS;
+}
+
+static inline int sysinfo_get_int(struct udevice *dev, int id, int *val)
+{
+ return -ENOSYS;
+}
+
+static inline int sysinfo_get_str(struct udevice *dev, int id, size_t size,
+ char *val)
+{
+ return -ENOSYS;
+}
+
+static inline int sysinfo_get(struct udevice **devp)
+{
+ return -ENOSYS;
+}
+
+static inline int sysinfo_get_fit_loadable(struct udevice *dev, int index,
+ const char *type, const char **strp)
+{
+ return -ENOSYS;
+}
+
+#endif
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
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
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2018
- */
-
-#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);
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2018
+ */
+
+#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);