Commit graph

24538 commits

Author SHA1 Message Date
Hao Luo
6ed058887e drivers: spi: simplified spi_ambiq_xfer function
Simplified spi transfer process to make it more readable

Signed-off-by: Hao Luo <hluo@ambiq.com>
2024-07-28 07:29:28 +03:00
Hao Luo
8379f64393 drivers: bluetooth: hci_ambiq: get the spi cfg from the device
Use the SPI configuration from the SPI device for data transaction.

Signed-off-by: Hao Luo <hluo@ambiq.com>
2024-07-28 07:29:28 +03:00
Hao Luo
3faaaaba59 drivers: spi: Change to use software controlled cs in default
Added support for software controlled cs in Ambiq SPI drivers

Signed-off-by: Hao Luo <hluo@ambiq.com>
2024-07-28 07:29:28 +03:00
Kacper Dalach
32eb346e05 posix: can: if name from command-line
This commit introduces the ability to set the CAN
interface from command-line. This is helpful
if we want to run multiple instances of the app
with different CAN interfaces without making
separate compilations for each instance.

Signed-off-by: Kacper Dalach <dalachowsky@gmail.com>
2024-07-27 20:49:38 +03:00
Pieter De Gendt
ad63ca284e kconfig: replace known integer constants with variables
Make the intent of the value clear and avoid invalid ranges with typos.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-07-27 20:49:15 +03:00
Pisit Sawangvonganan
a2e0b1d366 drivers: serial: remove '&' when assigning init_fn
Remove address-of operator ('&') when assigning `init_fn`
function pointer in `DEVICE_DT_INST_DEFINE` macro.

This change aims to maintain consistency among the drivers in
`drivers/serial`, ensuring that all function pointer assignments
follow the same pattern.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-07-27 20:48:34 +03:00
Stefan Petersen
840e93fd60 drivers: flash: spi_nor: Print flash size properly when < 1 MiByte
When using SPI-NOR SFDP autodeteection, the flash size printed to
the log is rounded to 1 MiByte. If flash is smaller than 1 MiByte
it is printed as 0 MiByte.

With this patch smaller flash sizes are printed in kiByte, for instance
512 kiByte is printed correctly.

Signed-off-by: Stefan Petersen <spe@ciellt.se>
2024-07-27 20:47:39 +03:00
Fabio Baltieri
32fafc7176 input: analog_axis: add output inversion
The driver right now only allows inverting the input value, which can be
useful for differential channels but is quite confusing for single ended
ones. Implement a simple output inversion flag instead to make up for
that.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-07-27 20:47:18 +03:00
Chun-Chieh Li
f77023e649 drivers: hwinfo: add NuMaker support for device id
Add device id for Nuvoton NuMaker series

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2024-07-27 15:19:23 +03:00
Jordan Yates
5e2a4bca06 disk: flashdisk: init in POST_KERNEL
Initialise flashdisk devices in `POST_KERNEL` instead of `APPLICATION`.
This aligns with the other disk drivers, which are all `POST_KERNEL`,
and causes no problems as `disk_access_register` is a purely software
action and does not perform any operations on the underlying device.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-27 15:19:14 +03:00
Jordan Yates
9cb58cf53a disk: flashdisk: default enable if dts exists
Enable `DISK_DRIVER_FLASH` by default if the devicetree node exists, as
the other disk drivers do.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-27 15:19:14 +03:00
Jordan Yates
6bd77c848c disk: use standard DT kconfig dependencies
Use `depends on DT_HAS_* default y` instead of `default y if DT_HAS_*`
as the driver depends on devicetree instance.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-27 15:19:14 +03:00
Ryan McClelland
ec41afaa5d drivers: i3c: add KConfig to perform rstact during bus init
Sometimes, performing a rstact which will reset all devices during init
on the bus may not be ideal. Add a KConfig to easily turn off.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2024-07-27 15:18:18 +03:00
Andreas Klinger
dda519d48c drivers: gnss: remove dangerous loop
When ubx_m10_ubx_cfg_rst is returning something negative there is a loop
in the code which in turn can easily turn into an endless loop if the
function is never returning something positive or zero.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
2024-07-27 15:17:52 +03:00
Andreas Klinger
a1eb11bb59 drivers: gnss: remove sleep during init
It's not allowed to sleep during initialization of driver as called by
bg_thread_main --> z_sys_init_run_level(INIT_LEVEL_POST_KERNEL)
               --> do_device_init  -->  ubx_m10_init

