-
Notifications
You must be signed in to change notification settings - Fork 9.1k
drivers: usb: udc: dwc3: initial implementation #84544
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
Draft
josuah
wants to merge
1
commit into
zephyrproject-rtos:main
Choose a base branch
from
tinyvision-ai-inc:pr-dwc3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # SPDX-FileCopyrightText: Copyright tinyVision.ai Inc. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| config UDC_DWC3 | ||
| bool "Synopsys USB device controller driver" | ||
| default y | ||
| select NOCACHE_MEMORY if ARCH_HAS_NOCACHE_MEMORY_SUPPORT | ||
| select UDC_BUF_FORCE_NOCACHE | ||
| depends on DT_HAS_SNPS_DWC3_ENABLED | ||
| help | ||
| Synopsys DWC3 USB device controller driver. | ||
|
|
||
| if UDC_DWC3 | ||
|
|
||
| config UDC_DWC3_EVENTS_NUM | ||
| int "Number of events in the event ring buffer" | ||
| default 16 | ||
| help | ||
| It is typically not needed to increase the number of events, but | ||
| if it were to happen due to some rare condition, increasing this | ||
| number could be useful. | ||
|
|
||
| config UDC_DWC3_TRB_NUM | ||
| int "Number of buffers for each non-control endpoint" | ||
| default 4 | ||
| range 3 32 | ||
| help | ||
| This is a general knob for the number of buffers present for each | ||
| endpoint. This does not affect control endpoints. The default is | ||
| enough for most conditions, but for performance and debug purposes, | ||
| increasing could reveal useful. | ||
|
|
||
| endif # UDC_DWC3 | ||
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright The Zephyr Project Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #ifndef ZEPHYR_DRIVERS_USB_UDC_DWC3_QEMU_H | ||
| #define ZEPHYR_DRIVERS_USB_UDC_DWC3_QEMU_H | ||
|
|
||
| struct udc_dwc3_qemu_data { | ||
| uint32_t custom_content; | ||
| }; | ||
|
|
||
| struct udc_dwc3_qemu_config { | ||
| uint32_t custom_content; | ||
| }; | ||
|
|
||
| int udc_dwc3_qemu_init(const struct device *const dev) | ||
| { | ||
| const struct udc_dwc3_config *const config = dev->config; | ||
| struct udc_dwc3_qemu_data *const quirk_data = config->quirk_data; | ||
| const struct udc_dwc3_qemu_config *const quirk_config = config->quirk_config; | ||
|
|
||
| LOG_DBG("Example of quirk for init(): data=0x%x config=0x%x", | ||
| quirk_data->custom_content, quirk_config->custom_content); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| const struct udc_dwc3_vendor_quirks udc_dwc3_vendor_quirks = { | ||
| .init = udc_dwc3_qemu_init, | ||
| }; | ||
|
|
||
| #define UDC_DWC3_QUIRK_DEFINE(n) \ | ||
| static struct udc_dwc3_qemu_config udc_dwc3_quirk_config_##n = { \ | ||
| .custom_content = 0x1234 \ | ||
| }; \ | ||
| static struct udc_dwc3_qemu_data udc_dwc3_quirk_data_##n = { \ | ||
| .custom_content = 0x1234 \ | ||
| }; | ||
|
|
||
| #endif /* ZEPHYR_DRIVERS_USB_UDC_DWC3_VENDOR_QUIRKS_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # SPDX-FileCopyrightText: Copyright tinyVision.ai Inc. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| description: | | ||
| Synopsys DWC3 Controller in device mode | ||
|
|
||
| compatible: "snps,dwc3" | ||
|
|
||
| include: usb-ep.yaml | ||
|
|
||
| properties: | ||
| reg: | ||
| required: true | ||
|
|
||
| interrupts: | ||
| required: true | ||
|
|
||
| num-in-endpoints: | ||
| required: true | ||
|
|
||
| num-out-endpoints: | ||
| required: true |
20 changes: 20 additions & 0 deletions
20
tests/drivers/build_all/usb/boards/qemu_cortex_a53.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright The Zephyr Project Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| /* This is only a placeholder, will be removed once this PR matured */ | ||
|
|
||
| / { | ||
| zephyr_udc0: usb@b0000000 { | ||
| compatible = "snps,dwc3"; | ||
| reg = <0x0 0xb0000000 0x0 0x1000000>; | ||
| reg-names = "base"; | ||
| maximum-speed = "high-speed"; | ||
| interrupt-parent = <&gic>; | ||
| interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL IRQ_DEFAULT_PRIORITY>; | ||
| num-bidir-endpoints = <16>; | ||
| num-in-endpoints = <8>; | ||
| num-out-endpoints = <8>; | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| CONFIG_TEST=y | ||
| CONFIG_TEST_USERSPACE=y | ||
| CONFIG_USB_BC12=y | ||
| CONFIG_UDC_DRIVER=y | ||
| CONFIG_UHC_DRIVER=y | ||
| CONFIG_GPIO=y | ||
| CONFIG_USBC_TCPC_DRIVER=y |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UDC_DRIVER_HAS_HIGH_SPEED_SUPPORT ;USB APP use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo, this should be set by the application itself. either this or superspeed
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@natto1784
My understanding is that if the controller layer does not support high speed, the application layer cannot enable this macro. I tried enabling it in the webusb application but couldn't find a way to do so. Without configuring this option, the webusb application only compiles the Full Speed (FS) configuration into the ELF, but dwc3 runs in High Speed (HS), causing a mismatch error. Later, I saw this option used in Kconfig.dwc2, and after attempting to add it to dwc3's Kconfig, it passed.
The macro used by the application layer is USBD_SUPPORTS_HIGH_SPEED, and it is used as follows in include/zephyr/usb/usbd.h:
Additionally: If it's convenient for you, you can configure your board to HS, compile the webusb application, and try it. This should reproduce my error.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch about
UDC_DRIVER_HAS_HIGH_SPEED_SUPPORT. Adding it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
CONFIG_UDC_DRIVER_HIGH_SPEED_SUPPORT_ENABLED?