X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=drivers%2Fdfu%2Fdfu.c;h=a298c2c43999bd0970ba3e7ac55bbb554a97a890;hb=HEAD;hp=8bd5216017a5689f544266b2f85a81f88e6cc2ab;hpb=febabe3ed4f422a39e461ba4c2aff5f0fde6e4d2;p=oweals%2Fu-boot.git diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index 8bd5216017..a298c2c439 100644 --- a/drivers/dfu/dfu.c +++ b/drivers/dfu/dfu.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,25 @@ static LIST_HEAD(dfu_list); static int dfu_alt_num; static int alt_num_cnt; static struct hash_algo *dfu_hash_algo; +#ifdef CONFIG_DFU_TIMEOUT +static unsigned long dfu_timeout = 0; +#endif + +/* + * The purpose of the dfu_flush_callback() function is to + * provide callback for dfu user + */ +__weak void dfu_flush_callback(struct dfu_entity *dfu) +{ +} + +/* + * The purpose of the dfu_initiated_callback() function is to + * provide callback for dfu user + */ +__weak void dfu_initiated_callback(struct dfu_entity *dfu) +{ +} /* * The purpose of the dfu_usb_get_reset() function is to @@ -42,6 +62,18 @@ __weak bool dfu_usb_get_reset(void) #endif } +#ifdef CONFIG_DFU_TIMEOUT +void dfu_set_timeout(unsigned long timeout) +{ + dfu_timeout = timeout; +} + +unsigned long dfu_get_timeout(void) +{ + return dfu_timeout; +} +#endif + static int dfu_find_alt_num(const char *s) { int i = 0; @@ -263,6 +295,7 @@ int dfu_transaction_initiate(struct dfu_entity *dfu, bool read) } dfu->inited = 1; + dfu_initiated_callback(dfu); return 0; } @@ -282,6 +315,8 @@ int dfu_flush(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) printf("\nDFU complete %s: 0x%08x\n", dfu_hash_algo->name, dfu->crc); + dfu_flush_callback(dfu); + dfu_transaction_cleanup(dfu); return ret; @@ -396,6 +431,8 @@ static int dfu_read_buffer_fill(struct dfu_entity *dfu, void *buf, int size) debug("%s: Read error!\n", __func__); return ret; } + if (dfu->b_left == 0) + break; dfu->offset += dfu->b_left; dfu->r_left -= dfu->b_left; @@ -460,6 +497,9 @@ static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt, if (strcmp(interface, "mmc") == 0) { if (dfu_fill_entity_mmc(dfu, devstr, s)) return -1; + } else if (strcmp(interface, "mtd") == 0) { + if (dfu_fill_entity_mtd(dfu, devstr, s)) + return -1; } else if (strcmp(interface, "nand") == 0) { if (dfu_fill_entity_nand(dfu, devstr, s)) return -1; @@ -469,6 +509,9 @@ static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt, } else if (strcmp(interface, "sf") == 0) { if (dfu_fill_entity_sf(dfu, devstr, s)) return -1; + } else if (strcmp(interface, "virt") == 0) { + if (dfu_fill_entity_virt(dfu, devstr, s)) + return -1; } else { printf("%s: Device %s not (yet) supported!\n", __func__, interface); @@ -564,7 +607,7 @@ int dfu_config_entities(char *env, char *interface, char *devstr) const char *dfu_get_dev_type(enum dfu_device_type t) { const char *const dev_t[] = {NULL, "eMMC", "OneNAND", "NAND", "RAM", - "SF"}; + "SF", "MTD", "VIRT"}; return dev_t[t]; }