There is no thread_base.timeout struct setup so far.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
2024-07-27 15:17:52 +03:00
Andreas Klinger
7c8033f8d8 drivers: gnss: cleanup function returning
Cleanup more returns and gotos as they are redundant.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
2024-07-27 15:17:52 +03:00
Andreas Klinger
f89f2ae46c drivers: gnss: clean up labels
Clean up labels no longer needed.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
2024-07-27 15:17:52 +03:00
Andreas Klinger
8d8fe9d169 drivers: gnss: fix setting of baudrate
ubx_m10_init_pipe is calling modem_backend_uart_init which in turn is
memsetting the backend data structure and thus also overwrites the work
queue function pointer in it.

Remove call to ubx_m10_init_pipe as data structures are already set up.

Tested with u-blox NEO M9N.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
2024-07-27 15:17:52 +03:00
Fabio Baltieri
03f1dd413d input: paw32xx: only reschedule the handler if motion is asserted
The motion event handler is currently setup to always retrigger until
there's no more motion data from the sensor. Change that to only
retrigger if the motion pin is asserted when the handler has finished
running, this saves a bunch of unnecessary spi transactions.

Ideally this driver would use a level interrupt, but I'd rather avoid
that as that is unsupported by many gpio controllers.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-07-27 15:17:38 +03:00
Jordan Yates
7b18cc112c flash: nrf_qspi_nor: don't auto call pm_device_runtime_enable
Device drivers should not be calling `pm_device_runtime_enable` on
themselves, it should be left up to the application. If automatic
enablement is desired, `zephyr,pm-device-runtime-auto` exists as a
devicetree property.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-27 15:16:23 +03:00
Jordan Yates
0b935295c6 flash: nrf_qspi_nor: remove PM_DEVICE_RUNTIME guards
The `pm_device_runtime_get` and `pm_device_runtime_put` functions work
correctly regardless of whether `PM_DEVICE_RUNTIME` is enabled or not.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-27 15:16:23 +03:00
Jordan Yates
db87eface2 flash: nrf_qspi_nor: remove excessive semaphore
The `count` semaphore was being used as an atomic counter, so replace
it with an atomic variable, which is a simpler solution and enables
removing the conditionals with `PM_DEVICE_RUNTIME`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-27 15:16:23 +03:00
Jun Lin
51cfbd8c5f drivers: espi: host_subs: npcx: fix LDN register definition of PMCH
The register offset definition of the I/O port Data Base Address
register (0x60, 0x61) and Command/Status Base Address register
(0x62, 0x63) are reversed. This commit fixes it to avoid confusion.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2024-07-27 15:15:22 +03:00
Flavio Ceolin
5822267c23 serial: uart_async_rx: Avoid possible division by zero
Ensures that config->but_cnt is not zero.

Fixes #66800
CID #338107

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-07-27 15:14:26 +03:00
Emanuele Di Santo
271ef88e05 drivers: mbox: nrf_bellboard: only clear events that raised the IRQ
The current implementation is such that if two or more events are
generated in quick succession, only one is handled. This would
have happened as follows.

At the beginning of the ISR, the contents of INTPEND are read.
Then, the ISR unconditionally clears all events that are set.

When two (or more) events are generated in rapid succession,
it may happen that by the time we enter the ISR, INTPEND is set
only for one event, but while we process the ISR, EVENTS_TRIGGERED
will be set for more than just that one event (more events are
generated).

By unconditionally clearing all events, we can potentially lose
all events that are generated during ISR processing.

