@@ -71,10 +71,10 @@ struct gpio_siwx91x_port_data {
71
71
/* Functions */
72
72
static int gpio_siwx91x_pin_configure (const struct device * dev , gpio_pin_t pin , gpio_flags_t flags )
73
73
{
74
- const struct gpio_siwx91x_port_config * cfg = dev -> config ;
74
+ const struct gpio_siwx91x_port_config * port_cfg = dev -> config ;
75
75
struct gpio_siwx91x_port_data * port_data = dev -> data ;
76
- const struct device * parent = cfg -> parent ;
77
- const struct gpio_siwx91x_common_config * pcfg = parent -> config ;
76
+ const struct device * parent = port_cfg -> parent ;
77
+ const struct gpio_siwx91x_common_config * cfg = parent -> config ;
78
78
uint8_t cur_cfg_pin = 0 ;
79
79
sl_status_t status ;
80
80
int i ;
@@ -84,11 +84,12 @@ static int gpio_siwx91x_pin_configure(const struct device *dev, gpio_pin_t pin,
84
84
return - ENOTSUP ;
85
85
}
86
86
87
- uint8_t pad = cfg -> pads [pin ];
87
+ uint8_t pad = port_cfg -> pads [pin ];
88
88
89
89
if (pad == 0 ) {
90
90
/* Enable MCU pad */
91
- status = sl_si91x_gpio_driver_enable_host_pad_selection ((cfg -> hal_port << 4 ) | pin );
91
+ status = sl_si91x_gpio_driver_enable_host_pad_selection ((port_cfg -> hal_port << 4 ) |
92
+ pin );
92
93
if (status != SL_STATUS_OK ) {
93
94
return - ENODEV ;
94
95
}
@@ -105,36 +106,36 @@ static int gpio_siwx91x_pin_configure(const struct device *dev, gpio_pin_t pin,
105
106
} else if (flags & GPIO_PULL_DOWN ) {
106
107
disable_state = GPIO_PULLDOWN ;
107
108
}
108
- if (cfg -> ulp ) {
109
+ if (port_cfg -> ulp ) {
109
110
sl_si91x_gpio_select_ulp_pad_driver_disable_state (pin , disable_state );
110
111
} else {
111
- sl_si91x_gpio_select_pad_driver_disable_state ((cfg -> port << 4 ) | pin ,
112
+ sl_si91x_gpio_select_pad_driver_disable_state ((port_cfg -> port << 4 ) | pin ,
112
113
disable_state );
113
114
}
114
115
115
116
if (flags & GPIO_INPUT ) {
116
- if (cfg -> ulp ) {
117
+ if (port_cfg -> ulp ) {
117
118
sl_si91x_gpio_driver_enable_ulp_pad_receiver (pin );
118
119
} else {
119
- sl_si91x_gpio_driver_enable_pad_receiver ((cfg -> port << 4 ) | pin );
120
+ sl_si91x_gpio_driver_enable_pad_receiver ((port_cfg -> port << 4 ) | pin );
120
121
}
121
122
} else {
122
- if (cfg -> ulp ) {
123
+ if (port_cfg -> ulp ) {
123
124
sl_si91x_gpio_driver_disable_ulp_pad_receiver (pin );
124
125
} else {
125
- sl_si91x_gpio_driver_disable_pad_receiver ((cfg -> port << 4 ) | pin );
126
+ sl_si91x_gpio_driver_disable_pad_receiver ((port_cfg -> port << 4 ) | pin );
126
127
}
127
128
}
128
129
129
- pcfg -> reg -> PIN_CONFIG [(cfg -> port << 4 ) + pin ].GPIO_CONFIG_REG_b .MODE = 0 ;
130
+ cfg -> reg -> PIN_CONFIG [(port_cfg -> port << 4 ) + pin ].GPIO_CONFIG_REG_b .MODE = 0 ;
130
131
131
132
if (flags & GPIO_OUTPUT_INIT_HIGH ) {
132
- sl_gpio_set_pin_output (cfg -> hal_port , pin );
133
+ sl_gpio_set_pin_output (port_cfg -> hal_port , pin );
133
134
} else if (flags & GPIO_OUTPUT_INIT_LOW ) {
134
- sl_gpio_clear_pin_output (cfg -> hal_port , pin );
135
+ sl_gpio_clear_pin_output (port_cfg -> hal_port , pin );
135
136
}
136
137
137
- sl_si91x_gpio_set_pin_direction (cfg -> hal_port , pin , (flags & GPIO_OUTPUT ) ? 0 : 1 );
138
+ sl_si91x_gpio_set_pin_direction (port_cfg -> hal_port , pin , (flags & GPIO_OUTPUT ) ? 0 : 1 );
138
139
139
140
for (i = 0 ; i < port_data -> next_pin ; i ++ ) {
140
141
if (port_data -> pin_config_info [i ].pin == pin ) {
@@ -148,7 +149,7 @@ static int gpio_siwx91x_pin_configure(const struct device *dev, gpio_pin_t pin,
148
149
port_data -> next_pin ++ ;
149
150
}
150
151
151
- if (cur_cfg_pin < __builtin_popcount (cfg -> common .port_pin_mask )) {
152
+ if (cur_cfg_pin < __builtin_popcount (port_cfg -> common .port_pin_mask )) {
152
153
port_data -> pin_config_info [cur_cfg_pin ].port_dev = dev ;
153
154
port_data -> pin_config_info [cur_cfg_pin ].pin = pin ;
154
155
port_data -> pin_config_info [cur_cfg_pin ].flags = flags ;
@@ -202,50 +203,50 @@ static int gpio_siwx91x_pm_action(const struct device *dev, enum pm_device_actio
202
203
203
204
static int gpio_siwx91x_port_get (const struct device * port , gpio_port_value_t * value )
204
205
{
205
- const struct gpio_siwx91x_port_config * cfg = port -> config ;
206
+ const struct gpio_siwx91x_port_config * port_cfg = port -> config ;
206
207
207
- * value = sl_gpio_get_port_input (cfg -> hal_port );
208
+ * value = sl_gpio_get_port_input (port_cfg -> hal_port );
208
209
209
210
return 0 ;
210
211
}
211
212
212
213
static int gpio_siwx91x_port_set_masked (const struct device * port , gpio_port_pins_t mask ,
213
214
gpio_port_value_t value )
214
215
{
215
- const struct gpio_siwx91x_port_config * cfg = port -> config ;
216
- const struct device * parent = cfg -> parent ;
217
- const struct gpio_siwx91x_common_config * pcfg = parent -> config ;
216
+ const struct gpio_siwx91x_port_config * port_cfg = port -> config ;
217
+ const struct device * parent = port_cfg -> parent ;
218
+ const struct gpio_siwx91x_common_config * cfg = parent -> config ;
218
219
219
220
/* Cannot use HAL function sl_gpio_set_port_output_value(), as it doesn't clear bits. */
220
- pcfg -> reg -> PORT_CONFIG [cfg -> port ].PORT_LOAD_REG =
221
- (pcfg -> reg -> PORT_CONFIG [cfg -> port ].PORT_LOAD_REG & ~mask ) | (value & mask );
221
+ cfg -> reg -> PORT_CONFIG [port_cfg -> port ].PORT_LOAD_REG =
222
+ (cfg -> reg -> PORT_CONFIG [port_cfg -> port ].PORT_LOAD_REG & ~mask ) | (value & mask );
222
223
223
224
return 0 ;
224
225
}
225
226
226
227
static int gpio_siwx91x_port_set_bits (const struct device * port , gpio_port_pins_t pins )
227
228
{
228
- const struct gpio_siwx91x_port_config * cfg = port -> config ;
229
+ const struct gpio_siwx91x_port_config * port_cfg = port -> config ;
229
230
230
- sl_gpio_set_port_output (cfg -> hal_port , pins );
231
+ sl_gpio_set_port_output (port_cfg -> hal_port , pins );
231
232
232
233
return 0 ;
233
234
}
234
235
235
236
static int gpio_siwx91x_port_clear_bits (const struct device * port , gpio_port_pins_t pins )
236
237
{
237
- const struct gpio_siwx91x_port_config * cfg = port -> config ;
238
+ const struct gpio_siwx91x_port_config * port_cfg = port -> config ;
238
239
239
- sl_gpio_clear_port_output (cfg -> hal_port , pins );
240
+ sl_gpio_clear_port_output (port_cfg -> hal_port , pins );
240
241
241
242
return 0 ;
242
243
}
243
244
244
245
static int gpio_siwx91x_port_toggle_bits (const struct device * port , gpio_port_pins_t pins )
245
246
{
246
- const struct gpio_siwx91x_port_config * cfg = port -> config ;
247
+ const struct gpio_siwx91x_port_config * port_cfg = port -> config ;
247
248
248
- sl_gpio_toggle_port_output (cfg -> hal_port , pins );
249
+ sl_gpio_toggle_port_output (port_cfg -> hal_port , pins );
249
250
250
251
return 0 ;
251
252
}
@@ -262,7 +263,7 @@ static bool receiver_enabled(bool ulp, sl_gpio_port_t port, int pin)
262
263
int gpio_siwx91x_port_get_direction (const struct device * port , gpio_port_pins_t map ,
263
264
gpio_port_pins_t * inputs , gpio_port_pins_t * outputs )
264
265
{
265
- const struct gpio_siwx91x_port_config * cfg = port -> config ;
266
+ const struct gpio_siwx91x_port_config * port_cfg = port -> config ;
266
267
267
268
if (inputs != NULL ) {
268
269
* inputs = 0 ;
@@ -272,12 +273,12 @@ int gpio_siwx91x_port_get_direction(const struct device *port, gpio_port_pins_t
272
273
}
273
274
for (int i = 0 ; i < MAX_PIN_COUNT ; i ++ ) {
274
275
if ((map & BIT (i ))) {
275
- if (sl_si91x_gpio_get_pin_direction (cfg -> hal_port , i ) == 0 ) {
276
+ if (sl_si91x_gpio_get_pin_direction (port_cfg -> hal_port , i ) == 0 ) {
276
277
if (outputs != NULL ) {
277
278
* outputs |= BIT (i );
278
279
}
279
280
}
280
- if (receiver_enabled (cfg -> ulp , cfg -> port , i )) {
281
+ if (receiver_enabled (port_cfg -> ulp , port_cfg -> port , i )) {
281
282
if (inputs != NULL ) {
282
283
* inputs |= BIT (i );
283
284
}
@@ -290,33 +291,33 @@ int gpio_siwx91x_port_get_direction(const struct device *port, gpio_port_pins_t
290
291
static int gpio_siwx91x_manage_callback (const struct device * port , struct gpio_callback * callback ,
291
292
bool set )
292
293
{
293
- struct gpio_siwx91x_port_data * data = port -> data ;
294
+ struct gpio_siwx91x_port_data * port_data = port -> data ;
294
295
295
- return gpio_manage_callback (& data -> callbacks , callback , set );
296
+ return gpio_manage_callback (& port_data -> callbacks , callback , set );
296
297
}
297
298
298
299
static int gpio_siwx91x_interrupt_configure (const struct device * port , gpio_pin_t pin ,
299
300
enum gpio_int_mode mode , enum gpio_int_trig trig )
300
301
{
301
- const struct gpio_siwx91x_port_config * cfg = port -> config ;
302
- const struct device * parent = cfg -> parent ;
303
- const struct gpio_siwx91x_common_config * pcfg = parent -> config ;
302
+ const struct gpio_siwx91x_port_config * port_cfg = port -> config ;
303
+ const struct device * parent = port_cfg -> parent ;
304
+ const struct gpio_siwx91x_common_config * cfg = parent -> config ;
304
305
struct gpio_siwx91x_common_data * data = parent -> data ;
305
306
sl_si91x_gpio_interrupt_config_flag_t flags = 0 ;
306
307
307
308
if (mode & GPIO_INT_DISABLE ) {
308
309
ARRAY_FOR_EACH (data -> interrupts , i ) {
309
- if (data -> interrupts [i ].port == cfg -> port &&
310
+ if (data -> interrupts [i ].port == port_cfg -> port &&
310
311
data -> interrupts [i ].pin == pin ) {
311
312
data -> interrupts [i ].port = INVALID_PORT ;
312
- if (cfg -> ulp ) {
313
+ if (port_cfg -> ulp ) {
313
314
sl_si91x_gpio_configure_ulp_pin_interrupt (i , flags , pin );
314
315
} else {
315
- sl_gpio_configure_interrupt (cfg -> port , pin , i , flags );
316
+ sl_gpio_configure_interrupt (port_cfg -> port , pin , i , flags );
316
317
}
317
318
/* Configure function doesn't mask interrupts when disabling */
318
- pcfg -> reg -> INTR [i ].GPIO_INTR_CTRL_b .MASK = 1 ;
319
- if (cfg -> ulp ) {
319
+ cfg -> reg -> INTR [i ].GPIO_INTR_CTRL_b .MASK = 1 ;
320
+ if (port_cfg -> ulp ) {
320
321
sl_si91x_gpio_clear_ulp_interrupt (i );
321
322
} else {
322
323
sl_gpio_clear_interrupts (i );
@@ -343,14 +344,15 @@ static int gpio_siwx91x_interrupt_configure(const struct device *port, gpio_pin_
343
344
344
345
ARRAY_FOR_EACH (data -> interrupts , i ) {
345
346
if (data -> interrupts [i ].port == INVALID_PORT ||
346
- (data -> interrupts [i ].port == cfg -> port && data -> interrupts [i ].pin == pin )) {
347
- data -> interrupts [i ].port = cfg -> port ;
347
+ (data -> interrupts [i ].port == port_cfg -> port &&
348
+ data -> interrupts [i ].pin == pin )) {
349
+ data -> interrupts [i ].port = port_cfg -> port ;
348
350
data -> interrupts [i ].pin = pin ;
349
351
350
- if (cfg -> ulp ) {
352
+ if (port_cfg -> ulp ) {
351
353
sl_si91x_gpio_configure_ulp_pin_interrupt (i , flags , pin );
352
354
} else {
353
- sl_gpio_configure_interrupt (cfg -> port , pin , i , flags );
355
+ sl_gpio_configure_interrupt (port_cfg -> port , pin , i , flags );
354
356
}
355
357
return 0 ;
356
358
}
@@ -375,34 +377,35 @@ static inline int gpio_siwx91x_init_port(const struct device *port)
375
377
376
378
static void gpio_siwx91x_isr (const struct device * parent )
377
379
{
378
- const struct gpio_siwx91x_common_config * pcfg = parent -> config ;
380
+ const struct gpio_siwx91x_common_config * cfg = parent -> config ;
379
381
struct gpio_siwx91x_common_data * common = parent -> data ;
380
382
const struct device * port ;
381
- struct gpio_siwx91x_port_data * data ;
383
+ struct gpio_siwx91x_port_data * port_data ;
382
384
383
385
ARRAY_FOR_EACH (common -> interrupts , i ) {
384
386
sl_gpio_port_t port_no = common -> interrupts [i ].port ;
385
- uint32_t pending = pcfg -> reg -> INTR [i ].GPIO_INTR_STATUS_b .INTERRUPT_STATUS ;
387
+ uint32_t pending = cfg -> reg -> INTR [i ].GPIO_INTR_STATUS_b .INTERRUPT_STATUS ;
386
388
387
389
if (pending && port_no != INVALID_PORT ) {
388
390
/* Clear interrupt */
389
- pcfg -> reg -> INTR [i ].GPIO_INTR_STATUS_b .INTERRUPT_STATUS = 1 ;
391
+ cfg -> reg -> INTR [i ].GPIO_INTR_STATUS_b .INTERRUPT_STATUS = 1 ;
390
392
port = common -> ports [port_no ];
391
- data = port -> data ;
392
- gpio_fire_callbacks (& data -> callbacks , port , BIT (common -> interrupts [i ].pin ));
393
+ port_data = port -> data ;
394
+ gpio_fire_callbacks (& port_data -> callbacks , port ,
395
+ BIT (common -> interrupts [i ].pin ));
393
396
}
394
397
}
395
398
}
396
399
397
400
static uint32_t gpio_siwx91x_get_pending_int (const struct device * port )
398
401
{
399
- const struct gpio_siwx91x_port_config * cfg = port -> config ;
400
- const struct device * parent = cfg -> parent ;
401
- const struct gpio_siwx91x_common_config * pcfg = parent -> config ;
402
+ const struct gpio_siwx91x_port_config * port_cfg = port -> config ;
403
+ const struct device * parent = port_cfg -> parent ;
404
+ const struct gpio_siwx91x_common_config * cfg = parent -> config ;
402
405
uint32_t status = 0 ;
403
406
404
- ARRAY_FOR_EACH (pcfg -> reg -> INTR , i ) {
405
- if (pcfg -> reg -> INTR [i ].GPIO_INTR_STATUS_b .INTERRUPT_STATUS ) {
407
+ ARRAY_FOR_EACH (cfg -> reg -> INTR , i ) {
408
+ if (cfg -> reg -> INTR [i ].GPIO_INTR_STATUS_b .INTERRUPT_STATUS ) {
406
409
status |= BIT (i );
407
410
}
408
411
}
0 commit comments