ARM i.MX bbu internal: Add spi/i2c support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
1ad78f3c80
commit
8e9a1d9943
|
@ -36,6 +36,7 @@
|
|||
|
||||
#define IMX_INTERNAL_FLAG_NAND (1 << 0)
|
||||
#define IMX_INTERNAL_FLAG_KEEP_DOSPART (1 << 1)
|
||||
#define IMX_INTERNAL_FLAG_ERASE (1 << 2)
|
||||
|
||||
struct imx_internal_bbu_handler {
|
||||
struct bbu_handler handler;
|
||||
|
@ -60,6 +61,17 @@ static int imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler,
|
|||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
if (imx_handler->flags & IMX_INTERNAL_FLAG_ERASE) {
|
||||
debug("%s: eraseing %s from 0 to 0x%08x\n", __func__,
|
||||
data->devicefile, image_len);
|
||||
ret = erase(fd, image_len, 0);
|
||||
if (ret) {
|
||||
printf("erasing %s failed with %s\n", data->devicefile,
|
||||
strerror(-ret));
|
||||
goto err_close;
|
||||
}
|
||||
}
|
||||
|
||||
if (imx_handler->flags & IMX_INTERNAL_FLAG_KEEP_DOSPART) {
|
||||
void *mbr = xzalloc(512);
|
||||
|
||||
|
@ -543,6 +555,32 @@ int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
|
|||
return __register_handler(imx_handler);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register a i.MX53 internal boot update handler for i2c/spi
|
||||
* EEPROMs / flashes. Nearly the same as MMC/SD, but we do not need to
|
||||
* keep a partition table. We have to erase the device beforehand though.
|
||||
*/
|
||||
int imx53_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
|
||||
unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
|
||||
unsigned long app_dest)
|
||||
{
|
||||
struct imx_internal_bbu_handler *imx_handler;
|
||||
|
||||
imx_handler = __init_handler(name, devicefile, flags);
|
||||
imx53_bbu_internal_init_dcd(imx_handler, dcd, dcdsize);
|
||||
imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
|
||||
|
||||
if (app_dest)
|
||||
imx_handler->app_dest = app_dest;
|
||||
else
|
||||
imx_handler->app_dest = 0x70000000;
|
||||
|
||||
imx_handler->flags = IMX_INTERNAL_FLAG_ERASE;
|
||||
imx_handler->handler.handler = imx_bbu_internal_v2_update;
|
||||
|
||||
return __register_handler(imx_handler);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register a i.MX53 internal boot update handler for NAND
|
||||
*/
|
||||
|
@ -582,3 +620,19 @@ int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
|
|||
return imx53_bbu_internal_mmc_register_handler(name, devicefile,
|
||||
flags, dcd, dcdsize, app_dest);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register a i.MX53 internal boot update handler for i2c/spi
|
||||
* EEPROMs / flashes. Nearly the same as MMC/SD, but we do not need to
|
||||
* keep a partition table. We have to erase the device beforehand though.
|
||||
*/
|
||||
int imx6_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
|
||||
unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
|
||||
unsigned long app_dest)
|
||||
{
|
||||
if (!app_dest)
|
||||
app_dest = 0x10000000;
|
||||
|
||||
return imx53_bbu_internal_spi_i2c_register_handler(name, devicefile,
|
||||
flags, dcd, dcdsize, app_dest);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,10 @@ int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
|
|||
unsigned long flags, struct imx_dcd_v2_entry *, int dcdsize,
|
||||
unsigned long app_dest);
|
||||
|
||||
int imx53_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
|
||||
unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
|
||||
unsigned long app_dest);
|
||||
|
||||
int imx53_bbu_internal_nand_register_handler(const char *name,
|
||||
unsigned long flags, struct imx_dcd_v2_entry *, int dcdsize,
|
||||
int partition_size, unsigned long app_dest);
|
||||
|
@ -24,6 +28,10 @@ int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
|
|||
unsigned long flags, struct imx_dcd_v2_entry *, int dcdsize,
|
||||
unsigned long app_dest);
|
||||
|
||||
int imx6_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
|
||||
unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
|
||||
unsigned long app_dest);
|
||||
|
||||
#else
|
||||
|
||||
static inline int imx51_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
|
||||
|
@ -40,6 +48,13 @@ static inline int imx53_bbu_internal_mmc_register_handler(const char *name, char
|
|||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int imx53_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
|
||||
unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
|
||||
unsigned long app_dest)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int imx53_bbu_internal_nand_register_handler(const char *name,
|
||||
unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
|
||||
int partition_size, unsigned long app_dest)
|
||||
|
@ -54,6 +69,13 @@ static inline int imx6_bbu_internal_mmc_register_handler(const char *name, char
|
|||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int imx6_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
|
||||
unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
|
||||
unsigned long app_dest)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
struct dcd_table {
|
||||
|
|
Loading…
Reference in New Issue