This patch changes the ISR so that it only clears those events
that have a corresponding bit set in INTPEND at the time it is read.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2024-07-27 15:13:45 +03:00
Fin Maaß
da090f1cb9 drivers: ethernet: phy: phy_mii: use no-reset option
the dts binding of the ethernet-phy has the option
"no-reset" and the according driver already has the
right logic to make use of it, but unfortunately
the connection between them was missing.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-07-27 15:12:49 +03:00
Declan Snyder
9f56ff5d64 drivers: mdio: Clear interrupt signal in ISR
Apparently, disabling the intterupt is not enough,
because without clearing the flag, some errors are occurring.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-07-27 15:10:42 +03:00
Tom Burdick
5474b611cb icm42688: Fix divide by zero potential
There were code paths that could have lead to divide by zero given an
invalid scale setting for accel or gyro. In practice this should be an
invalid setup even before getting to these conversion functions. The
conversion functions now better show all valid values are accounted for
by using CODE_UNREACHABLE in the default case.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-07-27 15:10:27 +03:00
Fin Maaß
27aa4bc988 drivers: ethernet: add get_phy function
add get_phy function to the ethernet drivers.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-07-27 15:07:26 +03:00
Fin Maaß
ba5b4ae817 drivers: flash: spi_nor: doc: correct comment
the durations in the spi_nor_config struct
are in milliseconds not in microseconds.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-07-27 10:48:33 +03:00
Ryan McClelland
919d908d73 drivers: i3c: shell: add i2c scan command
This adds a workaround command to perform an I2C scan on
an I3C bus.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2024-07-27 10:46:50 +03:00
aab5730d0f drivers: mipi_dbi: reduce the RAM overhead
Constify the config and reorder the data fields for better packing.
This reduces the RAM usage of `mipi_dbi_spi` by 20 bytes.

Signed-off-by: Michael Hope <mlhx@google.com>
2024-07-27 10:45:34 +03:00
Ian Morris
a6a27aa43e drivers: sensor: tmp116: Add ability to set conversion averaging mode
Adds support for setting the number of conversion results that are
collected and averaged before updating the temperature register.

Signed-off-by: Ian Morris <ian.d.morris@outlook.com>
2024-07-27 10:45:01 +03:00
Gerard Marull-Paretas
a0da850497 drivers: i3c: common: add reference to address restrictions
This makes actions taken by the code easier to follow for newbies like
me.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-07-27 10:42:14 +03:00
Gerard Marull-Paretas
ba0ccae924 drivers: i3c: common: improve slot bit position code readability
Perform the modulo operation on `bitpos` before using it. This should
make code slightly more clear.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-07-27 10:42:14 +03:00
Jimmy Zheng
89250adea6 drivers: interrupt_controller: intc_nuclei_eclic: fixed $ra polluted
Both $ra and $t2 are caller-saved registers and may be modified in ISR
callback. Save $ra to stack to follow the calling convention.

Signed-off-by: Jimmy Zheng <jimmyzhe@andestech.com>
2024-07-27 10:42:03 +03:00
Fabio Baltieri
ef14c9b867 lib: os: add a header for printk hook functions
Add a zephyr/printk.h header for the __printk_hook functions, these are
currently manually declared by all console drivers for no good reason.

Move the documentation into the header and also unify the way that
console drivers call the function.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-07-27 10:41:01 +03:00
Johann Fischer
c7767e30cf drivers: udc_kinetis: emit Start of Frame events
Everything is in place, just emit SOF events.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-07-27 10:37:27 +03:00
Armando Visconti
a1f9793e0e drivers/sensor: lis2dux12: fix temperature conversion
Return to sensor_api i/f the temperature in Celsius instead
of the register raw value in LSB.

Fixes #75686

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2024-07-27 10:37:11 +03:00
Armando Visconti
cf20aa050d drivers/sensor: lis2dux12: fix odr and range
The current implementation assumes that sensor odr and range are
always configured in the Device Tree at compile time which might
not be the case.

