27
27
CONFIG_GPIO_INIT_PRIORITY.
28
28
#endif
29
29
30
- #define MAX_PORT_COUNT 4
31
30
#define MAX_PIN_COUNT 16
32
31
#define INVALID_PORT 0xFF
33
32
#define INTERRUPT_COUNT 8
34
33
35
34
/* Types */
36
35
struct gpio_siwx91x_common_config {
37
36
EGPIO_Type * reg ;
37
+ uint8_t port_count ;
38
38
};
39
39
40
40
struct gpio_siwx91x_port_config {
@@ -49,7 +49,7 @@ struct gpio_siwx91x_port_config {
49
49
50
50
struct gpio_siwx91x_common_data {
51
51
/* a list of all ports */
52
- const struct device * ports [ MAX_PORT_COUNT ] ;
52
+ const struct device * * ports ;
53
53
sl_gpio_t interrupts [INTERRUPT_COUNT ];
54
54
};
55
55
@@ -322,13 +322,14 @@ static int gpio_siwx91x_interrupt_configure(const struct device *port, gpio_pin_
322
322
323
323
static inline int gpio_siwx91x_init_port (const struct device * port )
324
324
{
325
- const struct gpio_siwx91x_port_config * cfg = port -> config ;
326
- const struct device * parent = cfg -> parent ;
325
+ const struct gpio_siwx91x_port_config * port_cfg = port -> config ;
326
+ const struct device * parent = port_cfg -> parent ;
327
+ __maybe_unused const struct gpio_siwx91x_common_config * cfg = parent -> config ;
327
328
struct gpio_siwx91x_common_data * data = parent -> data ;
328
329
329
330
/* Register port as active */
330
- __ASSERT (cfg -> port < MAX_PORT_COUNT , "Too many ports" );
331
- data -> ports [cfg -> port ] = port ;
331
+ __ASSERT (port_cfg -> port < cfg -> port_count , "Too many ports" );
332
+ data -> ports [port_cfg -> port ] = port ;
332
333
333
334
return pm_device_driver_init (port , gpio_siwx91x_port_pm_action );
334
335
}
@@ -409,10 +410,14 @@ static DEVICE_API(gpio, gpio_siwx91x_api) = {
409
410
static DEVICE_API (gpio , gpio_siwx91x_common_api ) = { };
410
411
411
412
#define GPIO_CONTROLLER_INIT (idx ) \
413
+ const struct device *ports_##idx[DT_INST_CHILD_NUM(idx)]; \
412
414
static const struct gpio_siwx91x_common_config gpio_siwx91x_config##idx = { \
413
415
.reg = (EGPIO_Type *)DT_INST_REG_ADDR(idx), \
416
+ .port_count = DT_INST_CHILD_NUM(idx), \
417
+ }; \
418
+ static struct gpio_siwx91x_common_data gpio_siwx91x_data##idx = { \
419
+ .ports = ports_##idx, \
414
420
}; \
415
- static struct gpio_siwx91x_common_data gpio_siwx91x_data##idx; \
416
421
\
417
422
static int gpio_siwx91x_init_controller_##idx(const struct device *dev) \
418
423
{ \
0 commit comments