Commit graph

808 commits

Author SHA1 Message Date
Benjamin Cabé
2408ca6795 drivers: adc: renesas_rz: fix error handling
Fix a bunch of occurrences of API calls returning error codes that were
being ignored.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-21 08:19:28 +02:00
Colin Evrard
97f9411f32 drivers: adc: esp32: check reference at compile time
Check that the channels are configured with the reference
ADC_REF_INTERNAL when compiling the driver.

Signed-off-by: Colin Evrard <colin.evrard@mind.be>
2025-06-20 16:24:09 +02:00
Khaoula Bidani
f568b0d68a drivers: adc: update adc driver to integrate stm32u3
add u3 config_soc conditions in adc driver to handle
news peripherals.

Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
2025-06-19 22:27:35 -07:00
Benjamin Cabé
45920741dc drivers: adc: max1125x: fix typo in GPIO config
Corrected the property assignment for gpo0_enable.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-19 14:01:31 +02:00
Jakub Zymelka
f3d2507423 drivers: adc: rework Nordic SAADC driver
SHIM Nordic modification for the ADC driver controlling the SAADC
peripheral. Replaced HAL based implementation in favor of nrfx driver.

As a next step, it is planned to implement a feature that will allow
the peripheral SAADC timer to be used for sampling, and for this it is
necessary to use the nrfx driver in this SHIM.
This will allow more accurate and faster sampling than the kernel
mechanism currently provides.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2025-06-18 09:23:23 -04:00
Benjamin Cabé
a7405dc7bf drivers: adc: ti_am335x: fix timeout condition
Corrected the timeout condition in the ti_adc_sequencer_start function
to ensure proper timeout handling during ADC sequencer operations.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-18 11:22:57 +01:00
Andrzej Głąbek
616ec7522c drivers: adc_nrfx_saadc: Remove dead and misleading code
For a long time (since version 3.3.0) nrfx contained an incorrectly
defined symbol NRF_SAADC_8BIT_SAMPLE_WIDTH that was set to 8 for nRF54L
and nRF54H Series SoCs, which was probably only true for very early
engineering revisions of those. Based on this, the adc_nrfx_saadc driver
was incorrectly writing consecutive 8-bit samples in supplied buffers,
cutting off the highest 8 bits of the results. And for sequences with
multiple channels, it was even causing that the results written as
16-bit words by hardware were partially overwritten in next iteration.

In nrfx 3.12.0 (see commit f46798fa55)
this was finally corrected - the symbol is now deprecated and it is
always set to 16. This commit is a follow-up to the above and removes
parts of adc_nrfx_saadc that now became dead code to prevent further
confusion regarding 8-bit sampling.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-06-18 10:55:58 +02:00
Benjamin Cabé
e7f58da491 drivers: adc: use asserts in adc_gain_invert implementations
no need for runtime checks here, let's save a few bytes of code

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-17 16:25:15 -05:00
Michał Stasiak
4d6585488b drivers: adc: adc_nrfx_saadc: Extend internal reference values
Current target-reference mapping does not cover all cases.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2025-06-17 16:11:33 +02:00
Michał Stasiak
18c0c3aeb9 drivers: Extend analog pins mapping for nRF54L.
Extended analog pins mappings for more nRF54L targets.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2025-06-17 16:11:33 +02:00
Aksel Skauge Mellbye
651ddd69af drivers: adc: silabs: Don't fail to init if clock is on
It is not an error if the clock source is already enabled. This
may happen if a bootloader has used the peripheral and not
de-initialized it before booting the application.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2025-06-13 10:18:26 -07:00
sudarsan N
6d88a62417 drivers: adc: fix underflow in lmp90xxx_adc_start_read channel check
Prevent integer underflow when sequence->channels is 0.
Add an explicit check before calling find_msb_set().

Coverity CID: 487765

Signed-off-by: sudarsan N <sudarsansamy2002@gmail.com>
2025-06-11 09:55:42 +02:00
Julien Panis
45a8a0f0c6 drivers: adc: cc23x0: Add support for DMA mode
The ADC has a dedicated interface for communicating with the DMA.
The ADC module provides four interrupt sources (one for each
conversion result storage register) which can be configured to
source the DMA trigger.

