If the clock device (i.e., RCC) failed to initialize, we have bigger
problems than trying to call clock_control_{off,on,configure} on it.
Don't bother checking to save some footprint.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Modify the STM32 UDC driver to support multiple instances.
While at it, align the device initialization callback name with other
UDC drivers: `udc_stm32_driver_init0` becomes `udc_stm32_driver_preinit`.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
For some reason, the driver was not requesting the HAL to enable SOF even
if the feature was enabled at UDC stack level.
Fix by requesting HAL to enable SOF based on stack configuration.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
The udc_submit_ep_event() does not document this requirement, but the
`net_buf` provided to it must have been removed from the driver's
internal queue before submission. This wasn't noticed because the list
node member of `net_buf` was untouched, but is now causing list corruption
due to 5137439a47 when multiple packets are
enqueued.
Fix by always dequeuing buffers before submitting them to the UDC stack.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Add DCP auto status support and update the control stage update
sequence to adapt with hardware auto response mode
Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
Move all PHY configuration code to dedicated drivers called using a custom
API (we can't instantiate proper devices because some of these "PHYs" are
really used to initialize an interface to a device NOT owned by the SoC,
such as when an ULPI PHY is in use).
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Refactor utility macros in the STM32 UDC driver, and move some of them to
the STM32 common USB header as they can be useful in other places.
While at it, add new helper macro USB_STM32_NODE_PHY_IS_EMBEDDED_FS.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
As per Zephyr coding guideline #59, "operands shall not be of an
inappropriate essential type". This makes sure boolean variables are
assigned true/false values, not 1/0.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Fix submit condition for non-control transfer. Do submit when any
of the following conditions is met:
1. Transfer buffer (net_buf) is full
2. Last packet size is less than mps
3. Isochronous transfer
USB mass may request C1 for sector size (512 bytes)-aligned and C2
for CBW (13 bytes).
Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
With USBD and HSUSBD re-organized, SoC must have USBD and HSUSBD at
the same time to pass compile. However, M2L31 just has USBD and meets
compile error with HSUSBD unsupported. To avoid adding too many
conditional (#if condition) code for the error, create one dummy
HSUSBD device definition for M2L31 to pass compile.
Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
For HSUSBD, Control transfer with Data OUT stage will break. This is
caused by FIFO flush which cannot be done timely even though in Setup
token interrupt handler. For this, error recovery with FIFO is not
done in Setup token/packet handler and rely on USB reset handler to do
it as catch-all.
Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
Some SoC series allow USB controller to be disabled temporarily
on unplug, and then enabled back on re-plug. Add support for such
configuration option in DT and UDC driver.
Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
Create infrastructure for shared USB common code on STM32 family, and move
the Power Controller configuration logic to common code. This removes some
midly unrelated code from the UDC driver while enabling reuse by a future
UHC driver implementation for STM32.
While at it, clean up the migrated code.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
numaker_usbd_ep_fifo_copy_to_user() never reports errors and always
returns 0.
The error check at the call site is therefore dead code.
Make the function void and drop the unused error handling.
Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
numaker_usbd_ep_fifo_copy_from_user() never reports errors and
always returns 0.
The error check at the call site is therefore dead code.
Make the function void and drop the unused error handling.
Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
Upcoming MDK will make nrf52 errata check functions exist only for
nRF52 and therefore the code will no longer compile for nRF5340. Replace
nrf52 errata checks with new NRF_ERRATA_DYNAMIC_CHECK().
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Replace some manually-defined DT_COMPAT_<> Kconfig macro variables with
their automatically generated counterparts. In most cases, this is
straightforward as the manually defined macro is named identically to the
one generated by the build system.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Remove duplicated #include directives within the same
preprocessor scope across the Zephyr tree.
Duplicates inside different #ifdef branches are preserved
as they may be intentional.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Add support for Nuvoton NuMaker M55M1X high-speed USB 2.0 device
controller. Compared to M46X HSUSBD, M55M1X HSUSBD introduces some
differences:
- DMA must handle cache coherency because net_buf can be cache-able
- USB suspend interrupt becomes continuous. Aavoid being locked by
this interrupt and forward this message just once
- New register bit HSUSBD_OPER_HISHSEN_Msk, which controls to enable
USB handshake
Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
Add support for Nuvoton NuMaker M46X high-speed USB 2.0 device
controller.
The code is re-organized to implement both usbd and hsusbd in single
source file. Multiple instances of either usbd or hsusbd are supported,
but usbd and hsusbd cannot support simultaneously. This limitation is
for easy implementation with just single source file, assuming that real
application just needs one usb device type.
Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
Previous control transfer can be incomplete and then causes not only
net_buf leak but also logic error. This recycles dangling net_buf for
new clean control transfer.
Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
On Control Out failure, this changes to report error message instead of
assert failure because USB bus error is allowed to happen.
Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
Refine code on ATTR undefined bits:
- Add USBD_ATTR_PWRDN_Msk if it is not defined
- Following BSP USBD driver, add note on BIT(6) for hidden
Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
mcux_eps_interval is added as the new member of
uhc_mcux_data. It is used to save endpoint's
original interval value and can be compared
with xfer->interval.
Signed-off-by: Aiden Hu <weiwei.hu@nxp.com>
The original driver is only feasible for M-Core, but for Cortex-A Core,
it need to do MMU mapping to map physical address to virtual address,
to the main update is to add MMIO mapping in this driver, and all the
register access should use virtual address.
Replace direct base address access with DEVICE_MMIO_NAMED_* macros
to provide better memory mapping abstraction and improve platform
portability.
This change:
- Adds DEVICE_MMIO_NAMED_ROM/RAM to config and data structures
- Maps the register base address during driver pre-initialization
- Updates all base address references to use DEVICE_MMIO_NAMED_GET
- Maintains backward compatibility with existing functionality
The DEVICE_MMIO API provides a standardized way to handle memory-mapped
registers across different platforms and memory protection schemes.
Signed-off-by: Jason He <jason.he_1@nxp.com>
Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
Signed-off-by: Jony Zhang <jony.zhang@nxp.com>
Support device tree specified clock rates for USB controller and PHY.
Signed-off-by: Jason He <jason.he_1@nxp.com>
Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
Signed-off-by: Jony Zhang <jony.zhang@nxp.com>
Instead of having one "make_thread" function per instance, called through
a function pointer in the instance configuration, save the thread stack
information instead and consume it from shared code in the driver pre-init
function. This makes the driver more readable (less code in the instance
creation macro) and should reduce its footprint impact (since the thread
creation code is no longer duplicated).
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Fixes the max3421e devicetree compatible to follow the convention of
using a hyphen rather than an underscore as the word separator.
Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Make ULPI reset GPIO accessible via a pointer in the instance configuration
block, initialized only when the instance's PHY is an ULPI PHY with the
corresponding property. Check at runtime during instance initialization for
this GPIO, and perform appropriate action depending on its presence.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Make disconnect GPIO accessible via a pointer in the instance configuration
block, initialized only when the instance does have it as property. Always
provide the HAL_PCDEx_SetConnectionState() callback which configures the
GPIO when present in the instance configuration block.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Move message queue backing buffer inside instance data block to reduce
usage of globals. The message queue structure itself was already inside the
instance data block, only the initialization code needed an update.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Obtain the stack info for each instance's worker thread from the instance
configuration block instead of using globals.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Use pinctrl from the instance configuration block instead of global object.
Create pinctrl on all series (even STM32N6) and always attempt to configure
it, but don't treat empty configuration as an error to allow pinctrl-less
series to work.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Get rid of global macro USB_NUM_BIDIR_ENDPOINTS by using the direct DT
macro when creating the endpoint configuration arrays and initializing
the instance configuration block. Access the endpoint configurations
through the instance configuration block instead of using global objects.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Get rid of global macros UDC_STM32_IRQ and UDC_STM32_IRQ_PRI by using the
direct DT macro when initializing the instance configuration block, and
performing IRQ_CONNECT() in a per-instance function called indirectly via
the instance configuration block.
While at it, get rid of the driver's useless ISR wrapping layer: the Zephyr
ISR calling convention just so happens to allow using the HAL IRQ handler
directly without a trampoline, which is slightly faster and ought to use
less ROM.
Note that global UDC_STM32_IRQ_NAME is still consumed, but it will be
replaced by another mechanism as part of the final step of multi-instance
support implementation.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Starting with nrfx 4.0.0, the nrfx_err_t, NRFX_SUCCESS and NRFX_ERROR_*
have been deprecated. Most of them were removed here:
https://github.com/zephyrproject-rtos/zephyr/pull/99399
but a few were missed.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>