Lines Matching +full:pin +full:- +full:id
4 * SPDX-License-Identifier: Apache-2.0
12 #include <zephyr/dt-bindings/gpio/nordic-nrf-gpio.h>
41 return port->data; in get_port_data()
46 return port->config; in get_port_cfg()
51 return cfg->gpiote.p_reg != NULL; in has_gpiote()
70 if (cfg->pad_pd == NRF_GPD_FAST_ACTIVE1) { in gpio_nrfx_gpd_retain_set()
74 nrf_gpio_port_retain_enable(cfg->port, mask); in gpio_nrfx_gpd_retain_set()
96 if (cfg->pad_pd == NRF_GPD_FAST_ACTIVE1) { in gpio_nrfx_gpd_retain_clear()
104 nrf_gpio_port_retain_disable(cfg->port, mask); in gpio_nrfx_gpd_retain_clear()
114 static int gpio_nrfx_pin_configure(const struct device *port, gpio_pin_t pin, in gpio_nrfx_pin_configure() argument
122 nrfx_gpiote_pin_t abs_pin = NRF_GPIO_PIN_MAP(cfg->port_num, pin); in gpio_nrfx_pin_configure()
152 return -EINVAL; in gpio_nrfx_pin_configure()
155 ret = gpio_nrfx_gpd_retain_clear(port, BIT(pin)); in gpio_nrfx_pin_configure()
161 nrf_gpio_port_out_set(cfg->port, BIT(pin)); in gpio_nrfx_pin_configure()
163 nrf_gpio_port_out_clear(cfg->port, BIT(pin)); in gpio_nrfx_pin_configure()
179 /* Get the GPIOTE channel associated with this pin, if any. It needs in gpio_nrfx_pin_configure()
180 * to be freed when the pin is reconfigured or disconnected. in gpio_nrfx_pin_configure()
183 err = nrfx_gpiote_channel_get(&cfg->gpiote, abs_pin, &ch); in gpio_nrfx_pin_configure()
188 /* Ignore the error code. The pin may not have been used. */ in gpio_nrfx_pin_configure()
189 (void)nrfx_gpiote_pin_uninit(&cfg->gpiote, abs_pin); in gpio_nrfx_pin_configure()
191 /* Remove previously configured trigger when pin is reconfigured. */ in gpio_nrfx_pin_configure()
200 err = nrfx_gpiote_input_configure(&cfg->gpiote, in gpio_nrfx_pin_configure()
203 ret = -EINVAL; in gpio_nrfx_pin_configure()
217 err = nrfx_gpiote_output_configure(&cfg->gpiote, in gpio_nrfx_pin_configure()
224 err = nrfx_gpiote_input_configure(&cfg->gpiote, in gpio_nrfx_pin_configure()
229 ret = -EINVAL; in gpio_nrfx_pin_configure()
235 err = nrfx_gpiote_channel_free(&cfg->gpiote, ch); in gpio_nrfx_pin_configure()
240 (void)gpio_nrfx_gpd_retain_set(port, BIT(pin), flags); in gpio_nrfx_pin_configure()
247 NRF_GPIO_Type *reg = get_port_cfg(port)->port; in gpio_nrfx_port_get_raw()
258 NRF_GPIO_Type *reg = get_port_cfg(port)->port; in gpio_nrfx_port_set_masked_raw()
278 NRF_GPIO_Type *reg = get_port_cfg(port)->port; in gpio_nrfx_port_set_bits_raw()
294 NRF_GPIO_Type *reg = get_port_cfg(port)->port; in gpio_nrfx_port_clear_bits_raw()
310 NRF_GPIO_Type *reg = get_port_cfg(port)->port; in gpio_nrfx_port_toggle_bits()
342 gpio_pin_t pin, in gpio_nrfx_pin_interrupt_configure() argument
347 uint32_t abs_pin = NRF_GPIO_PIN_MAP(cfg->port_num, pin); in gpio_nrfx_pin_interrupt_configure()
352 return -ENOTSUP; in gpio_nrfx_pin_interrupt_configure()
356 nrfx_gpiote_trigger_disable(&cfg->gpiote, abs_pin); in gpio_nrfx_pin_interrupt_configure()
368 /* If edge mode is to be used and pin is not configured to use sense for in gpio_nrfx_pin_interrupt_configure()
371 if (!(BIT(pin) & cfg->edge_sense) && in gpio_nrfx_pin_interrupt_configure()
374 err = nrfx_gpiote_channel_get(&cfg->gpiote, abs_pin, &ch); in gpio_nrfx_pin_interrupt_configure()
376 err = nrfx_gpiote_channel_alloc(&cfg->gpiote, &ch); in gpio_nrfx_pin_interrupt_configure()
378 return -ENOMEM; in gpio_nrfx_pin_interrupt_configure()
385 err = nrfx_gpiote_input_configure(&cfg->gpiote, abs_pin, &input_pin_config); in gpio_nrfx_pin_interrupt_configure()
387 return -EINVAL; in gpio_nrfx_pin_interrupt_configure()
390 nrfx_gpiote_trigger_enable(&cfg->gpiote, abs_pin, true); in gpio_nrfx_pin_interrupt_configure()
399 return gpio_manage_callback(&get_port_data(port)->callbacks, in gpio_nrfx_manage_callback()
411 NRF_GPIO_Type *reg = cfg->port; in gpio_nrfx_port_get_direction()
413 map &= cfg->common.port_pin_mask; in gpio_nrfx_port_get_direction()
416 *outputs = map & nrf_gpio_port_dir_read(cfg->port); in gpio_nrfx_port_get_direction()
422 uint32_t pin = NRF_CTZ(map); in gpio_nrfx_port_get_direction() local
423 uint32_t pin_cnf = reg->PIN_CNF[pin]; in gpio_nrfx_port_get_direction()
425 /* Check if the pin has its input buffer connected. */ in gpio_nrfx_port_get_direction()
429 *inputs |= BIT(pin); in gpio_nrfx_port_get_direction()
432 map &= ~BIT(pin); in gpio_nrfx_port_get_direction()
441 /* Get port device from port id. */
463 uint32_t pin = abs_pin; in nrfx_gpio_handler() local
464 uint32_t port_id = nrf_gpio_pin_port_number_extract(&pin); in nrfx_gpio_handler()
473 sys_slist_t *list = &data->callbacks; in nrfx_gpio_handler()
475 gpio_fire_callbacks(list, port, BIT(pin)); in nrfx_gpio_handler()
492 if (nrfx_gpiote_init_check(&cfg->gpiote)) { in gpio_nrfx_init()
496 err = nrfx_gpiote_init(&cfg->gpiote, 0 /*not used*/); in gpio_nrfx_init()
498 return -EIO; in gpio_nrfx_init()
502 nrfx_gpiote_global_callback_set(&cfg->gpiote, nrfx_gpio_handler, NULL); in gpio_nrfx_init()
525 #define GPIOTE_PHANDLE(id) DT_INST_PHANDLE(id, gpiote_instance) argument
526 #define GPIOTE_INST(id) DT_PROP(GPIOTE_PHANDLE(id), instance) argument
528 #define GPIOTE_INSTANCE(id) \ argument
529 COND_CODE_1(DT_INST_NODE_HAS_PROP(id, gpiote_instance), \
530 (NRFX_GPIOTE_INSTANCE(GPIOTE_INST(id))), \
538 #define GPIOTE_CHECK(id) \ argument
539 COND_CODE_1(DT_INST_NODE_HAS_PROP(id, gpiote_instance), \
540 (BUILD_ASSERT(DT_NODE_HAS_STATUS_OKAY(GPIOTE_PHANDLE(id)), \
546 .pad_pd = DT_INST_PHA_BY_NAME_OR(inst, power_domains, pad, id, \
552 #define GPIO_NRF_DEVICE(id) \ argument
553 GPIOTE_CHECK(id); \
554 static const struct gpio_nrfx_cfg gpio_nrfx_p##id##_cfg = { \
557 GPIO_PORT_PIN_MASK_FROM_DT_INST(id), \
559 .port = _CONCAT(NRF_P, DT_INST_PROP(id, port)), \
560 .port_num = DT_INST_PROP(id, port), \
561 .edge_sense = DT_INST_PROP_OR(id, sense_edge_mask, 0), \
562 .gpiote = GPIOTE_INSTANCE(id), \
563 PAD_PD(id) \
566 static struct gpio_nrfx_data gpio_nrfx_p##id##_data; \
568 DEVICE_DT_INST_DEFINE(id, gpio_nrfx_init, \
570 &gpio_nrfx_p##id##_data, \
571 &gpio_nrfx_p##id##_cfg, \