board: Rename uclass to sysinfo

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.

Note: Due to the patch delta caused by the symbol renames, this patch
shows some renamed files as being deleted in one place and created in
another.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
Simon Glass
2020-11-05 06:32:05 -07:00
committed by Bin Meng
parent a40f890bdb
commit 3a8ee3df83
29 changed files with 314 additions and 308 deletions

View File

@@ -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"
@@ -114,6 +112,8 @@ source "drivers/spi/Kconfig"
source "drivers/spmi/Kconfig"
source "drivers/sysinfo/Kconfig"
source "drivers/sysreset/Kconfig"
source "drivers/tee/Kconfig"

View File

@@ -27,9 +27,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/

View File

@@ -1,71 +0,0 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2017
* Mario Six, Guntermann & Drunck GmbH, mario.six@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,
};

View File

@@ -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.

View File

@@ -2,6 +2,6 @@
#
# (C) Copyright 2017
# Mario Six, Guntermann & Drunck GmbH, mario.six@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

View File

@@ -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,
};

View File

@@ -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,
};

View File

@@ -0,0 +1,71 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2017
* Mario Six, Guntermann & Drunck GmbH, mario.six@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,
};

View File

@@ -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)",