Signed-off-by: Julien Panis <jpanis@baylibre.com>
2025-06-10 12:07:54 +02:00
Sai Santhosh Malae
bfe4065657 drivers: adc: siwx91x: Add siwx91x ADC driver
Implement ADC driver for siwx91x device

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
2025-06-10 12:07:33 +02:00
sudarsan N
1d51942c50 drivers: adc: fix overflow and div-by-zero in adc_ad7124_odr_to_fs
Add check for odr <= 0 and cast odr to uint32_t before multiplication
to avoid integer overflow and division by zero.

Fixes: CID 489220

Signed-off-by: sudarsan N <sudarsansamy2002@gmail.com>
2025-06-10 08:48:05 +02:00
Jordan Yates
8ab300d63e adc: 64bit gain inversion function
Add a variant of `adc_gain_invert` that operates on an `int64_t` instead
of `int32_t`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-06-09 10:25:52 +01:00
Henrik Lindblom
24b4ce189f drivers: stm32: dma: fix external dcache support
Several drivers checked for the presense and availability of data cache
through Kconfig symbol. This is supported according to the current
documentation, but the symbol DCACHE masks two types of cache devices: arch
and external caches. The latter is present on some Cortex-M33 chips, like
the STM32U5xx. The external dcache is bypassed when accessing internal
SRAM and only used for external memories.

In commit a2dd232410 ("drivers: adc: stm32: dma support") the rationale
for gating dcache for adc_stm32 behind STM32H7X is only hinted at, but
reason seems to be that it was the only SOC the change was tested on. The
SOC configures DCACHE=y so it is most likely safe to swap the SOC gate for
DCACHE.

The DCACHE ifdefs are now hidden inside the shared stm32_buf_in_nocache()
implementation.

Signed-off-by: Henrik Lindblom <henrik.lindblom@vaisala.com>
2025-06-06 10:19:58 +02:00
Amneesh Singh
07c1d95d69 drivers: adc: ti_am335x: initial support
This patch adds the ADC driver for TI K3 family of SoCs. Technical
reference can be found in the Technical Reference Manual (TRM) of the
board.

Signed-off-by: Amneesh Singh <a-singh7@ti.com>
2025-06-06 08:42:32 +02:00
Nikodem Kastelik
647477c851 drivers: adc: nrf: align to non-gain configuration
Some nRF devices do not allow to configure gain.

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
2025-06-04 17:03:48 +02:00
Nikodem Kastelik
5abf43c7dd drivers: adc: nrf: align to channel-wide burst configuration
Some nRF devices allow to configure burst setting per channel
while others globally.

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
2025-06-04 17:03:48 +02:00
Johan Lafon
cf569036d1 driver: adc: add MCP3561/2/4R driver
Add driver for the microchip MCP3561/2/4R ADC. Registers lock and
CRCCFG protection mecanism is not implemented. Tested on an MCP3564R.

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2025-06-04 16:58:52 +02:00
Sudarsan N
34f5f8d556 drivers: adc: Prevent overflow in max1125x_read_sample
Fix potential integer overflow caused by unsafe shift when computing
ADC mid-scale offset. Applies resolution bounds and uses unsigned
shift to avoid undefined behavior.

Fixes: CID 487740
Signed-off-by: Sudarsan N <sudarsansamy2002@gmail.com>
2025-06-04 10:04:14 +02:00
Andrzej Głąbek
a9405d005c drivers: adc_ad4130|adc_7124: Add ret initialization in *_perform_read()
Add initialization of `ret` to avoid reports of uninitialized variable
being returned. This variable normally gets initialized while the loop
iterates over channels, but potentially it could be left uninitialized
if the loop finished in its first iteration because of no channels to
be processed.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-05-28 15:33:14 +02:00
Andrzej Głąbek
ec8632dcd1 drivers: adc_ad4130: Fix out-of-bounds accesses to channel_setup_cfg
Correct the size of the channel_setup_cfg array, as it should contain
entries for all available channels (AD4130_MAX_CHANNELS), not for the
available configuration slots (AD4130_MAX_SETUPS).
Move also checking of the channel index to the very beginning of
adc_ad4130_channel_setup(), to avoid potential writes to .live_cfg
beyond the channel_setup_cfg array.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-05-28 10:05:02 +02:00
Tu Nguyen Van
6f4f702ed2 drivers: adc: update new macro name in RTD 2.0.1
FEATURE_ADC_MAX_CHN_COUNT changed to ADC_SAR_IP_MAX_CHN_COUNT
in RTD 2.0.1

