summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/Kconfig1
-rw-r--r--drivers/fastboot/Kconfig19
-rw-r--r--drivers/fastboot/fb_command.c108
-rw-r--r--drivers/fastboot/fb_common.c11
-rw-r--r--drivers/fastboot/fb_getvar.c49
-rw-r--r--drivers/reboot-mode/Kconfig7
-rw-r--r--drivers/reboot-mode/Makefile1
-rw-r--r--drivers/reboot-mode/reboot-mode-nvmem.c57
-rw-r--r--drivers/rtc/abx80x.c68
-rw-r--r--drivers/tee/optee/core.c6
-rw-r--r--drivers/usb/gadget/f_fastboot.c7
11 files changed, 202 insertions, 132 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index a063b221cd1..3fe53d6d4f3 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -135,6 +135,7 @@ config SATA_MV
config SATA_SIL
bool "Enable Silicon Image SIL3131 / SIL3132 / SIL3124 SATA driver support"
+ depends on PCI
select AHCI
select LIBATA
help
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index b97c67bf609..eefa34779c4 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -80,12 +80,13 @@ config FASTBOOT_FLASH
this to enable the "fastboot flash" command.
config FASTBOOT_UUU_SUPPORT
- bool "Enable FASTBOOT i.MX UUU special command"
+ bool "Enable UUU support"
help
- The fastboot protocol includes "UCmd" and "ACmd" command.
- Be aware that you provide full access to any U-Boot command,
- including working with memory and may open a huge backdoor,
- when enabling this option.
+ This extends the fastboot protocol with the "UCmd" and "ACmd"
+ commands, which are used by NXP's "universal update utility" (UUU).
+ These commands allow running any shell command. Do not enable this
+ feature if you are using verified boot, as it will allow an attacker
+ to bypass any restrictions you have in place.
choice
prompt "Flash provider for FASTBOOT"
@@ -218,6 +219,14 @@ config FASTBOOT_CMD_OEM_BOOTBUS
Add support for the "oem bootbus" command from a client. This set
the mmc boot configuration for the selecting eMMC device.
+config FASTBOOT_OEM_RUN
+ bool "Enable the 'oem run' command"
+ help
+ This extends the fastboot protocol with an "oem run" command. This
+ command allows running arbitrary U-Boot shell commands. Do not enable
+ this feature if you are using verified boot, as it will allow an
+ attacker to bypass any restrictions you have in place.
+
endif # FASTBOOT
endmenu
diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
index bdfdf262c8a..67a94798287 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
@@ -31,27 +31,16 @@ static u32 fastboot_bytes_expected;
static void okay(char *, char *);
static void getvar(char *, char *);
static void download(char *, char *);
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
static void flash(char *, char *);
static void erase(char *, char *);
-#endif
static void reboot_bootloader(char *, char *);
static void reboot_fastbootd(char *, char *);
static void reboot_recovery(char *, char *);
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
static void oem_format(char *, char *);
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF)
static void oem_partconf(char *, char *);
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
static void oem_bootbus(char *, char *);
-#endif
-
-#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
static void run_ucmd(char *, char *);
static void run_acmd(char *, char *);
-#endif
static const struct {
const char *command;
@@ -65,16 +54,14 @@ static const struct {
.command = "download",
.dispatch = download
},
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
[FASTBOOT_COMMAND_FLASH] = {
.command = "flash",
- .dispatch = flash
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_FLASH, (flash), (NULL))
},
[FASTBOOT_COMMAND_ERASE] = {
.command = "erase",
- .dispatch = erase
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_FLASH, (erase), (NULL))
},
-#endif
[FASTBOOT_COMMAND_BOOT] = {
.command = "boot",
.dispatch = okay
@@ -103,34 +90,30 @@ static const struct {
.command = "set_active",
.dispatch = okay
},
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
[FASTBOOT_COMMAND_OEM_FORMAT] = {
.command = "oem format",
- .dispatch = oem_format,
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT, (oem_format), (NULL))
},
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF)
[FASTBOOT_COMMAND_OEM_PARTCONF] = {
.command = "oem partconf",
- .dispatch = oem_partconf,
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF, (oem_partconf), (NULL))
},
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
[FASTBOOT_COMMAND_OEM_BOOTBUS] = {
.command = "oem bootbus",
- .dispatch = oem_bootbus,
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS, (oem_bootbus), (NULL))
+ },
+ [FASTBOOT_COMMAND_OEM_RUN] = {
+ .command = "oem run",
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_OEM_RUN, (run_ucmd), (NULL))
},
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
[FASTBOOT_COMMAND_UCMD] = {
.command = "UCmd",
- .dispatch = run_ucmd,
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT, (run_ucmd), (NULL))
},
[FASTBOOT_COMMAND_ACMD] = {
.command = "ACmd",
- .dispatch = run_acmd,
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT, (run_acmd), (NULL))
},
-#endif
};
/**
@@ -156,7 +139,9 @@ int fastboot_handle_command(char *cmd_string, char *response)
response);
return i;
} else {
- break;
+ pr_err("command %s not supported.\n", cmd_string);
+ fastboot_fail("Unsupported command", response);
+ return -1;
}
}
}
@@ -299,7 +284,6 @@ void fastboot_data_complete(char *response)
fastboot_bytes_received = 0;
}
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
/**
* flash() - write the downloaded image to the indicated partition.
*
@@ -309,16 +293,15 @@ void fastboot_data_complete(char *response)
* Writes the previously downloaded image to the partition indicated by
* cmd_parameter. Writes to response.
*/
-static void flash(char *cmd_parameter, char *response)
+static void __maybe_unused flash(char *cmd_parameter, char *response)
{
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
- fastboot_mmc_flash_write(cmd_parameter, fastboot_buf_addr, image_size,
- response);
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND)
- fastboot_nand_flash_write(cmd_parameter, fastboot_buf_addr, image_size,
- response);
-#endif
+ if (CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC))
+ fastboot_mmc_flash_write(cmd_parameter, fastboot_buf_addr,
+ image_size, response);
+
+ if (CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND))
+ fastboot_nand_flash_write(cmd_parameter, fastboot_buf_addr,
+ image_size, response);
}
/**
@@ -330,25 +313,22 @@ static void flash(char *cmd_parameter, char *response)
* Erases the partition indicated by cmd_parameter (clear to 0x00s). Writes
* to response.
*/
-static void erase(char *cmd_parameter, char *response)
+static void __maybe_unused erase(char *cmd_parameter, char *response)
{
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
- fastboot_mmc_erase(cmd_parameter, response);
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND)
- fastboot_nand_erase(cmd_parameter, response);
-#endif
+ if (CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC))
+ fastboot_mmc_erase(cmd_parameter, response);
+
+ if (CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND))
+ fastboot_nand_erase(cmd_parameter, response);
}
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
/**
* run_ucmd() - Execute the UCmd command
*
* @cmd_parameter: Pointer to command parameter
* @response: Pointer to fastboot response buffer
*/
-static void run_ucmd(char *cmd_parameter, char *response)
+static void __maybe_unused run_ucmd(char *cmd_parameter, char *response)
{
if (!cmd_parameter) {
pr_err("missing slot suffix\n");
@@ -375,7 +355,7 @@ void fastboot_acmd_complete(void)
* @cmd_parameter: Pointer to command parameter
* @response: Pointer to fastboot response buffer
*/
-static void run_acmd(char *cmd_parameter, char *response)
+static void __maybe_unused run_acmd(char *cmd_parameter, char *response)
{
if (!cmd_parameter) {
pr_err("missing slot suffix\n");
@@ -392,7 +372,6 @@ static void run_acmd(char *cmd_parameter, char *response)
strcpy(g_a_cmd_buff, cmd_parameter);
fastboot_okay(NULL, response);
}
-#endif
/**
* reboot_bootloader() - Sets reboot bootloader flag.
@@ -436,40 +415,40 @@ static void reboot_recovery(char *cmd_parameter, char *response)
fastboot_okay(NULL, response);
}
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
/**
* oem_format() - Execute the OEM format command
*
* @cmd_parameter: Pointer to command parameter
* @response: Pointer to fastboot response buffer
*/
-static void oem_format(char *cmd_parameter, char *response)
+static void __maybe_unused oem_format(char *cmd_parameter, char *response)
{
char cmdbuf[32];
+ const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
+ CONFIG_FASTBOOT_FLASH_MMC_DEV, -1);
if (!env_get("partitions")) {
fastboot_fail("partitions not set", response);
} else {
- sprintf(cmdbuf, "gpt write mmc %x $partitions",
- CONFIG_FASTBOOT_FLASH_MMC_DEV);
+ sprintf(cmdbuf, "gpt write mmc %x $partitions", mmc_dev);
if (run_command(cmdbuf, 0))
fastboot_fail("", response);
else
fastboot_okay(NULL, response);
}
}
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF)
/**
* oem_partconf() - Execute the OEM partconf command
*
* @cmd_parameter: Pointer to command parameter
* @response: Pointer to fastboot response buffer
*/
-static void oem_partconf(char *cmd_parameter, char *response)
+static void __maybe_unused oem_partconf(char *cmd_parameter, char *response)
{
char cmdbuf[32];
+ const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
+ CONFIG_FASTBOOT_FLASH_MMC_DEV, -1);
if (!cmd_parameter) {
fastboot_fail("Expected command parameter", response);
@@ -477,26 +456,25 @@ static void oem_partconf(char *cmd_parameter, char *response)
}
/* execute 'mmc partconfg' command with cmd_parameter arguments*/
- snprintf(cmdbuf, sizeof(cmdbuf), "mmc partconf %x %s 0",
- CONFIG_FASTBOOT_FLASH_MMC_DEV, cmd_parameter);
+ snprintf(cmdbuf, sizeof(cmdbuf), "mmc partconf %x %s 0", mmc_dev, cmd_parameter);
printf("Execute: %s\n", cmdbuf);
if (run_command(cmdbuf, 0))
fastboot_fail("Cannot set oem partconf", response);
else
fastboot_okay(NULL, response);
}
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
/**
* oem_bootbus() - Execute the OEM bootbus command
*
* @cmd_parameter: Pointer to command parameter
* @response: Pointer to fastboot response buffer
*/
-static void oem_bootbus(char *cmd_parameter, char *response)
+static void __maybe_unused oem_bootbus(char *cmd_parameter, char *response)
{
char cmdbuf[32];
+ const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
+ CONFIG_FASTBOOT_FLASH_MMC_DEV, -1);
if (!cmd_parameter) {
fastboot_fail("Expected command parameter", response);
@@ -504,12 +482,10 @@ static void oem_bootbus(char *cmd_parameter, char *response)
}
/* execute 'mmc bootbus' command with cmd_parameter arguments*/
- snprintf(cmdbuf, sizeof(cmdbuf), "mmc bootbus %x %s",
- CONFIG_FASTBOOT_FLASH_MMC_DEV, cmd_parameter);
+ snprintf(cmdbuf, sizeof(cmdbuf), "mmc bootbus %x %s", mmc_dev, cmd_parameter);
printf("Execute: %s\n", cmdbuf);
if (run_command(cmdbuf, 0))
fastboot_fail("Cannot set oem bootbus", response);
else
fastboot_okay(NULL, response);
}
-#endif
diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index ef399d0c4ab..7563650d07d 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -91,20 +91,21 @@ void fastboot_okay(const char *reason, char *response)
*/
int __weak fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
{
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
static const char * const boot_cmds[] = {
[FASTBOOT_REBOOT_REASON_BOOTLOADER] = "bootonce-bootloader",
[FASTBOOT_REBOOT_REASON_FASTBOOTD] = "boot-fastboot",
[FASTBOOT_REBOOT_REASON_RECOVERY] = "boot-recovery"
};
+ const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
+ CONFIG_FASTBOOT_FLASH_MMC_DEV, -1);
+
+ if (!CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC))
+ return -EINVAL;
if (reason >= FASTBOOT_REBOOT_REASONS_COUNT)
return -EINVAL;
- return bcb_write_reboot_reason(CONFIG_FASTBOOT_FLASH_MMC_DEV, "misc", boot_cmds[reason]);
-#else
- return -EINVAL;
-#endif
+ return bcb_write_reboot_reason(mmc_dev, "misc", boot_cmds[reason]);
}
/**
diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
index 018989dd166..2fbd285db38 100644
--- a/drivers/fastboot/fb_getvar.c
+++ b/drivers/fastboot/fb_getvar.c
@@ -21,15 +21,9 @@ static void getvar_version_baseband(char *var_parameter, char *response);
static void getvar_product(char *var_parameter, char *response);
static void getvar_platform(char *var_parameter, char *response);
static void getvar_current_slot(char *var_parameter, char *response);
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
static void getvar_has_slot(char *var_parameter, char *response);
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
static void getvar_partition_type(char *part_name, char *response);
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
static void getvar_partition_size(char *part_name, char *response);
-#endif
static void getvar_is_userspace(char *var_parameter, char *response);
static const struct {
@@ -84,7 +78,6 @@ static const struct {
}
};
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
/**
* Get partition number and size for any storage type.
*
@@ -102,28 +95,26 @@ static int getvar_get_part_info(const char *part_name, char *response,
size_t *size)
{
int r;
-# if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
struct blk_desc *dev_desc;
- struct disk_partition part_info;
-
- r = fastboot_mmc_get_part_info(part_name, &dev_desc, &part_info,
- response);
- if (r >= 0 && size)
- *size = part_info.size * part_info.blksz;
-# elif CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND)
+ struct disk_partition disk_part;
struct part_info *part_info;
- r = fastboot_nand_get_part_info(part_name, &part_info, response);
- if (r >= 0 && size)
- *size = part_info->size;
-# else
- fastboot_fail("this storage is not supported in bootloader", response);
- r = -ENODEV;
-# endif
+ if (CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)) {
+ r = fastboot_mmc_get_part_info(part_name, &dev_desc, &disk_part,
+ response);
+ if (r >= 0 && size)
+ *size = disk_part.size * disk_part.blksz;
+ } else if (CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND)) {
+ r = fastboot_nand_get_part_info(part_name, &part_info, response);
+ if (r >= 0 && size)
+ *size = part_info->size;
+ } else {
+ fastboot_fail("this storage is not supported in bootloader", response);
+ r = -ENODEV;
+ }
return r;
}
-#endif
static void getvar_version(char *var_parameter, char *response)
{
@@ -181,8 +172,7 @@ static void getvar_current_slot(char *var_parameter, char *response)
fastboot_okay("a", response);
}
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
-static void getvar_has_slot(char *part_name, char *response)
+static void __maybe_unused getvar_has_slot(char *part_name, char *response)
{
char part_name_wslot[PART_NAME_LEN];
size_t len;
@@ -213,10 +203,8 @@ static void getvar_has_slot(char *part_name, char *response)
fail:
fastboot_fail("invalid partition name", response);
}
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
-static void getvar_partition_type(char *part_name, char *response)
+static void __maybe_unused getvar_partition_type(char *part_name, char *response)
{
int r;
struct blk_desc *dev_desc;
@@ -232,10 +220,8 @@ static void getvar_partition_type(char *part_name, char *response)
fastboot_okay(fs_get_type_name(), response);
}
}
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
-static void getvar_partition_size(char *part_name, char *response)
+static void __maybe_unused getvar_partition_size(char *part_name, char *response)
{
int r;
size_t size;
@@ -244,7 +230,6 @@ static void getvar_partition_size(char *part_name, char *response)
if (r >= 0)
fastboot_response("OKAY", response, "0x%016zx", size);
}
-#endif
static void getvar_is_userspace(char *var_parameter, char *response)
{
diff --git a/drivers/reboot-mode/Kconfig b/drivers/reboot-mode/Kconfig
index 63ea18cdf09..d57baacc93d 100644
--- a/drivers/reboot-mode/Kconfig
+++ b/drivers/reboot-mode/Kconfig
@@ -30,4 +30,11 @@ config DM_REBOOT_MODE_RTC
a device in a specific mode by using a register(s) that can be controlled
outside U-Boot (e.g. Kernel).
+config REBOOT_MODE_NVMEM
+ bool "Use NVMEM reboot mode"
+ depends on DM_REBOOT_MODE && NVMEM
+ help
+ Use any kind of non-volatile memory (EEPROM, RTC, etc) to control the
+ reboot mode.
+
endmenu
diff --git a/drivers/reboot-mode/Makefile b/drivers/reboot-mode/Makefile
index 2c13780ced4..48c8ab7fe71 100644
--- a/drivers/reboot-mode/Makefile
+++ b/drivers/reboot-mode/Makefile
@@ -7,3 +7,4 @@
obj-$(CONFIG_DM_REBOOT_MODE) += reboot-mode-uclass.o
obj-$(CONFIG_DM_REBOOT_MODE_GPIO) += reboot-mode-gpio.o
obj-$(CONFIG_DM_REBOOT_MODE_RTC) += reboot-mode-rtc.o
+obj-$(CONFIG_REBOOT_MODE_NVMEM) += reboot-mode-nvmem.o
diff --git a/drivers/reboot-mode/reboot-mode-nvmem.c b/drivers/reboot-mode/reboot-mode-nvmem.c
new file mode 100644
index 00000000000..da41ca41d9a
--- /dev/null
+++ b/drivers/reboot-mode/reboot-mode-nvmem.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2022 Sean Anderson <sean.anderson@seco.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <nvmem.h>
+#include <reboot-mode/reboot-mode.h>
+
+/**
+ * struct nvmem_reboot_mode_priv - Private data for the nvmem reboot mode device
+ * @cell: The nvmem cell to store the mode in
+ */
+struct nvmem_reboot_mode_priv {
+ struct nvmem_cell cell;
+};
+
+static int reboot_mode_get(struct udevice *dev, u32 *mode)
+{
+ struct nvmem_reboot_mode_priv *priv = dev_get_priv(dev);
+
+ return nvmem_cell_read(&priv->cell, mode, sizeof(*mode));
+}
+
+static int reboot_mode_set(struct udevice *dev, u32 mode)
+{
+ struct nvmem_reboot_mode_priv *priv = dev_get_priv(dev);
+
+ return nvmem_cell_write(&priv->cell, &mode, sizeof(mode));
+}
+
+static const struct reboot_mode_ops nvmem_reboot_mode_ops = {
+ .get = reboot_mode_get,
+ .set = reboot_mode_set,
+};
+
+static int reboot_mode_probe(struct udevice *dev)
+{
+ struct nvmem_reboot_mode_priv *priv = dev_get_priv(dev);
+
+ return nvmem_cell_get_by_name(dev, "reboot-mode", &priv->cell);
+}
+
+static const struct udevice_id nvmem_reboot_mode_ids[] = {
+ { .compatible = "nvmem-reboot-mode" },
+ { }
+};
+
+U_BOOT_DRIVER(nvmem_reboot_mode) = {
+ .name = "nvmem-reboot-mode",
+ .id = UCLASS_REBOOT_MODE,
+ .of_match = nvmem_reboot_mode_ids,
+ .probe = reboot_mode_probe,
+ .priv_auto = sizeof(struct nvmem_reboot_mode_priv),
+ .ops = &nvmem_reboot_mode_ops,
+};
diff --git a/drivers/rtc/abx80x.c b/drivers/rtc/abx80x.c
index 528b06cbd69..823aff03f5f 100644
--- a/drivers/rtc/abx80x.c
+++ b/drivers/rtc/abx80x.c
@@ -17,6 +17,7 @@
#include <i2c.h>
#include <rtc.h>
#include <log.h>
+#include <linux/bitfield.h>
#define ABX8XX_REG_HTH 0x00
#define ABX8XX_REG_SC 0x01
@@ -88,6 +89,16 @@
#define ABX8XX_TRICKLE_STANDARD_DIODE 0x8
#define ABX8XX_TRICKLE_SCHOTTKY_DIODE 0x4
+#define ABX8XX_REG_EXTRAM 0x3f
+#define ABX8XX_EXTRAM_XADS GENMASK(1, 0)
+
+#define ABX8XX_SRAM_BASE 0x40
+#define ABX8XX_SRAM_WIN_SIZE 0x40U
+#define ABX8XX_RAM_SIZE 256
+
+#define RAM_ADDR_LOWER GENMASK(5, 0)
+#define RAM_ADDR_UPPER GENMASK(7, 6)
+
static u8 trickle_resistors[] = {0, 3, 6, 11};
enum abx80x_chip {AB0801, AB0803, AB0804, AB0805,
@@ -112,29 +123,52 @@ static struct abx80x_cap abx80x_caps[] = {
[ABX80X] = {.pn = 0}
};
-static int abx80x_rtc_read8(struct udevice *dev, unsigned int reg)
+static int abx80x_rtc_xfer(struct udevice *dev, unsigned int offset,
+ u8 *val, unsigned int bytes, bool write)
{
- int ret = 0;
- u8 buf;
+ int ret;
- if (reg > 0xff)
+ if (offset + bytes > ABX8XX_RAM_SIZE)
return -EINVAL;
- ret = dm_i2c_read(dev, reg, &buf, sizeof(buf));
- if (ret < 0)
- return ret;
+ while (bytes) {
+ u8 extram, reg, len, lower, upper;
+
+ lower = FIELD_GET(RAM_ADDR_LOWER, offset);
+ upper = FIELD_GET(RAM_ADDR_UPPER, offset);
+ extram = FIELD_PREP(ABX8XX_EXTRAM_XADS, upper);
+ reg = ABX8XX_SRAM_BASE + lower;
+ len = min(lower + bytes, ABX8XX_SRAM_WIN_SIZE) - lower;
+
+ ret = dm_i2c_reg_write(dev, ABX8XX_REG_EXTRAM, extram);
+ if (ret)
+ return ret;
+
+ if (write)
+ ret = dm_i2c_write(dev, reg, val, len);
+ else
+ ret = dm_i2c_read(dev, reg, val, len);
+ if (ret)
+ return ret;
+
+ offset += len;
+ val += len;
+ bytes -= len;
+ }
- return buf;
+ return 0;
}
-static int abx80x_rtc_write8(struct udevice *dev, unsigned int reg, int val)
+static int abx80x_rtc_read(struct udevice *dev, unsigned int offset, u8 *val,
+ unsigned int bytes)
{
- u8 buf = (u8)val;
-
- if (reg > 0xff)
- return -EINVAL;
+ return abx80x_rtc_xfer(dev, offset, val, bytes, false);
+}
- return dm_i2c_write(dev, reg, &buf, sizeof(buf));
+static int abx80x_rtc_write(struct udevice *dev, unsigned int offset,
+ const u8 *val, unsigned int bytes)
+{
+ return abx80x_rtc_xfer(dev, offset, (u8 *)val, bytes, true);
}
static int abx80x_is_rc_mode(struct udevice *dev)
@@ -334,9 +368,9 @@ static int abx80x_rtc_reset(struct udevice *dev)
static const struct rtc_ops abx80x_rtc_ops = {
.get = abx80x_rtc_read_time,
.set = abx80x_rtc_set_time,
- .reset = abx80x_rtc_reset,
- .read8 = abx80x_rtc_read8,
- .write8 = abx80x_rtc_write8
+ .reset = abx80x_rtc_reset,
+ .read = abx80x_rtc_read,
+ .write = abx80x_rtc_write,
};
static int abx80x_dt_trickle_cfg(struct udevice *dev)
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index b21031d7d81..a813a84a4f1 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -92,7 +92,8 @@ static int bind_service_list(struct udevice *dev, struct tee_shm *service_list,
if (!service)
continue;
- ret = device_bind_driver(dev, service->driver_name, service->driver_name, NULL);
+ ret = device_bind_driver_to_node(dev, service->driver_name, service->driver_name,
+ dev_ofnode(dev), NULL);
if (ret) {
dev_warn(dev, "%s was not bound: %d, ignored\n", service->driver_name, ret);
continue;
@@ -846,7 +847,8 @@ static int optee_probe(struct udevice *dev)
* Discovery of TAs on the TEE bus is not supported in U-Boot:
* only bind the drivers associated to the supported OP-TEE TA
*/
- ret = device_bind_driver(dev, "optee-rng", "optee-rng", NULL);
+ ret = device_bind_driver_to_node(dev, "optee-rng", "optee-rng",
+ dev_ofnode(dev), NULL);
if (ret)
dev_warn(dev, "ftpm_tee failed to bind: %d\n", ret);
}
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 07b1681c8a9..c6e7f424075 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -495,7 +495,6 @@ static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
do_exit_on_complete(ep, req);
}
-#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
static void do_acmd_complete(struct usb_ep *ep, struct usb_request *req)
{
/* When usb dequeue complete will be called
@@ -505,7 +504,6 @@ static void do_acmd_complete(struct usb_ep *ep, struct usb_request *req)
if (req->status == 0)
fastboot_acmd_complete();
}
-#endif
static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
{
@@ -546,11 +544,10 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
fastboot_func->in_req->complete = compl_do_reset;
g_dnl_trigger_detach();
break;
-#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
case FASTBOOT_COMMAND_ACMD:
- fastboot_func->in_req->complete = do_acmd_complete;
+ if (CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT))
+ fastboot_func->in_req->complete = do_acmd_complete;
break;
-#endif
}
}