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

drivers: usb: udc: add Smartbond UDC driver #79184

Merged

Conversation

kasjer
Copy link
Contributor

@kasjer kasjer commented Sep 30, 2024

Code adds USB UDC driver for Smartbond device.

Code was NOT tested with ISO endpoints yet.
It was tested with console, mass, and cdc_acm applications

Additionally small fix in DMA power management was needed.

Function dma_smartbond_set_channel_status() used incorrect
condition to release state lock.
In initialization function dma_smartbond_init() function
dma_smartbond_set_channel_status() was called for each DMA
channel and tried to release lock that was never taken.

Fixes #74662

Signed-off-by: Jerzy Kasenberg jerzy.kasenberg@codecoup.pl

Function dma_smartbond_set_channel_status() used incorrect
condition to release state lock.
In initialization function dma_smartbond_init() function
dma_smartbond_set_channel_status() was called for each DMA
channel and tried to release lock that was never taken.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
@zephyrbot zephyrbot added area: USB Universal Serial Bus area: DMA Direct Memory Access platform: Renesas SmartBond Renesas Electronics Corporation, SmartBond labels Sep 30, 2024
@kasjer kasjer force-pushed the kasjer/da1469x-usb-next branch from f375211 to 1ea1e01 Compare September 30, 2024 09:16
@ydamigos
Copy link
Collaborator

ydamigos commented Oct 3, 2024

Please add usbd as supported peripheral in DA1469x boards' yaml file.

@kasjer
Copy link
Contributor Author

kasjer commented Oct 3, 2024

Please add usbd as supported peripheral in DA1469x boards' yaml file.

done

@kasjer kasjer force-pushed the kasjer/da1469x-usb-next branch from 6356fe9 to 6416c0c Compare October 9, 2024 10:30
@kasjer
Copy link
Contributor Author

kasjer commented Oct 9, 2024

Build fails due to unrelated change #73189 (issue #79594)

ydamigos
ydamigos previously approved these changes Oct 9, 2024
tmon-nordic
tmon-nordic previously approved these changes Oct 10, 2024
drivers/usb/udc/udc_smartbond.c Outdated Show resolved Hide resolved
drivers/usb/udc/udc_smartbond.c Outdated Show resolved Hide resolved
drivers/usb/udc/udc_smartbond.c Outdated Show resolved Hide resolved
drivers/usb/udc/udc_smartbond.c Outdated Show resolved Hide resolved
boards/renesas/da14695_dk_usb/da14695_dk_usb.yaml Outdated Show resolved Hide resolved
drivers/usb/udc/udc_smartbond.c Outdated Show resolved Hide resolved
drivers/usb/udc/udc_smartbond.c Outdated Show resolved Hide resolved
drivers/usb/udc/udc_smartbond.c Outdated Show resolved Hide resolved
drivers/usb/udc/udc_smartbond.c Outdated Show resolved Hide resolved
drivers/usb/udc/udc_smartbond.c Outdated Show resolved Hide resolved
drivers/usb/udc/udc_smartbond.c Outdated Show resolved Hide resolved
drivers/usb/udc/udc_smartbond.c Outdated Show resolved Hide resolved
drivers/usb/udc/udc_smartbond.c Outdated Show resolved Hide resolved
drivers/usb/udc/udc_smartbond.c Outdated Show resolved Hide resolved
@kasjer kasjer force-pushed the kasjer/da1469x-usb-next branch from 386b9a9 to 8294832 Compare October 18, 2024 07:18
@kasjer kasjer requested a review from jfischer-no October 18, 2024 07:24
LOG_INF("ep 0x%02x dequeue all", ep);

lock_key = irq_lock();

Copy link
Collaborator

Choose a reason for hiding this comment

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

That looks too easy, do you need to find and cancel DMA transfers in progress?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your are right, can you give me a quick tip on how to trigger this case so I can verify that it works correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed (scenario when this happens not tested though).

Copy link
Collaborator

Choose a reason for hiding this comment

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

There are few, (There was a simple one using shell commands to enqueue transfers, I have to bring it back). You can try CDC ACM sample, build it with CONFIG_SHELL and CONFIG_USBD_SHELL enabled. On Zephyr side enter shell command usbd select sample_usbd.


python3
>>> import usb
>>> dev = usb.core.find(idVendor=0x2fe3, idProduct=0x0001)
>>> dev.detach_kernel_driver(0)
>>> #to set DTR
>>> dev.ctrl_transfer(0x21, 0x22, 3, 0, 0)
0
>>> #Read all DCD and DSR notifications
>>> dev.read(0x81, 100)
array('B', [161, 32, 0, 0, 0, 0, 2, 0, 1, 0])
>>> dev.read(0x81, 100)
array('B', [161, 32, 0, 0, 0, 0, 2, 0, 3, 0])
>>> #On Zephyr side 'usbd disable' should trigger dequeue transfers for endpoint 0x01

Code adds Smartbond UDC driver to be used with
USB next stack.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
Marks boards da1469x_dk_pro and da14695_dk_usb as supporting
new usb driver support

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
@kasjer kasjer force-pushed the kasjer/da1469x-usb-next branch from 8294832 to 59da6f0 Compare October 21, 2024 13:45
@henrikbrixandersen henrikbrixandersen merged commit 70364e8 into zephyrproject-rtos:main Oct 22, 2024
26 checks passed
@kasjer kasjer deleted the kasjer/da1469x-usb-next branch October 24, 2024 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: DMA Direct Memory Access area: USB Universal Serial Bus platform: Renesas SmartBond Renesas Electronics Corporation, SmartBond
Projects
None yet
Development

Successfully merging this pull request may close these issues.

drivers: usb: Port usb_dc_smartbond to UDC API
8 participants