From 8e1264314d1db33ae28786ec7cb1c32b18c87c74 Mon Sep 17 00:00:00 2001 From: Cyril Fougeray Date: Tue, 17 Oct 2023 17:56:32 +0200 Subject: [PATCH] pca95xx: set init prio per instance allows to have some gpio expanders initialized before some others --- drivers/gpio/gpio_pca95xx.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio_pca95xx.c b/drivers/gpio/gpio_pca95xx.c index e8ae5ca26a2d6f..8c88e76af97d33 100644 --- a/drivers/gpio/gpio_pca95xx.c +++ b/drivers/gpio/gpio_pca95xx.c @@ -843,6 +843,22 @@ static int gpio_pca95xx_init(const struct device *dev) return 0; } +/* allow redefinition of init priority, per instance, + * at least for the 4 first instances + */ +#ifndef CONFIG_PCA95XX_INIT_PRIO_INST_0 +#define CONFIG_PCA95XX_INIT_PRIO_INST_0 CONFIG_GPIO_PCA95XX_INIT_PRIORITY +#endif +#ifndef CONFIG_PCA95XX_INIT_PRIO_INST_1 +#define CONFIG_PCA95XX_INIT_PRIO_INST_1 CONFIG_GPIO_PCA95XX_INIT_PRIORITY +#endif +#ifndef CONFIG_PCA95XX_INIT_PRIO_INST_2 +#define CONFIG_PCA95XX_INIT_PRIO_INST_2 CONFIG_GPIO_PCA95XX_INIT_PRIORITY +#endif +#ifndef CONFIG_PCA95XX_INIT_PRIO_INST_3 +#define CONFIG_PCA95XX_INIT_PRIO_INST_3 CONFIG_GPIO_PCA95XX_INIT_PRIORITY +#endif + #define GPIO_PCA95XX_DEVICE_INSTANCE(inst) \ static const struct gpio_pca95xx_config gpio_pca95xx_##inst##_cfg = { \ .common = { \ @@ -880,7 +896,8 @@ DEVICE_DT_INST_DEFINE(inst, \ NULL, \ &gpio_pca95xx_##inst##_drvdata, \ &gpio_pca95xx_##inst##_cfg, \ - POST_KERNEL, CONFIG_GPIO_PCA95XX_INIT_PRIORITY, \ + POST_KERNEL, \ + _CONCAT(CONFIG_PCA95XX_INIT_PRIO_INST_, inst), \ &gpio_pca95xx_drv_api_funcs); DT_INST_FOREACH_STATUS_OKAY(GPIO_PCA95XX_DEVICE_INSTANCE)