From 43e6627259da3900a73f40fb2fe3a6f106c0e2d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Majewski?= Date: Thu, 23 Aug 2012 23:33:55 +0000 Subject: dfu:usb: Support for ext4 Support for ext4 file system handling at DFU. Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park Reviewed-by: Marek Vasut --- drivers/dfu/dfu_mmc.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c index 060145b..2270a61 100644 --- a/drivers/dfu/dfu_mmc.c +++ b/drivers/dfu/dfu_mmc.c @@ -63,10 +63,23 @@ static int mmc_file_op(enum dfu_mmc_op op, struct dfu_entity *dfu, char *str_env; int ret; - sprintf(cmd_buf, "fat%s mmc %d:%d 0x%x %s %lx", - op == DFU_OP_READ ? "load" : "write", - dfu->data.mmc.dev, dfu->data.mmc.part, - (unsigned int) buf, dfu->name, *len); + switch (dfu->layout) { + case DFU_FS_FAT: + sprintf(cmd_buf, "fat%s mmc %d:%d 0x%x %s %lx", + op == DFU_OP_READ ? "load" : "write", + dfu->data.mmc.dev, dfu->data.mmc.part, + (unsigned int) buf, dfu->name, *len); + break; + case DFU_FS_EXT4: + sprintf(cmd_buf, "ext4%s mmc %d:%d /%s 0x%x %ld", + op == DFU_OP_READ ? "load" : "write", + dfu->data.mmc.dev, dfu->data.mmc.part, + dfu->name, (unsigned int) buf, *len); + break; + default: + printf("%s: Layout (%s) not (yet) supported!\n", __func__, + dfu_get_layout(dfu->layout)); + } debug("%s: %s 0x%p\n", __func__, cmd_buf, cmd_buf); @@ -107,6 +120,7 @@ int dfu_write_medium_mmc(struct dfu_entity *dfu, void *buf, long *len) ret = mmc_block_write(dfu, buf, len); break; case DFU_FS_FAT: + case DFU_FS_EXT4: ret = mmc_file_write(dfu, buf, len); break; default: @@ -126,6 +140,7 @@ int dfu_read_medium_mmc(struct dfu_entity *dfu, void *buf, long *len) ret = mmc_block_read(dfu, buf, len); break; case DFU_FS_FAT: + case DFU_FS_EXT4: ret = mmc_file_read(dfu, buf, len); break; default: @@ -149,12 +164,17 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s) dfu->data.mmc.lba_blk_size = get_mmc_blk_size(dfu->dev_num); } else if (!strcmp(st, "fat")) { dfu->layout = DFU_FS_FAT; - dfu->data.mmc.dev = simple_strtoul(s, &s, 10); - dfu->data.mmc.part = simple_strtoul(++s, &s, 10); + } else if (!strcmp(st, "ext4")) { + dfu->layout = DFU_FS_EXT4; } else { printf("%s: Memory layout (%s) not supported!\n", __func__, st); } + if (dfu->layout == DFU_FS_EXT4 || dfu->layout == DFU_FS_FAT) { + dfu->data.mmc.dev = simple_strtoul(s, &s, 10); + dfu->data.mmc.part = simple_strtoul(++s, &s, 10); + } + dfu->read_medium = dfu_read_medium_mmc; dfu->write_medium = dfu_write_medium_mmc; -- cgit v1.1 From 81c1d7b605e1a48d3c02248c5e51fabcf42f5014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Majewski?= Date: Thu, 23 Aug 2012 23:33:56 +0000 Subject: dfu:usb:fix: Read the "filesize" environment variable only when file read The "filesize" environment variable shall be read only when relevant file is read. Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park Reviewed-by: Marek Vasut --- drivers/dfu/dfu_mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c index 2270a61..5d504df 100644 --- a/drivers/dfu/dfu_mmc.c +++ b/drivers/dfu/dfu_mmc.c @@ -89,7 +89,7 @@ static int mmc_file_op(enum dfu_mmc_op op, struct dfu_entity *dfu, return ret; } - if (dfu->layout != DFU_RAW_ADDR) { + if (dfu->layout != DFU_RAW_ADDR && op == DFU_OP_READ) { str_env = getenv("filesize"); if (str_env == NULL) { puts("dfu: Wrong file size!\n"); -- cgit v1.1 From 93ad908c43ed5d8e3e546dd22fa08b668c5090d9 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Thu, 6 Sep 2012 08:00:13 +0200 Subject: usb: do explicit unaligned accesses usb_hub_descriptor has to be packed as it's used for communication with the device. Member wHubCharacteristics violates the natural alignment rules. Use explicit unaligned access functions for this member. Fixes ARMv7 traping while using USB. v2: fix typo found by Thomas Langer v3: rebased on top of u-boot-usb/master Signed-off-by: Lucas Stach --- drivers/usb/host/ehci-hcd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 18b4bc6..392e286 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -22,6 +22,7 @@ */ #include #include +#include #include #include #include @@ -866,10 +867,12 @@ int usb_lowlevel_init(void) printf("Register %x NbrPorts %d\n", reg, descriptor.hub.bNbrPorts); /* Port Indicators */ if (HCS_INDICATOR(reg)) - descriptor.hub.wHubCharacteristics |= 0x80; + put_unaligned(get_unaligned(&descriptor.hub.wHubCharacteristics) + | 0x80, &descriptor.hub.wHubCharacteristics); /* Port Power Control */ if (HCS_PPC(reg)) - descriptor.hub.wHubCharacteristics |= 0x01; + put_unaligned(get_unaligned(&descriptor.hub.wHubCharacteristics) + | 0x01, &descriptor.hub.wHubCharacteristics); /* Start the host controller. */ cmd = ehci_readl(&hcor->or_usbcmd); -- cgit v1.1