summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-imx/imx-bbu-internal.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-11-29 10:24:50 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-12-06 13:43:29 +0100
commit8e9a1d99437cff633e370677faa782604fa39238 (patch)
tree9103916d7fc12898ff1fa6974d573b655d83e648 /arch/arm/mach-imx/imx-bbu-internal.c
parent1ad78f3c80ff1ff4ed0e0f3fa793cc930ab0c7de (diff)
downloadbarebox-8e9a1d99437cff633e370677faa782604fa39238.tar.gz
barebox-8e9a1d99437cff633e370677faa782604fa39238.tar.xz
ARM i.MX bbu internal: Add spi/i2c support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-imx/imx-bbu-internal.c')
-rw-r--r--arch/arm/mach-imx/imx-bbu-internal.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index e84a1e0611..43f188d710 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -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);
@@ -544,6 +556,32 @@ int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
}
/*
+ * 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
*/
int imx53_bbu_internal_nand_register_handler(const char *name,
@@ -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);
+}