Expose the high framerates first so that it can be listed first and
chosen as the default frame rate in some applications.
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
SAM4E doesn't have PLLB, so the USB clock must be derived from PLLA
which is shared with the system clock.
Use PMC_MCKR_CSS_PLLB_CLK to detect PLLB availability at compile time:
- SAM4S (has PLLB): Use dedicated PLLB, 96MHz / 2 = 48MHz
- SAM4E (no PLLB): Use PLLA, ~240MHz / 5 = 48MHz
For SAM4E, PLLA is already configured by the SoC init code for the
system clock, so we just verify it's locked and configure the USB
divider. On shutdown, we don't disable PLLA since it's needed for
the system clock.
Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
Add a new USB Device Controller (UDC) driver for Atmel SAM4S, SAM4E,
and SAM3S microcontrollers with the UDP (USB Device Port) peripheral.
This driver replaces the deprecated legacy USB stack before removal.
Hardware Specifications:
- USB 2.0 Full-Speed only (12 Mbps)
- 8 hardware endpoints (EP0-EP7)
- 2668 bytes embedded DPRAM/FIFO
- No DMA - all transfers via PIO
- Integrated transceiver with pull-up on DDP
- Dual-bank (ping-pong) support on EP1,2,4,5,6,7
Endpoint Configuration (per datasheet Table 40-1):
- EP0: Control, no dual-bank, 64 bytes
- EP1,2: Bulk/Iso/Int, dual-bank, 64 bytes each bank
- EP3: Bulk/Int, no dual-bank, 64 bytes
- EP4,5: Bulk/Iso/Int, dual-bank, 512 bytes each bank
- EP6,7: Bulk/Iso/Int, dual-bank, 64 bytes each bank
Key Implementation Details:
1. Dual-Bank Pipelining (IN transfers):
- Track filled banks with tx_banks counter (0-2)
- Set TXPKTRDY after each bank fill per datasheet 40.6.2.2
- Pre-fill second bank while first is transmitting
2. OUT Processing:
- Bulk/Int endpoints processed directly in ISR
- EP0 uses thread-based processing for control transfer flexibility
- Bank alternation tracking for dual-bank endpoints
3. Clock Management:
- PLLB configured for 48MHz USB clock (UDPCK)
- Proper suspend/resume with clock gating
- Transceiver disable during disconnect for power saving
4. CSR Register Handling:
- Special "write 1 to preserve" bits handled correctly
- Polling after set/clear for MCK/UDPCK synchronization
- RX_DATA_BK0, RX_DATA_BK1, RXSETUP, STALLSENT, TXCOMP preserved
5. Endpoint Allocation Strategy:
- Odd endpoints (1,3,5,7) for IN, even (2,4,6) for OUT
- EP0 for control transfers
Performance:
- Achieves ~800-900 KB/s throughput
- Near USB Full-Speed theoretical maximum (~1.2 MB/s)
- All testusb tests (0-29) passing
Tested on sam4s_xplained board with Linux testusb utility.
Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
The pcf857x_port_set_raw() function has a race condition where
the lock is only taken after the I2C write to update the cached
outputs_state. This allows concurrent threads to read stale
outputs_state values and compute tx_buf based on outdated data.
Since PCF8574/PCF8575 devices have a single output register that
is written atomically (all pins at once), a stale read causes one
thread's pin changes to be overwritten by another thread's write.
Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
Replace raw clock_ip_name_t cast with a structured decode of the
encoded `id` clock cell introduced by the KINETIS_SIM_CLOCK() macros.
The sub_system pointer carries a 32-bit encoded value. Extract it via
(uint32_t)(uintptr_t)sub_system and use the KINETIS_SIM_CLOCK_DECODE_*()
macros to retrieve gate_offset, gate_bit and clock_name. This avoids
relying on a C bitfield struct overlay (implementation-defined bit
ordering) or undefined pointer casting behaviour.
Also add mcux_sim_validate_gate_offset() which checks that the decoded
gate register offset is word-aligned and within the SIM register region
size declared in DT, returning -EINVAL if not. This prevents a malformed
clock specifier from accidentally enabling or disabling an unintended
peripheral gate.
Remove the LOG_ERR call and the entire logging module infrastructure
(LOG_LEVEL define, log.h include, LOG_MODULE_REGISTER) since no log
calls remain in the file. This also eliminates the GNU statement
expression extension warning triggered by LOG_ERR macro expansion
under -Wpedantic.
The NXP_KINETIS_SIM_NODE macro is moved to the top of the file so it
can be shared by both the validation helper and the clkout_source /
clkout_divider property accessors.
Fix pinctrl_nxp_port.c to pass the encoded `id` cell (name) as the
clock subsystem instead of constructing CLK_GATE_DEFINE() directly
from the explicit offset/bits DT cells. The old approach bypassed
the new encoding and caused PORT clocks to not be enabled, resulting
in UART pins not being muxed and no serial output.
Signed-off-by: Holt Sun <holt.sun@nxp.com>
counter_handlers.c was missing verifier/marshaling coverage for multiple
counter APIs, especially 64-bit helpers.
This change adds the missing z_vrfy handlers and corresponding mrsh
includes so the syscall layer matches the public counter API surface.
Missing functions now covered in drivers/counter/counter_handlers.c:
z_vrfy_counter_get_frequency_64
z_vrfy_counter_us_to_ticks_64
z_vrfy_counter_ticks_to_us_64
z_vrfy_counter_ns_to_ticks
z_vrfy_counter_ns_to_ticks_64
z_vrfy_counter_ticks_to_ns
z_vrfy_counter_ticks_to_ns_64
z_vrfy_counter_reset
z_vrfy_counter_set_value
z_vrfy_counter_set_value_64
z_vrfy_counter_get_max_top_value_64
z_vrfy_counter_set_top_value_64
z_vrfy_counter_set_channel_alarm_64
z_vrfy_counter_get_top_value_64
z_vrfy_counter_get_guard_period_64
z_vrfy_counter_set_guard_period_64
z_vrfy_counter_get_pending_int was removed from the macro as it
returns a uint32_t and not exactly an int.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Add secproxy_mailbox_flush_thread() to clear stale messages from
rx thread when enabling a channel. Read and discard all pending
messages to ensure clean thread state and prevent errors from
previous unclean state.
Signed-off-by: Dave Joseph <d-joseph@ti.com>
Replace single shared interrupt with per-channel interrupt support.
Change .irq to .interrupts[] array in config, use LISTIFY macros
for ISR generation and connection, add channel_enable[] array for
per-channel state tracking. Each rx channel now has independent ISR.
Signed-off-by: Dave Joseph <d-joseph@ti.com>
Remove duplicate error validation in ISR and send path that is
already performed by secproxy_verify_thread(). Remove error mask
checks, message queue fullness checks, and unused
SECPROXY_MAILBOX_NUM_MSGS macro.
Signed-off-by: Dave Joseph <d-joseph@ti.com>
Forward actual error codes from secproxy_verify_thread() instead
of masking all errors as -EBUSY. Now returns -EINVAL,
-EBUSY, or -ENODATA from secproxy_mailbox_send() to aid debugging.
Signed-off-by: Dave Joseph <d-joseph@ti.com>
Remove busy wait from secproxy_verify_thread() to return immediately
with error status. If mailbox is full, waiting for message processing
is unnecessary and blocks execution until timeout, reporting a timeout
error message reducing debuggability.
The mailbox driver should only return the appropriate error code.
Any required retry logic can be implemented in the caller layer.
Signed-off-by: Dave Joseph <d-joseph@ti.com>
The winc1500_socket function returns a socket index that was only
being checked for negative error values. Coverity identified that
the index was not being verified against the upper bound of the
socket_data array, potentially leading to an out-of-bounds write.
Added an explicit check to ensure the socket index is within the
valid range [0, CONFIG_WIFI_WINC1500_OFFLOAD_MAX_SOCKETS].
Fixes#84708
Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
Add an option to enable the secondary chained buffer mechanism for
the RX direction to improve its ability to adapt to high SPS rates
Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
Clean code, update clock calculation to avoid wrong truncate when
mixing double and integer calculation
Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
Clean up i2s_configure flow
Use singleton active configuration instead of concurent for each
stream buffer
Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
Add dependencies for the dt props for the
SPI_NOR_SFDP choice.
Also removes the no no longer needed build asserts.
Nice benefit is, that we fallback to SPI_NOR_SFDP_RUNTIME,
if the required dt props for the other options are not set.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
The MSPI API exposes xfer.packets as const, but the driver assigned
it to a non-const pointer, triggering -Wdiscarded-qualifiers.
Update packet to be a const struct mspi_xfer_packet * and remove
the cast.
No functional changes.
Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
Rename FLASH_SIZE(inst) to FLASH_SIZE_INST(inst) and
FLASH_PAGE_SIZE(inst) to FLASH_PAGE_SIZE_INST(inst) in
flash_mspi_nor_sfdp.h to avoid redefinition conflicts with
STM32 HAL headers (stm32l562xx.h and stm32l5xx_hal_flash.h).
Note: Several HAL STM32 files use this macro naming convention;
this issue is not specific to STM32L5.
Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
This adds initial support for the CH32V ethernet peripheral.
The driver supports both internal and external PHY configurations.
Signed-off-by: James Bennion-Pedley <james@bojit.org>
The infineon i2c driver will lock the calling thread on an error event
because the transfer semaphore is never released. This change allows the
driver to recover and resume normal operation.
Signed-off-by: Brett Peterson <brett.peterson@infineon.com>
Max32 PWM already has built-in support for interrupts at the end of
each PWM period so added baseline support for the PERIOD event type
in CONFIG_PWM_EVENT. Updated PWM Event sample to support
Max32672EvKit.
Signed-off-by: Ryan Wiebe <ryan.wiebe@analog.com>
Now that obtaining the GPIO port device object is always done, the IOsync
configuration logic can be cleaned up. Notably, we can perform it while
still holding the PM Device Runtime reference to avoid an unnecessary
clock_disable and clock_enable.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
The `gpio_stm32_configure()` function is used by both the GPIO and PINCTRL
drivers to configure I/O pins. Move it to the GPIO port manager module's
code so it can be shared properly and update both drivers accordingly.
With this change, the GPIO and PINCTRL drivers are completely decoupled.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
On STM32 hardware, the GPIO port's MMIO interface is used for two purposes
which have their own separate Zephyr API: controlling the state of digital
I/O pins directly (GPIO API) and configuring I/O pins for a specific usage
(PINCTRL API). Historically, this was handled by having the PINCTRL driver
call inside the GPIO driver which works but creates a dependency loop.
Introduce a new `GPIO port manager` module in SoC-specific common code that
takes over various from the existing GPIO/PINCTRL drivers: GPIO port device
instantiation and `GPIO port index -> device` mapping respectively.
Modify the GPIO and PINCTRL drivers to make use of this GPIO port manager
module - a first step in decoupling both drivers from each other.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Move the helper function which computes the LL pin value from a pin number
to the <stm32_gpio_shared.h> header as this function can be useful for
modules other than the GPIO driver.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Move the ports list from the GPIO driver to a shared SoC-specific header.
This will allow reuse from other drivers such as pinctrl.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
The function is only used from the device's PM action and is very trivial.
Inline it inside gpio_stm32_pm_action to simplify the driver.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
The STM32 pinctrl dt-bindings headers were full of definitions used by the
SoC-specific pinctrl header (<pinctrl_soc.h>) rather than from Devicetree.
Move these definitions to the appropriate header. While at it, include the
<pinctrl_soc.h> header from GPIO driver instead of series-specific pinctrl
header since it uses these definitions.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Fix warnings about using char * for %p argument in cbprintf. It's
recommended to cast it to void * because it may cause misbehavior
in certain configurations.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>