Commit Graph

577 Commits

Author SHA1 Message Date
Anas Nashif 56fddd805a syscall: rename z_user_from_copy -> k_usermode_from_copy
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 684b8fcdd0 syscall: Z_SYSCALL_VERIFY_MSG -> K_SYSCALL_VERIFY_MSG
Rename macros and do not use Z_ for internal APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 4e396174ce kernel: move syscall_handler.h to internal include directory
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Benedikt Schmidt 49ce054200 drivers: adc: fix thread function signatures
Fix the data acquisition thread function signatures to avoid a stack
corruption on thread exit.
Fixes #62637

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
TOKITA Hiroshi 2e848d8357 drivers: adc: rpi_pico: Fix pinctrl doesn't apply in initialization.
Fix the problem not apply pinctrl eventhough the config is defined.

In practice, the setting is equals to soc default.
So, there is no apparent change in behavior.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2023-10-27 10:49:17 +02:00
Flavio Ceolin b483c9251c drivers: adc: Fix misuse of const and k_tid_t
"const k_tid_t" is "struct k_thread * const" and not "const struct
k_thread *" as the code may be assuming. Just drop it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-23 11:35:33 +02:00
Mulin Chao a6496e056b soc: npcx: replace Nuvoton NPCX series definitions in the npcx drivers
Replace Nuvoton NPCX series definitions with new Kconfig definitions in
the npcx drivers. The benefit of this approach is that we won't touch
the npcx driver sources again during introducing a new npcx series next
time.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2023-10-20 15:07:21 +02:00
Daniel Leung 04a0cf7d79 kernel: deprecate K_THREAD_STACK_MEMBER
The macro K_THREAD_STACK_MEMBER has actually been deprecated
since v2.4.0 in the macro doxygen description, but it was
never marked with __DEPRECATED_MACRO. Since this was being
used in various drivers, make it follow the deprecation
process.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-10-12 11:07:00 +01:00
Guillaume Gautier 69fb18a19d drivers: adc: stm32: ADC nocache buffers can be in CONFIG_NOCACHE_MEMORY
CONFIG_NOCACHE_MEMORY is a valid way of declaring buffers in
nocache regions. Consider them valid in the STM32 ADC driver
nocache check.
Copied from commit 818aa2d

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-09-29 16:52:33 +03:00
Guillaume Gautier e8e5d5554c drivers: adc: stm32: reset acquisition time between reads
For all STM32 ADC that use common sampling times, there is a check made to
ensure that all channels of a sequence use the same sampling time.
The value was not reset between reads, resulting in error if two
consecutive sequences used different values.
This commit adds a reset of this value once read is done.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-09-29 09:47:07 +02:00
Nick Ward 4fe5beb2c5 drivers: adc: shell: add differential command
Add differential command.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-09-25 16:42:10 +02:00
Nick Ward f2af46aaa0 drivers: adc: shell: remove \n from logs
Remove \n from logs.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-09-25 16:42:10 +02:00
Nick Ward 50462228f2 drivers: adc: shell: fix - read result is signed
Previously negative read results were being printed
by the shell as large uint16_t.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-09-25 16:42:10 +02:00
Guillaume Gautier e09c594711 drivers: adc: stm32: remove channel count limit
Remove CHANNEL_COUNT limit used to check the channel bitmask.
This value was not applicable on STM32L1 where channel can go up to 31.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-09-22 15:30:47 +02:00
Guillaume Gautier c201d21964 drivers: adc: rework stm32 adc sequencer
Add sequencer support for all STM32 series.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-09-22 15:30:47 +02:00
Guillaume Gautier a1adc17b31 drivers: adc: stm32: move internal path setting to sensor drivers
On some STM32 families (such as F4), temperature and Vbat sensor share the
same ADC channel, which can lead to conflict when reading them, and wrong
measurement can follow.

To alleviate this problem, this commit moves the setting of the common
path internal channel to the sensor drivers themselves instead of doing
it in the ADC driver.

The teardown is still done in the ADC driver, systematically, instead of
channel by channel (which has the same result).

By moving this logic in the sensor drivers, the properties temp-channel,
vbat-channel and vref-channel becomes useless and are thus removed.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-09-22 09:21:34 +02:00
Declan Snyder fe8b112efd dts: bindings: lpadc: Add regulator phandle prop
Add phandle prop to reference any regulator that must
be enabled in order for the LPADC to function as intended.

Change LPADC driver to use this property if present.

LPADC on LPC55S36 depends on VREF peripheral, enable for this platform.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-09-21 09:26:57 +02:00
Carlo Caione e4a125b6a4 dt: Make zephyr,memory-attr a capabilities bitmask
This is the final step in making the `zephyr,memory-attr` property
actually useful.