Signed-off-by: Tu Nguyen Van <tu.nguyenvan@nxp.com>
2025-05-28 05:54:38 +02:00
Julien Panis
dd5ed02146 drivers: adc: Add support for cc23x0 ADC
Add support for 16-channel ADC to cc23x0 SoC. The driver supports the
following conversion modes:
- Single channel | Single conversion,
- Sequence of channels (up to 4) | Single conversion.

Signed-off-by: Julien Panis <jpanis@baylibre.com>
2025-05-23 19:49:48 +02:00
jhan bo chao
98478189f2 drivers: adc: rts5912: clear pending irq when setup
clear pending irq when setup.

Signed-off-by: jhan bo chao <jhan_bo_chao@realtek.com>
2025-05-22 04:51:36 +02:00
Hao Luo
ba52a93ac9 drivers: adc: Add support for Apollo510 ADC
This commit adds support for Apollo510 SoC in ambiq adc driver

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-05-14 09:11:17 +02:00
Michał Stasiak
8b998060f2 drivers: adc: adc_nrf_saadc: Add analog pins for nRF54L20
Added set of analog pins for nRF54L20 SAADC.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2025-05-13 17:45:18 +02:00
Krzysztof Chruściński
2f7d799c99 drivers: adc: nrfx_saadc: Add validation of channel configuration
On nrf54h20 there are additional analog pins (AIN8+). When differential
mode is used they must not be mixed with AIN0-AIN7. Add build time
validation which detects if configuration is invalid.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-05-09 15:40:53 +02:00
John Bason Mitchell
28c2521926 drivers: adc: disabling timer after DMA eror
The ADC timer should be disabled however the read is finished.

Signed-off-by: John Bason Mitchell <johnbasonmitchell@gmail.com>
2025-04-30 10:55:17 +01:00
Yunshao Chiang
13087ee1b0 drivers: adc: add it515xx_evb board adc driver
Add it515xx analog to digital converter driver which supports 8 channels
ch0 ~ ch7 and 12-bit resolution.

Signed-off-by: Yunshao Chiang <Yunshao.Chiang@ite.com.tw>
2025-04-23 15:02:36 +02:00
Dylan Hsieh
f3bc550117 driver: adc: add adc driver for rts5912
Add adc driver for Realtek rts5912.

Signed-off-by: Dylan Hsieh <dylan.hsieh@realtek.com>
2025-04-22 14:02:37 +02:00
Hao Luo
6f4b92d64d soc: ambiq: Optimize the inclusion relationship of header files
Optimized the inclusion relationship of header files

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-04-17 09:06:18 +02:00
Okan Sahin
be1218081a drivers: adc: Introduce AD4130 adc driver
This commit introduces ad4130 adc driver.

Signed-off-by: Okan Sahin <Okan.Sahin@analog.com>
2025-04-09 17:32:29 +02:00
Sreeram Tatapudi
970460e809 drivers: adc: Update configuration values for CAT1B ADC
- Update resolution and inter reference mV
	- make unused code conditional

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2025-04-09 09:03:19 +02:00
Andrew Featherstone
a2aa0a3e2b docs: raspberrrypi: Correct names of products
Replace occurrences of "RaspberryPi" with "Raspberry Pi" in
documentation, comment blocks etc. Correct the name of "PicoW" to
"Pico W", matching Raspberry Pi's documentation at
https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html .

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
2025-04-03 15:27:50 -07:00
Etienne Carriere
bec3a6fc98 drivers: adc: stm32: support DMA when CONFIG_MEM_ATTR=n
Allow STM32 ADC driver to operate with DMA support even when
CONFIG_MEM_ATTR is disabled which happen when CONFIG_ARM_MPU is
intentionally disabled despite the CPU supports MPU.

