Browse Source

提高升级时U盘兼容性

huangliang 1 year ago
parent
commit
52fb131a8e

+ 0 - 1
u-boot/common/usb.c

@@ -70,7 +70,6 @@ int usb_init(void)
 		memset(&usb_dev[i], 0, sizeof(struct usb_device));
 		usb_dev[i].devnum = -1;
 	}
-
 	/* init low_level USB */
 	for (i = 0; i < CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
 		/* init low_level USB */

+ 2 - 0
u-boot/disk/part.c

@@ -590,6 +590,8 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 	if (part == PART_UNSPECIFIED)
 		part = 1;
 
+		part = PART_AUTO;
+
 	/*
 	 * If user didn't specify a partition number, or did specify something
 	 * other than "auto", use that partition number directly.

+ 39 - 1
u-boot/disk/part_dos.c

@@ -58,7 +58,7 @@ static void print_one_part(dos_partition_t *p, lbaint_t ext_part_sector,
 		(is_extended(p->sys_ind) ? " Extd" : ""),
 		(is_bootable(p) ? " Boot" : ""));
 }
-
+#if 0
 static int test_block_type(unsigned char *buffer)
 {
 	int slot;
@@ -87,7 +87,45 @@ static int test_block_type(unsigned char *buffer)
 	}
 	return DOS_MBR;	    /* Is MBR */
 }
+#else
+static int test_block_type(unsigned char *buffer)
+{
+	int slot;
+	struct dos_partition *p;
+	int part_count = 0;
 
+	if((buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
+	    (buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) ) {
+		return (-1);
+	} /* no DOS Signature at all */
+	p = (struct dos_partition *)&buffer[DOS_PART_TBL_OFFSET];
+
+	/* Check that the boot indicators are valid and count the partitions. */
+	for (slot = 0; slot < 4; ++slot, ++p) {
+		if (p->boot_ind != 0 && p->boot_ind != 0x80)
+			break;
+		if (p->sys_ind)
+			++part_count;
+	}
+
+	/*
+	 * If the partition table is invalid or empty,
+	 * check if this is a DOS PBR
+	 */
+	if (slot != 4 || !part_count) {
+		if (!strncmp((char *)&buffer[DOS_PBR_FSTYPE_OFFSET],
+			     "FAT", 3) ||
+		    !strncmp((char *)&buffer[DOS_PBR32_FSTYPE_OFFSET],
+			     "FAT32", 5))
+			return DOS_PBR; /* This is a DOS PBR and not an MBR */
+	}
+	if (slot == 4)
+		return DOS_MBR;	/* This is an DOS MBR */
+
+	/* This is neither a DOS MBR nor a DOS PBR */
+	return -1;
+}
+#endif
 
 static int part_test_dos(struct blk_desc *dev_desc)
 {

+ 10 - 5
u-boot/drivers/usb/musb-new/ark_musb.c

@@ -1,24 +1,29 @@
 #include "musb_core.h"
-
+#define rSYS_SOFT_RSTNA			*((volatile unsigned int *)(0xe4900074))
+void ark_usb_controller_reset(void)
+{
+	printf("ark_usb_phy_reset\n");
+	rSYS_SOFT_RSTNA &= ~(3 << 5);
+	udelay(100);
+	rSYS_SOFT_RSTNA |= 3 << 5;
+	udelay(10);
+}
 static int ark_musb_init(struct musb *musb)
 {
 	return 0;
 }
-
 static int ark_musb_enable(struct musb *musb)
 {
 	return 0;
 }
-
 static void ark_musb_disable(struct musb *musb)
 {
-}
 
+}
 static int ark_musb_exit(struct musb *musb)
 {
 	return 0;
 }
-
 const struct musb_platform_ops ark_musb_ops = {
 	.init		= ark_musb_init,
 	.exit		= ark_musb_exit,

+ 6 - 9
u-boot/drivers/usb/musb-new/musb_uboot.c

@@ -4,7 +4,6 @@
 #include <linux/errno.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
-
 #include <usb.h>
 #include "linux-compat.h"
 #include "usb-compat.h"
@@ -12,13 +11,11 @@
 #include "musb_host.h"
 #include "musb_gadget.h"
 #include "musb_uboot.h"
-
 #ifdef CONFIG_USB_MUSB_HOST
 struct int_queue {
 	struct usb_host_endpoint hep;
 	struct urb urb;
 };
-
 #ifndef CONFIG_DM_USB
 struct musb_host_data musb_host;
 #endif
@@ -155,7 +152,7 @@ static struct int_queue *_musb_create_int_queue(struct musb_host_data *host,
 static int _musb_destroy_int_queue(struct musb_host_data *host,
 	struct usb_device *dev, struct int_queue *queue)
 {
-	int index = usb_pipein(queue->urb.pipe) * 16 + 
+	int index = usb_pipein(queue->urb.pipe) * 16 +
 		    usb_pipeendpoint(queue->urb.pipe);
 
 	if (queue->urb.status == -EINPROGRESS)
@@ -209,19 +206,20 @@ static int _musb_reset_root_port(struct musb_host_data *host,
 
 	return 0;
 }
-
+extern void ark_usb_controller_reset(void);
 int musb_lowlevel_init(struct musb_host_data *host)
 {
 	void *mbase;
+	unsigned int timedelay = 2000;
 	/* USB spec says it may take up to 1 second for a device to connect */
-	unsigned long timeout = get_timer(0) + 1000;
+	unsigned long timeout = get_timer(0) + /*1000*/timedelay;
 	int ret;
 
 	if (!host->host) {
 		printf("MUSB host is not registered\n");
 		return -ENODEV;
 	}
-
+	ark_usb_controller_reset();
 	ret = musb_start(host->host);
 	if (ret)
 		return ret;
@@ -233,16 +231,15 @@ int musb_lowlevel_init(struct musb_host_data *host)
 	} while (get_timer(0) < timeout);
 	if (get_timer(0) >= timeout) {
 		musb_stop(host->host);
+		printf(">>>>>>>timeout delay = %d\n",timedelay);
 		return -ENODEV;
 	}
-
 	_musb_reset_root_port(host, NULL);
 	host->host->is_active = 1;
 	host->hcd.hcd_priv = host->host;
 
 	return 0;
 }
-
 #ifndef CONFIG_DM_USB
 int usb_lowlevel_stop(int index)
 {