vbe: Add a bootmeth driver for abrec
Add a VBE-ABrec bootmeth so that the VBE state can be accessed. Series-changes: 2 - Add new patch with a bootmeth driver for abrec Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#define LOG_CATEGORY LOGC_BOOT
|
||||
|
||||
#include <bootmeth.h>
|
||||
#include <dm.h>
|
||||
#include <memalign.h>
|
||||
#include <mmc.h>
|
||||
@@ -81,3 +82,101 @@ int abrec_read_state(struct udevice *dev, struct abrec_state *state)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vbe_abrec_get_state_desc(struct udevice *dev, char *buf,
|
||||
int maxsize)
|
||||
{
|
||||
struct abrec_state state;
|
||||
int ret;
|
||||
|
||||
ret = abrec_read_state(dev, &state);
|
||||
if (ret)
|
||||
return log_msg_ret("read", ret);
|
||||
|
||||
if (maxsize < 30)
|
||||
return -ENOSPC;
|
||||
snprintf(buf, maxsize, "Version: %s\nVernum: %x/%x", state.fw_version,
|
||||
state.fw_vernum >> FWVER_KEY_SHIFT,
|
||||
state.fw_vernum & FWVER_FW_MASK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vbe_abrec_read_bootflow(struct udevice *dev, struct bootflow *bflow)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (CONFIG_IS_ENABLED(BOOTMETH_VBE_ABREC_FW)) {
|
||||
if (vbe_phase() == VBE_PHASE_FIRMWARE) {
|
||||
ret = abrec_read_bootflow_fw(dev, bflow);
|
||||
if (ret)
|
||||
return log_msg_ret("fw", ret);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int vbe_abrec_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||
const char *file_path, ulong addr,
|
||||
enum bootflow_img_t type, ulong *sizep)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (vbe_phase() == VBE_PHASE_OS) {
|
||||
ret = bootmeth_common_read_file(dev, bflow, file_path, addr,
|
||||
type, sizep);
|
||||
if (ret)
|
||||
return log_msg_ret("os", ret);
|
||||
}
|
||||
|
||||
/* To be implemented */
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static struct bootmeth_ops bootmeth_vbe_abrec_ops = {
|
||||
.get_state_desc = vbe_abrec_get_state_desc,
|
||||
.read_bootflow = vbe_abrec_read_bootflow,
|
||||
.read_file = vbe_abrec_read_file,
|
||||
};
|
||||
|
||||
static int bootmeth_vbe_abrec_probe(struct udevice *dev)
|
||||
{
|
||||
struct abrec_priv *priv = dev_get_priv(dev);
|
||||
int ret;
|
||||
|
||||
ret = abrec_read_priv(dev_ofnode(dev), priv);
|
||||
if (ret)
|
||||
return log_msg_ret("abp", ret);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bootmeth_vbe_abrec_bind(struct udevice *dev)
|
||||
{
|
||||
struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
|
||||
|
||||
plat->desc = "VBE A/B/recovery";
|
||||
plat->flags = BOOTMETHF_GLOBAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(OF_REAL)
|
||||
static const struct udevice_id generic_simple_vbe_abrec_ids[] = {
|
||||
{ .compatible = "fwupd,vbe-abrec" },
|
||||
{ }
|
||||
};
|
||||
#endif
|
||||
|
||||
U_BOOT_DRIVER(vbe_abrec) = {
|
||||
.name = "vbe_abrec",
|
||||
.id = UCLASS_BOOTMETH,
|
||||
.of_match = of_match_ptr(generic_simple_vbe_abrec_ids),
|
||||
.ops = &bootmeth_vbe_abrec_ops,
|
||||
.bind = bootmeth_vbe_abrec_bind,
|
||||
.probe = bootmeth_vbe_abrec_probe,
|
||||
.flags = DM_FLAG_PRE_RELOC,
|
||||
.priv_auto = sizeof(struct abrec_priv),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user