Instead, application can set odr and range either at compile time
through the DT or using SENSOR_ATTR_SAMPLING_FREQUENCY and
SENSOR_ATTR_FULL_SCALE attributes at runtime, so each driver instance
must keep trace of the latest values set and use them in the sensor
APIs which require them (e.g. lis2dux12_mode_set).

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2024-07-27 10:37:11 +03:00
Armando Visconti
2eaec8b779 sensor: lis2dux12: fix SENSOR_ATTR_FULL_SCALE case
When setting the full scale through SENSOR_ATTR_FULL_SCALE the
driver must convert the g value (i.e. one of 2g/4g/8g/16g) to
the corrispondent sensor fs raw value.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2024-07-27 10:37:11 +03:00
Jimmy Zheng
7802fffc7f drivers: interrupt_controller: nuclei_eclic: do not modifiy trap entry
RISC-V trap entry is handled in soc/common/riscv-privileged/vector.S.
Remove the redundant modification in CLIC driver.

Signed-off-by: Jimmy Zheng <jimmyzhe@andestech.com>
2024-07-12 16:09:22 -04:00
Jimmy Zheng
f989ed949a driver: interrupt_controller: nuclei_eclic: fixed interrupt level
CLIC should be the first level interrupt controller because it replaces
the basic RISC-V local interrupt.
The interrupt level in CLIC controls preemption between IRQs, rather than
specifying the number of nested interrupt controllers.
Removed CONFIG_MULTI_LEVEL_INTERRUPTS and the incorrect interrupt level.

Signed-off-by: Jimmy Zheng <jimmyzhe@andestech.com>
2024-07-12 16:09:22 -04:00
Bjarki Arge Andreasen
ee69e9fadf drivers: sensor: voltage_divider: revert patch
A patch was added to the voltage divider to handle an erroneous
negative voltage reading for the nrfx_saadc which could return
negative voltages even though the ADC mode was single ended.

This has now been patched in the ADC driver.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2024-07-12 19:50:27 +02:00
Bjarki Arge Andreasen
bb2f49fb51 drivers: adc: adc_nrfx_saadc: remove redundant code
Remove redundant copy of error code and 0 initialization of static
m_data struct.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2024-07-12 19:50:27 +02:00
Bjarki Arge Andreasen
13658a6687 drivers: adc: adc_nrfx_saadc: Patch neg single ended readings
The NRF SAADC produces negative values in single ended mode if the
positive input is below 0V (ground). This behavior does not match
the ADC device driver API, which states that in single ended mode,
the readings must be positive [0 .. 2^resolution - 1].

This commit extends the adc_nrfx_saadc device driver to track which
channels in a sequence are configured to be single ended, to then
corrects negative readings for these channels to 0.

This patch only works if the ADC resolution is lower than the sample
bit size. This is the case for 8, 10, 12 and 14 bit resolutions for
the nRF 52, 53 and 91 series which store readings in a int16_t.

The nRF 54H and 54L series store 8-bit resolution readings in a 8-bit
sample size. A check has been added to start_read() to prevent single
ended mode readings if the resolution is 8-bit for these platforms.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2024-07-12 19:50:27 +02:00
Dat Nguyen Duy
4884262088 drivers: intc: eirq_nxp_s32: allow the same callback to be set
Allow setting the same callback as long as the same data is used

Signed-off-by: Dat Nguyen Duy <dat.nguyenduy@nxp.com>
2024-07-12 09:39:12 -04:00
Johann Fischer
c5b93effe1 drivers: usb_dc_rpi_pico: set AVAILABLE bit separately
The DPSRAM ports can run at different clocks, this is the default
configuration, follow the advice in the datasheet and wait 3 nop
instructions before setting the AVAILABLE bit.

It can be observed that when the controller is continuously sending data
to the host, it rarely has a 0-byte transaction instead of a short
packet. The reason for this is not easy to find, it also seems to depend
on the runtime of individual components. This may fix the problem, but
there is no sure proof that this is the solution.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-07-12 09:38:30 -04:00
Liam Beguin
67544a6d2d spi: shell: add missing newline character
Add missing newline in help string.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
2024-07-12 09:12:47 -04:00
Simon Guinot
740d7f735e drivers: serial: lpc11u6x: allow to configure data polarity
This patch adds support for the rx-invert and tx-invert device-tree
properties to the uart_lpc11u6x driver for USARTs 1, 2, 3 and 4.

Note that this feature is not supported by USART 0.

Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
2024-07-12 06:29:56 -04:00