drivers: i2c: tca954x: Add build assert avoiding prio issues

In order for TCA954X driver to work well, we know that
mux root must be initialized before channels.
(see #37786).

This commit is:
- Ensuring that this condition is met at build.
- Document needed values for menuconfig to help user.
- Edit these values for TCA954X test sample

Fixes #40833

Signed-off-by: Aymeric Aillet <aymeric.aillet@iot.bzh>
This commit is contained in:
Aymeric Aillet 2023-06-12 16:15:25 +02:00 committed by Carles Cufí
parent 15b8bff832
commit 1ddc41e7dd
3 changed files with 9 additions and 0 deletions

View file

@ -13,9 +13,13 @@ if I2C_TCA954X
config I2C_TCA954X_ROOT_INIT_PRIO
int "TCA954x root driver init priority"
default I2C_INIT_PRIORITY
help
Should be lower than `I2C_TCA954X_CHANNEL_INIT_PRIO`
config I2C_TCA954X_CHANNEL_INIT_PRIO
int "TCA954x channel driver init priority"
default I2C_INIT_PRIORITY
help
Should be higher than `I2C_TCA954X_ROOT_INIT_PRIO`
endif

View file

@ -156,6 +156,9 @@ const struct i2c_driver_api tca954x_api_funcs = {
.transfer = tca954x_transfer,
};
BUILD_ASSERT(CONFIG_I2C_TCA954X_CHANNEL_INIT_PRIO > CONFIG_I2C_TCA954X_ROOT_INIT_PRIO,
"I2C multiplexer channels must be initialized after their root");
#define TCA954x_CHILD_DEFINE(node_id, n) \
static const struct tca954x_channel_config \
tca##n##a_down_config_##node_id = { \

View file

@ -1,3 +1,5 @@
CONFIG_ZTEST=y
CONFIG_ZTEST_NEW_API=y
CONFIG_I2C=y
CONFIG_I2C_TCA954X_ROOT_INIT_PRIO=61
CONFIG_I2C_TCA954X_CHANNEL_INIT_PRIO=62