Commit graph

808 commits

Author SHA1 Message Date
Jeppe Odgaard
3a8dddcdad drivers: adc: stm32: use __maybe_unused
Replace conditional `ARG_UNUSED` with `__maybe_unused`. This is recommended
by coding style:
https://kernel.org/doc/html/latest/process/coding-style.html#conditional-compilation

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2025-02-28 14:53:17 +01:00
Marcio Ribeiro
71277577be driver: adc: esp32: fix read function
Compensates raw value reading before adc_read returns it

Signed-off-by: Marcio Ribeiro <marcio.ribeiro@espressif.com>
2025-02-25 07:57:00 +01:00
Sebastian Głąb
99c398845d drivers: adc: Fix Vref selection for nRF54L20pdk
Select Reference voltage of 900mV for ADC on nRF54L20pdk.

Add ADC to the list of supported peripherals.

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
2025-02-17 10:22:03 +01:00
Bjarki Arge Andreasen
96c3cd6cd3 drivers: adc: nrf_saadc: add pm device support
Extend nrf saadc device driver with pm device runtime support.

To preserve previous behavior:

* if pm device is disabled, saadc is resumed on sampling start
  and suspended when sampling done.
* if pm device is enabled only, saadc does nothing on
  sampling start/stop. its resumed on init.
* if pm device runtime is enabled, saadc is got on
  sampling start, and put on sampling stop.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-02-14 17:12:03 +01:00
Guillaume Gautier
a0761d6353 drivers: adc: stm32: configure data size for stm32n6
On STM32N6, the register holding the data is 32 bits and DMA must operate
in word transfer to work properly. So we change the type of the buffer in
which we store the ADC data from uint16_t to uint32_t for N6.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2025-02-14 10:48:35 +01:00
Guillaume Gautier
a28381f459 drivers: adc: stm32: enable analog supply in dedicated function
Move code to enable the analog supply in a dedicated function.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2025-02-14 10:48:35 +01:00
Guillaume Gautier
9ee33e990e drivers: adc: stm32: add support for stm32n6 adc
Add support for STM32N6 ADC in the STM32 ADC driver.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2025-02-14 10:48:35 +01:00
Rafał Kuźnia
f78742ff75 tests: drivers: adc: add nRF54L20 configuration
Added the test configuration for nRF54L20 for the following tests:
- adc_api
- adc_error_cases

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2025-02-13 16:41:57 +01:00
Aksel Skauge Mellbye
2322cc92c5 drivers: adc: iadc_gecko: Use clock control
Use clock control driver instead of hard-coding HAL function calls
to configure clocks.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2025-02-03 19:51:46 +01:00
Aksel Skauge Mellbye
117d7d1582 drivers: adc: iadc_gecko: Use pinctrl for bus allocation
Make use of ABUS support in the pinctrl driver to allocate
analog buses, rather than hard-coding bus 0 in the ADC driver.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2025-02-03 19:51:46 +01:00
McAtee Maxwell
24eb735b24 adc: modifications to support adc on cyw920829m2evk_02 platform
- Modifications to adc driver
	- Modifications to clock_control driver
	- Add adc to board's yaml
	- Add adc to relevant dts file

Signed-off-by: McAtee Maxwell <maxwell.mcatee@infineon.com>
2025-02-03 19:50:11 +01:00
Sylvio Alves
491bbcfcbd drivers: adc: esp32: delete line curve scheme
Make sure to delete line scheme instead of curve scheme
for socs that uses line scheme.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-02-03 17:00:04 +01:00
Terry Geng
49308e45d2 drivers: adc: ads1x4s0x: Add ADS124S0X support into existing drivers
Refactor code for ADS114S08 (12 ch, 16 bit) to accommodate ADS114S06
(6 ch, 16 bit), ADS124S06 (6 ch, 24 bit), and ADS124S08 (12 ch, 24 bit).

