Commit graph

808 commits

Author SHA1 Message Date
Declan Snyder
4b45928e86 drivers: lpadc: Move SOC code out of driver
To be consistent with the current NXP clocking scheme,
move the LPADC clocking code to the SOC files where
all of the other peripheral clocking is done.

Also remove any other SOC-specific code to the
respective SOC file and out of this driver.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-04-28 10:08:05 +02:00
Declan Snyder
af6b9d857f drivers: lpadc: re-add power level code
Code for power level property was accidentally
removed by accident from driver in commit 9921c59f40

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-04-28 10:08:05 +02:00
Bill Waters
3e02d48e4e driver: adc: infineon: Adding ADC driver
- This includes the driver, test app, and sample app
- Only the boards\arm\cy8cproto_062_4343w board is supported for now

Signed-off-by: Bill Waters <bill.waters@infineon.com>
2023-04-27 10:16:23 -07:00
Guillaume Gautier
f3a8279996 drivers: adc: get resolutions from dtsi for stm32 adc
Simplify the STM32 ADC driver code by using the new ADC resolutions
property in dtsi files.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-04-26 12:53:03 +02:00
Declan Snyder
9921c59f40 drivers: lpadc: Make DT props match RM
- Remove build asserts in favor of DT enums
- Remove power level property since it is unused by SDK
- Correct voltage ref value in DT to correspond to
  chip specific values documented in reference manuals
  instead of corresponding to SDK enum names.
- Fix SOC devicetrees affected by these changes.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-04-25 19:59:23 +02:00
Brian Juel Folkmann
f05b6f412e drivers: adc: stm32h5 adc driver must wait about 1ms after enabling
port commit f7f47dc to stm32h5

Without this fix, ADC driver will hang when reading internal channels.

Signed-off-by: Brian Juel Folkmann <bju@trackunit.com>
2023-04-24 13:34:50 +02:00
Gerard Marull-Paretas
989d103d53 drivers: all: mcux: remove conditional support for pinctrl
The MCUX platform always uses pinctrl, there's no need to keep extra
macrology around pinctrl. Also updated driver's Kconfig options to
`select PINCTRL` (note that some already did).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-24 13:34:22 +02:00
Mateusz Sierszulski
0417d38d4d drivers/adc: add Gecko IADC driver
This commit adds the Gecko IADC driver and support for it to the
efr32bg_sltb010a board.

Signed-off-by: Mateusz Sierszulski <msierszulski@antmicro.com>
Signed-off-by: Roman Dobrodii <rdobrodii@antmicro.com>
2023-04-21 16:24:39 +02:00
Benjamin Björnsson
f08b80054e drivers: adc: adc_emul: Move semicolon to allow for multi-instancing
Move semicolon from end of DT_INST_FOREACH to DEVICE_DT_INST_DEFINE
to make multi-instancing possible. This caused some problems with
CI after adding adc node to native_posix dts.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2023-04-20 10:48:33 +02:00
Gerard Marull-Paretas
1eb683a514 device: remove redundant init functions
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-19 10:00:25 +02:00
Tim Lin
bcb173becd tests: drivers: Unit test for it82xx2_evb board
The below is the unit test result for the driver and kernel of
it82xx2_evb board.

GPIO/gpio_basic_api: PASS
I2C/i2c_api: PASS
Flash: PASS
UART/uart_basic_api: PASS
PWM/pwm_api: PASS
WDT/wdt_basic_api: PASS
KSCAN/kscan_api: PASS
kernel/sched/schedule_api: PASS
kernel/sched/preempt: PASS
kernel/timer/timer_api: PASS
kernel/sleep: PASS
ADC/adc_api: PASS.
ADC note: conversion time~=61.6us
          sample time delay~=60us
          wait voltage stable time~=202.8us
Set sampling time to 500us will pass for ADC test.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-04-19 03:48:38 -04:00
Gerard Marull-Paretas
667eeb11fb shell: fix MISRA 5.7 violations on struct shell
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Declan Snyder
65aad527b7 drivers: lpadc: Enable VREF in init
Enable VREF peripheral in the LPADC init
so that ADC can measure voltages properly.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-04-13 16:13:25 +02:00
David Leach
70d045fd7a drivers: adc: Add LPADC driver support to lpc55s36
Add LPADC support to LPC55S36 SOC platform

Signed-off-by: David Leach <david.leach@nxp.com>
2023-04-13 16:13:25 +02:00
Hake Huang
e01586a03a driver: adc16 dma support async and repeat sample
add support for async call and repeat sample test

1. change the DMA req to 2 byte each
2. increase the buffer pre-dma
3. add protection on invalid buffer

depends on: PR #56104
fixing: issue #56070

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2023-04-13 10:00:24 +02:00
Hein Wessels
6427ba861c drivers: adc: stm32h7: remove oversampling workaround
Removes a workaround that was required while there was a bug in
upstream STM32 HAL drivers where the oversampling was not set
correctly in all cases. This has since been fixed, and also
added to the Zephyr STM32 HAL.