By the way, remove some #ifdef directive on header files inclusion
that add noise in the header file inclusion section without any
benefit. Also remove inclusion of zephyr/arch/cache.h that is not
needed at all.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2025-04-02 12:54:50 +02:00
Dimitrije Lilic
c0e5e5236f drivers: adc: ad405x: Add diff support and res used form adc spec
Added support for differentail or single ended setup.
Reading resolution form dt - adc spec.

Signed-off-by: Dimitrije Lilic <dimitrije.lilic@orioninc.com>
2025-04-01 22:14:31 +02:00
Elliott Cutmore
1788c701cb drivers: adc: adc_ads1x4s0x remove duplicated initialiser
Removed duplicated "vbias_level" initialiser in driver

Signed-off-by: Elliott Cutmore <elliott.cutmore@gmail.com>
2025-03-27 14:01:32 +01:00
Hao Luo
4744d138c2 drivers: ambiq: Change the way to power on ambiq drivers
This commit changes to use ambiq hal power control APIs
to replace the previous register settings to power on
ambiq drivers.

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-03-24 09:54:17 +01:00
Krzysztof Chruściński
f2e1ac0da5 drivers: adc: nrfx_saadc: Add support for AIN8-AIN13 on nrf54h20
Extend support in dt bindings and in the driver to allow use of
AIN8 to AIN13 analog inputs.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-03-19 10:57:33 +01:00
Aksel Skauge Mellbye
d2c49544c8 drivers: adc: iadc_gecko: Use pm_device_driver_init
Enable PM device support by making use of the pm_device_driver_init
helper.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2025-03-19 01:23:24 +01:00
Emil Gydesen
60a980185d Revert "drivers: adc: adopt new count_bits util function"
This reverts commit 17c42550f3.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-18 16:39:47 +01:00
Benjamin Cabé
17c42550f3 drivers: adc: adopt new count_bits util function
Adopt new count_bits helper from util.h and avoid
having conflicting definition

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-03-18 08:24:16 +01:00
Phuc Pham
fe53749cdf drivers: adc: Initial support for RZ/G3S
Add ADC driver support for Renesas RZ/G3S

Signed-off-by: Phuc Pham <phuc.pham.xr@bp.renesas.com>
Signed-off-by: Binh Nguyen <binh.nguyen.xw@renesas.com>
2025-03-13 07:21:40 +01:00
Dimitrije Lilic
4a9d1473d3 drivers: adc: ad405x: Add AD405X driver
Initial AD405X driver supporting sampling, averaging
and burst averaging operation modes. Configurable
without interrupts or with device ready and
data ready interrupt.

Signed-off-by: Dimitrije Lilic <dimitrije.lilic@orioninc.com>
2025-03-12 19:02:25 +01:00
Khoa Nguyen
8671fdd86d drivers: adc: Remove channel_count property for Renesas driver
Currently, in Renesas adc driver, channel_count is used
as the maximum index of the channels can be supported.
However, the value input in dts of "channel_count"
represents the total number of supported channels.

After consideration, we have decided to remove this
reduntant property.

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2025-03-10 08:58:52 +01:00
Elliott Cutmore
e44a9523d4 drivers: adc: Fix ads1x4s0x driver initialised asynchronously
Definition of stack variable did not match the initialiser
reference in the driver

Signed-off-by: Elliott Cutmore <elliott.cutmore@gmail.com>
2025-03-08 08:56:33 +01:00
Khoa Nguyen
c768144002 drivers: Correct value of event macro for all Renesas SoC
Since the RA2L1 uses the macro "ICU_EVENT" instead of
"ELC_EVENT" (which is currently used) to input into
the IELSR register, the ek_ra2l1 board cannot assign
any interrupts for any driver.

This commit aim to correct the Event macro to input correct
value for IELSR register on all the Renesas SoC by using
"BSP_PRV_IELS_ENUM" macro.

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2025-02-28 18:29:17 +01:00