FWU: Add FWU metadata access driver for MTD storage regions

In the FWU Multi Bank Update feature, the information about the
updatable images is stored as part of the metadata, on a separate
region. Add a driver for reading from and writing to the metadata
when the updatable images and the metadata are stored on a raw
MTD region.
The code is divided into core under drivers/fwu-mdata/ and some helper
functions clubbed together under lib/fwu_updates/

Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
This commit is contained in:
Masami Hiramatsu
2023-05-31 00:29:14 -05:00
committed by Tom Rini
parent 72168b929e
commit 4898679e19
6 changed files with 503 additions and 0 deletions

View File

@@ -8,6 +8,8 @@
#include <blk.h>
#include <efi.h>
#include <mtd.h>
#include <uuid.h>
#include <linux/types.h>
@@ -18,6 +20,12 @@ struct fwu_mdata_gpt_blk_priv {
struct udevice *blk_dev;
};
struct fwu_mtd_image_info {
u32 start, size;
int bank_num, image_num;
char uuidbuf[UUID_STR_LEN + 1];
};
struct fwu_mdata_ops {
/**
* read_mdata() - Populate the asked FWU metadata copy
@@ -251,4 +259,28 @@ u8 fwu_empty_capsule_checks_pass(void);
*/
int fwu_trial_state_ctr_start(void);
/**
* fwu_gen_alt_info_from_mtd() - Parse dfu_alt_info from metadata in mtd
* @buf: Buffer into which the dfu_alt_info is filled
* @len: Maximum characters that can be written in buf
* @mtd: Pointer to underlying MTD device
*
* Parse dfu_alt_info from metadata in mtd. Used for setting the env.
*
* Return: 0 if OK, -ve on error
*/
int fwu_gen_alt_info_from_mtd(char *buf, size_t len, struct mtd_info *mtd);
/**
* fwu_mtd_get_alt_num() - Mapping of fwu_plat_get_alt_num for MTD device
* @image_guid: Image GUID for which DFU alt number needs to be retrieved
* @alt_num: Pointer to the alt_num
* @mtd_dev: Name of mtd device instance
*
* To map fwu_plat_get_alt_num onto mtd based metadata implementation.
*
* Return: 0 if OK, -ve on error
*/
int fwu_mtd_get_alt_num(efi_guid_t *image_guid, u8 *alt_num, const char *mtd_dev);
#endif /* _FWU_H_ */