aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authordeadprogram <[email protected]>2023-09-11 21:57:25 +0200
committerRon Evans <[email protected]>2023-09-12 08:41:58 +0200
commitc4de195f04eac0f9764615cb567339de9a14fcb1 (patch)
treedc8d9a802ed8cc098ed2006f8b21cb724198fbda /src
parent75aca0f5eea5f93bd16a5369ca3f817bad4be6a1 (diff)
downloadtinygo-c4de195f04eac0f9764615cb567339de9a14fcb1.tar.gz
tinygo-c4de195f04eac0f9764615cb567339de9a14fcb1.zip
machine/rp2040: always use the USB device enum fix, even in chips that supposedly have the HW fix.
Additionally, correct the amount of time spent waiting after USB reset, based on advice from @sago35 Signed-off-by: deadprogram <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/machine/machine_rp2040_usb_fix_usb_device_enumeration.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/machine/machine_rp2040_usb_fix_usb_device_enumeration.go b/src/machine/machine_rp2040_usb_fix_usb_device_enumeration.go
index eedcc4d21..f027f9424 100644
--- a/src/machine/machine_rp2040_usb_fix_usb_device_enumeration.go
+++ b/src/machine/machine_rp2040_usb_fix_usb_device_enumeration.go
@@ -8,21 +8,21 @@ import (
)
// https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c
+// According to errata RP2040-E5:
+// "It is safe (and inexpensive) to enable the software workaround even when using versions of RP2040
+// which include the fix in hardware."
+// So let us always use the software fix.
func fixRP2040UsbDeviceEnumeration() {
-
- // Actually check for B0/B1 h/w
- if ChipVersion() == 1 {
- // After coming out of reset, the hardware expects 800us of LS_J (linestate J) time
- // before it will move to the connected state. However on a hub that broadcasts packets
- // for other devices this isn't the case. The plan here is to wait for the end of the bus
- // reset, force an LS_J for 1ms and then switch control back to the USB phy. Unfortunately
- // this requires us to use GPIO15 as there is no other way to force the input path.
- // We only need to force DP as DM can be left at zero. It will be gated off by GPIO
- // logic if it isn't func selected.
-
- // Wait SE0 phase will call force ls_j phase which will call finish phase
- hw_enumeration_fix_wait_se0()
- }
+ // After coming out of reset, the hardware expects 800us of LS_J (linestate J) time
+ // before it will move to the connected state. However on a hub that broadcasts packets
+ // for other devices this isn't the case. The plan here is to wait for the end of the bus
+ // reset, force an LS_J for 1ms and then switch control back to the USB phy. Unfortunately
+ // this requires us to use GPIO15 as there is no other way to force the input path.
+ // We only need to force DP as DM can be left at zero. It will be gated off by GPIO
+ // logic if it isn't func selected.
+
+ // Wait SE0 phase will call force ls_j phase which will call finish phase
+ hw_enumeration_fix_wait_se0()
}
func hw_enumeration_fix_wait_se0() {
@@ -87,8 +87,8 @@ func hw_enumeration_fix_force_ls_j() {
// Switch to GPIO phy with LS_J forced
rp.USBCTRL_REGS.USB_MUXING.Set(rp.USBCTRL_REGS_USB_MUXING_TO_DIGITAL_PAD | rp.USBCTRL_REGS_USB_MUXING_SOFTCON)
- // LS_J is now forced but while loop here just to check
- waitCycles(125000)
+ // LS_J is now forced but while loop to wait ~800us here just to check
+ waitCycles(25000)
// if timer pool disabled, or no timer available, have to busy wait.
hw_enumeration_fix_finish()