The problem with the current implementation is that `zephyr,memory-attr`
is an enum type, this is making very difficult to use that to actually
describe the memory capabilities. The solution proposed in this PR is to
use the `zephyr,memory-attr` property as an OR-ed bitmask of memory
attributes.

With the change proposed in this PR it is possible in the DeviceTree to
mark the memory regions with a bitmask of attributes by using the
`zephyr,memory-attr` property. This property and the related memory
region can then be retrieved at run-time by leveraging a provided helper
library or the usual DT helpers.

The set of general attributes that can be specified in the property are
defined and explained in
`include/zephyr/dt-bindings/memory-attr/memory-attr.h` (the list can be
extended when needed).

For example, to mark a memory region in the DeviceTree as volatile,
non-cacheable, out-of-order:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_VOLATILE |
			       DT_MEM_NON_CACHEABLE |
			       DT_MEM_OOO )>;
   };

The `zephyr,memory-attr` property can also be used to set
architecture-specific custom attributes that can be interpreted at run
time. This is leveraged, among other things, to create MPU regions out
of DeviceTree defined memory regions on ARM, for example:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-region = "NOCACHE_REGION";
       zephyr,memory-attr = <( DT_ARM_MPU(ATTR_MPU_RAM_NOCACHE) )>;
   };

See `include/zephyr/dt-bindings/memory-attr/memory-attr-mpu.h` to see
how an architecture can define its own special memory attributes (in
this case ARM MPU).

The property can also be used to set custom software-specific
attributes. For example we can think of marking a memory region as
available to be used for memory allocation (not yet implemented):

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_NON_CACHEABLE |
			       DT_MEM_SW_ALLOCATABLE )>;
   };

Or maybe we can leverage the property to specify some alignment
requirements for the region:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_CACHEABLE |
			       DT_MEM_SW_ALIGN(32) )>;
   };

The conventional and recommended way to deal and manage with memory
regions marked with attributes is by using the provided `mem-attr`
helper library by enabling `CONFIG_MEM_ATTR` (or by using the usual DT
helpers).

When this option is enabled the list of memory regions and their
attributes are compiled in a user-accessible array and a set of
functions is made available that can be used to query, probe and act on
regions and attributes, see `include/zephyr/mem_mgmt/mem_attr.h`

Note that the `zephyr,memory-attr` property is only a descriptive
property of the capabilities of the associated memory  region, but it
does not result in any actual setting for the memory to be set. The
user, code or subsystem willing to use this information to do some work
(for example creating an MPU region out of the property) must use either
the provided `mem-attr` library or the usual DeviceTree helpers to
perform the required work / setting.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-09-15 12:46:54 +02:00
Gerard Marull-Paretas aaeb0a672e toolchain: only include <zephyr/toolchain.h>
It is wrong to use toolchain-specific header files.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-15 09:27:30 +02:00
Benedikt Schmidt 413267ea4f drivers: adc: add MAX11102-MAX11117 to ADC shell
Add all available instances of the ADC series
MAX11102-MAX11117 to the ADC shell.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-09-14 08:32:46 -05:00
Benedikt Schmidt 666520b8b6 drivers: adc: add driver for MAX11102-MAX11117
Add a driver for the following ADCs:
- MAX11102
- MAX11103
- MAX11105
- MAX11106
- MAX11110
- MAX11111
- MAX11115
- MAX11116
- MAX11117

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-09-14 08:32:46 -05:00
Mulin Chao eacdadf270 driver: adc: npcx: remove `threshold-reg-offset` DT property
Remove `threshold-reg-offset` DT property and implement them with static
inline functions in `reg_def.h`

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2023-09-08 14:43:37 +02:00
Mulin Chao 72ee4f75ef driver: adc: npcx: add multi-device support in npcx adc driver
Add multi-device support in npcx adc driver since there is more than one
adc module in npcx4 series. And each adc's reference voltage might be
different, this CL introduces the `vref-mv` prop. to select its own
reference voltage.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Signed-off-by: Kate Yen <htyen@nuvoton.com>
2023-09-08 14:43:37 +02:00
Sreeram Tatapudi 09a07e42c0 drivers: cat1: Updates to support latest version of HAL/PDL
- Refactoring to support latest versions of HAL/PDL

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2023-09-01 09:52:25 +02:00
Guillaume Gautier 7f8831aa7e drivers: adc: stm32: add support for kernel source clock
Add support for ADC kernel source clock, similar to other STM32 drivers.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-08-29 11:27:07 +01:00
Guillaume Gautier 484028306d drivers: adc: stm32: use dts to set the clock prescaler
Now that everything is in place, the prescaler value picked from dts is
used to properly configure the clock.
The code is moved into its own function.
There are four main cases:
- F1 and F37x don't have prescaler (in ADC register) so nothing is done.
- F0 only has individual registers.
- C0, G0, L0, WB1x and WL have both invidual and common registers. The
  individual one is used to define either synchronous mode with its
  prescaler, or asynchronous mode. The common one is only used to store
  the value of the asynchronous prescaler.
