Change in simtrace2[master]: USB: increase USB reset time

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Kévin Redon gerrit-no-reply at lists.osmocom.org
Mon Aug 6 16:10:20 UTC 2018


Kévin Redon has uploaded this change for review. ( https://gerrit.osmocom.org/10360


Change subject: USB: increase USB reset time
......................................................................

USB: increase USB reset time

USB reset can be signaled by pulling low USB D+ for at least 10 ms,
according to the USB specification. This force a re-enumeration.
This time is increased to 20 ms to work with more USB HUBs.

Some SAM3S based board have external D+ pull-up mechanism (such as
SIMtrace) which needs to be used to pull D+ low.
This is a legacy mechanism from SAM7S history.
This mechanism is not required anymore on the SAM3S, and the qmod
does not use it. In this case D+ can be pulled low using PIO.
This board difference is not defined on the board header.

Change-Id: I9b58d8101c2fcf5595026b675728826af26127a3
---
M firmware/apps/dfu/main.c
M firmware/libboard/common/include/board_common.h
M firmware/libboard/simtrace/include/board.h
M firmware/libcommon/source/usb.c
4 files changed, 26 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/60/10360/1

diff --git a/firmware/apps/dfu/main.c b/firmware/apps/dfu/main.c
index 74268ad..9dd06ec 100644
--- a/firmware/apps/dfu/main.c
+++ b/firmware/apps/dfu/main.c
@@ -294,11 +294,21 @@
 
 	TRACE_INFO("USB init...\n\r");
 	/* Signal USB reset by disabling the pull-up on USB D+ for at least 10 ms */
+#ifdef PIN_USB_PULLUP
 	const Pin usb_dp_pullup = PIN_USB_PULLUP;
 	PIO_Configure(&usb_dp_pullup, 1);
 	PIO_Set(&usb_dp_pullup);
-	mdelay(15);
+#endif
+
+	const Pin usb_dp = {PIO_PB11, PIOB, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT};
+	PIO_Configure(&usb_dp, 1);
+	PIO_Clear(&usb_dp);
+	mdelay(20);
+
+#ifdef PIN_USB_PULLUP
 	PIO_Clear(&usb_dp_pullup);
+#endif
+
 	USBDFU_Initialize(&dfu_descriptors);
 
 	while (USBD_GetState() < USBD_STATE_CONFIGURED) {
diff --git a/firmware/libboard/common/include/board_common.h b/firmware/libboard/common/include/board_common.h
index 06d3d6a..1b29680 100644
--- a/firmware/libboard/common/include/board_common.h
+++ b/firmware/libboard/common/include/board_common.h
@@ -114,15 +114,8 @@
 #define SIM_PWEN        PIO_PA5
 #define VCC_FWD         PIO_PA26
 
-/** Pin configuration to control USB pull-up on D+
- *  @details the USB pull-up on D+ is enable by default on the board but can be disabled by setting PA16 high
- */
-#define PIN_USB_PULLUP  {PIO_PA16, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
-
 // Board has UDP controller
 #define BOARD_USB_UDP
-// D+ has external pull-up
-#define BOARD_USB_PULLUP_EXTERNAL
 
 #define BOARD_USB_DFU
 #define BOARD_DFU_BOOT_SIZE	(16 * 1024)
diff --git a/firmware/libboard/simtrace/include/board.h b/firmware/libboard/simtrace/include/board.h
index db3a925..6751863 100644
--- a/firmware/libboard/simtrace/include/board.h
+++ b/firmware/libboard/simtrace/include/board.h
@@ -117,6 +117,11 @@
 /* SPI flash write protect pin (active low, pulled low) */
 #define PIN_SPI_WP    {PA15, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
 
+/** Pin configuration to control USB pull-up on D+
+ *  @details the USB pull-up on D+ is enable by default on the board but can be disabled by setting PA16 high
+ */
+#define PIN_USB_PULLUP  {PIO_PA16, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
+
 /** USB definitions */
 /* OpenMoko SIMtrace 2 USB vendor ID */
 #define BOARD_USB_VENDOR_ID	USB_VENDOR_OPENMOKO
diff --git a/firmware/libcommon/source/usb.c b/firmware/libcommon/source/usb.c
index e929a05..2864860 100644
--- a/firmware/libcommon/source/usb.c
+++ b/firmware/libcommon/source/usb.c
@@ -576,11 +576,20 @@
 {
 
 	/* Signal USB reset by disabling the pull-up on USB D+ for at least 10 ms */
+#ifdef PIN_USB_PULLUP
 	const Pin usb_dp_pullup = PIN_USB_PULLUP;
 	PIO_Configure(&usb_dp_pullup, 1);
 	PIO_Set(&usb_dp_pullup);
-	mdelay(15);
+#endif
+
+	const Pin usb_dp = {PIO_PB11, PIOB, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT};
+	PIO_Configure(&usb_dp, 1);
+	PIO_Clear(&usb_dp);
+	mdelay(20);
+
+#ifdef PIN_USB_PULLUP
 	PIO_Clear(&usb_dp_pullup);
+#endif
 
 	// Get std USB driver
 	USBDDriver *pUsbd = USBD_GetDriver();

-- 
To view, visit https://gerrit.osmocom.org/10360
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b58d8101c2fcf5595026b675728826af26127a3
Gerrit-Change-Number: 10360
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon <kredon at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180806/744b01a1/attachment.htm>


More information about the gerrit-log mailing list