mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 23:51:33 +00:00
Merge branch '2022-07-08-assorted-updates' into next
- Assorted bugfixes and improvements
This commit is contained in:
commit
7bc0be96f7
25 changed files with 164 additions and 63 deletions
6
Makefile
6
Makefile
|
@ -673,6 +673,12 @@ else
|
|||
include/config/auto.conf: ;
|
||||
endif # $(dot-config)
|
||||
|
||||
ifdef CONFIG_CC_OPTIMIZE_FOR_DEBUG
|
||||
KBUILD_HOSTCFLAGS := -Wall -Wstrict-prototypes -Og -g -fomit-frame-pointer \
|
||||
$(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
|
||||
KBUILD_HOSTCXXFLAGS := -Og -g $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
|
||||
endif
|
||||
|
||||
#
|
||||
# Xtensa linker script cannot be preprocessed with -ansi because of
|
||||
# preprocessor operations on strings that don't make C identifiers.
|
||||
|
|
|
@ -78,8 +78,10 @@ __weak void board_init_f_init_stack_protection(void)
|
|||
ulong board_init_f_alloc_reserve(ulong top)
|
||||
{
|
||||
/* Reserve early malloc arena */
|
||||
#ifndef CONFIG_MALLOC_F_ADDR
|
||||
#if CONFIG_VAL(SYS_MALLOC_F_LEN)
|
||||
top -= CONFIG_VAL(SYS_MALLOC_F_LEN);
|
||||
#endif
|
||||
#endif
|
||||
/* LAST : reserve GD (rounded up to a multiple of 16 bytes) */
|
||||
top = rounddown(top-sizeof(struct global_data), 16);
|
||||
|
|
|
@ -95,27 +95,17 @@ static enum led_state_t led_pwm_get_state(struct udevice *dev)
|
|||
static int led_pwm_probe(struct udevice *dev)
|
||||
{
|
||||
struct led_pwm_priv *priv = dev_get_priv(dev);
|
||||
struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev);
|
||||
|
||||
/* Ignore the top-level LED node */
|
||||
if (!uc_plat->label)
|
||||
return 0;
|
||||
|
||||
return led_pwm_set_state(dev, (priv->enabled) ? LEDST_ON : LEDST_OFF);
|
||||
}
|
||||
|
||||
static int led_pwm_of_to_plat(struct udevice *dev)
|
||||
{
|
||||
struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev);
|
||||
struct led_pwm_priv *priv = dev_get_priv(dev);
|
||||
struct ofnode_phandle_args args;
|
||||
uint def_brightness, max_brightness;
|
||||
int ret;
|
||||
|
||||
/* Ignore the top-level LED node */
|
||||
if (!uc_plat->label)
|
||||
return 0;
|
||||
|
||||
ret = dev_read_phandle_with_args(dev, "pwms", "#pwm-cells", 0, 0, &args);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
@ -173,10 +163,15 @@ static const struct udevice_id led_pwm_ids[] = {
|
|||
U_BOOT_DRIVER(led_pwm) = {
|
||||
.name = LEDS_PWM_DRIVER_NAME,
|
||||
.id = UCLASS_LED,
|
||||
.of_match = led_pwm_ids,
|
||||
.ops = &led_pwm_ops,
|
||||
.priv_auto = sizeof(struct led_pwm_priv),
|
||||
.bind = led_pwm_bind,
|
||||
.probe = led_pwm_probe,
|
||||
.of_to_plat = led_pwm_of_to_plat,
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(led_pwm_wrap) = {
|
||||
.name = LEDS_PWM_DRIVER_NAME "_wrap",
|
||||
.id = UCLASS_NOP,
|
||||
.of_match = led_pwm_ids,
|
||||
.bind = led_pwm_bind,
|
||||
};
|
||||
|
|
|
@ -974,6 +974,22 @@ static int nand_reset_data_interface(struct nand_chip *chip, int chipnr)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int nand_onfi_set_timings(struct mtd_info *mtd, struct nand_chip *chip)
|
||||
{
|
||||
if (!chip->onfi_version ||
|
||||
!(le16_to_cpu(chip->onfi_params.opt_cmd)
|
||||
& ONFI_OPT_CMD_SET_GET_FEATURES))
|
||||
return 0;
|
||||
|
||||
u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = {
|
||||
chip->onfi_timing_mode_default,
|
||||
};
|
||||
|
||||
return chip->onfi_set_features(mtd, chip,
|
||||
ONFI_FEATURE_ADDR_TIMING_MODE,
|
||||
tmode_param);
|
||||
}
|
||||
|
||||
/**
|
||||
* nand_setup_data_interface - Setup the best data interface and timings
|
||||
* @chip: The NAND chip
|
||||
|
@ -999,17 +1015,9 @@ static int nand_setup_data_interface(struct nand_chip *chip, int chipnr)
|
|||
* Ensure the timing mode has been changed on the chip side
|
||||
* before changing timings on the controller side.
|
||||
*/
|
||||
if (chip->onfi_version) {
|
||||
u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = {
|
||||
chip->onfi_timing_mode_default,
|
||||
};
|
||||
|
||||
ret = chip->onfi_set_features(mtd, chip,
|
||||
ONFI_FEATURE_ADDR_TIMING_MODE,
|
||||
tmode_param);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
ret = nand_onfi_set_timings(mtd, chip);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = chip->setup_data_interface(mtd, chipnr, chip->data_interface);
|
||||
err:
|
||||
|
|
|
@ -328,6 +328,10 @@ static inline void _debug_uart_init(void)
|
|||
struct ns16550 *com_port = (struct ns16550 *)CONFIG_VAL(DEBUG_UART_BASE);
|
||||
int baud_divisor;
|
||||
|
||||
/* Wait until tx buffer is empty */
|
||||
while (!(serial_din(&com_port->lsr) & UART_LSR_TEMT))
|
||||
;
|
||||
|
||||
/*
|
||||
* We copy the code from above because it is already horribly messy.
|
||||
* Trying to refactor to nicely remove the duplication doesn't seem
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#define DA7219_ACPI_HID "DLGS7219"
|
||||
|
||||
__maybe_unused
|
||||
static int da7219_acpi_fill_ssdt(const struct udevice *dev,
|
||||
struct acpi_ctx *ctx)
|
||||
{
|
||||
|
@ -171,10 +172,12 @@ static int da7219_acpi_setup_nhlt(const struct udevice *dev,
|
|||
#endif
|
||||
|
||||
struct acpi_ops da7219_acpi_ops = {
|
||||
#ifdef CONFIG_ACPIGEN
|
||||
.fill_ssdt = da7219_acpi_fill_ssdt,
|
||||
#ifdef CONFIG_X86
|
||||
.setup_nhlt = da7219_acpi_setup_nhlt,
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
static const struct udevice_id da7219_ids[] = {
|
||||
|
|
|
@ -38,6 +38,7 @@ static int max98357a_of_to_plat(struct udevice *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
__maybe_unused
|
||||
static int max98357a_acpi_fill_ssdt(const struct udevice *dev,
|
||||
struct acpi_ctx *ctx)
|
||||
{
|
||||
|
@ -137,10 +138,12 @@ static int max98357a_acpi_setup_nhlt(const struct udevice *dev,
|
|||
#endif
|
||||
|
||||
struct acpi_ops max98357a_acpi_ops = {
|
||||
#ifdef CONFIG_ACPIGEN
|
||||
.fill_ssdt = max98357a_acpi_fill_ssdt,
|
||||
#ifdef CONFIG_X86
|
||||
.setup_nhlt = max98357a_acpi_setup_nhlt,
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
static const struct audio_codec_ops max98357a_ops = {
|
||||
|
|
5
env/ext4.c
vendored
5
env/ext4.c
vendored
|
@ -31,6 +31,7 @@
|
|||
#include <errno.h>
|
||||
#include <ext4fs.h>
|
||||
#include <mmc.h>
|
||||
#include <scsi.h>
|
||||
#include <asm/global_data.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
@ -146,6 +147,10 @@ static int env_ext4_load(void)
|
|||
if (!strcmp(ifname, "mmc"))
|
||||
mmc_initialize(NULL);
|
||||
#endif
|
||||
#if defined(CONFIG_AHCI) || defined(CONFIG_SCSI)
|
||||
if (!strcmp(ifname, "scsi"))
|
||||
scsi_scan(true);
|
||||
#endif
|
||||
|
||||
part = blk_get_device_part_str(ifname, dev_and_part,
|
||||
&dev_desc, &info, 1);
|
||||
|
|
8
env/fat.c
vendored
8
env/fat.c
vendored
|
@ -17,6 +17,7 @@
|
|||
#include <errno.h>
|
||||
#include <fat.h>
|
||||
#include <mmc.h>
|
||||
#include <scsi.h>
|
||||
#include <asm/cache.h>
|
||||
#include <asm/global_data.h>
|
||||
#include <linux/stddef.h>
|
||||
|
@ -128,7 +129,12 @@ static int env_fat_load(void)
|
|||
if (!strcmp(ifname, "mmc"))
|
||||
mmc_initialize(NULL);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SPL_BUILD
|
||||
#if defined(CONFIG_AHCI) || defined(CONFIG_SCSI)
|
||||
if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "scsi"))
|
||||
scsi_scan(true);
|
||||
#endif
|
||||
#endif
|
||||
part = blk_get_device_part_str(ifname, dev_and_part,
|
||||
&dev_desc, &info, 1);
|
||||
if (part < 0)
|
||||
|
|
|
@ -1757,6 +1757,8 @@ void ubifs_umount(struct ubifs_info *c)
|
|||
kfree(c->bottom_up_buf);
|
||||
ubifs_debugging_exit(c);
|
||||
#ifdef __UBOOT__
|
||||
ubi_close_volume(c->ubi);
|
||||
mutex_unlock(&c->umount_mutex);
|
||||
/* Finally free U-Boot's global copy of superblock */
|
||||
if (ubifs_sb != NULL) {
|
||||
free(ubifs_sb->s_fs_info);
|
||||
|
@ -2058,9 +2060,9 @@ static void ubifs_put_super(struct super_block *sb)
|
|||
ubifs_umount(c);
|
||||
#ifndef __UBOOT__
|
||||
bdi_destroy(&c->bdi);
|
||||
#endif
|
||||
ubi_close_volume(c->ubi);
|
||||
mutex_unlock(&c->umount_mutex);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2327,6 +2329,9 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
|
|||
|
||||
out_umount:
|
||||
ubifs_umount(c);
|
||||
#ifdef __UBOOT__
|
||||
goto out;
|
||||
#endif
|
||||
out_unlock:
|
||||
mutex_unlock(&c->umount_mutex);
|
||||
#ifndef __UBOOT__
|
||||
|
|
|
@ -70,18 +70,23 @@
|
|||
#ifdef CONFIG_CMD_UBIFS
|
||||
#define BOOTENV_SHARED_UBIFS \
|
||||
"ubifs_boot=" \
|
||||
"env exists bootubipart || " \
|
||||
"env set bootubipart UBI; " \
|
||||
"env exists bootubivol || " \
|
||||
"env set bootubivol boot; " \
|
||||
"if ubi part ${bootubipart} && " \
|
||||
"ubifsmount ubi${devnum}:${bootubivol}; " \
|
||||
"ubifsmount ubi0:${bootubivol}; " \
|
||||
"then " \
|
||||
"devtype=ubi; " \
|
||||
"devnum=ubi0; " \
|
||||
"bootfstype=ubifs; " \
|
||||
"distro_bootpart=${bootubivol}; " \
|
||||
"run scan_dev_for_boot; " \
|
||||
"ubifsumount; " \
|
||||
"fi\0"
|
||||
#define BOOTENV_DEV_UBIFS BOOTENV_DEV_BLKDEV
|
||||
#define BOOTENV_DEV_NAME_UBIFS BOOTENV_DEV_NAME_BLKDEV
|
||||
#define BOOTENV_DEV_UBIFS(devtypeu, devtypel, instance, bootubipart, bootubivol) \
|
||||
"bootcmd_ubifs" #instance "=" \
|
||||
"bootubipart=" #bootubipart "; " \
|
||||
"bootubivol=" #bootubivol "; " \
|
||||
"run ubifs_boot\0"
|
||||
#define BOOTENV_DEV_NAME_UBIFS(devtypeu, devtypel, instance, bootubipart, bootubivol) \
|
||||
#devtypel #instance " "
|
||||
#else
|
||||
#define BOOTENV_SHARED_UBIFS
|
||||
#define BOOTENV_DEV_UBIFS \
|
||||
|
@ -411,13 +416,13 @@
|
|||
BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE
|
||||
#endif
|
||||
|
||||
#define BOOTENV_DEV_NAME(devtypeu, devtypel, instance) \
|
||||
BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance)
|
||||
#define BOOTENV_DEV_NAME(devtypeu, devtypel, instance, ...) \
|
||||
BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance, ## __VA_ARGS__)
|
||||
#define BOOTENV_BOOT_TARGETS \
|
||||
"boot_targets=" BOOT_TARGET_DEVICES(BOOTENV_DEV_NAME) "\0"
|
||||
|
||||
#define BOOTENV_DEV(devtypeu, devtypel, instance) \
|
||||
BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance)
|
||||
#define BOOTENV_DEV(devtypeu, devtypel, instance, ...) \
|
||||
BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance, ## __VA_ARGS__)
|
||||
#define BOOTENV \
|
||||
BOOTENV_SHARED_HOST \
|
||||
BOOTENV_SHARED_MMC \
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
"ramdisk_addr_r=0x88080000\0" \
|
||||
|
||||
#define BOOT_TARGET_DEVICES(func) \
|
||||
func(UBIFS, ubifs, 0)
|
||||
func(UBIFS, ubifs, 0, UBI, rootfs)
|
||||
|
||||
#define AM335XX_BOARD_FDTFILE "fdtfile=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0"
|
||||
|
||||
|
@ -51,7 +51,6 @@
|
|||
BOOTENV \
|
||||
GUARDIAN_DEFAULT_PROD_ENV \
|
||||
"backlight_brightness=50\0" \
|
||||
"bootubivol=rootfs\0" \
|
||||
"distro_bootcmd=" \
|
||||
"setenv rootflags \"bulk_read,chk_data_crc\"; " \
|
||||
"setenv ethact usb_ether; " \
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
UBI_BOOTCMD \
|
||||
UBOOT_UPDATE \
|
||||
"boot_script_dhcp=boot.scr\0" \
|
||||
"bootubipart=ubi\0" \
|
||||
"console=ttymxc0\0" \
|
||||
"defargs=user_debug=30\0" \
|
||||
"fdt_board=eval-v3\0" \
|
||||
|
|
|
@ -130,7 +130,6 @@
|
|||
UBOOT_UPDATE \
|
||||
"boot_file=zImage\0" \
|
||||
"boot_script_dhcp=boot.scr\0" \
|
||||
"bootubipart=ubi\0" \
|
||||
"console=ttymxc0\0" \
|
||||
"defargs=\0" \
|
||||
"fdt_board=eval-v3\0" \
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#define BOOT_TARGET_DEVICES(func) \
|
||||
func(MMC, mmc, 1) \
|
||||
func(MMC, mmc, 0) \
|
||||
func(UBIFS, ubifs, 0) \
|
||||
func(UBIFS, ubifs, 0, UBI, boot) \
|
||||
func(USB, usb, 0) \
|
||||
func(PXE, pxe, na) \
|
||||
func(DHCP, dhcp, na)
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
#define BOOT_TARGET_DEVICES(func) \
|
||||
func(MMC, mmc, 0) \
|
||||
func(UBIFS, ubifs, 0) \
|
||||
func(UBIFS, ubifs, 0, UBI, boot) \
|
||||
func(PXE, pxe, na) \
|
||||
func(DHCP, dhcp, na)
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
|
||||
#define BOOT_TARGET_DEVICES(func) \
|
||||
func(MMC, mmc, 0) \
|
||||
func(UBIFS, ubifs, 0) \
|
||||
func(UBIFS, ubifs, 0, UBI, boot) \
|
||||
func(PXE, pxe, na) \
|
||||
func(DHCP, dhcp, na)
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
#define BOOT_TARGET_DEVICES(func) \
|
||||
func(MMC, mmc, 0) \
|
||||
func(LEGACY_MMC, legacy_mmc, 0) \
|
||||
func(UBIFS, ubifs, 0) \
|
||||
func(UBIFS, ubifs, 0, rootfs, rootfs) \
|
||||
func(NAND, nand, 0)
|
||||
|
||||
#else /* !CONFIG_MTD_RAW_NAND */
|
||||
|
@ -84,8 +84,6 @@
|
|||
"bootenv=uEnv.txt\0" \
|
||||
"bootfile=zImage\0" \
|
||||
"bootpart=0:2\0" \
|
||||
"bootubivol=rootfs\0" \
|
||||
"bootubipart=rootfs\0" \
|
||||
"usbtty=cdc_acm\0" \
|
||||
"mpurate=auto\0" \
|
||||
"buddy=none\0" \
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
#define BOOT_TARGET_DEVICES(func) \
|
||||
func(MMC, mmc, 0) \
|
||||
func(LEGACY_MMC, legacy_mmc, 0) \
|
||||
func(UBIFS, ubifs, 0) \
|
||||
func(UBIFS, ubifs, 0, rootfs, rootfs) \
|
||||
func(NAND, nand, 0)
|
||||
|
||||
#else /* !CONFIG_MTD_RAW_NAND */
|
||||
|
@ -82,8 +82,6 @@
|
|||
"bootenv=uEnv.txt\0" \
|
||||
"bootfile=zImage\0" \
|
||||
"bootpart=0:2\0" \
|
||||
"bootubivol=rootfs\0" \
|
||||
"bootubipart=rootfs\0" \
|
||||
"optargs=\0" \
|
||||
"nandroot=ubi0:rootfs ubi.mtd=rootfs rw noinitrd\0" \
|
||||
"nandrootfstype=ubifs rootwait\0" \
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
|
||||
#define BOOT_TARGET_DEVICES(func) \
|
||||
func(MMC, mmc, 0) \
|
||||
func(UBIFS, ubifs, 0) \
|
||||
func(UBIFS, ubifs, 0, UBI, boot) \
|
||||
func(PXE, pxe, na) \
|
||||
func(DHCP, dhcp, na)
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef CONFIG_CMD_UBIFS
|
||||
#define BOOT_TARGET_UBIFS(func) func(UBIFS, ubifs, 0)
|
||||
#define BOOT_TARGET_UBIFS(func) func(UBIFS, ubifs, 0, UBI, boot)
|
||||
#else
|
||||
#define BOOT_TARGET_UBIFS(func)
|
||||
#endif
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef CONFIG_CMD_UBIFS
|
||||
#define BOOT_TARGET_DEVICE_UBIFS(func) func(UBIFS, ubifs, 0)
|
||||
#define BOOT_TARGET_DEVICE_UBIFS(func) func(UBIFS, ubifs, 0, UBI, boot)
|
||||
#else
|
||||
#define BOOT_TARGET_DEVICE_UBIFS(func)
|
||||
#endif
|
||||
|
|
|
@ -460,7 +460,7 @@ struct reg_field {
|
|||
struct regmap_field;
|
||||
|
||||
/**
|
||||
* REG_FIELD() - A convenient way to initialize a 'struct reg_feild'.
|
||||
* REG_FIELD() - A convenient way to initialize a 'struct reg_field'.
|
||||
*
|
||||
* @_reg: Offset of the register within the regmap bank
|
||||
* @_lsb: lsb of the register field.
|
||||
|
@ -519,9 +519,9 @@ void devm_regmap_field_free(struct udevice *dev, struct regmap_field *field);
|
|||
int regmap_field_write(struct regmap_field *field, unsigned int val);
|
||||
|
||||
/**
|
||||
* regmap_read() - Read a 32-bit value from a regmap
|
||||
* regmap_field_read() - Read a 32-bit value from a regmap
|
||||
*
|
||||
* @field: Regmap field to write to
|
||||
* @field: Regmap field to read from
|
||||
* @valp: Pointer to the buffer to receive the data read from the regmap
|
||||
* field
|
||||
*
|
||||
|
|
|
@ -18,9 +18,13 @@ obj-$(CONFIG_UT_DM) += core.o
|
|||
obj-$(CONFIG_UT_DM) += read.o
|
||||
obj-$(CONFIG_UT_DM) += phys2bus.o
|
||||
ifneq ($(CONFIG_SANDBOX),)
|
||||
obj-$(CONFIG_ACPIGEN) += acpi.o
|
||||
obj-$(CONFIG_ACPIGEN) += acpigen.o
|
||||
obj-$(CONFIG_ACPIGEN) += acpi_dp.o
|
||||
ifeq ($(CONFIG_ACPIGEN),y)
|
||||
obj-y += acpi.o
|
||||
obj-y += acpigen.o
|
||||
obj-y += acpi_dp.o
|
||||
obj-(CONFIG_DM_GPIO) += gpio.o
|
||||
obj-y += irq.o
|
||||
endif
|
||||
obj-$(CONFIG_ADC) += adc.o
|
||||
obj-$(CONFIG_SOUND) += audio.o
|
||||
obj-$(CONFIG_AXI) += axi.o
|
||||
|
@ -43,11 +47,9 @@ ifneq ($(CONFIG_EFI_PARTITION),)
|
|||
obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fastboot.o
|
||||
endif
|
||||
obj-$(CONFIG_FIRMWARE) += firmware.o
|
||||
obj-$(CONFIG_DM_GPIO) += gpio.o
|
||||
obj-$(CONFIG_DM_HWSPINLOCK) += hwspinlock.o
|
||||
obj-$(CONFIG_DM_I2C) += i2c.o
|
||||
obj-$(CONFIG_SOUND) += i2s.o
|
||||
obj-y += irq.o
|
||||
obj-$(CONFIG_CLK_K210_SET_RATE) += k210_pll.o
|
||||
obj-$(CONFIG_IOMMU) += iommu.o
|
||||
obj-$(CONFIG_LED) += led.o
|
||||
|
|
70
tools/env/fw_env.c
vendored
70
tools/env/fw_env.c
vendored
|
@ -1713,6 +1713,67 @@ static int check_device_config(int dev)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int find_nvmem_device(void)
|
||||
{
|
||||
const char *path = "/sys/bus/nvmem/devices";
|
||||
struct dirent *dent;
|
||||
char *nvmem = NULL;
|
||||
char comp[256];
|
||||
char buf[32];
|
||||
int bytes;
|
||||
DIR *dir;
|
||||
|
||||
dir = opendir(path);
|
||||
if (!dir) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
while (!nvmem && (dent = readdir(dir))) {
|
||||
FILE *fp;
|
||||
|
||||
if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bytes = snprintf(comp, sizeof(comp), "%s/%s/of_node/compatible", path, dent->d_name);
|
||||
if (bytes < 0 || bytes == sizeof(comp)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
fp = fopen(comp, "r");
|
||||
if (!fp) {
|
||||
continue;
|
||||
}
|
||||
|
||||
fread(buf, sizeof(buf), 1, fp);
|
||||
|
||||
if (!strcmp(buf, "u-boot,env")) {
|
||||
bytes = asprintf(&nvmem, "%s/%s/nvmem", path, dent->d_name);
|
||||
if (bytes < 0) {
|
||||
nvmem = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
if (nvmem) {
|
||||
struct stat s;
|
||||
|
||||
stat(nvmem, &s);
|
||||
|
||||
DEVNAME(0) = nvmem;
|
||||
DEVOFFSET(0) = 0;
|
||||
ENVSIZE(0) = s.st_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int parse_config(struct env_opts *opts)
|
||||
{
|
||||
int rc;
|
||||
|
@ -1723,9 +1784,12 @@ static int parse_config(struct env_opts *opts)
|
|||
#if defined(CONFIG_FILE)
|
||||
/* Fills in DEVNAME(), ENVSIZE(), DEVESIZE(). Or don't. */
|
||||
if (get_config(opts->config_file)) {
|
||||
fprintf(stderr, "Cannot parse config file '%s': %m\n",
|
||||
opts->config_file);
|
||||
return -1;
|
||||
if (find_nvmem_device()) {
|
||||
fprintf(stderr, "Cannot parse config file '%s': %m\n",
|
||||
opts->config_file);
|
||||
fprintf(stderr, "Failed to find NVMEM device\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#else
|
||||
DEVNAME(0) = DEVICE1_NAME;
|
||||
|
|
Loading…
Reference in a new issue