1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-10-27 00:24:09 +01:00

drivers: introduce mtdblock abstraction

MTD block - abstraction over MTD subsystem, allowing
to read and write in blocks using BLK UCLASS.

Signed-off-by: Alexey Romanov <avromanov@salutedevices.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
This commit is contained in:
Alexey Romanov
2024-07-18 08:46:05 +03:00
committed by Michael Trimarchi
parent c29a6daec1
commit e108d10d8c
5 changed files with 262 additions and 0 deletions

View File

@@ -26,6 +26,7 @@
#include <dm/device.h>
#endif
#include <dm/ofnode.h>
#include <blk.h>
#define MAX_MTD_DEVICES 32
#endif
@@ -412,6 +413,30 @@ int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
const u_char *buf);
#if CONFIG_IS_ENABLED(MTD_BLOCK)
static inline struct mtd_info *blk_desc_to_mtd(struct blk_desc *bdesc)
{
void *priv = dev_get_priv(bdesc->bdev);
if (!priv)
return NULL;
return *((struct mtd_info **)priv);
}
int mtd_bind(struct udevice *dev, struct mtd_info **mtd);
#else
static inline struct mtd_info *blk_desc_to_mtd(struct blk_desc *bdesc)
{
return NULL;
}
static inline int mtd_bind(struct udevice *dev, struct mtd_info **mtd)
{
return -EOPNOTSUPP;
}
#endif
int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
int mtd_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);