-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Add support for UDC for Apollo4P family #79547
Conversation
The following west manifest projects have been modified in this Pull Request:
Note: This message is automatically posted and updated by the Manifest GitHub Action. |
/* Max Packet Size for USB endpoints */ | ||
#define EP0_MPS 64U | ||
#define EP_FS_MPS 64U | ||
#define EP_HS_MPS 512U |
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.
Later the code sets the iso capability on the endpoints. Are the endpoints limited in hardware to these specific values and not the maximum allowed values?
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.
Hi @tmon-nordic, there is a limitation that the end of transaction is not able to be identified when OUT endpoint received data that is multiple of endpoint MPS, when the data count is lower than the triggered size. Hence, the safest way to expose this now is to limit it to 64 bytes for FS and 512 bytes for HS.
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.
Where is this limitation, in your shim driver, HAL driver, or controller?
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.
I think it can be categorized as controller limitation.
9290c51
to
a13fc8c
Compare
samples/subsys/usb/hid-keyboard/boards/apollo4p_blue_kxr_evb.overlay
Outdated
Show resolved
Hide resolved
a13fc8c
to
15e03ff
Compare
b8f2d43
to
7c3fdab
Compare
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.
The boards and dts changes look good to me.
Hi @jfischer-no, I believe your comments above are addressed, please help to have a review again. Thank you 😉 |
6e6a278
7c3fdab
to
6e6a278
Compare
/* Max Packet Size for USB endpoints */ | ||
#define EP0_MPS 64U | ||
#define EP_FS_MPS 64U | ||
#define EP_HS_MPS 512U |
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.
Where is this limitation, in your shim driver, HAL driver, or controller?
6e6a278
to
ce491e0
Compare
ce491e0
to
681060f
Compare
Added user button for apollo4p_blue_kxr_evb and apollo4p_evb Signed-off-by: Chew Zeh Yang <[email protected]>
681060f
to
3ff319e
Compare
Added ambiq-usb bindings needed by udc_ambiq. Signed-off-by: Chew Zeh Yang <[email protected]>
3ff319e
to
6ce193f
Compare
6ce193f
to
7594166
Compare
drivers/usb/udc/udc_ambiq.c
Outdated
struct gpio_dt_spec usb_vddusb33_gpio; | ||
struct gpio_dt_spec usb_vddusb0p9_gpio; |
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.
As mentioned above, there is no need to prefix it with usb_
.
struct gpio_dt_spec vddusb33_gpio;
struct gpio_dt_spec vddusb0p9_gpio;
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.
Hi @jfischer-no, I think I have missed that point earlier. removed usb_
from the 2 variable names
am_hal_usb_intr_usb_enable(priv->usb_handle, | ||
USB_CFG2_SOFE_Msk | USB_CFG2_ResumeE_Msk | | ||
USB_CFG2_SuspendE_Msk | USB_CFG2_ResetE_Msk); |
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.
am_hal_usb_intr_usb_enable(priv->usb_handle,
USB_CFG2_SOFE_Msk | USB_CFG2_ResumeE_Msk |
USB_CFG2_SuspendE_Msk | USB_CFG2_ResetE_Msk);
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.
clang-format keeps add a tab there. I have manually reverted the change by clang-format and push. Let's see whether the CI will let us through 😄
am_hal_usb_interrupt_service(priv->usb_handle, int_status[0], int_status[1], int_status[2]); | ||
} | ||
|
||
static int usb_power_rails_set(const struct device *dev, bool on) |
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.
The return value is never checked, maybe static void usb_power_rails_set(const struct device *dev, bool on)
?
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.
Hi @jfischer-no, since the error status return might be useful to indicate that the power rail control is not successful, I have made the change to propagate the error to upper layer. Please help to have a look at the change and see whether it is okay.
drivers/usb/udc/udc_ambiq.c
Outdated
/* power rails set */ | ||
ret = gpio_pin_set_dt(&cfg->usb_vddusb33_gpio, on == true ? 1 : 0); | ||
if (ret) { | ||
return ret; | ||
} | ||
ret = gpio_pin_set_dt(&cfg->usb_vddusb0p9_gpio, on == true ? 1 : 0); | ||
if (ret) { | ||
return ret; | ||
} |
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.
Just on
, bool is either 0 or 1 and can be promoted to any integer type.
/* power rails set */
ret = gpio_pin_set_dt(&cfg->usb_vddusb33_gpio, on);
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.
Hi @jfischer-no, understood and made the change. Will use implicit bool to integer casting in the future.
Added implementation for udc_ambiq with its required Kconfig and CMakelist updates. Signed-off-by: Chew Zeh Yang <[email protected]>
Add USB node to apollo4p and apollo4p_blue qualifier, and apollo4p_evb and apollo4p_blue_kxr_evb board to enableUSB support on the MCU and its EVB. Signed-off-by: Chew Zeh Yang <[email protected]>
7594166
to
f6a7d61
Compare
This PR adds support for UDC for Ambiq Apollo4p family. The boards tested are:
Followings are the USB samples tested: