Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize synopsys dwc2 #1163

Merged
merged 53 commits into from
Nov 4, 2021
Merged

Generalize synopsys dwc2 #1163

merged 53 commits into from
Nov 4, 2021

Conversation

hathach
Copy link
Owner

@hathach hathach commented Oct 25, 2021

Describe the PR
Generalize Synopsys DWC2 driver. New driver is at synopsys/dwc2 For the time being, application can still pick the existing driver e.g st/synopsys/dcd_synopsys.c for stm32. Using this generalized driver is user choice until proven reliably.

MCUs that use DWC2

  • ST STM32 (F4, F7, H7 etc ..) OTG
  • Espressif ESP32 S2/S3
  • Giga GDVF103
  • Silabs EFM32
  • Broadcom bcm28/27 on RPi

Ref: linux driver for dwc https://github.com/torvalds/linux/tree/master/drivers/usb/dwc2

…t calibration.

still has issue with gd32 with msc (does work with running with rtt as
log).
merge GG12 GG12 to simply OPT_MCU_EFM32GG
@hathach hathach marked this pull request as ready for review October 30, 2021 13:50
@hathach
Copy link
Owner Author

hathach commented Nov 3, 2021

somehow the example (cdc_msc) does not work with latest broadcom peripherals since commit

I have tried poking around and making modification where I think it could help. It seems usb phy is initialized but IRQ is not triggered. This proves to be too much knowledge for me digest.

@tannewt
Copy link
Collaborator

tannewt commented Nov 3, 2021

From what I can tell this is a caching issue, not an interrupt one. The first gig of memory is marked as cachable now. If I change it to non-cacheable then the problem goes away. Does the DWC write to or read from any memory directly? It would need to be invalidated or cleaned if so.

diff --git a/broadcom/mmu.c b/broadcom/mmu.c
index 098c728..3eefaac 100644
--- a/broadcom/mmu.c
+++ b/broadcom/mmu.c
@@ -24,7 +24,7 @@ void setup_mmu_flat_map(void) {
     for (uint64_t i = 1; i < 512 - 8; i++) {
         level_2_0x0_0000_0000_to_0x0_4000_0000[i] = (0x0000000000000000 + (i << 21)) |
                                                     MM_DESCRIPTOR_EXECUTE_NEVER |
-                                                    MM_DESCRIPTOR_MAIR_INDEX(MT_READONLY) |
+                                                    MM_DESCRIPTOR_MAIR_INDEX(MT_NORMAL_NC) |
                                                     MM_DESCRIPTOR_INNER_SHAREABLE |
                                                     MM_DESCRIPTOR_ACCESS_FLAG |
                                                     MM_DESCRIPTOR_BLOCK |

@hathach
Copy link
Owner Author

hathach commented Nov 4, 2021

thanks @tannewt for looking into this, I thought of the cache as well, did a quick check but didn't see any shared memory between cpu and usb. I could miss something, will poke more at that direction. thanks for looking into this 👍 👍

…t_enable90

also add hwcfg_list for reference
this get usb irq triggered even without ISB() in previous commit
@hathach
Copy link
Owner Author

hathach commented Nov 4, 2021

Thanks to Scott hint, I have narrowed it down to

It probably needs more efforts and knowledge to understand the reason behind this, for now I am happy with adding ISB() to dwc2_dcd_int_enable(). since the PRs has been quite lengthy with lots of commits. We should merge it now and come back to this later if it is an issue.


TU_ATTR_ALWAYS_INLINE
static inline void dwc2_dcd_int_enable(uint8_t rhport)
{
(void) rhport;
BP_EnableIRQ(USB_IRQn);
__asm__ volatile("isb");
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mentioned in #1163 (comment)

// Timer 1/1024 second tick
SYSTMR->CS_b.M1 = 1;
SYSTMR->C1 = SYSTMR->CLO + 977;
BP_EnableIRQ(TIMER_1_IRQn);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mentioned in #1163 (comment)

@hathach hathach merged commit fc59515 into master Nov 4, 2021
@hathach hathach deleted the generalize-synopsys-dwc2 branch November 4, 2021 06:41
This was referenced Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BCM283x (Raspberry Pi chip) Support Generalize Synopsys DCD/HCD Port STM32 L4
2 participants