From 8e1264314d1db33ae28786ec7cb1c32b18c87c74 Mon Sep 17 00:00:00 2001 From: Cyril Fougeray Date: Tue, 17 Oct 2023 17:56:32 +0200 Subject: [PATCH 1/2] 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) From ac1bf1b6c67c7abef0c4613aefce8662f71a38e4 Mon Sep 17 00:00:00 2001 From: Moritz Diller Date: Tue, 14 Nov 2023 11:09:29 +0100 Subject: [PATCH 2/2] add init priorities for instances 4 and 5 --- drivers/gpio/gpio_pca95xx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpio/gpio_pca95xx.c b/drivers/gpio/gpio_pca95xx.c index 8c88e76af97d33..3d7d12e4f25c65 100644 --- a/drivers/gpio/gpio_pca95xx.c +++ b/drivers/gpio/gpio_pca95xx.c @@ -858,6 +858,12 @@ static int gpio_pca95xx_init(const struct device *dev) #ifndef CONFIG_PCA95XX_INIT_PRIO_INST_3 #define CONFIG_PCA95XX_INIT_PRIO_INST_3 CONFIG_GPIO_PCA95XX_INIT_PRIORITY #endif +#ifndef CONFIG_PCA95XX_INIT_PRIO_INST_4 +#define CONFIG_PCA95XX_INIT_PRIO_INST_4 CONFIG_GPIO_PCA95XX_INIT_PRIORITY +#endif +#ifndef CONFIG_PCA95XX_INIT_PRIO_INST_5 +#define CONFIG_PCA95XX_INIT_PRIO_INST_5 CONFIG_GPIO_PCA95XX_INIT_PRIORITY +#endif #define GPIO_PCA95XX_DEVICE_INSTANCE(inst) \ static const struct gpio_pca95xx_config gpio_pca95xx_##inst##_cfg = { \