The upstream issue:
https://github.com/STMicroelectronics/STM32CubeH7/issues/177

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-04-13 09:59:42 +02:00
Gerard Marull-Paretas
a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
Gerard Marull-Paretas
0ebe14beb4 sys: util: migrate all files to DIV_ROUND_UP
ceiling_fraction is deprecated, use DIV_ROUND_UP.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-11 12:00:37 +02:00
Al Semjonovs
9fa35bc9a0 adc: Add TI ADS7052 SPI driver
Add driver for TI ADS7052.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-04-07 16:23:17 -05:00
Benjamin Björnsson
05e9387663 drivers: adc: adc_stm32: Add support for C0-series
Add support for ADC on STM32C0-series.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2023-04-07 08:18:03 +00:00
Pieter De Gendt
6b532ff43e treewide: Update clock control API usage
Replace all (clock_control_subsys_t *) casts with (clock_control_subsys_t)

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-05 10:55:46 +02:00
Kumar Gala
a29bc8d086 adc: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-04 14:07:14 +02:00
Mahesh Mahadevan
793f1dacec drivers: adc_mcux_lpadc: Fix the config initilization
offset_b of the config structure was never initialized.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2023-04-03 10:22:27 -05:00
Francois Ramu
3f6a3d6031 drivers: adc stm32adc driver for the new stm32h5 serie
Add the support of the new stm32h5 to the stm32 ADC driver
Note : LL_ADC_CLOCK_ASYNC_DIV6 is the value for getting the
expected results of ADC.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-04-03 09:50:43 +02:00
Jordan Yates
5e09f5b1f1 adc: adc_mchp_xec: fix CONFIG_PM_DEVICE compilation
Replace pointer construction macro with value from config struct.
Fixes what appears to be an oversight from #55522.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-03-28 17:36:32 -04:00
Henrik Brix Andersen
c41dd36de2 drivers: kconfig: unify menuconfig title strings
Unify the drivers/*/Kconfig menuconfig title strings to the format
"<class> [(acronym)] [bus] drivers".

Including both the full name of the driver class and an acronym makes
menuconfig more user friendly as some of the acronyms are less well-known
than others. It also improves Kconfig search, both via menuconfig and via
the generated Kconfig documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-28 15:06:06 +02:00
Francois Ramu
f7f47dc437 drivers: adc: stm32 adc driver must wait about 1ms after enabling
After enabling the ADC, the peripheral has a certain delay (about 1ms)
to set its ADC Ready flag in the ADC ISR register.
In between, the ADRDY is still 0 and the ADEN is 1 in the CR.
The ADC can be used for conversion, only when the ADRDY bit is set

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-03-28 09:57:28 +02:00
scott worley
6b8bc83f54 tests: adc: Microchip XEC fix ADC API test and ADC shell
Microchip XEC ADC and ADC V2 driver were merged into one
That PR did not change the ADC API test and ADC shell resulting
in twister build failures. Fixed both ADC API test and ADC shell.

Signed-off-by: scott worley <scott.worley@microchip.com>
2023-03-24 11:28:20 -04:00
Manimaran A
c3b2dbd1fb driver: adc: microchip: Keep single adc driver for MEC devices
Deleted adc_mchp_xec.c and microchip,xec-adc.yaml file.
DTSI, yaml, CMakeLists.txt and Kconfig.xec files are
updated for compatible.

Signed-off-by: Manimaran A <manimaran.a@microchip.com>
2023-03-23 11:43:30 -04:00
Manimaran A
51b1c5b9d6 driver: adc: microchip: Merged MEC172x and MEC15xx version drivers.
Updated the "adc_mchp_xec_v2.c" adc driver to support both MEC172x and
MEC15xx SOC.
ADC smapling clock configuration updated using DTS.

Signed-off-by: Manimaran A <manimaran.a@microchip.com>
2023-03-23 11:43:30 -04:00
Manimaran A
f6a0d9c7f7 driver: adc: microchip: MEC172x driver clean up
adc_mchp_xec_v2.c driver clean up by variable name change
and redundant macro removal.

Signed-off-by: Manimaran A <manimaran.a@microchip.com>
2023-03-23 11:43:30 -04:00
Daniel DeGrasse
e587047dc6 drivers: adc: rewrite mcux LPADC driver
Rewrite MCUX LPADC driver, to better utilize hardware.
the following changes have been applied:
- channel numbers now correspond to hardware channel command slots,
  use "input_positive" and "input_negative" fields along with channel
  definitions in dt-bindings/adc/mcux-lpadc.h to select a channel
- the number of channel command slots available is configurable via
  CONFIG_LPADC_CHANNEL_COUNT
- Side A and side B channels are now supported
- differential channel mode is now supported
- ADC channels now are sampled via hardware, without additional
  software triggering

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-03-23 08:58:44 +00:00
Pieter De Gendt
0b45710219 drivers: adc: adc_sam: Introduce Atmel SAM ADC driver
This commit adds support for Atmel SAM ADC driver with up to
16 channels.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-03-23 09:41:00 +01:00
Hein Wessels
36f592ddbc drivers: adc: stm32: only handle OVR flag when supported
STM32 ADC DMA support added in #52965 incorrectly assumed
that all ADC devices have a OVR flag. This commit changes
the driver to only account for it if it's found in the
LL drivers.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-03-22 09:34:42 +01:00
Gerson Fernando Budke
6951160dd2 drivers: afec: sam: Enable sam4e SoCs
Add support to Atmel SAM SAM4E AFEC feature.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2023-03-21 14:12:25 -07:00
Gerson Fernando Budke
6634d6b4ff drivers: afec: sam: Update to use clock control
This update Atmel SAM afec driver to use clock control driver.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2023-03-21 14:12:25 -07:00
Hein Wessels
a2dd232410 drivers: adc: stm32: dma support
Sampling multiple adc channels at once using dma

Only verified to be working on nucleo_h743zi

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-03-20 16:29:24 +01:00
Francois Ramu
551be5c7f6 drivers: adc: stm32 adc driver disable before calibration
In the adc_stm32_init() function, when adc_stm32_calib() is called,
the ADC is not yet enabled but still disabled.
This patch makes sure to Disable the ADC before  its calibration.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-03-08 11:06:27 +01:00
Jay Vasanth
f8d9465332 pm: adc: MEC172x adc device PM support
update MEC172x adc driver to support device PM.
Implement pm resume and suspend actions to put adc
pins in proper state for suspend and resume.
Notify kernel of busy when adc sampling is in progress.

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2023-03-01 08:41:16 -06:00
Tim Lin
00e6c19ab5 ITE: drivers/adc: Add config of ADC reference voltage full-scale 3300mV
This option can enable ADC internal reference voltage as
full-scale 3300mV.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-02-23 08:59:54 +01:00
Cyril Fougeray
f43292a01a adc: stm32: stop ADC before disabling it
It is advised to stop any ongoing ADC conversion before
disabling the peripheral.
Added some comments so that ADC state isn't left into
intermediate state that would prevent correctly
enabling or disabling the peripheral

Signed-off-by: Cyril Fougeray <cyril.fougeray@worldcoin.org>
2023-02-22 12:05:32 +01:00
Daniel DeGrasse
f7d9ea889b drivers: adc: support side B channels in LPADC driver
Add support for side B channels in MCUX LPADC driver. Given
that no instances of the IP block have more than 8 a side channels,
use channel numbers over 8 to indicate side B channel is desired.

Fixes #51076

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-02-08 01:08:08 +09:00
Andrei Emeltchenko
3f0487b725 drivers: adc_ads1119: Fix using wrong status bit
Fixes using wrong status bit for ADS1119_STATUS_MASK_ID. Moreover
using BIT(8) does not make much sense for working with uint8_t.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-27 18:09:49 +09:00
Guillaume Gautier
6deebdd13a drivers: adc: Remove now unused variables for STM32 ADC
Remove boolean variables for internal channels now that we use channel
number directly

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-01-25 15:00:21 +00:00
Guillaume Gautier
9c6d44ef5a drivers: adc: Simplify STM32 ADC channels setup
Now that we have the information of internal channel number for STM32
ADCs in the dts, we can use it to remove a lot of specific code and
make it clearer.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-01-25 15:00:21 +00:00
Erwan Gouriou
34e49a7c54 drivers: adc: stm32: Refactor driver init section
Slightly refactor STM32_ADC_INIT macro.
adc_stm32_cfg_##index declaration is now part of ADC_STM32_INIT
and extracted from CONFIG_ADC_STM32_SHARED_IRQS #ifdef.

Aim is to minimize code duplication when adding new adc_stm32_cfg_X
or adc_stm32_data_Y entries

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-25 15:00:21 +00:00
Hein Wessels
6724c8d1fe drivers: adc: stm32: only teardown channel after context complete
Previously channels could be tore down before a sequence completes,

either when using async, or when ADC_ACTION_REPEAT was specified

The teardown is now moved to after an entire context is complete

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-01-23 09:59:46 +00:00
Hein Wessels
cbe52e9027 drivers: adc: stm32: support multiple channels
Support sequencing multiple channels into a single read

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-01-23 09:59:46 +00:00
Hein Wessels
dce0eb7e8f drivers: adc: adc_context: add optional context_on_complete
This optional function allows a driver to do operations

after a complete sampling sequence is completed.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-01-23 09:59:46 +00:00
YuLong Yao
aed1f1ac5b drivers: gd32_adc: add support for gd32a50x series.
add support for gd32a50x series.

Signed-off-by: YuLong Yao <feilongphone@gmail.com>
2023-01-12 21:45:38 +01:00