Signed-off-by: Terry Geng <terry@terriex.com>
2025-01-31 09:39:07 +01:00
Terry Geng
cbcb2d8f12 drivers: adc: ads1x4s0x: Rename files, preparing for adding new devices
Renamed ads114s0x/8 to ads1x4s0x.

Signed-off-by: Terry Geng <terry@terriex.com>
2025-01-31 09:39:07 +01:00
Terry Geng
43079c8086 drivers: adc: ads114s0x: Rename variables, preparing for adding new devices
Renamed ads114s0x/8 to ads1x4s0x.

Signed-off-by: Terry Geng <terry@terriex.com>
2025-01-31 09:39:07 +01:00
Sylvio Alves
e472fb603e drivers: adc: esp32: delete previous calibration curve
In case channel_setup is called with a new attenuation
config, make sure previous calibration scheme is deleted properly.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-01-30 22:59:21 +01:00
Yasin Ustuner
d411b4f67b drivers: adc: Introduce AD7124 adc driver
This commit introduces ad7124 adc driver.

Signed-off-by: Yasin Ustuner <Yasin.Ustuner@analog.com>
2025-01-30 20:33:10 +01:00
Karol Lasończyk
057de458e2 drivers: adc: Add support for gain 2/7 in nRF devices
Extend current adc gains with new entry 2/7.

Signed-off-by: Karol Lasończyk <karol.lasonczyk@nordicsemi.no>
2025-01-29 15:13:19 +01:00
Raffael Rostagno
8af0d881f4 drivers: adc: esp32: Clang run
Clang run for code formatting and calibrationc control for
repeated calls at channel_setup().

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2025-01-27 17:08:30 +01:00
Raffael Rostagno
1ed70820ca drivers: adc: esp32: GPIO config
Share GPIO config for both DMA and non-DMA mode.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2025-01-27 17:08:30 +01:00
Raffael Rostagno
5ee8600a59 drivers: adc: esp32: Clock init
Peripheral clock init.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2025-01-27 17:08:30 +01:00
Raffael Rostagno
f195b3528c drivers: adc: esp32: Driver update
Driver update to support newer HAL versions.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Signed-off-by: Marek Matej <marek.matej@espressif.com>
2025-01-27 17:08:30 +01:00
Pieter De Gendt
f1c4760304 drivers: Update APIs to use DEVICE_API macro
Some drivers APIs were not wrapped using the DEVICE_API macro.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-01-24 01:15:19 +01:00
Jordan Yates
055b7e886e adc: adc_emul: support adc_read_async with no signal
`adc_read_async` is documented as supporting the `async` signal as NULL.
Update the emulator to no longer block until completion when
`adc_read_async` is called in this situation.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-01-16 22:40:39 +01:00
Pierrick Curt
8250cc68b7 drivers: adc: ad4114: add driver support
The AD4114 is a low power, low noise, 24-bit, sigma-delta ADC.
This driver allows to use it with the Zephyr ADC API. It uses
the continuous acquisition ADC feature.

This ADC allows many configutations, but this driver uses it as the
most generic way :
- each can channel can be enable or disable using the device
tree configuration
- configure two setups (one for unipolar inputs, one for bipolar inputs)
- use an external clock

Signed-off-by: Pierrick Curt <pierrickcurt@gmail.com>
2025-01-15 19:04:20 +01:00
Patrick Günzel
66dceba537 driver: adjust res when oversampling
The SAM0 ADC has an internal register to divide the accumulated results
of oversampling the ADC by the amount of samples collected. This value
has to be set by the driver and was missing.

Signed-off-by: Patrick Günzel <patrick.guenzel@kinexon.com>
2025-01-15 07:19:03 +01:00
Gerson Fernando Budke
ea7922195b clocks: atmel: sam0: Fix gclk and mclk clock bindings
The Atmel SAM0 SoC enable peripherals clocks in distinct places: PM and
MCLK. The old devices had defined the peripheral clock enable bit at PM.
On the newer devices this was extracted on a dedicated memory section
called Master Clock (MCLK). This change excludes the dedicated bindings
in favor of a generic approach that cover all cases.

Now the clocks properties is complemented by the atmel,assigned-clocks
property. It gives the liberty to user to customize the clock source
from a generic clock or configure the direct connections.

All peripherals drivers were reworked with the newer solution.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2025-01-14 20:49:03 +01:00
Bart De Vos
4724c314ae drivers: adc: shell: add support for nxp RW61x
The compatible of NXP rw61x family is the 'nxp_gau_adc', which was
missing to the list.

Signed-off-by: Bart De Vos <bart.devos@verhaert.com>
2025-01-08 12:59:10 +01:00
Jeff Daly
334c6be2da drivers: adc: microchip: Fix PR #80933
Fixed bug calculating offset of registers after unused space in the ADC
register space for the SZ package parts.

Signed-off-by: Jeff Daly <jeffd@silicom-usa.com>
2024-12-23 23:58:47 +01:00
Karthikeyan Krishnasamy
b0389ce5b5 drivers: adc: add ads131m02 adc driver
ADS131M02 is Texas Instruments 2-channel, 24-Bit differential
input ADC which support wide range datarate.
Driver add support for adc read, channel configure, adc sampling
mode configuration and power management.

[1]. https://www.ti.com/lit/ds/symlink/ads131m02.pdf

Signed-off-by: Karthikeyan Krishnasamy <karthikeyan@linumiz.com>
2024-12-18 18:16:40 +01:00
Guillaume Gautier
2460e894e4 drivers: adc: stm32: remove unused cast
config->base is already defined as ADC_TypeDef so no there is no need to
cast it as such. Remove all occurrences throughout the file.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-12-18 15:32:35 +01:00
Guillaume Gautier
47b2bb7652 drivers: adc: stm32: listify some tables
Listify the content of the tables used for sequencer and oversampling.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-12-18 15:32:35 +01:00
Guillaume Gautier
420b2a053c drivers: adc: stm32: move define from dt-binding into driver
Now that clock source and sequencer are defined with strings in device
tree, move the old defines directly in the driver

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-12-18 15:32:35 +01:00
Guillaume Gautier
e0554aa453 drivers: adc: stm32: use a string for sequencer and clock source property
Now that st,adc-sequencer and st,adc_clock-source use a string, update the
ADC driver.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>

fu drv adc update driver with string
2024-12-18 15:32:35 +01:00
Guillaume Gautier
afa97d12ec drivers: adc: stm32: simplify adc dma enable function
Remove specific cases for H7 and U5: group them together and only call a
single function. ADC3 of H72x/H73x and ADC4 of U5 are different from other
ADC of their series, and have dedicated functions in the LL for enabling
DMA, but they're doing the exact same operation as
LL_ADC_REG_SetDataTransferMode.

Incidentally, this change allows H7A/H7B to use the DMA (it seems to have
been missed before).

Last, this change enables the DMA support for F1x ADC.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-12-18 15:32:35 +01:00
Guillaume Gautier
4cfbf78939 drivers: adc: stm32: simplify oversampling with new property
Use the new oversampler property to simplify the management of the
ADC oversampling.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-12-18 15:32:35 +01:00
Guillaume Gautier
fb5ff902e8 drivers: adc: stm32: better express f3 and h7 adc versions
STM32F3 and H7 have multiple ADC versions difficult to differentiate.
Use clearer macros to make code more readable.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-12-18 15:32:35 +01:00
Guillaume Gautier
e978164a6b drivers: adc: stm32: add log message when adc overrun
Displays an error log message when an ADC overrun occurs.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-12-18 15:32:35 +01:00
Khoa Nguyen
e95d18587f drivers: adc: Add ADC properties in Renesas RA ADC node
- Add "channel-available-mask" property in ADC node
to detect which channels are available to use

- Add "add-average-count" property in ADC node to chose
number of count of the addition or average mode

- Change the source code of ADC to match with 2 new properties.

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2024-12-18 12:46:31 +01:00
Benjamin Bigler
f1087d2042 drivers: adc: tla202x: add support for tla2022 and tla2024
This extends the tla2021 driver to support tla2022 and tla2024

Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
2024-12-18 08:33:49 +01:00
Benjamin Bigler
7609ceadc4 drivers: adc: tla2021: rename everything from tla2021 to tla202x
Rename everything from tla2021 to tla202x (except dtcompatible)
in preparation to add support for tla2022 and tla2024

Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
2024-12-18 08:33:49 +01:00
Benjamin Bigler
25c210e8eb drivers: adc: tla2021: sleep until sampling is done
Sleep until sampling is done instead of polling. This avoids
blocking of other threads.

Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
2024-12-18 08:33:49 +01:00
Nathan Olff
42e7095d1e drivers: adc: adc_emul: implement raw func set function in adc_emul
allow setting a function as generator of raw adc values in adc_emul

Signed-off-by: Nathan Olff <nathan@kickmaker.net>
2024-12-18 08:33:26 +01:00
Nathan Olff
d793b86a82 drivers: adc: adc_emul: write function to set const raw value
implement storage and retrieval of raw value in adc_emul

Signed-off-by: Nathan Olff <nathan@kickmaker.net>
2024-12-18 08:33:26 +01:00
Steven Chang
216391b1cc driver: adc: ene_kb1200: Use logging API
Use logging API instead of printk

Remove ampersand for function

Signed-off-by: Steven Chang <steven@ene.com.tw>
2024-12-16 10:53:58 +01:00
Benjamin Geiger
2ed8790e8b drivers: adc: fix IF_ENABLED macro usage in ADS1X1X trigger
The ADC_ADS1X1X_TRIGGER macro was defined without an explicit value,
preventing ALERT/RDY pin configuration even when alert_rdy_gpios
were properly defined in devicetree. This occurred because
the IF_ENABLED macro specifically requires macros to be defined as 1,
not just defined empty.

Fixed this by explicitly defining ADC_ADS1X1X_TRIGGER as 1 when
alert_rdy_gpios properties are present in devicetree.

Signed-off-by: Benjamin Geiger <BenjaminGeiger1@gmail.com>
2024-12-12 20:00:10 +01:00
Jeff Daly
371ca13c6d drivers: adc: microchip: Different channels per package type
LJ packages have 16 ADC channels vs 8 for SZ packages.  Enhance
devicetree to account for this as well as conditional defines/code.

Signed-off-by: Jeff Daly <jeffd@silicom-usa.com>
2024-12-11 21:35:49 +01:00
Guillaume Gautier
b8b6afd198 drivers: adc: stm32: use dedicated status function for ldo state
Now that the U5 HAL contains the dedicated LDO status function, use it
instead of reading the register directly.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-12-07 11:02:18 +01:00
Raymond Lei
0db1c07bf0 soc: nxp: imxrt11xx: select CONFIG_HAS_MCUX_ADC_ETC
On NXP RT1170 SOC, ADC ETC exists but it can not be enabled because
of dependency on HAS_MCUX_ADC_ETC.
Also, ADC ETC should only work with ADC together, there is no use
case to run it standalone.
Fixes:#81466

Signed-off-by: Raymond Lei <raymond.lei@nxp.com>
2024-12-07 02:03:45 +01:00
Neil Chen
0436801cf9 drivers: adc: mcux_lpadc: support IP instances without side B channel
Updating the LPADC driver to support IP without a side B channel.
The MCXA156 is an example with this instantiation of the IP.

Signed-off-by: Neil Chen <cheng.chen_1@nxp.com>
2024-12-06 10:01:26 +01:00