mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-20 20:04:46 +00:00
treewide: fdt: Move fdt_get_config_... to ofnode_conf_read...
The current API is outdated as it requires a devicetree pointer. Move these functions to use the ofnode API and update this globally. Add some tests while we are here. Correct the call in exynos_dsim_config_parse_dt() which is obviously wrong. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
bb38d77ca7
commit
7de8bd03c3
20 changed files with 124 additions and 116 deletions
|
@ -15,6 +15,7 @@
|
||||||
#include <asm/arch-rockchip/clock.h>
|
#include <asm/arch-rockchip/clock.h>
|
||||||
#include <asm/arch-rockchip/grf_rk3188.h>
|
#include <asm/arch-rockchip/grf_rk3188.h>
|
||||||
#include <asm/arch-rockchip/hardware.h>
|
#include <asm/arch-rockchip/hardware.h>
|
||||||
|
#include <dm/ofnode.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
|
|
||||||
#define GRF_BASE 0x20008000
|
#define GRF_BASE 0x20008000
|
||||||
|
@ -107,7 +108,6 @@ int rk_board_late_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SPL_BUILD
|
#ifdef CONFIG_SPL_BUILD
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
|
||||||
static int setup_led(void)
|
static int setup_led(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_SPL_LED
|
#ifdef CONFIG_SPL_LED
|
||||||
|
@ -115,7 +115,7 @@ static int setup_led(void)
|
||||||
char *led_name;
|
char *led_name;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
led_name = fdtdec_get_config_string(gd->fdt_blob, "u-boot,boot-led");
|
led_name = ofnode_conf_read_str("u-boot,boot-led");
|
||||||
if (!led_name)
|
if (!led_name)
|
||||||
return 0;
|
return 0;
|
||||||
ret = led_get_by_label(led_name, &dev);
|
ret = led_get_by_label(led_name, &dev);
|
||||||
|
|
|
@ -62,6 +62,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
config {
|
config {
|
||||||
|
testing-bool;
|
||||||
|
testing-int = <123>;
|
||||||
|
testing-str = "testing";
|
||||||
environment {
|
environment {
|
||||||
from_fdt = "yes";
|
from_fdt = "yes";
|
||||||
fdt_env_path = "";
|
fdt_env_path = "";
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
#include <asm/mtrr.h>
|
#include <asm/mtrr.h>
|
||||||
#include <asm/cb_sysinfo.h>
|
#include <asm/cb_sysinfo.h>
|
||||||
#include <asm/arch/timestamp.h>
|
#include <asm/arch/timestamp.h>
|
||||||
|
#include <dm/ofnode.h>
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
|
||||||
|
|
||||||
int arch_cpu_init(void)
|
int arch_cpu_init(void)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +64,7 @@ static void board_final_init(void)
|
||||||
mtrr_close(&state, true);
|
mtrr_close(&state, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fdtdec_get_config_bool(gd->fdt_blob, "u-boot,no-apm-finalize")) {
|
if (!ofnode_conf_read_bool("u-boot,no-apm-finalize")) {
|
||||||
/*
|
/*
|
||||||
* Issue SMI to coreboot to lock down ME and registers
|
* Issue SMI to coreboot to lock down ME and registers
|
||||||
* when allowed via device tree
|
* when allowed via device tree
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <usb.h>
|
#include <usb.h>
|
||||||
#include <usb/dwc2_udc.h>
|
#include <usb/dwc2_udc.h>
|
||||||
#include <watchdog.h>
|
#include <watchdog.h>
|
||||||
|
#include <dm/ofnode.h>
|
||||||
#include "../../st/common/stpmic1.h"
|
#include "../../st/common/stpmic1.h"
|
||||||
|
|
||||||
/* SYSCFG registers */
|
/* SYSCFG registers */
|
||||||
|
@ -382,10 +383,10 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
|
||||||
#ifdef CONFIG_LED
|
#ifdef CONFIG_LED
|
||||||
static int get_led(struct udevice **dev, char *led_string)
|
static int get_led(struct udevice **dev, char *led_string)
|
||||||
{
|
{
|
||||||
char *led_name;
|
const char *led_name;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
led_name = fdtdec_get_config_string(gd->fdt_blob, led_string);
|
led_name = ofnode_conf_read_str(led_string);
|
||||||
if (!led_name) {
|
if (!led_name) {
|
||||||
pr_debug("%s: could not find %s config string\n",
|
pr_debug("%s: could not find %s config string\n",
|
||||||
__func__, led_string);
|
__func__, led_string);
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
#include <led.h>
|
#include <led.h>
|
||||||
#include <log.h>
|
#include <log.h>
|
||||||
#include <asm/global_data.h>
|
#include <asm/global_data.h>
|
||||||
|
#include <dm/ofnode.h>
|
||||||
|
|
||||||
#ifdef CONFIG_SPL_BUILD
|
#ifdef CONFIG_SPL_BUILD
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
|
||||||
static int setup_led(void)
|
static int setup_led(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_SPL_LED
|
#ifdef CONFIG_SPL_LED
|
||||||
|
@ -18,7 +18,7 @@ static int setup_led(void)
|
||||||
char *led_name;
|
char *led_name;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
led_name = fdtdec_get_config_string(gd->fdt_blob, "u-boot,boot-led");
|
led_name = ofnode_conf_read_str("u-boot,boot-led");
|
||||||
if (!led_name)
|
if (!led_name)
|
||||||
return 0;
|
return 0;
|
||||||
ret = led_get_by_label(led_name, &dev);
|
ret = led_get_by_label(led_name, &dev);
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <asm/gpio.h>
|
#include <asm/gpio.h>
|
||||||
#include <asm/arch/stm32.h>
|
#include <asm/arch/stm32.h>
|
||||||
#include <asm/arch/sys_proto.h>
|
#include <asm/arch/sys_proto.h>
|
||||||
|
#include <dm/ofnode.h>
|
||||||
#include <jffs2/load_kernel.h>
|
#include <jffs2/load_kernel.h>
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
@ -235,10 +236,10 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
|
||||||
|
|
||||||
static int get_led(struct udevice **dev, char *led_string)
|
static int get_led(struct udevice **dev, char *led_string)
|
||||||
{
|
{
|
||||||
char *led_name;
|
const char *led_name;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
led_name = fdtdec_get_config_string(gd->fdt_blob, led_string);
|
led_name = ofnode_conf_read_str(led_string);
|
||||||
if (!led_name) {
|
if (!led_name) {
|
||||||
log_debug("could not find %s config string\n", led_string);
|
log_debug("could not find %s config string\n", led_string);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <u-boot/sha256.h>
|
#include <u-boot/sha256.h>
|
||||||
#include <bootcount.h>
|
#include <bootcount.h>
|
||||||
#include <crypt.h>
|
#include <crypt.h>
|
||||||
|
#include <dm/ofnode.h>
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
|
@ -424,12 +425,12 @@ static void process_fdt_options(const void *blob)
|
||||||
ulong addr;
|
ulong addr;
|
||||||
|
|
||||||
/* Add an env variable to point to a kernel payload, if available */
|
/* Add an env variable to point to a kernel payload, if available */
|
||||||
addr = fdtdec_get_config_int(gd->fdt_blob, "kernel-offset", 0);
|
addr = ofnode_conf_read_int("kernel-offset", 0);
|
||||||
if (addr)
|
if (addr)
|
||||||
env_set_addr("kernaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
|
env_set_addr("kernaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
|
||||||
|
|
||||||
/* Add an env variable to point to a root disk, if available */
|
/* Add an env variable to point to a root disk, if available */
|
||||||
addr = fdtdec_get_config_int(gd->fdt_blob, "rootdisk-offset", 0);
|
addr = ofnode_conf_read_int("rootdisk-offset", 0);
|
||||||
if (addr)
|
if (addr)
|
||||||
env_set_addr("rootaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
|
env_set_addr("rootaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
|
||||||
#endif /* CONFIG_SYS_TEXT_BASE */
|
#endif /* CONFIG_SYS_TEXT_BASE */
|
||||||
|
@ -446,8 +447,7 @@ const char *bootdelay_process(void)
|
||||||
bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
|
bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_OF_CONTROL))
|
if (IS_ENABLED(CONFIG_OF_CONTROL))
|
||||||
bootdelay = fdtdec_get_config_int(gd->fdt_blob, "bootdelay",
|
bootdelay = ofnode_conf_read_int("bootdelay", bootdelay);
|
||||||
bootdelay);
|
|
||||||
|
|
||||||
debug("### main_loop entered: bootdelay=%d\n\n", bootdelay);
|
debug("### main_loop entered: bootdelay=%d\n\n", bootdelay);
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include <asm/sections.h>
|
#include <asm/sections.h>
|
||||||
#include <dm/root.h>
|
#include <dm/root.h>
|
||||||
|
#include <dm/ofnode.h>
|
||||||
#include <linux/compiler.h>
|
#include <linux/compiler.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <efi_loader.h>
|
#include <efi_loader.h>
|
||||||
|
@ -448,8 +449,7 @@ static int initr_pvblock(void)
|
||||||
static int should_load_env(void)
|
static int should_load_env(void)
|
||||||
{
|
{
|
||||||
if (IS_ENABLED(CONFIG_OF_CONTROL))
|
if (IS_ENABLED(CONFIG_OF_CONTROL))
|
||||||
return fdtdec_get_config_int(gd->fdt_blob,
|
return ofnode_conf_read_int("load-environment", 1);
|
||||||
"load-environment", 1);
|
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_DELAY_ENVIRONMENT))
|
if (IS_ENABLED(CONFIG_DELAY_ENVIRONMENT))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -19,8 +19,7 @@
|
||||||
#include <hang.h>
|
#include <hang.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <asm/global_data.h>
|
#include <asm/global_data.h>
|
||||||
|
#include <dm/ofnode.h>
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
|
||||||
|
|
||||||
#ifdef CONFIG_CMDLINE
|
#ifdef CONFIG_CMDLINE
|
||||||
/*
|
/*
|
||||||
|
@ -157,7 +156,7 @@ int do_run(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||||
bool cli_process_fdt(const char **cmdp)
|
bool cli_process_fdt(const char **cmdp)
|
||||||
{
|
{
|
||||||
/* Allow the fdt to override the boot command */
|
/* Allow the fdt to override the boot command */
|
||||||
char *env = fdtdec_get_config_string(gd->fdt_blob, "bootcmd");
|
const char *env = ofnode_conf_read_str("bootcmd");
|
||||||
if (env)
|
if (env)
|
||||||
*cmdp = env;
|
*cmdp = env;
|
||||||
/*
|
/*
|
||||||
|
@ -165,7 +164,7 @@ bool cli_process_fdt(const char **cmdp)
|
||||||
* Always use 'env' in this case, since bootsecure requres that the
|
* Always use 'env' in this case, since bootsecure requres that the
|
||||||
* bootcmd was specified in the FDT too.
|
* bootcmd was specified in the FDT too.
|
||||||
*/
|
*/
|
||||||
return fdtdec_get_config_int(gd->fdt_blob, "bootsecure", 0) != 0;
|
return ofnode_conf_read_int("bootsecure", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <spl.h>
|
#include <spl.h>
|
||||||
#include <asm/global_data.h>
|
#include <asm/global_data.h>
|
||||||
|
#include <dm/ofnode.h>
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
|
||||||
|
|
||||||
#ifdef CONFIG_SPL_OS_BOOT
|
#ifdef CONFIG_SPL_OS_BOOT
|
||||||
/*
|
/*
|
||||||
|
@ -104,9 +103,8 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
|
||||||
header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
|
header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
|
||||||
|
|
||||||
#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
|
#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
|
||||||
payload_offs = fdtdec_get_config_int(gd->fdt_blob,
|
payload_offs = ofnode_conf_read_int("u-boot,spl-payload-offset",
|
||||||
"u-boot,spl-payload-offset",
|
payload_offs);
|
||||||
payload_offs);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SPL_OS_BOOT
|
#ifdef CONFIG_SPL_OS_BOOT
|
||||||
|
|
|
@ -23,12 +23,11 @@
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <memalign.h>
|
#include <memalign.h>
|
||||||
#include <part_efi.h>
|
#include <part_efi.h>
|
||||||
|
#include <dm/ofnode.h>
|
||||||
#include <linux/compiler.h>
|
#include <linux/compiler.h>
|
||||||
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
||||||
#include <u-boot/crc.h>
|
#include <u-boot/crc.h>
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
|
||||||
|
|
||||||
#ifdef CONFIG_HAVE_BLOCK_DEVICE
|
#ifdef CONFIG_HAVE_BLOCK_DEVICE
|
||||||
|
|
||||||
/* GUID for basic data partitons */
|
/* GUID for basic data partitons */
|
||||||
|
@ -563,9 +562,8 @@ static uint32_t partition_entries_offset(struct blk_desc *dev_desc)
|
||||||
* from the start of the device) to be specified as a property
|
* from the start of the device) to be specified as a property
|
||||||
* of the device tree '/config' node.
|
* of the device tree '/config' node.
|
||||||
*/
|
*/
|
||||||
config_offset = fdtdec_get_config_int(gd->fdt_blob,
|
config_offset = ofnode_conf_read_int(
|
||||||
"u-boot,efi-partition-entries-offset",
|
"u-boot,efi-partition-entries-offset", -EINVAL);
|
||||||
-EINVAL);
|
|
||||||
if (config_offset != -EINVAL) {
|
if (config_offset != -EINVAL) {
|
||||||
offset_bytes = PAD_TO_BLOCKSIZE(config_offset, dev_desc);
|
offset_bytes = PAD_TO_BLOCKSIZE(config_offset, dev_desc);
|
||||||
offset_blks = offset_bytes / dev_desc->blksz;
|
offset_blks = offset_bytes / dev_desc->blksz;
|
||||||
|
|
|
@ -2,8 +2,8 @@ The /config node (Configuration Options)
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
A number of run-time configuration options are provided in the /config node
|
A number of run-time configuration options are provided in the /config node
|
||||||
of the control device tree. You can access these using fdtdec_get_config_int(),
|
of the control device tree. You can access these using ofnode_conf_read_int(),
|
||||||
fdtdec_get_config_bool() and fdtdec_get_config_string().
|
ofnode_conf_read_bool() and ofnode_conf_read_str().
|
||||||
|
|
||||||
These options are designed to affect the operation of U-Boot at runtime.
|
These options are designed to affect the operation of U-Boot at runtime.
|
||||||
Runtime-configuration items can help avoid proliferation of different builds
|
Runtime-configuration items can help avoid proliferation of different builds
|
||||||
|
|
|
@ -1103,3 +1103,36 @@ int ofnode_set_enabled(ofnode node, bool value)
|
||||||
else
|
else
|
||||||
return ofnode_write_string(node, "status", "disabled");
|
return ofnode_write_string(node, "status", "disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ofnode_conf_read_bool(const char *prop_name)
|
||||||
|
{
|
||||||
|
ofnode node;
|
||||||
|
|
||||||
|
node = ofnode_path("/config");
|
||||||
|
if (!ofnode_valid(node))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return ofnode_read_bool(node, prop_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ofnode_conf_read_int(const char *prop_name, int default_val)
|
||||||
|
{
|
||||||
|
ofnode node;
|
||||||
|
|
||||||
|
node = ofnode_path("/config");
|
||||||
|
if (!ofnode_valid(node))
|
||||||
|
return default_val;
|
||||||
|
|
||||||
|
return ofnode_read_u32_default(node, prop_name, default_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *ofnode_conf_read_str(const char *prop_name)
|
||||||
|
{
|
||||||
|
ofnode node;
|
||||||
|
|
||||||
|
node = ofnode_path("/config");
|
||||||
|
if (!ofnode_valid(node))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return ofnode_read_string(node, prop_name);
|
||||||
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <video.h>
|
#include <video.h>
|
||||||
#include <asm/global_data.h>
|
#include <asm/global_data.h>
|
||||||
|
#include <dm/ofnode.h>
|
||||||
#include <linux/compiler.h>
|
#include <linux/compiler.h>
|
||||||
|
|
||||||
#if defined(CONFIG_VIDEO_MXS)
|
#if defined(CONFIG_VIDEO_MXS)
|
||||||
|
@ -2137,8 +2138,7 @@ int drv_video_init(void)
|
||||||
#if defined(CONFIG_VGA_AS_SINGLE_DEVICE)
|
#if defined(CONFIG_VGA_AS_SINGLE_DEVICE)
|
||||||
have_keyboard = false;
|
have_keyboard = false;
|
||||||
#elif defined(CONFIG_OF_CONTROL)
|
#elif defined(CONFIG_OF_CONTROL)
|
||||||
have_keyboard = !fdtdec_get_config_bool(gd->fdt_blob,
|
have_keyboard = !ofnode_conf_read_bool("u-boot,no-keyboard");
|
||||||
"u-boot,no-keyboard");
|
|
||||||
#else
|
#else
|
||||||
have_keyboard = true;
|
have_keyboard = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -288,8 +288,8 @@ int exynos_dsim_config_parse_dt(const void *blob, struct mipi_dsim_config *dt,
|
||||||
dt->rx_timeout = fdtdec_get_int(blob, node,
|
dt->rx_timeout = fdtdec_get_int(blob, node,
|
||||||
"samsung,dsim-config-rx-timeout", 0);
|
"samsung,dsim-config-rx-timeout", 0);
|
||||||
|
|
||||||
lcd_dt->name = fdtdec_get_config_string(blob,
|
lcd_dt->name = fdt_getprop(blob, node, "samsung,dsim-device-name",
|
||||||
"samsung,dsim-device-name");
|
NULL);
|
||||||
|
|
||||||
lcd_dt->id = fdtdec_get_int(blob, node,
|
lcd_dt->id = fdtdec_get_int(blob, node,
|
||||||
"samsung,dsim-device-id", 0);
|
"samsung,dsim-device-id", 0);
|
||||||
|
|
5
env/mmc.c
vendored
5
env/mmc.c
vendored
|
@ -19,6 +19,7 @@
|
||||||
#include <part.h>
|
#include <part.h>
|
||||||
#include <search.h>
|
#include <search.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <dm/ofnode.h>
|
||||||
|
|
||||||
#define __STR(X) #X
|
#define __STR(X) #X
|
||||||
#define STR(X) __STR(X)
|
#define STR(X) __STR(X)
|
||||||
|
@ -73,7 +74,7 @@ static inline s64 mmc_offset(int copy)
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
/* look for the partition in mmc CONFIG_SYS_MMC_ENV_DEV */
|
/* look for the partition in mmc CONFIG_SYS_MMC_ENV_DEV */
|
||||||
str = fdtdec_get_config_string(gd->fdt_blob, dt_prop.partition);
|
str = ofnode_conf_read_str(dt_prop.partition);
|
||||||
if (str) {
|
if (str) {
|
||||||
/* try to place the environment at end of the partition */
|
/* try to place the environment at end of the partition */
|
||||||
err = mmc_offset_try_partition(str, copy, &val);
|
err = mmc_offset_try_partition(str, copy, &val);
|
||||||
|
@ -90,7 +91,7 @@ static inline s64 mmc_offset(int copy)
|
||||||
propname = dt_prop.offset_redund;
|
propname = dt_prop.offset_redund;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return fdtdec_get_config_int(gd->fdt_blob, propname, defvalue);
|
return ofnode_conf_read_int(propname, defvalue);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline s64 mmc_offset(int copy)
|
static inline s64 mmc_offset(int copy)
|
||||||
|
|
|
@ -1117,4 +1117,41 @@ int ofnode_write_string(ofnode node, const char *propname, const char *value);
|
||||||
*/
|
*/
|
||||||
int ofnode_set_enabled(ofnode node, bool value);
|
int ofnode_set_enabled(ofnode node, bool value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ofnode_conf_read_bool() - Read a boolean value from the U-Boot config
|
||||||
|
*
|
||||||
|
* This reads a property from the /config node of the devicetree.
|
||||||
|
*
|
||||||
|
* See doc/config.txt for bindings
|
||||||
|
*
|
||||||
|
* @prop_name property name to look up
|
||||||
|
* @return true, if it exists, false if not
|
||||||
|
*/
|
||||||
|
bool ofnode_conf_read_bool(const char *prop_name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ofnode_conf_read_int() - Read an integer value from the U-Boot config
|
||||||
|
*
|
||||||
|
* This reads a property from the /config node of the devicetree.
|
||||||
|
*
|
||||||
|
* See doc/config.txt for bindings
|
||||||
|
*
|
||||||
|
* @prop_name: property name to look up
|
||||||
|
* @default_val: default value to return if the property is not found
|
||||||
|
* @return integer value, if found, or @default_val if not
|
||||||
|
*/
|
||||||
|
int ofnode_conf_read_int(const char *prop_name, int default_val);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ofnode_conf_read_str() - Read a string value from the U-Boot config
|
||||||
|
*
|
||||||
|
* This reads a property from the /config node of the devicetree.
|
||||||
|
*
|
||||||
|
* See doc/config.txt for bindings
|
||||||
|
*
|
||||||
|
* @prop_name: property name to look up
|
||||||
|
* @return string value, if found, or NULL if not
|
||||||
|
*/
|
||||||
|
const char *ofnode_conf_read_str(const char *prop_name);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -746,39 +746,6 @@ int fdtdec_get_bool(const void *blob, int node, const char *prop_name);
|
||||||
*/
|
*/
|
||||||
int fdtdec_get_child_count(const void *blob, int node);
|
int fdtdec_get_child_count(const void *blob, int node);
|
||||||
|
|
||||||
/**
|
|
||||||
* Look in the FDT for a config item with the given name and return its value
|
|
||||||
* as a 32-bit integer. The property must have at least 4 bytes of data. The
|
|
||||||
* value of the first cell is returned.
|
|
||||||
*
|
|
||||||
* @param blob FDT blob to use
|
|
||||||
* @param prop_name Node property name
|
|
||||||
* @param default_val default value to return if the property is not found
|
|
||||||
* @return integer value, if found, or default_val if not
|
|
||||||
*/
|
|
||||||
int fdtdec_get_config_int(const void *blob, const char *prop_name,
|
|
||||||
int default_val);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Look in the FDT for a config item with the given name
|
|
||||||
* and return whether it exists.
|
|
||||||
*
|
|
||||||
* @param blob FDT blob
|
|
||||||
* @param prop_name property name to look up
|
|
||||||
* @return 1, if it exists, or 0 if not
|
|
||||||
*/
|
|
||||||
int fdtdec_get_config_bool(const void *blob, const char *prop_name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Look in the FDT for a config item with the given name and return its value
|
|
||||||
* as a string.
|
|
||||||
*
|
|
||||||
* @param blob FDT blob
|
|
||||||
* @param prop_name property name to look up
|
|
||||||
* @returns property string, NULL on error.
|
|
||||||
*/
|
|
||||||
char *fdtdec_get_config_string(const void *blob, const char *prop_name);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look up a property in a node and return its contents in a byte
|
* Look up a property in a node and return its contents in a byte
|
||||||
* array of given length. The property must have at least enough data for
|
* array of given length. The property must have at least enough data for
|
||||||
|
|
44
lib/fdtdec.c
44
lib/fdtdec.c
|
@ -870,50 +870,6 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node,
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fdtdec_get_config_int(const void *blob, const char *prop_name,
|
|
||||||
int default_val)
|
|
||||||
{
|
|
||||||
int config_node;
|
|
||||||
|
|
||||||
debug("%s: %s\n", __func__, prop_name);
|
|
||||||
config_node = fdt_path_offset(blob, "/config");
|
|
||||||
if (config_node < 0)
|
|
||||||
return default_val;
|
|
||||||
return fdtdec_get_int(blob, config_node, prop_name, default_val);
|
|
||||||
}
|
|
||||||
|
|
||||||
int fdtdec_get_config_bool(const void *blob, const char *prop_name)
|
|
||||||
{
|
|
||||||
int config_node;
|
|
||||||
const void *prop;
|
|
||||||
|
|
||||||
debug("%s: %s\n", __func__, prop_name);
|
|
||||||
config_node = fdt_path_offset(blob, "/config");
|
|
||||||
if (config_node < 0)
|
|
||||||
return 0;
|
|
||||||
prop = fdt_get_property(blob, config_node, prop_name, NULL);
|
|
||||||
|
|
||||||
return prop != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *fdtdec_get_config_string(const void *blob, const char *prop_name)
|
|
||||||
{
|
|
||||||
const char *nodep;
|
|
||||||
int nodeoffset;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
debug("%s: %s\n", __func__, prop_name);
|
|
||||||
nodeoffset = fdt_path_offset(blob, "/config");
|
|
||||||
if (nodeoffset < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
nodep = fdt_getprop(blob, nodeoffset, prop_name, &len);
|
|
||||||
if (!nodep)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return (char *)nodep;
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 fdtdec_get_number(const fdt32_t *ptr, unsigned int cells)
|
u64 fdtdec_get_number(const fdt32_t *ptr, unsigned int cells)
|
||||||
{
|
{
|
||||||
u64 number = 0;
|
u64 number = 0;
|
||||||
|
|
|
@ -318,3 +318,18 @@ static int dm_test_ofnode_get_path(struct unit_test_state *uts)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DM_TEST(dm_test_ofnode_get_path, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
|
DM_TEST(dm_test_ofnode_get_path, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
|
||||||
|
|
||||||
|
static int dm_test_ofnode_conf(struct unit_test_state *uts)
|
||||||
|
{
|
||||||
|
ut_assert(!ofnode_conf_read_bool("missing"));
|
||||||
|
ut_assert(ofnode_conf_read_bool("testing-bool"));
|
||||||
|
|
||||||
|
ut_asserteq(123, ofnode_conf_read_int("testing-int", 0));
|
||||||
|
ut_asserteq(6, ofnode_conf_read_int("missing", 6));
|
||||||
|
|
||||||
|
ut_assertnull(ofnode_conf_read_str("missing"));
|
||||||
|
ut_asserteq_str("testing", ofnode_conf_read_str("testing-str"));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
DM_TEST(dm_test_ofnode_conf, 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue