Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions drivers/gpio/Kconfig.nrfx
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ config GPIO_NRFX_INTERRUPT
The option can be used to disable the GPIO interrupt support to
significantly reduce memory footprint in case of application that does
not need GPIO interrupts.

config GPIO_NRFX_HAS_LATCH_DETECT
bool
default y if !(SOC_NRF54H20 || TRUSTED_EXECUTION_NONSECURE)
13 changes: 13 additions & 0 deletions drivers/gpio/gpio_nrfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#define GPIOTE_FLAG_FIXED_CHAN BIT(1)
#endif

#if NRF_GPIO_HAS_DETECT_MODE && defined(CONFIG_GPIO_NRFX_HAS_LATCH_DETECT)
#define GPIO_LATCH_DETECT_SUPPORT 1
#endif

struct gpio_nrfx_data {
/* gpio_driver_data needs to be first */
struct gpio_driver_data common;
Expand All @@ -51,6 +55,9 @@
nrfx_gpiote_t *gpiote;
uint32_t edge_sense;
uint8_t port_num;
#if defined(GPIO_LATCH_DETECT_SUPPORT)
bool latch_detect;
#endif
#if defined(GPIOTE_FEATURE_FLAG)
uint32_t flags;
#endif
Expand Down Expand Up @@ -449,6 +456,10 @@
return 0;
}

#if defined(GPIO_LATCH_DETECT_SUPPORT)
nrf_gpio_port_detect_latch_set(cfg->port, cfg->latch_detect);
#endif

nrfx_gpiote_trigger_config_t trigger_config = {
.trigger = get_trigger(mode, trig),
};
Expand Down Expand Up @@ -699,6 +710,8 @@
.gpiote = GPIOTE_REF(id), \
.edge_sense = DT_INST_PROP_OR(id, sense_edge_mask, 0), \
.port_num = DT_INST_PROP(id, port), \
IF_ENABLED(GPIO_LATCH_DETECT_SUPPORT, \
(.latch_detect = DT_INST_PROP(id, latch_detect),)) \
IF_ENABLED(GPIOTE_FEATURE_FLAG, \
(.flags = \
(DT_PROP_OR(GPIOTE_PHANDLE(id), no_port_event, 0) ? \
Expand All @@ -717,5 +730,5 @@
PRE_KERNEL_1, \
CONFIG_GPIO_INIT_PRIORITY, \
&gpio_nrfx_drv_api_funcs);

Check notice on line 733 in drivers/gpio/gpio_nrfx.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/gpio/gpio_nrfx.c:733 -#define GPIO_NRF_DEVICE(id) \ - GPIOTE_CHECK(id); \ - static struct gpio_nrfx_data gpio_nrfx_p##id##_data; \ - static const struct gpio_nrfx_cfg gpio_nrfx_p##id##_cfg = { \ - .common = { \ - .port_pin_mask = \ - GPIO_PORT_PIN_MASK_FROM_DT_INST(id), \ - }, \ - .port = _CONCAT(NRF_P, DT_INST_PROP(id, port)), \ - .gpiote = GPIOTE_REF(id), \ - .edge_sense = DT_INST_PROP_OR(id, sense_edge_mask, 0), \ - .port_num = DT_INST_PROP(id, port), \ +#define GPIO_NRF_DEVICE(id) \ + GPIOTE_CHECK(id); \ + static struct gpio_nrfx_data gpio_nrfx_p##id##_data; \ + static const struct gpio_nrfx_cfg gpio_nrfx_p##id##_cfg = { \ + .common = \ + { \ + .port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(id), \ + }, \ + .port = _CONCAT(NRF_P, DT_INST_PROP(id, port)), \ + .gpiote = GPIOTE_REF(id), \ + .edge_sense = DT_INST_PROP_OR(id, sense_edge_mask, 0), \ + .port_num = DT_INST_PROP(id, port), \ IF_ENABLED(GPIO_LATCH_DETECT_SUPPORT, \ - (.latch_detect = DT_INST_PROP(id, latch_detect),)) \ - IF_ENABLED(GPIOTE_FEATURE_FLAG, \ + (.latch_detect = DT_INST_PROP(id, latch_detect),)) \ + IF_ENABLED(GPIOTE_FEATURE_FLAG, \ (.flags = \ (DT_PROP_OR(GPIOTE_PHANDLE(id), no_port_event, 0) ? \ GPIOTE_FLAG_NO_PORT_EVT : 0) | \ (DT_PROP_OR(GPIOTE_PHANDLE(id), fixed_channels_supported, 0) ? \ GPIOTE_FLAG_FIXED_CHAN : 0),) \ - ) \ - }; \ - \ - PM_DEVICE_DT_INST_DEFINE(id, gpio_nrfx_pm_hook); \ - \ - DEVICE_DT_INST_DEFINE(id, gpio_nrfx_init, \ - PM_DEVICE_DT_INST_GET(id), \ - &gpio_nrfx_p##id##_data, \ - &gpio_nrfx_p##id##_cfg, \ - PRE_KERNEL_1, \ - CONFIG_GPIO_INIT_PRIORITY, \ - &gpio_nrfx_drv_api_funcs); + ) }; \ + \ + PM_DEVICE_DT_INST_DEFINE(id, gpio_nrfx_pm_hook); \ + \ + DEVICE_DT_INST_DEFINE(id, gpio_nrfx_init, PM_DEVICE_DT_INST_GET(id), \ + &gpio_nrfx_p##id##_data, &gpio_nrfx_p##id##_cfg, PRE_KERNEL_1, \ + CONFIG_GPIO_INIT_PRIORITY, &gpio_nrfx_drv_api_funcs);
DT_INST_FOREACH_STATUS_OKAY(GPIO_NRF_DEVICE)
5 changes: 5 additions & 0 deletions dts/bindings/gpio/nordic,nrf-gpio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ properties:

port = <1>;

latch-detect:
type: boolean
description: |
Enable latch detect mode for this GPIO port.

gpio-cells:
- pin
- flags
Loading