From ed0f868d501ee2bc31391210c214e9d07ae0874b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 5 Oct 2020 05:27:00 -0600 Subject: cros_ec: Fix up driver names to avoid dtoc warnings Fix the dtoc warning in these file by using a driver name that matches the compatible string. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- drivers/misc/cros_ec_i2c.c | 4 ++-- drivers/misc/cros_ec_lpc.c | 4 ++-- drivers/misc/cros_ec_spi.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/misc/cros_ec_i2c.c b/drivers/misc/cros_ec_i2c.c index c00f5f764a0..664bd2b9385 100644 --- a/drivers/misc/cros_ec_i2c.c +++ b/drivers/misc/cros_ec_i2c.c @@ -231,8 +231,8 @@ static const struct udevice_id cros_ec_ids[] = { { } }; -U_BOOT_DRIVER(cros_ec_i2c) = { - .name = "cros_ec_i2c", +U_BOOT_DRIVER(google_cros_ec_i2c) = { + .name = "google_cros_ec_i2c", .id = UCLASS_CROS_EC, .of_match = cros_ec_ids, .probe = cros_ec_probe, diff --git a/drivers/misc/cros_ec_lpc.c b/drivers/misc/cros_ec_lpc.c index 4ad6c8ca66d..63702f90fbc 100644 --- a/drivers/misc/cros_ec_lpc.c +++ b/drivers/misc/cros_ec_lpc.c @@ -243,8 +243,8 @@ static const struct udevice_id cros_ec_ids[] = { { } }; -U_BOOT_DRIVER(cros_ec_lpc) = { - .name = "cros_ec_lpc", +U_BOOT_DRIVER(google_cros_ec_lpc) = { + .name = "google_cros_ec_lpc", .id = UCLASS_CROS_EC, .of_match = cros_ec_ids, .probe = cros_ec_probe, diff --git a/drivers/misc/cros_ec_spi.c b/drivers/misc/cros_ec_spi.c index 153f971bdeb..bbc96301aeb 100644 --- a/drivers/misc/cros_ec_spi.c +++ b/drivers/misc/cros_ec_spi.c @@ -184,8 +184,8 @@ static const struct udevice_id cros_ec_ids[] = { { } }; -U_BOOT_DRIVER(cros_ec_spi) = { - .name = "cros_ec_spi", +U_BOOT_DRIVER(google_cros_ec_spi) = { + .name = "google_cros_ec_spi", .id = UCLASS_CROS_EC, .of_match = cros_ec_ids, .probe = cros_ec_probe, -- cgit v1.2.3 From 9d20db0483d54b507472fc33ee0c8a71d6c71c85 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 5 Oct 2020 05:27:01 -0600 Subject: x86: Fix up driver names to avoid dtoc warnings At present there are a lot of dtoc warnings reported when building chromebook_coral, of the form: WARNING: the driver intel_apl_lpc was not found in the driver list Correct these by using driver names that matches their compatible string. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- drivers/gpio/intel_gpio.c | 4 ++-- drivers/pinctrl/intel/pinctrl_apl.c | 2 +- drivers/rtc/mc146818.c | 4 ++-- drivers/sysreset/sysreset_x86.c | 4 ++-- drivers/timer/tsc_timer.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/gpio/intel_gpio.c b/drivers/gpio/intel_gpio.c index 6a3a8c4cfaa..c3b67f24d8f 100644 --- a/drivers/gpio/intel_gpio.c +++ b/drivers/gpio/intel_gpio.c @@ -193,8 +193,8 @@ static const struct udevice_id intel_intel_gpio_ids[] = { { } }; -U_BOOT_DRIVER(gpio_intel) = { - .name = "gpio_intel", +U_BOOT_DRIVER(intel_gpio) = { + .name = "intel_gpio", .id = UCLASS_GPIO, .of_match = intel_intel_gpio_ids, .ops = &gpio_intel_ops, diff --git a/drivers/pinctrl/intel/pinctrl_apl.c b/drivers/pinctrl/intel/pinctrl_apl.c index 7624a9974fe..727bacfd043 100644 --- a/drivers/pinctrl/intel/pinctrl_apl.c +++ b/drivers/pinctrl/intel/pinctrl_apl.c @@ -174,7 +174,7 @@ static const struct udevice_id apl_gpio_ids[] = { { } }; -U_BOOT_DRIVER(apl_pinctrl_drv) = { +U_BOOT_DRIVER(intel_apl_pinctrl) = { .name = "intel_apl_pinctrl", .id = UCLASS_PINCTRL, .of_match = apl_gpio_ids, diff --git a/drivers/rtc/mc146818.c b/drivers/rtc/mc146818.c index b98c39d8219..71f96e282e8 100644 --- a/drivers/rtc/mc146818.c +++ b/drivers/rtc/mc146818.c @@ -246,8 +246,8 @@ static const struct udevice_id rtc_mc146818_ids[] = { { } }; -U_BOOT_DRIVER(rtc_mc146818) = { - .name = "rtc_mc146818", +U_BOOT_DRIVER(motorola_mc146818) = { + .name = "motorola_mc146818", .id = UCLASS_RTC, .of_match = rtc_mc146818_ids, .probe = rtc_mc146818_probe, diff --git a/drivers/sysreset/sysreset_x86.c b/drivers/sysreset/sysreset_x86.c index bc911435602..7682ffbd294 100644 --- a/drivers/sysreset/sysreset_x86.c +++ b/drivers/sysreset/sysreset_x86.c @@ -148,8 +148,8 @@ static struct sysreset_ops x86_sysreset_ops = { .get_last = x86_sysreset_get_last, }; -U_BOOT_DRIVER(x86_sysreset) = { - .name = "x86-sysreset", +U_BOOT_DRIVER(x86_reset) = { + .name = "x86_reset", .id = UCLASS_SYSRESET, .of_match = x86_sysreset_ids, .ops = &x86_sysreset_ops, diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c index abc0a1da05e..e3677704b33 100644 --- a/drivers/timer/tsc_timer.c +++ b/drivers/timer/tsc_timer.c @@ -482,8 +482,8 @@ static const struct udevice_id tsc_timer_ids[] = { { } }; -U_BOOT_DRIVER(tsc_timer) = { - .name = "tsc_timer", +U_BOOT_DRIVER(x86_tsc_timer) = { + .name = "x86_tsc_timer", .id = UCLASS_TIMER, .of_match = tsc_timer_ids, .probe = tsc_timer_probe, -- cgit v1.2.3 From dd30c5bb574aba55e99284dbdfe0d6033bf44d7f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 4 Nov 2020 09:57:29 -0700 Subject: x86: sound: Correct error handling A few functions have changed to return pin numbers or I2C addresses. The error checking for some of the callers is therefore wrong. Fix them. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- drivers/sound/da7219.c | 4 ++-- drivers/sound/max98357a.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/sound/da7219.c b/drivers/sound/da7219.c index 6bc1ad0036e..8d674bcb4fa 100644 --- a/drivers/sound/da7219.c +++ b/drivers/sound/da7219.c @@ -54,13 +54,13 @@ static int da7219_acpi_fill_ssdt(const struct udevice *dev, acpigen_write_name(ctx, "_CRS"); acpigen_write_resourcetemplate_header(ctx); ret = acpi_device_write_i2c_dev(ctx, dev); - if (ret) + if (ret < 0) return log_msg_ret("i2c", ret); /* Use either Interrupt() or GpioInt() */ ret = acpi_device_write_interrupt_or_gpio(ctx, (struct udevice *)dev, "req-gpios"); - if (ret) + if (ret < 0) return log_msg_ret("irq_gpio", ret); acpigen_write_resourcetemplate_footer(ctx); diff --git a/drivers/sound/max98357a.c b/drivers/sound/max98357a.c index 827262d235c..b3d27a3616e 100644 --- a/drivers/sound/max98357a.c +++ b/drivers/sound/max98357a.c @@ -69,7 +69,7 @@ static int max98357a_acpi_fill_ssdt(const struct udevice *dev, acpigen_write_name(ctx, "_CRS"); acpigen_write_resourcetemplate_header(ctx); ret = acpi_device_write_gpio_desc(ctx, &priv->sdmode_gpio); - if (ret) + if (ret < 0) return log_msg_ret("gpio", ret); acpigen_write_resourcetemplate_footer(ctx); -- cgit v1.2.3 From 18434aec1b69d8490cb23ef35b2f39cf1784d1d0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 4 Nov 2020 09:57:33 -0700 Subject: acpi: Don't reset the tables with every new generation At present if SSDT and DSDT code is created, only the latter is retained for examination by the 'acpi items' command. Fix this by only resetting the list when explicitly requested. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- drivers/core/acpi.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index 7fe93992b5f..63a791f335e 100644 --- a/drivers/core/acpi.c +++ b/drivers/core/acpi.c @@ -268,8 +268,7 @@ int acpi_recurse_method(struct acpi_ctx *ctx, struct udevice *parent, if (func) { void *start = ctx->current; - log_debug("\n"); - log_debug("- %s %p\n", parent->name, func); + log_debug("- method %d, %s %p\n", method, parent->name, func); ret = device_ofdata_to_platdata(parent); if (ret) return log_msg_ret("ofdata", ret); @@ -299,7 +298,6 @@ int acpi_fill_ssdt(struct acpi_ctx *ctx) int ret; log_debug("Writing SSDT tables\n"); - item_count = 0; ret = acpi_recurse_method(ctx, dm_root(), METHOD_FILL_SSDT, TYPE_SSDT); log_debug("Writing SSDT finished, err=%d\n", ret); ret = sort_acpi_item_type(ctx, start, TYPE_SSDT); @@ -315,7 +313,6 @@ int acpi_inject_dsdt(struct acpi_ctx *ctx) int ret; log_debug("Writing DSDT tables\n"); - item_count = 0; ret = acpi_recurse_method(ctx, dm_root(), METHOD_INJECT_DSDT, TYPE_DSDT); log_debug("Writing DSDT finished, err=%d\n", ret); @@ -326,6 +323,11 @@ int acpi_inject_dsdt(struct acpi_ctx *ctx) return ret; } +void acpi_reset_items(void) +{ + item_count = 0; +} + int acpi_write_dev_tables(struct acpi_ctx *ctx) { int ret; -- cgit v1.2.3 From dd27cd6dab40765797962df500bda8eab6e665f5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 4 Nov 2020 09:57:42 -0700 Subject: x86: pinctrl: Silence the warning when a pin is not found This does not necessarily indicate a problem, since some pins are optional. Let the caller show an error if necessary. Reviewed-by: Bin Meng Signed-off-by: Simon Glass --- drivers/pinctrl/intel/pinctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pinctrl/intel/pinctrl.c b/drivers/pinctrl/intel/pinctrl.c index ba21c9dcc2e..e3d24646344 100644 --- a/drivers/pinctrl/intel/pinctrl.c +++ b/drivers/pinctrl/intel/pinctrl.c @@ -154,7 +154,7 @@ static int pinctrl_get_device(uint pad, struct udevice **devp) return 0; } } - printf("pad %d not found\n", pad); + log_debug("pad %d not found\n", pad); return -ENOTBLK; } -- cgit v1.2.3 From 3a8ee3df836614b68881f5b84d3197305ee1b08e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 06:32:05 -0700 Subject: 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 Reviewed-by: Bin Meng --- drivers/Kconfig | 4 +- drivers/Makefile | 2 +- drivers/board/Kconfig | 25 ---- drivers/board/Makefile | 7 -- drivers/board/board-uclass.c | 71 ----------- drivers/board/gazerbeam.c | 265 --------------------------------------- drivers/board/gazerbeam.h | 17 --- drivers/board/sandbox.c | 107 ---------------- drivers/board/sandbox.h | 12 -- drivers/sysinfo/Kconfig | 25 ++++ drivers/sysinfo/Makefile | 7 ++ drivers/sysinfo/gazerbeam.c | 265 +++++++++++++++++++++++++++++++++++++++ drivers/sysinfo/gazerbeam.h | 17 +++ drivers/sysinfo/sandbox.c | 107 ++++++++++++++++ drivers/sysinfo/sandbox.h | 12 ++ drivers/sysinfo/sysinfo-uclass.c | 71 +++++++++++ drivers/timer/mpc83xx_timer.c | 10 +- 17 files changed, 512 insertions(+), 512 deletions(-) delete mode 100644 drivers/board/Kconfig delete mode 100644 drivers/board/Makefile delete mode 100644 drivers/board/board-uclass.c delete mode 100644 drivers/board/gazerbeam.c delete mode 100644 drivers/board/gazerbeam.h delete mode 100644 drivers/board/sandbox.c delete mode 100644 drivers/board/sandbox.h create mode 100644 drivers/sysinfo/Kconfig create mode 100644 drivers/sysinfo/Makefile create mode 100644 drivers/sysinfo/gazerbeam.c create mode 100644 drivers/sysinfo/gazerbeam.h create mode 100644 drivers/sysinfo/sandbox.c create mode 100644 drivers/sysinfo/sandbox.h create mode 100644 drivers/sysinfo/sysinfo-uclass.c (limited to 'drivers') diff --git a/drivers/Kconfig b/drivers/Kconfig index ed8a39c994d..b1ada1cb7f8 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" @@ -114,6 +112,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 33f1d536cdd..e371bc32bb8 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -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/ diff --git a/drivers/board/Kconfig b/drivers/board/Kconfig deleted file mode 100644 index 254f657049d..00000000000 --- a/drivers/board/Kconfig +++ /dev/null @@ -1,25 +0,0 @@ -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 diff --git a/drivers/board/Makefile b/drivers/board/Makefile deleted file mode 100644 index cc16361755a..00000000000 --- a/drivers/board/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0+ -# -# (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 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@gdsys.cc - */ - -#include -#include -#include - -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/gazerbeam.c b/drivers/board/gazerbeam.c deleted file mode 100644 index ed50fc530cb..00000000000 --- a/drivers/board/gazerbeam.c +++ /dev/null @@ -1,265 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * (C) Copyright 2017 - * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc - */ - -#include -#include -#include -#include -#include -#include - -#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, -}; diff --git a/drivers/board/gazerbeam.h b/drivers/board/gazerbeam.h deleted file mode 100644 index 171729d2031..00000000000 --- a/drivers/board/gazerbeam.h +++ /dev/null @@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * (C) Copyright 2017 - * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc - * - */ - -enum { - BOARD_MULTICHANNEL, - BOARD_VARIANT, - BOARD_HWVERSION, -}; - -enum { - VAR_CON, - VAR_CPU, -}; diff --git a/drivers/board/sandbox.c b/drivers/board/sandbox.c deleted file mode 100644 index 50621e47a4f..00000000000 --- a/drivers/board/sandbox.c +++ /dev/null @@ -1,107 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * (C) Copyright 2018 - * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc - */ - -#include -#include -#include - -#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, -}; diff --git a/drivers/board/sandbox.h b/drivers/board/sandbox.h deleted file mode 100644 index 2cff494f56e..00000000000 --- a/drivers/board/sandbox.h +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * (C) Copyright 2018 - * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc - */ - -enum { - BOOL_CALLED_DETECT, - INT_TEST1, - INT_TEST2, - STR_VACATIONSPOT, -}; diff --git a/drivers/sysinfo/Kconfig b/drivers/sysinfo/Kconfig new file mode 100644 index 00000000000..39141500a05 --- /dev/null +++ b/drivers/sysinfo/Kconfig @@ -0,0 +1,25 @@ +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 diff --git a/drivers/sysinfo/Makefile b/drivers/sysinfo/Makefile new file mode 100644 index 00000000000..aecf0b0d47c --- /dev/null +++ b/drivers/sysinfo/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# (C) Copyright 2017 +# Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc +obj-y += sysinfo-uclass.o +obj-$(CONFIG_SYSINFO_GAZERBEAM) += gazerbeam.o +obj-$(CONFIG_SYSINFO_SANDBOX) += sandbox.o diff --git a/drivers/sysinfo/gazerbeam.c b/drivers/sysinfo/gazerbeam.c new file mode 100644 index 00000000000..9e7a4966554 --- /dev/null +++ b/drivers/sysinfo/gazerbeam.c @@ -0,0 +1,265 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2017 + * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc + */ + +#include +#include +#include +#include +#include +#include + +#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, +}; diff --git a/drivers/sysinfo/gazerbeam.h b/drivers/sysinfo/gazerbeam.h new file mode 100644 index 00000000000..171729d2031 --- /dev/null +++ b/drivers/sysinfo/gazerbeam.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2017 + * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc + * + */ + +enum { + BOARD_MULTICHANNEL, + BOARD_VARIANT, + BOARD_HWVERSION, +}; + +enum { + VAR_CON, + VAR_CPU, +}; diff --git a/drivers/sysinfo/sandbox.c b/drivers/sysinfo/sandbox.c new file mode 100644 index 00000000000..62a1cb4ac65 --- /dev/null +++ b/drivers/sysinfo/sandbox.c @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2018 + * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc + */ + +#include +#include +#include + +#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, +}; diff --git a/drivers/sysinfo/sandbox.h b/drivers/sysinfo/sandbox.h new file mode 100644 index 00000000000..2cff494f56e --- /dev/null +++ b/drivers/sysinfo/sandbox.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2018 + * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc + */ + +enum { + BOOL_CALLED_DETECT, + INT_TEST1, + INT_TEST2, + STR_VACATIONSPOT, +}; 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@gdsys.cc + */ + +#include +#include +#include + +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 ba7704225a3..6139252a73c 100644 --- a/drivers/timer/mpc83xx_timer.c +++ b/drivers/timer/mpc83xx_timer.c @@ -5,12 +5,12 @@ */ #include -#include #include #include #include #include #include +#include #include #include #include @@ -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)", -- cgit v1.2.3 From 44c74bdd5828c885b97a1518b9d85239a1020c6c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 06:32:11 -0700 Subject: sysinfo: Provide a default driver to set SMBIOS values Some boards want to specify the manufacturer or product name but do not need to have their own sysinfo driver. Add a default driver which provides a way to specify this SMBIOS information in the devicetree, without needing any board-specific functionality. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- drivers/sysinfo/Kconfig | 8 ++++++++ drivers/sysinfo/Makefile | 1 + drivers/sysinfo/smbios.c | 24 ++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 drivers/sysinfo/smbios.c (limited to 'drivers') diff --git a/drivers/sysinfo/Kconfig b/drivers/sysinfo/Kconfig index 39141500a05..85c1e81e411 100644 --- a/drivers/sysinfo/Kconfig +++ b/drivers/sysinfo/Kconfig @@ -22,4 +22,12 @@ config SYSINFO_SANDBOX help Support querying device information for the Sandbox boards. +config SYSINFO_SMBIOS + bool "Provide a default sysinfo driver for SMBIOS information" + help + Some boards want to specify the manufacturer or product name but do + not need to have their own sysinfo driver. This includes a default + one which provides a way to specify this SMBIOS information in the + devicetree, without needing any board-specific functionality. + endif diff --git a/drivers/sysinfo/Makefile b/drivers/sysinfo/Makefile index aecf0b0d47c..6d04fcba1d1 100644 --- a/drivers/sysinfo/Makefile +++ b/drivers/sysinfo/Makefile @@ -5,3 +5,4 @@ obj-y += sysinfo-uclass.o obj-$(CONFIG_SYSINFO_GAZERBEAM) += gazerbeam.o obj-$(CONFIG_SYSINFO_SANDBOX) += sandbox.o +obj-$(CONFIG_SYSINFO_SMBIOS) += smbios.o diff --git a/drivers/sysinfo/smbios.c b/drivers/sysinfo/smbios.c new file mode 100644 index 00000000000..80ebd1921d8 --- /dev/null +++ b/drivers/sysinfo/smbios.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2020 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include + +static const struct udevice_id sysinfo_smbios_ids[] = { + { .compatible = "u-boot,sysinfo-smbios" }, + { /* sentinel */ } +}; + +static const struct sysinfo_ops sysinfo_smbios_ops = { +}; + +U_BOOT_DRIVER(sysinfo_smbios) = { + .name = "sysinfo_smbios", + .id = UCLASS_SYSINFO, + .of_match = sysinfo_smbios_ids, + .ops = &sysinfo_smbios_ops, +}; -- cgit v1.2.3