- All others only have a common register where both the mode and the
  prescaler is stored.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-08-29 11:27:07 +01:00
Guillaume Gautier e8c4990639 drivers: adc: stm32: get prescaler value from dts
Get the STM32 ADC prescaler data from dts to create the appropriate LL
macro to use for the ADC clock.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-08-29 11:27:07 +01:00
Mustafa Abdullah Kus 2e4e992644 drivers: adc: add max1125x driver
This adds support for the max1125x (max11254, max11254)
family of spi adc devices.

Signed-off-by: Mustafa Abdullah Kus <mustafa.kus@sparsetechnology.com>
2023-08-18 12:05:17 +02:00
Eric Holmberg 9452cbfe9d soc: esp32s3: add ADC single-shot support
Add support for single-shot ADC readings.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2023-08-17 10:36:20 +02:00
Eric Holmberg 38203f9cb0 drivers: adc: esp32: return unsupported for unsupported options
To allow the ADC API unit test to skip tests for non-implemented
features, return -ENOTSUP.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2023-08-17 10:36:20 +02:00
Chris Collins 2bf231f39a adc: ads1x1x: improve behaviour during i2c errors
Fixes #61401

The ADS1x1x driver has a bad habit of assuming i2c operations will
always suceed - this fixes the two worse cases in the code I could
identify (there may yet be more).

* During initial ADC setup, if either of the two I2C operations
  (read or write) fails, raise the error immediately to the caller
  rather than letting it fall through to the acquisition thread.

  This ensures that we only ever attempt to give a result that was
  definitely connected to our attempt to start the capture.

* If the acquisition thread encounters an I2C error, raise the error
  but do not terminate the aquisition thread.  This ensures the
  application can attempt to fix the condition that caused the I2C
  error and try again.

Signed-off-by: Chris Collins <kuroneko@sysadninjas.net>
2023-08-16 17:05:44 +02:00
Cong Nguyen Huu a872aa9a5e drivers: adc: support adc shell for mr_canhubk3
Add device nxp_s32_adc_sar  to adc shell list

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2023-08-03 08:28:31 +00:00
Cong Nguyen Huu f809614136 drivers: adc: add NXP S32 ADC SAR driver
Add support ADC SAR for NXP S32. ADC SAR diver
support 3 group channels (precision, standard
and external), run normal trigger in oneshot
conversion mode with 2 callbacks normal end
of conversion and normal end chain callbacks.
An instance only run on 1 group channel and
1 kind of callback at the same time.

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2023-07-28 08:55:38 -05:00
Marek Matej 6b57b3b786 soc: xtensa,riscv: esp32xx: refactor folder structure
Refactor the ESP32 target SOCs together with
all related boards. Most braking changes includes:

- changing the CONFIG_SOC_ESP32* to refer to
  the actual soc line (esp32,esp32s2,esp32s3,esp32c3)
- replacing CONFIG_SOC with the CONFIG_SOC_SERIES
- creating CONFIG_SOC_FAMILY_ESP32 to embrace all
  the ESP32 across all used architectures
- introducing CONFIG_SOC_PART_NUMBER_* to
  provide a SOC model config
- introducing the 'common' folder to hide all
  commonly used configs and files.
