Skip to content

Commit 8db851f

Browse files
ubiedakartben
authored andcommitted
general: icm4268x: Refactor ICM42688 driver to ICM4268X
As a first step to enable the similar variants (e.g: ICM42686), refactor common functionality into icm4268x files. As a result, applications using the icm42688 will need to have both compatible properties: "invensense,icm42688" and "invensense,icm4268x" defined. In-tree boards have been modified to comply with this pattern. This patch does not contain functional changes. The driver should work the same as before. Signed-off-by: Luis Ubieda <[email protected]>
1 parent 5c7c398 commit 8db851f

35 files changed

+859
-766
lines changed

boards/nxp/vmu_rt1170/vmu_rt1170_mimxrt1176_cm7.dts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
cs-gpios =<&gpio2 11 GPIO_ACTIVE_LOW>;
251251

252252
icm42688_0: icm42688p0@0 {
253-
compatible = "invensense,icm42688";
253+
compatible = "invensense,icm42688", "invensense,icm4268x";
254254
reg = <0>;
255255
int-gpios = <&gpio3 19 GPIO_ACTIVE_HIGH>;
256256
spi-max-frequency = <24000000>;
@@ -272,7 +272,7 @@
272272
cs-gpios =<&gpio3 24 GPIO_ACTIVE_LOW>;
273273

274274
icm42688_1: icm42688p1@0 {
275-
compatible = "invensense,icm42688";
275+
compatible = "invensense,icm42688", "invensense,icm4268x";
276276
reg = <0>;
277277
int-gpios = <&gpio2 7 GPIO_ACTIVE_HIGH>;
278278
spi-max-frequency = <24000000>;

boards/tdk/robokit1/robokit1-common.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
status = "okay";
102102

103103
icm42688: icm42688p@0 {
104-
compatible = "invensense,icm42688";
104+
compatible = "invensense,icm42688", "invensense,icm4268x";
105105
reg = <0>;
106106
int-gpios = <&pioc 5 GPIO_ACTIVE_HIGH>;
107107
spi-max-frequency = <24000000>;

doc/hardware/peripherals/sensor/device_tree.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ then be used in a boards devicetree to configure a sensor to its initial state.
1515
/* SPI bus options here, not shown */
1616
1717
accel_gyro0: icm42688p@0 {
18-
compatible = "invensense,icm42688";
18+
compatible = "invensense,icm42688", "invensense,icm4268x";
1919
reg = <0>;
2020
int-gpios = <&pioc 6 GPIO_ACTIVE_HIGH>; /* SoC specific pin to select for interrupt line */
2121
spi-max-frequency = <DT_FREQ_M(24)>; /* Maximum SPI bus frequency */

drivers/sensor/tdk/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# zephyr-keep-sorted-start
55
add_subdirectory_ifdef(CONFIG_ICM40627 icm40627)
66
add_subdirectory_ifdef(CONFIG_ICM42605 icm42605)
7-
add_subdirectory_ifdef(CONFIG_ICM42688 icm42688)
7+
add_subdirectory_ifdef(CONFIG_ICM4268X icm4268x)
88
add_subdirectory_ifdef(CONFIG_ICM42X70 icm42x70)
99
add_subdirectory_ifdef(CONFIG_ICM45686 icm45686)
1010
add_subdirectory_ifdef(CONFIG_ICP101XX icp101xx)

drivers/sensor/tdk/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# zephyr-keep-sorted-start
55
source "drivers/sensor/tdk/icm40627/Kconfig"
66
source "drivers/sensor/tdk/icm42605/Kconfig"
7-
source "drivers/sensor/tdk/icm42688/Kconfig"
7+
source "drivers/sensor/tdk/icm4268x/Kconfig"
88
source "drivers/sensor/tdk/icm42x70/Kconfig"
99
source "drivers/sensor/tdk/icm45686/Kconfig"
1010
source "drivers/sensor/tdk/icp101xx/Kconfig"

drivers/sensor/tdk/icm42688/CMakeLists.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.

drivers/sensor/tdk/icm42688/icm42688_rtio.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

drivers/sensor/tdk/icm42688/icm42688_trigger.h

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
zephyr_library()
4+
5+
zephyr_library_sources(
6+
icm4268x.c
7+
icm4268x_common.c
8+
icm4268x_spi.c
9+
)
10+
11+
zephyr_library_sources_ifdef(CONFIG_SENSOR_ASYNC_API icm4268x_rtio.c)
12+
zephyr_library_sources_ifdef(CONFIG_ICM4268X_DECODER icm4268x_decoder.c)
13+
zephyr_library_sources_ifdef(CONFIG_ICM4268X_STREAM icm4268x_rtio_stream.c)
14+
zephyr_library_sources_ifdef(CONFIG_ICM4268X_TRIGGER icm4268x_trigger.c)
15+
zephyr_library_sources_ifdef(CONFIG_EMUL_ICM4268X icm4268x_emul.c)
16+
zephyr_include_directories_ifdef(CONFIG_EMUL_ICM4268X .)
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
1-
# ICM42688-P Six-Axis Motion Tracking device configuration options
1+
# ICM4268X-P Six-Axis Motion Tracking device configuration options
22
#
33
# Copyright (c) 2022 Intel Corporation
44
# Copyright (c) 2024 Croxel Inc.
55
#
66
# SPDX-License-Identifier: Apache-2.0
77

8-
menuconfig ICM42688
9-
bool "ICM42688 Six-Axis Motion Tracking Device"
8+
menuconfig ICM4268X
9+
bool "ICM4268X Six-Axis Motion Tracking Device"
1010
default y
1111
depends on DT_HAS_INVENSENSE_ICM42688_ENABLED
1212
select SPI
1313
select RTIO_WORKQ if SENSOR_ASYNC_API
1414
help
15-
Enable driver for ICM42688 SPI-based six-axis motion tracking device.
15+
Enable driver for ICM4268X SPI-based six-axis motion tracking device.
1616

17-
if ICM42688
17+
if ICM4268X
1818

19-
config EMUL_ICM42688
20-
bool "Emulator for the ICM42688"
19+
config EMUL_ICM4268X
20+
bool "Emulator for the ICM4268X"
2121
default y
2222
depends on EMUL
2323
help
24-
Enable the hardware emulator for the ICM42688. Doing so allows exercising
24+
Enable the hardware emulator for the ICM4268X. Doing so allows exercising
2525
sensor APIs for this IMU in native_sim and qemu.
2626

27-
config ICM42688_DECODER
28-
bool "ICM42688 decoder logic"
27+
config ICM4268X_DECODER
28+
bool "ICM4268X decoder logic"
2929
default y
3030
select SENSOR_ASYNC_API
3131
help
32-
Compile the ICM42688 decoder API which allows decoding raw data returned
32+
Compile the ICM4268X decoder API which allows decoding raw data returned
3333
from the sensor.
3434

3535
choice
3636
prompt "Trigger mode"
37-
default ICM42688_TRIGGER_NONE if ICM42688_STREAM
38-
default ICM42688_TRIGGER_GLOBAL_THREAD
37+
default ICM4268X_TRIGGER_NONE if ICM4268X_STREAM
38+
default ICM4268X_TRIGGER_GLOBAL_THREAD
3939
help
4040
Specify the type of triggering to be used by the driver
4141

42-
config ICM42688_TRIGGER_NONE
42+
config ICM4268X_TRIGGER_NONE
4343
bool "No trigger"
4444

45-
config ICM42688_TRIGGER_GLOBAL_THREAD
45+
config ICM4268X_TRIGGER_GLOBAL_THREAD
4646
bool "Use global thread"
4747
depends on GPIO
48-
depends on $(dt_compat_any_has_prop,$(DT_COMPAT_INVENSENSE_ICM42688),int-gpios)
49-
select ICM42688_TRIGGER
48+
depends on $(dt_compat_any_has_prop,$(DT_COMPAT_INVENSENSE_ICM4268X),int-gpios)
49+
select ICM4268X_TRIGGER
5050

51-
config ICM42688_TRIGGER_OWN_THREAD
51+
config ICM4268X_TRIGGER_OWN_THREAD
5252
bool "Use own thread"
5353
depends on GPIO
54-
depends on $(dt_compat_any_has_prop,$(DT_COMPAT_INVENSENSE_ICM42688),int-gpios)
55-
select ICM42688_TRIGGER
54+
depends on $(dt_compat_any_has_prop,$(DT_COMPAT_INVENSENSE_ICM4268X),int-gpios)
55+
select ICM4268X_TRIGGER
5656

5757
endchoice
5858

59-
config ICM42688_STREAM
59+
config ICM4268X_STREAM
6060
bool "Use hardware FIFO to stream data"
61-
select ICM42688_TRIGGER
61+
select ICM4268X_TRIGGER
6262
default y
6363
depends on SPI_RTIO
6464
depends on SENSOR_ASYNC_API
6565
help
6666
Use this config option to enable streaming sensor data via RTIO subsystem.
6767

68-
config ICM42688_TRIGGER
68+
config ICM4268X_TRIGGER
6969
bool
7070

71-
config ICM42688_THREAD_PRIORITY
71+
config ICM4268X_THREAD_PRIORITY
7272
int "Own thread priority"
73-
depends on ICM42688_TRIGGER_OWN_THREAD
73+
depends on ICM4268X_TRIGGER_OWN_THREAD
7474
default 10
7575
help
7676
The priority of the thread used for handling interrupts.
7777

78-
config ICM42688_THREAD_STACK_SIZE
78+
config ICM4268X_THREAD_STACK_SIZE
7979
int "Own thread stack size"
80-
depends on ICM42688_TRIGGER_OWN_THREAD
80+
depends on ICM4268X_TRIGGER_OWN_THREAD
8181
default 1024
8282
help
8383
The thread stack size.
8484

85-
endif # ICM42688
85+
endif # ICM4268X

0 commit comments

Comments
 (0)