Skip to content

Commit f5273aa

Browse files
committed
drivers: gpio: silabs-siwx91x: Differentiate port count
Add the port_count field to the configuration structure and allocate different sizes for the ports array based on whether the node is HP or ULP. Signed-off-by: Sai Santhosh Malae <[email protected]>
1 parent e739740 commit f5273aa

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/gpio/gpio_silabs_siwx91x.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
CONFIG_GPIO_INIT_PRIORITY.
2828
#endif
2929

30-
#define MAX_PORT_COUNT 4
3130
#define MAX_PIN_COUNT 16
3231
#define INVALID_PORT 0xFF
3332
#define INTERRUPT_COUNT 8
3433

3534
/* Types */
3635
struct gpio_siwx91x_common_config {
3736
EGPIO_Type *reg;
37+
uint8_t port_count;
3838
};
3939

4040
struct gpio_siwx91x_port_config {
@@ -49,7 +49,7 @@ struct gpio_siwx91x_port_config {
4949

5050
struct gpio_siwx91x_common_data {
5151
/* a list of all ports */
52-
const struct device *ports[MAX_PORT_COUNT];
52+
const struct device **ports;
5353
sl_gpio_t interrupts[INTERRUPT_COUNT];
5454
};
5555

@@ -327,7 +327,7 @@ static inline int gpio_siwx91x_init_port(const struct device *port)
327327
struct gpio_siwx91x_common_data *data = parent->data;
328328

329329
/* Register port as active */
330-
__ASSERT(cfg->port < MAX_PORT_COUNT, "Too many ports");
330+
__ASSERT(cfg->port < parent->config->port_count, "Too many ports");
331331
data->ports[cfg->port] = port;
332332

333333
return pm_device_driver_init(port, gpio_siwx91x_port_pm_action);
@@ -409,10 +409,14 @@ static DEVICE_API(gpio, gpio_siwx91x_api) = {
409409
static DEVICE_API(gpio, gpio_siwx91x_common_api) = { };
410410

411411
#define GPIO_CONTROLLER_INIT(idx) \
412+
const struct device *ports_##idx[DT_INST_PROP(idx, silabs_port_count)]; \
412413
static const struct gpio_siwx91x_common_config gpio_siwx91x_config##idx = { \
413414
.reg = (EGPIO_Type *)DT_INST_REG_ADDR(idx), \
415+
.port_count = DT_INST_PROP(idx, silabs_port_count), \
416+
}; \
417+
static struct gpio_siwx91x_common_data gpio_siwx91x_data##idx = { \
418+
.ports = ports_##idx, \
414419
}; \
415-
static struct gpio_siwx91x_common_data gpio_siwx91x_data##idx; \
416420
\
417421
static int gpio_siwx91x_init_controller_##idx(const struct device *dev) \
418422
{ \

0 commit comments

Comments
 (0)