- updating west.yml to reflect previous changes in hal

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-07-25 18:12:33 +02:00
Carlo Caione 15e84cbfac dts: Move to 'zephyr,memory-attr'
Move to 'zephyr,memory-attr' and use the newly introduced helpers.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-07-25 11:22:10 +02:00
Benedikt Schmidt 332850a367 drivers: adc: configurable acquisition time for ADS114s0x
Implement a configurable acquisition time for the ADS114s0x.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-07-24 13:21:13 +00:00
Benedikt Schmidt d2e89eb512 drivers: adc: make all enabled ADCs available in the shell
Previously, only a single type of ADCs was always available
in the ADC shell. This change enables the usage of the ADC
shell for different ADC types at the same time.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-07-24 08:14:03 -05:00
Benedikt Schmidt 0d33ecd56a drivers: adc: configurable wait for completion timeout
Depending on the ADC implementation it might happen that
the driver is waiting on an external interrupt. If this interrupt
gets lost, for instance due to a race condition with an external
port expander, the system will get stuck.
Making this configurable allows the user to recover from such
an error.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-07-19 15:22:33 +00:00
Wojciech Sipak 48fc80fa79 drivers: adc: iadc_gecko: select proper bits from sample
Only 12-bit resolution is currently available in the driver,
and each of the 16-bit samples store the actual data
aligned to the left.
A sample should be shifted 4 bits to the right to allow
proper interpretation.

Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
2023-07-18 16:21:09 +02:00
Wojciech Sipak c811a4f430 drivers: adc: add ADC driver for EFM32
This adds a driver for ADCs available on EFM32

Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
2023-07-18 11:05:39 +00:00
Guillaume Gautier d15f3448b5 drivers: adc: Update ADC driver for STM32WBA series
Update ADC driver for STM32WBA series

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-07-12 11:48:10 +02:00
Elisabeth Friedrich f4356f3b2e drivers: lpadc: fix ADC command chaining
When reading multiple ADC channel in parallel, an ADC command chain will be
build. This is similar to a linked list, as every command references the
next command.

Before this patch every ADC command after the first, would always reference
this initial command. So that during execution only two commands (the last
and first) would be executed which resulted in readout of only two analog
values. As Zephyr expected more to come in, the `read_adc` function would
block endlessly.

The patch fixes the behaviour and allows a correct chain to build up.

Signed-off-by: Elisabeth Friedrich <auxsys@flowerpot.me>
2023-07-12 09:25:44 +02:00
Wojciech Sipak 490281a1d0 drivers: adc: fix missing ref_internal in iadc_gecko
The adc_driver_api structure provides .ref_internal
which previously was unset.
Now .ref_internal is set to the proper value.

Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
2023-07-10 15:10:23 +02:00
Brett Witherspoon 8f73a479d1 drivers: adc: stm32: use correct device in dma callback
The device passed to the DMA callback is the DMA device. Instead use
the ADC device available in the private data.

Signed-off-by: Brett Witherspoon <brett@witherspoon.engineering>
2023-07-03 13:50:37 +00:00
Caspar Friedrich 9291c9f7d6 drivers: tla2021: Add driver
This adds a driver for Texas Instruments Cost-Optimized, Ultra-Small,
12-Bit, System-Monitoring ADCs. Currently only TLA2021 is supported,
TLA2022 and TLA2024 may follow based on this driver.

Signed-off-by: Caspar Friedrich <c.s.w.friedrich@gmail.com>
2023-07-03 09:30:54 +02:00
Daniel Leung 26ecaba4af drivers: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Jordan Montgomery b1e9a813fe drivers: adc: adc-shell: Add support for ADS111x ADCs to adc-shell.c
The adc-shell uses a hardcoded list of defines to check whether it should
throw a compile-time error. The ADS1119 and ADS1112 driver both support
the APIs needed by the shell, so this commit enables support for them in
the hardcoded support list.

Signed-off-by: Jordan Montgomery <jordan.montgomery@getcruise.com>
2023-06-17 07:49:59 -04:00
Jordan Montgomery a7014d01da drivers: adc: Add support for TI ADS1112 ADCs
This PR adds a custom driver for the ADS1112 ADCs. Unlike ADS1113/4/5
family served by the ADS1x1x driver, the ADS1112 does not use an address
pointer to address config registers. Instead, there is only one writable
register and all i2c writes will set it. The registers resemble the
ADS1119 device, but config bitmap is different, include a distinct data
rate table, gain table, and input multiplexing table. There is also not a
status register to be monitored with the ADS1112, as it uses config bit 7
for the same purpose instead of a separate register.

The driver was tested on hardware using the ADC shell interface. Manual
probing validated the voltages for the MUX_SINGLE configs at datarate 15
in CM_SINGLE. Higher gains were not tested and CM_CONTINUOUS is not
supported in this initial implementation.

The new driver has also been added to the existing ADC test using adc_emul
for completeness.

Origin: original
License: Apache 2.0
Purpose: Adding support for ADS1112 ADCs

Signed-off-by: Jordan Montgomery <jordan.montgomery@getcruise.com>
2023-06-17 07:49:59 -04:00
Ryan McClelland 77fb2025a8 drivers: adc: ads1x1x: fix pga enum comment
The pga enum internal reference voltage and gain values
were fixed in the code, but a comment was forgotten to be
updated. Correct the comment to match how the code uses
the enum.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2023-05-31 10:35:53 +02:00
Benedikt Schmidt 4540c833a8 drivers: adc: Implement the current sources of ADS114S08
Implement support for the current sources of ADS114S08.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-05-27 05:33:52 -04:00