Replace 12 open-coded PRESENT_STATE_CURRENT_MASTER register checks
with a dw_i3c_is_current_controller() inline helper that takes the
device pointer, improving readability and reducing duplication.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
When a secondary controller receives a DEFSLVS/DEFTGTS CCC, the DW
IP writes SDCT (Secondary Device Characteristic Table) entries to the
DCT region and generates a response with TID=0xf and DATA_LENGTH set
to the device count.
Read the SDCT entries and populate data->common.deftgts with the
active controller and target device information, matching the pattern
used by the Cadence I3C driver. This is done via a k_work item to
avoid allocating memory in ISR context.
On bus owner update, when gaining controllership, enqueue
i3c_sec_handoffed() to consume the deftgts data and attach all
devices from the previous controller's bus state. Also invoke the
controller_handoff_cb if registered.
Guarded by both CONFIG_I3C_CONTROLLER and CONFIG_I3C_TARGET since
DEFTGTS is used for controller role handoff which requires both roles.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Add support for controller role (mastership) handoff using standard
DW I3C registers:
- Implement I3C_IBI_CONTROLLER_ROLE_REQUEST in target ibi_raise using
SLV_INTR_REQ (0x8C, bit 3) with HW capability, DA validity, and
DISEC checks before issuing the request.
- Handle mastership request IBIs on the controller side via
i3c_ibi_work_enqueue_controller_request() instead of dropping them.
- Handle INTR_BUSOWNER_UPDATE_STAT in the ISR to flush FIFOs, resume
the controller, and reconfigure interrupt masks for the new role.
Guarded by both CONFIG_I3C_CONTROLLER and CONFIG_I3C_TARGET since
role switching requires both roles compiled in.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Add an ARM SCMI option to force polling based communication flow.
This may be needed if SCMI platform does not support interrupt-driven
communication flow.
Signed-off-by: Julien Panis <jpanis@baylibre.com>
syscon_sanitize_reg() was silently rounding down misaligned offsets to
the nearest aligned address via ROUND_DOWN(). This masks caller bugs:
an offset of 0x03 with reg_width=4 would silently become 0x00, reading
the wrong register with no error reported.
Change to reject misaligned accesses with -EINVAL instead.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Add a spinlock to the generic syscon driver data so that concurrent
register accesses from multiple consumers are serialized per-device.
Also introduce syscon_update_bits() which performs an atomic
read-modify-write under a single lock hold.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
When analog_axis_calibration_get and similar are called in
analog_axis_set_raw_data_cb installed callback, analog_axis_loop
can self-deadlock. Loop takes cal_lock before invoking callback
and analog_axis_calibration_get (ex.) tries to aquire cal_lock again
at K_FOREVER in same context. Fixed by reducing cal_lock scope
and taking copy of callback ptr while under cal_lock, so cal_lock is
released before running raw callback in analog_axis_loop.
Signed-off-by: David Chalco <david@chalco.io>
Used Zephyr inline register access functions (sys_read/write)
instead of CMSIS register structure.
Used soc helper api to access/configure girq registers.
Signed-off-by: Manimaran A <manimaran.a@microchip.com>
When ESP32_WIFI_STA_AUTO_DHCPV4 is
enabled functions from the dhcpv4 clients are
used, therefore we need to depend on it, otherwise
a user could activate that Kconfig without the dhcpv4
client being enabled, which would lead to a build error.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Same issue as the GPIO driver: esp32_pin_is_valid() and
esp32_pin_is_output_capable() use BIT() which overflows on 32-bit
Xtensa for pin numbers >= 32.
Fix by using BIT64() to match the 64-bit SOC_GPIO_VALID_GPIO_MASK.
Signed-off-by: Matin Lotfaliei <matinlotfali@gmail.com>
gpio_pin_is_valid() and gpio_pin_is_output_capable() use BIT() which
expands to (1UL << n). On 32-bit Xtensa targets, unsigned long is
32 bits, so BIT(n) for n >= 32 is undefined behavior.
This causes gpio1 pins (GPIO32+) to always fail validation with
-EINVAL, breaking any peripheral connected to GPIO32-GPIO48 on
ESP32-S3 (and similar ESP32 variants with gpio1).
Fix by using BIT64() which correctly handles pin numbers >= 32
since SOC_GPIO_VALID_GPIO_MASK is already a 64-bit value.
Signed-off-by: Matin Lotfaliei <matinlotfali@gmail.com>
Use the WFET (Wait For Event with Timeout) instruction, introduced in
Armv8.8-A (FEAT_WFxT), to let the CPU enter a low-power state during
arch_busy_wait() instead of spinning on the counter.
The availability of WFxT is detected at runtime by reading
ID_AA64ISAR2_EL1. When the feature is absent, the existing polling
loop is used as before.
Also fix the cycles_to_wait computation to use 64-bit multiplication
to avoid truncation with large usec_to_wait values.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Add I3C_CONTROLLER_FLAG_DISABLE_HJ_AT_INIT as BIT(1) in the
controller config flags. When set via the devicetree boolean property
"disable-hj-at-init" on the I3C controller node, Hot-Join ACKs will
not be enabled at the end of bus initialization. Hot-Join events will
be NACKed until the application explicitly enables them.
Guard the ENEC HJ broadcast in i3c_bus_init() (i3c_common.c), the
cdns-specific HJ ACK register write, the dw HJ NACK clear, and the
stm32 LL_I3C_EnableHJAck() call with this flag.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Add a flags field (uint8_t) to struct i3c_driver_config and define
I3C_CONTROLLER_FLAG_DISABLE_BUS_INIT as BIT(0). When set via the
devicetree boolean property "disable-bus-init" on the I3C controller
node, i3c_bus_init() will not be called during driver initialization,
allowing the application to perform bus initialization at a later time.
Add I3C_CONTROLLER_CONFIG_FLAGS_DT_INST() macro in devicetree.h to
read the flag from the devicetree, following the same FIELD_PREP
pattern used for per-device flags in I3C_DEVICE_DESC_DT.
Update cdns, dw, max32, it51xxx, mcux, npcx, renesas_ra, and stm32
drivers to populate the new flags field and check it before calling
i3c_bus_init().
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
The `NET_IF_LOWER_UP` (carrier on/off) state is not intended to signify
network registration state, that is the job of `NET_IF_DORMANT`. The
example from the documentation is:
> An example of an event that changes the carrier state is Ethernet
cable being plugged in or out.
In the context of an LTE network, I am interpretting the equivalent of
the "cable" to be the modem ready to start searching for networks to
join. The state combinations end up being:
* `!LOWER_UP && DORMANT`: Modem off or booting
* `LOWER_UP && DORMANT`: Modem searching for network
* `LOWER_UP && !DORMANT`: Modem registered to network
Signed-off-by: Jordan Yates <jordan@embeint.com>
According to the networking documentation:
> The network association status is represented with NET_IF_DORMANT flag
Therefore, the flag should be set at any time that the network is not
associated with. This is achieved by setting the flag at boot, and only
controlling the dormant state at entry/exit from the `REGISTERED` state.
Signed-off-by: Jordan Yates <jordan@embeint.com>
The name of this state is misleading as it is the same as the internal
Zephyr networking interface state of dormant. Rename the state to match
what it is doing, in the same way other states are named.
The misapplication of the interface `dormant` state by `AWAIT_PPP_DEAD`
is fixed later.
Signed-off-by: Jordan Yates <jordan@embeint.com>
The driver transitions to this state upon registering to the LTE
network, not upon the internal Zephyr concept of `carrier_on`.
`carrier_on` is an internal (and incorrect) consequence of transitioning
to the registered state, and should not be the basis of the name.
Signed-off-by: Jordan Yates <jordan@embeint.com>
net_if_carrier_off() should be called before
phy_link_callback_set(), as itside it, the carrier could be
already changed.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
In `ep_check_config()`, capabilities of the endpoint provided by the driver
are logged, but not the requested endpoint configuration. As a result, when
the function fails, it is not possible to determine why using only logs.
Add logging of the requested configuration in addition to the driver caps
to allow easily determining the cause of the failure (when logging is on).
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
- PNG is treated similarly to JPEG with a rough worst-case estimate.
- Treat NV12/NV21 formats specially rather than fall into the default
condition. These 2-planar YUV formats have a pitch equal to width and
a total size of pitch * height * 2 (Y plane + interleaved UV plane).
Signed-off-by: Kate Wang <yumeng.wang@nxp.com>
The need to monitor battery voltage on nordic devices and nRF7120
in particular is required among other metrics such as die temperature.
Creating a sensor to measure battery voltage allows to easily monitoring
of all required metrics in a consistent way.
This commit adds a new sensor driver to monitor battery.
Signed-off-by: Robert Robinson <robert.robinson@nordicsemi.no>
Implement post-merge review remarks:
- check return values correctly
- fix bad function naming
- fix binding no title
- use function instead of macro as is possible
Signed-off-by: Camille BAUD <mail@massdriver.space>
STM32 HAL2 brings many changes regarding structure, macro and function
names, so add a compatibility layer to keep the driver working for both
versions.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
During RX duty cycle mode the SX126x keeps BUSY asserted even in
the sleep phase. The standby command cannot be sent because the HAL
waits for BUSY LOW first.
Fix by calling sx126x_hal_wakeup() before set_standby when
cancelling duty cycle reception. The wakeup function drives NSS low
directly (bypassing the BUSY check), which forces the radio out of
duty cycle and into STDBY_RC.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Implement the recv_duty_cycle API using the SX126x hardware
SetRxDutyCycle command. The radio autonomously alternates between
short RX windows and sleep, waking the MCU only on packet reception.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Add shared interrupt support for STM32 UART on SoC families where
multiple USART/LPUART peripherals share a single IRQ line (F0, G0,
L0, U0, C0).
Add a compile-time BUILD_ASSERT in the STM32 UART driver that detects
when two or more enabled UART instances share an IRQ and
CONFIG_SHARED_INTERRUPTS is not set.
Add configdefault SHARED_INTERRUPTS and SHARED_IRQ_MAX_NUM_CLIENTS
to the SoC Kconfig for STM32F0x, STM32L0x, STM32U0x, and STM32C0x.
Update DTS comments in the F0 family that previously stated shared
UART IRQs are unsupported.
The SHARED_IRQ_MAX_NUM_CLIENTS combinations in the F0x Kconfig were
generated with:
from itertools import combinations
usarts = ['usart3','usart4','usart5','usart6','usart7','usart8']
for n in range(6, 2, -1):
for combo in combinations(usarts, n):
conds = ' && '.join(
f'$(dt_nodelabel_enabled,{u})'
for u in combo)
print(f'\tdefault {n} if {conds}')
Fixes zephyrproject-rtos#39565
Signed-off-by: Anand Kumar <anandvtu16158@gmail.com>
Add I2C driver support for Realtek Bee series SoCs,
including RTL87x2G and RTL8752H.
This driver supports:
- Master mode operation
- 7-bit and 10-bit addressing
- Standard and Fast mode speeds
Signed-off-by: Yuzhuo Liu <yuzhuo_liu@realsil.com.cn>
Add support for configuring the Set Tear ScanLine (STE) command in the
ST7796S LCD display driver. This allows users to specify the exact
scanline where the Tearing Effect (TE) signal becomes active, providing
better control over display synchronization.
Changes:
- Add ST7796S_CMD_STE (0x44) command definition
- Add tear-scanline property to device tree binding
- Add tear_scanline field to driver configuration structure
- Implement STE command configuration in LCD initialization
The tear scanline can now be configured via device tree:
tear-scanline = <240>; // TE signal at scanline 240
Signed-off-by: Ankitkumar Modi <ankit.modi912@gmail.com>
The DWC2 USB driver was accessing hardware registers
through a raw dev->config->base pointer, which breaks on
MMU-enabled platforms where physical addresses need to be
mapped to virtual ones before use.
Use Zephyr's standard MMIO abstraction API by introducing
DEVICE_MMIO_NAMED_RAM/ROM(core) in the driver's data and
config structs, mapping the region at initialization time
with DEVICE_MMIO_NAMED_MAP, and routing all register accesses
through a dwc2_get_base() helper that calls DEVICE_MMIO_NAMED_GET.
These changes allows the driver to be useful on MMU-based
platforms like Broadcom BCM2711 SoC.
Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
Coverity reported a potential out-of-bounds access in
drivers/wifi/esp_at/esp_offload.c when accessing sin_addr
without validating the sockaddr family.
ESP-AT offload supports IPv4 only, so add an explicit
NET_AF_INET check before dereferencing the IPv4-specific
structure to prevent invalid memory access.
Fixes: #100001
Signed-off-by: Om Srivastava <srivastavaom97714@gmail.com>
Refactor the nrf_spim device driver to share the common code between
the nrf_spim_rtio implementation.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
Move the private spi_rtio.h header from the public path
include/zephyr/drivers/spi/rtio.h
the the private path
drivers/spi/spi_rtio.h
and update drivers to include it using a relative path.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
The SPI_LOCK_ON flag is not compatible with RTIO, nor is the
related spi_release API. Introduce stub implementation for drivers to
use which simply returns -ENOTSUP and validate SPI_LOCK_ON within the
spi_rtio_transceive wrappers.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
Introduce spi_rtio_transceive_cb which is an implementation of the
spi_transceive_cb API based on the spi_rtio context.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>