gpio: remove deprecated API functions/macros
This commit removes API functions and macros which were deprecated in 2.2 release. GPIO drivers are updated accordingly. Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
This commit is contained in:
parent
c48206d5ee
commit
4b194eb4fc
27 changed files with 37 additions and 1129 deletions
|
@ -34,7 +34,6 @@ struct gpio_cc13xx_cc26xx_data {
|
|||
/* gpio_driver_data needs to be first */
|
||||
struct gpio_driver_data common;
|
||||
sys_slist_t callbacks;
|
||||
uint32_t pin_callback_enables;
|
||||
};
|
||||
|
||||
static struct gpio_cc13xx_cc26xx_data gpio_cc13xx_cc26xx_data_0;
|
||||
|
@ -152,7 +151,6 @@ static int gpio_cc13xx_cc26xx_pin_interrupt_configure(struct device *port,
|
|||
gpio_pin_t pin, enum gpio_int_mode mode,
|
||||
enum gpio_int_trig trig)
|
||||
{
|
||||
struct gpio_cc13xx_cc26xx_data *data = port->driver_data;
|
||||
uint32_t config = 0;
|
||||
|
||||
if (mode != GPIO_INT_MODE_DISABLED) {
|
||||
|
@ -176,9 +174,6 @@ static int gpio_cc13xx_cc26xx_pin_interrupt_configure(struct device *port,
|
|||
config |= IOCPortConfigureGet(pin) & IOCFG_GEN_MASK;
|
||||
IOCPortConfigureSet(pin, IOC_PORT_GPIO, config);
|
||||
|
||||
WRITE_BIT(data->pin_callback_enables, pin,
|
||||
mode != GPIO_INT_MODE_DISABLED);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -191,28 +186,6 @@ static int gpio_cc13xx_cc26xx_manage_callback(struct device *port,
|
|||
return gpio_manage_callback(&data->callbacks, callback, set);
|
||||
}
|
||||
|
||||
static int gpio_cc13xx_cc26xx_enable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_cc13xx_cc26xx_data *data = port->driver_data;
|
||||
|
||||
__ASSERT_NO_MSG(pin < NUM_IO_MAX);
|
||||
data->pin_callback_enables |= (1 << pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_cc13xx_cc26xx_disable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_cc13xx_cc26xx_data *data = port->driver_data;
|
||||
|
||||
__ASSERT_NO_MSG(pin < NUM_IO_MAX);
|
||||
data->pin_callback_enables &= ~(1 << pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t gpio_cc13xx_cc26xx_get_pending_int(struct device *dev)
|
||||
{
|
||||
return GPIO_getEventMultiDio(GPIO_DIO_ALL_MASK);
|
||||
|
@ -226,17 +199,14 @@ static void gpio_cc13xx_cc26xx_isr(void *arg)
|
|||
struct gpio_cc13xx_cc26xx_data *data = dev->driver_data;
|
||||
|
||||
uint32_t status = GPIO_getEventMultiDio(GPIO_DIO_ALL_MASK);
|
||||
uint32_t enabled = status & data->pin_callback_enables;
|
||||
|
||||
GPIO_clearEventMultiDio(status);
|
||||
|
||||
gpio_fire_callbacks(&data->callbacks, dev, enabled);
|
||||
gpio_fire_callbacks(&data->callbacks, dev, status);
|
||||
}
|
||||
|
||||
static int gpio_cc13xx_cc26xx_init(struct device *dev)
|
||||
{
|
||||
struct gpio_cc13xx_cc26xx_data *data = dev->driver_data;
|
||||
|
||||
#ifdef CONFIG_SYS_POWER_MANAGEMENT
|
||||
/* Set dependency on gpio resource to turn on power domains */
|
||||
Power_setDependency(PowerCC26XX_PERIPH_GPIO);
|
||||
|
@ -266,9 +236,6 @@ static int gpio_cc13xx_cc26xx_init(struct device *dev)
|
|||
gpio_cc13xx_cc26xx_isr, DEVICE_GET(gpio_cc13xx_cc26xx), 0);
|
||||
irq_enable(DT_INST_IRQN(0));
|
||||
|
||||
/* Disable callbacks */
|
||||
data->pin_callback_enables = 0;
|
||||
|
||||
/* Peripheral should not be accessed until power domain is on. */
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_PERIPH) !=
|
||||
PRCM_DOMAIN_POWER_ON) {
|
||||
|
@ -287,8 +254,6 @@ static const struct gpio_driver_api gpio_cc13xx_cc26xx_driver_api = {
|
|||
.port_toggle_bits = gpio_cc13xx_cc26xx_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_cc13xx_cc26xx_pin_interrupt_configure,
|
||||
.manage_callback = gpio_cc13xx_cc26xx_manage_callback,
|
||||
.enable_callback = gpio_cc13xx_cc26xx_enable_callback,
|
||||
.disable_callback = gpio_cc13xx_cc26xx_disable_callback,
|
||||
.get_pending_int = gpio_cc13xx_cc26xx_get_pending_int
|
||||
};
|
||||
|
||||
|
|
|
@ -57,8 +57,6 @@ struct gpio_cc32xx_data {
|
|||
struct gpio_driver_data common;
|
||||
/* list of registered callbacks */
|
||||
sys_slist_t callbacks;
|
||||
/* callback enable pin bitmask */
|
||||
uint32_t pin_callback_enables;
|
||||
};
|
||||
|
||||
#define DEV_CFG(dev) \
|
||||
|
@ -165,7 +163,6 @@ static int gpio_cc32xx_pin_interrupt_configure(struct device *port,
|
|||
enum gpio_int_trig trig)
|
||||
{
|
||||
const struct gpio_cc32xx_config *gpio_config = DEV_CFG(port);
|
||||
struct gpio_cc32xx_data *data = DEV_DATA(port);
|
||||
unsigned long port_base = gpio_config->port_base;
|
||||
unsigned long int_type;
|
||||
|
||||
|
@ -198,9 +195,6 @@ static int gpio_cc32xx_pin_interrupt_configure(struct device *port,
|
|||
MAP_GPIOIntTypeSet(port_base, (1 << pin), int_type);
|
||||
MAP_GPIOIntClear(port_base, (1 << pin));
|
||||
MAP_GPIOIntEnable(port_base, (1 << pin));
|
||||
|
||||
WRITE_BIT(data->pin_callback_enables, pin,
|
||||
mode != GPIO_INT_MODE_DISABLED);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -214,50 +208,21 @@ static int gpio_cc32xx_manage_callback(struct device *dev,
|
|||
return gpio_manage_callback(&data->callbacks, callback, set);
|
||||
}
|
||||
|
||||
|
||||
static int gpio_cc32xx_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_cc32xx_data *data = DEV_DATA(dev);
|
||||
|
||||
__ASSERT(pin < 8, "Invalid pin number - only 8 pins per port");
|
||||
|
||||
data->pin_callback_enables |= (1 << pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int gpio_cc32xx_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_cc32xx_data *data = DEV_DATA(dev);
|
||||
|
||||
__ASSERT(pin < 8, "Invalid pin number - only 8 pins per port");
|
||||
|
||||
data->pin_callback_enables &= ~(1 << pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void gpio_cc32xx_port_isr(void *arg)
|
||||
{
|
||||
struct device *dev = arg;
|
||||
const struct gpio_cc32xx_config *config = DEV_CFG(dev);
|
||||
struct gpio_cc32xx_data *data = DEV_DATA(dev);
|
||||
uint32_t enabled_int, int_status;
|
||||
uint32_t int_status;
|
||||
|
||||
/* See which interrupts triggered: */
|
||||
int_status = (uint32_t)MAP_GPIOIntStatus(config->port_base, 1);
|
||||
|
||||
enabled_int = int_status & data->pin_callback_enables;
|
||||
|
||||
/* Clear GPIO Interrupt */
|
||||
MAP_GPIOIntClear(config->port_base, int_status);
|
||||
|
||||
/* Call the registered callbacks */
|
||||
gpio_fire_callbacks(&data->callbacks, (struct device *)dev,
|
||||
enabled_int);
|
||||
gpio_fire_callbacks(&data->callbacks, dev, int_status);
|
||||
}
|
||||
|
||||
static const struct gpio_driver_api api_funcs = {
|
||||
|
@ -269,9 +234,6 @@ static const struct gpio_driver_api api_funcs = {
|
|||
.port_toggle_bits = gpio_cc32xx_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_cc32xx_pin_interrupt_configure,
|
||||
.manage_callback = gpio_cc32xx_manage_callback,
|
||||
.enable_callback = gpio_cc32xx_enable_callback,
|
||||
.disable_callback = gpio_cc32xx_disable_callback,
|
||||
|
||||
};
|
||||
|
||||
#define GPIO_CC32XX_INIT_FUNC(n) \
|
||||
|
|
|
@ -209,26 +209,6 @@ static int gpio_cmsdk_ahb_manage_callback(struct device *dev,
|
|||
return gpio_manage_callback(&data->gpio_cb, callback, set);
|
||||
}
|
||||
|
||||
static int gpio_cmsdk_ahb_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config_info;
|
||||
|
||||
cfg->port->intenset |= BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_cmsdk_ahb_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config_info;
|
||||
|
||||
cfg->port->intenclr |= BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct gpio_driver_api gpio_cmsdk_ahb_drv_api_funcs = {
|
||||
.pin_configure = gpio_cmsdk_ahb_config,
|
||||
.port_get_raw = gpio_cmsdk_ahb_port_get_raw,
|
||||
|
@ -238,8 +218,6 @@ static const struct gpio_driver_api gpio_cmsdk_ahb_drv_api_funcs = {
|
|||
.port_toggle_bits = gpio_cmsdk_ahb_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_cmsdk_ahb_pin_interrupt_configure,
|
||||
.manage_callback = gpio_cmsdk_ahb_manage_callback,
|
||||
.enable_callback = gpio_cmsdk_ahb_enable_callback,
|
||||
.disable_callback = gpio_cmsdk_ahb_disable_callback,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -421,39 +421,6 @@ static inline int gpio_dw_manage_callback(struct device *port,
|
|||
return gpio_manage_callback(&context->callbacks, callback, set);
|
||||
}
|
||||
|
||||
static inline int gpio_dw_enable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_dw_runtime *context = port->driver_data;
|
||||
uint32_t base_addr = dw_base_to_block_base(context->base_addr);
|
||||
uint32_t data_port = dw_get_data_port(context->base_addr);
|
||||
|
||||
if (data_port != SWPORTA_DR) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
dw_write(base_addr, PORTA_EOI, BIT(pin));
|
||||
dw_set_bit(base_addr, INTMASK, pin, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int gpio_dw_disable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_dw_runtime *context = port->driver_data;
|
||||
uint32_t base_addr = dw_base_to_block_base(context->base_addr);
|
||||
uint32_t data_port = dw_get_data_port(context->base_addr);
|
||||
|
||||
if (data_port != SWPORTA_DR) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
dw_set_bit(base_addr, INTMASK, pin, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
|
||||
static void gpio_dw_set_power_state(struct device *port, uint32_t power_state)
|
||||
{
|
||||
|
@ -548,8 +515,6 @@ static const struct gpio_driver_api api_funcs = {
|
|||
.port_toggle_bits = gpio_dw_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_dw_pin_interrupt_configure,
|
||||
.manage_callback = gpio_dw_manage_callback,
|
||||
.enable_callback = gpio_dw_enable_callback,
|
||||
.disable_callback = gpio_dw_disable_callback,
|
||||
};
|
||||
|
||||
static int gpio_dw_initialize(struct device *port)
|
||||
|
|
|
@ -53,7 +53,6 @@ struct gpio_esp32_data {
|
|||
int pin_offset;
|
||||
} port;
|
||||
|
||||
uint32_t cb_pins;
|
||||
sys_slist_t cb;
|
||||
};
|
||||
|
||||
|
@ -230,12 +229,6 @@ static int gpio_esp32_pin_interrupt_configure(struct device *port,
|
|||
return intr_trig_mode;
|
||||
}
|
||||
|
||||
if (mode == GPIO_INT_MODE_DISABLED) {
|
||||
data->cb_pins &= ~BIT(pin);
|
||||
} else {
|
||||
data->cb_pins |= BIT(pin);
|
||||
}
|
||||
|
||||
key = irq_lock();
|
||||
|
||||
reg_val = *reg;
|
||||
|
@ -260,35 +253,14 @@ static int gpio_esp32_manage_callback(struct device *dev,
|
|||
return gpio_manage_callback(&data->cb, callback, set);
|
||||
}
|
||||
|
||||
static int gpio_esp32_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_esp32_data *data = dev->driver_data;
|
||||
|
||||
data->cb_pins |= BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_esp32_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_esp32_data *data = dev->driver_data;
|
||||
|
||||
data->cb_pins &= ~BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void gpio_esp32_fire_callbacks(struct device *device)
|
||||
{
|
||||
struct gpio_esp32_data *data = device->driver_data;
|
||||
uint32_t values = *data->port.irq_status_reg;
|
||||
uint32_t irq_status = *data->port.irq_status_reg;
|
||||
|
||||
*data->port.irq_ack_reg = values;
|
||||
if (values & data->cb_pins) {
|
||||
gpio_fire_callbacks(&data->cb, device, values);
|
||||
}
|
||||
*data->port.irq_ack_reg = irq_status;
|
||||
|
||||
gpio_fire_callbacks(&data->cb, device, irq_status);
|
||||
}
|
||||
|
||||
static void gpio_esp32_isr(void *param);
|
||||
|
@ -329,8 +301,6 @@ static const struct gpio_driver_api gpio_esp32_driver = {
|
|||
.port_toggle_bits = gpio_esp32_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_esp32_pin_interrupt_configure,
|
||||
.manage_callback = gpio_esp32_manage_callback,
|
||||
.enable_callback = gpio_esp32_enable_callback,
|
||||
.disable_callback = gpio_esp32_disable_callback,
|
||||
};
|
||||
|
||||
#if defined(CONFIG_GPIO_ESP32_0)
|
||||
|
|
|
@ -61,8 +61,8 @@ struct gpio_gecko_data {
|
|||
struct gpio_driver_data common;
|
||||
/* port ISR callback routine address */
|
||||
sys_slist_t callbacks;
|
||||
/* pin callback routine enable flags, by pin number */
|
||||
uint32_t pin_callback_enables;
|
||||
/* mask of pins on which interrupt is enabled */
|
||||
uint32_t int_enabled_mask;
|
||||
};
|
||||
|
||||
static inline void gpio_gecko_add_port(struct gpio_gecko_common_data *data,
|
||||
|
@ -222,7 +222,7 @@ static int gpio_gecko_pin_interrupt_configure(struct device *dev,
|
|||
rising_edge, falling_edge, true);
|
||||
}
|
||||
|
||||
WRITE_BIT(data->pin_callback_enables, pin, mode != GPIO_INT_DISABLE);
|
||||
WRITE_BIT(data->int_enabled_mask, pin, mode != GPIO_INT_DISABLE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -235,28 +235,6 @@ static int gpio_gecko_manage_callback(struct device *dev,
|
|||
return gpio_manage_callback(&data->callbacks, callback, set);
|
||||
}
|
||||
|
||||
static int gpio_gecko_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_gecko_data *data = dev->driver_data;
|
||||
|
||||
data->pin_callback_enables |= BIT(pin);
|
||||
GPIO->IEN |= BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_gecko_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_gecko_data *data = dev->driver_data;
|
||||
|
||||
data->pin_callback_enables &= ~BIT(pin);
|
||||
GPIO->IEN &= ~BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for both odd and even pin interrupts
|
||||
*/
|
||||
|
@ -273,7 +251,7 @@ static void gpio_gecko_common_isr(void *arg)
|
|||
for (unsigned int i = 0; int_status && (i < data->count); i++) {
|
||||
port_dev = data->ports[i];
|
||||
port_data = port_dev->driver_data;
|
||||
enabled_int = int_status & port_data->pin_callback_enables;
|
||||
enabled_int = int_status & port_data->int_enabled_mask;
|
||||
if (enabled_int != 0) {
|
||||
int_status &= ~enabled_int;
|
||||
GPIO->IFC = enabled_int;
|
||||
|
@ -283,7 +261,6 @@ static void gpio_gecko_common_isr(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static const struct gpio_driver_api gpio_gecko_driver_api = {
|
||||
.pin_configure = gpio_gecko_configure,
|
||||
.port_get_raw = gpio_gecko_port_get_raw,
|
||||
|
@ -293,14 +270,10 @@ static const struct gpio_driver_api gpio_gecko_driver_api = {
|
|||
.port_toggle_bits = gpio_gecko_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_gecko_pin_interrupt_configure,
|
||||
.manage_callback = gpio_gecko_manage_callback,
|
||||
.enable_callback = gpio_gecko_enable_callback,
|
||||
.disable_callback = gpio_gecko_disable_callback,
|
||||
};
|
||||
|
||||
static const struct gpio_driver_api gpio_gecko_common_driver_api = {
|
||||
.manage_callback = gpio_gecko_manage_callback,
|
||||
.enable_callback = gpio_gecko_enable_callback,
|
||||
.disable_callback = gpio_gecko_disable_callback,
|
||||
};
|
||||
|
||||
static int gpio_gecko_common_init(struct device *dev);
|
||||
|
|
|
@ -68,24 +68,6 @@ static inline int z_vrfy_gpio_pin_interrupt_configure(struct device *port,
|
|||
}
|
||||
#include <syscalls/gpio_pin_interrupt_configure_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_gpio_enable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, enable_callback));
|
||||
|
||||
return z_impl_gpio_enable_callback((struct device *)port, pin);
|
||||
}
|
||||
#include <syscalls/gpio_enable_callback_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_gpio_disable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, disable_callback));
|
||||
|
||||
return z_impl_gpio_disable_callback((struct device *)port, pin);
|
||||
}
|
||||
#include <syscalls/gpio_disable_callback_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_gpio_get_pending_int(struct device *dev)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_GPIO(dev, get_pending_int));
|
||||
|
|
|
@ -138,20 +138,6 @@ static int gpio_ht16k33_manage_callback(struct device *dev,
|
|||
return gpio_manage_callback(&data->callbacks, callback, set);
|
||||
}
|
||||
|
||||
static int gpio_ht16k33_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
/* All callbacks are always enabled */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_ht16k33_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
/* Individual callbacks can not be disabled */
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static uint32_t gpio_ht16k33_get_pending_int(struct device *dev)
|
||||
{
|
||||
struct gpio_ht16k33_data *data = dev->driver_data;
|
||||
|
@ -191,8 +177,6 @@ static const struct gpio_driver_api gpio_ht16k33_api = {
|
|||
.port_toggle_bits = gpio_ht16k33_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_ht16k33_pin_interrupt_configure,
|
||||
.manage_callback = gpio_ht16k33_manage_callback,
|
||||
.enable_callback = gpio_ht16k33_enable_callback,
|
||||
.disable_callback = gpio_ht16k33_disable_callback,
|
||||
.get_pending_int = gpio_ht16k33_get_pending_int,
|
||||
};
|
||||
|
||||
|
|
|
@ -26,8 +26,6 @@ struct imx_gpio_data {
|
|||
struct gpio_driver_data common;
|
||||
/* port ISR callback routine address */
|
||||
sys_slist_t callbacks;
|
||||
/* pin callback routine enable flags, by pin number */
|
||||
uint32_t pin_callback_enables;
|
||||
};
|
||||
|
||||
static int imx_gpio_configure(struct device *port, gpio_pin_t pin,
|
||||
|
@ -129,7 +127,6 @@ static int imx_gpio_pin_interrupt_configure(struct device *port,
|
|||
enum gpio_int_trig trig)
|
||||
{
|
||||
const struct imx_gpio_config *config = port->config_info;
|
||||
struct imx_gpio_data *data = port->driver_data;
|
||||
GPIO_Type *base = config->base;
|
||||
volatile uint32_t *icr_reg;
|
||||
unsigned int key;
|
||||
|
@ -171,8 +168,6 @@ static int imx_gpio_pin_interrupt_configure(struct device *port,
|
|||
WRITE_BIT(base->EDGE_SEL, pin, trig == GPIO_INT_TRIG_BOTH);
|
||||
WRITE_BIT(base->ISR, pin, mode != GPIO_INT_MODE_DISABLED);
|
||||
WRITE_BIT(base->IMR, pin, mode != GPIO_INT_MODE_DISABLED);
|
||||
WRITE_BIT(data->pin_callback_enables, pin,
|
||||
mode != GPIO_INT_MODE_DISABLED);
|
||||
|
||||
irq_unlock(key);
|
||||
|
||||
|
@ -187,41 +182,18 @@ static int imx_gpio_manage_callback(struct device *port,
|
|||
return gpio_manage_callback(&data->callbacks, cb, set);
|
||||
}
|
||||
|
||||
static int imx_gpio_enable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct imx_gpio_config *config = port->config_info;
|
||||
struct imx_gpio_data *data = port->driver_data;
|
||||
|
||||
data->pin_callback_enables |= BIT(pin);
|
||||
GPIO_SetPinIntMode(config->base, pin, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int imx_gpio_disable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct imx_gpio_config *config = port->config_info;
|
||||
struct imx_gpio_data *data = port->driver_data;
|
||||
|
||||
GPIO_SetPinIntMode(config->base, pin, false);
|
||||
data->pin_callback_enables &= ~BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void imx_gpio_port_isr(void *arg)
|
||||
{
|
||||
struct device *port = (struct device *)arg;
|
||||
const struct imx_gpio_config *config = port->config_info;
|
||||
struct imx_gpio_data *data = port->driver_data;
|
||||
uint32_t enabled_int;
|
||||
uint32_t int_status;
|
||||
|
||||
enabled_int = config->base->ISR & data->pin_callback_enables;
|
||||
config->base->ISR = enabled_int;
|
||||
int_status = config->base->ISR;
|
||||
|
||||
gpio_fire_callbacks(&data->callbacks, port, enabled_int);
|
||||
config->base->ISR = int_status;
|
||||
|
||||
gpio_fire_callbacks(&data->callbacks, port, int_status);
|
||||
}
|
||||
|
||||
static const struct gpio_driver_api imx_gpio_driver_api = {
|
||||
|
@ -233,8 +205,6 @@ static const struct gpio_driver_api imx_gpio_driver_api = {
|
|||
.port_toggle_bits = imx_gpio_port_toggle_bits,
|
||||
.pin_interrupt_configure = imx_gpio_pin_interrupt_configure,
|
||||
.manage_callback = imx_gpio_manage_callback,
|
||||
.enable_callback = imx_gpio_enable_callback,
|
||||
.disable_callback = imx_gpio_disable_callback,
|
||||
};
|
||||
|
||||
#define GPIO_IMX_INIT(n) \
|
||||
|
|
|
@ -380,52 +380,6 @@ static int gpio_intel_apl_manage_callback(struct device *dev,
|
|||
return gpio_manage_callback(&data->cb, callback, set);
|
||||
}
|
||||
|
||||
static int gpio_intel_apl_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_intel_apl_config *cfg = dev->config_info;
|
||||
uint32_t raw_pin, reg;
|
||||
|
||||
pin = k_array_index_sanitize(pin, cfg->num_pins + 1);
|
||||
|
||||
raw_pin = cfg->pin_offset + pin;
|
||||
|
||||
if (!check_perm(dev, raw_pin)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* clear (by setting) interrupt status bit */
|
||||
reg = cfg->reg_base + REG_GPI_INT_STS_BASE;
|
||||
sys_bitfield_set_bit(reg, raw_pin);
|
||||
|
||||
/* enable interrupt bit */
|
||||
reg = cfg->reg_base + REG_GPI_INT_EN_BASE;
|
||||
sys_bitfield_set_bit(reg, raw_pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_intel_apl_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_intel_apl_config *cfg = dev->config_info;
|
||||
uint32_t raw_pin, reg;
|
||||
|
||||
pin = k_array_index_sanitize(pin, cfg->num_pins + 1);
|
||||
|
||||
raw_pin = cfg->pin_offset + pin;
|
||||
|
||||
if (!check_perm(dev, raw_pin)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* disable interrupt bit */
|
||||
reg = cfg->reg_base + REG_GPI_INT_EN_BASE;
|
||||
sys_bitfield_clear_bit(reg, raw_pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_get_raw(struct device *dev, uint32_t mask, uint32_t *value,
|
||||
bool read_tx)
|
||||
{
|
||||
|
@ -547,8 +501,6 @@ static int gpio_intel_apl_port_get_raw(struct device *dev, uint32_t *value)
|
|||
static const struct gpio_driver_api gpio_intel_apl_api = {
|
||||
.pin_configure = gpio_intel_apl_config,
|
||||
.manage_callback = gpio_intel_apl_manage_callback,
|
||||
.enable_callback = gpio_intel_apl_enable_callback,
|
||||
.disable_callback = gpio_intel_apl_disable_callback,
|
||||
.port_get_raw = gpio_intel_apl_port_get_raw,
|
||||
.port_set_masked_raw = gpio_intel_apl_port_set_masked_raw,
|
||||
.port_set_bits_raw = gpio_intel_apl_port_set_bits_raw,
|
||||
|
|
|
@ -33,8 +33,6 @@ struct gpio_xec_data {
|
|||
struct gpio_driver_data common;
|
||||
/* port ISR callback routine address */
|
||||
sys_slist_t callbacks;
|
||||
/* pin callback routine enable flags, by pin number */
|
||||
uint32_t pin_callback_enables;
|
||||
};
|
||||
|
||||
struct gpio_xec_config {
|
||||
|
@ -133,7 +131,6 @@ static int gpio_xec_pin_interrupt_configure(struct device *dev,
|
|||
enum gpio_int_trig trig)
|
||||
{
|
||||
const struct gpio_xec_config *config = dev->config_info;
|
||||
struct gpio_xec_data *drv_data = dev->driver_data;
|
||||
__IO uint32_t *current_pcr1;
|
||||
uint32_t pcr1 = 0U;
|
||||
uint32_t mask = 0U;
|
||||
|
@ -195,12 +192,6 @@ static int gpio_xec_pin_interrupt_configure(struct device *dev,
|
|||
current_pcr1 = config->pcr1_base + pin;
|
||||
*current_pcr1 = (*current_pcr1 & ~mask) | pcr1;
|
||||
|
||||
if (mode == GPIO_INT_MODE_DISABLED) {
|
||||
drv_data->pin_callback_enables &= ~BIT(pin);
|
||||
} else {
|
||||
drv_data->pin_callback_enables |= BIT(pin);
|
||||
}
|
||||
|
||||
if (mode != GPIO_INT_MODE_DISABLED) {
|
||||
/* We enable the interrupts in the EC aggregator so that the
|
||||
* result can be forwarded to the ARM NVIC
|
||||
|
@ -283,44 +274,22 @@ static int gpio_xec_manage_callback(struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_xec_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_xec_data *data = dev->driver_data;
|
||||
|
||||
data->pin_callback_enables |= BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_xec_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_xec_data *data = dev->driver_data;
|
||||
|
||||
data->pin_callback_enables &= ~BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void gpio_gpio_xec_port_isr(void *arg)
|
||||
{
|
||||
struct device *dev = (struct device *)arg;
|
||||
const struct gpio_xec_config *config = dev->config_info;
|
||||
struct gpio_xec_data *data = dev->driver_data;
|
||||
uint32_t girq_result;
|
||||
uint32_t enabled_int;
|
||||
|
||||
/* Figure out which interrupts have been triggered from the EC
|
||||
* aggregator result register
|
||||
*/
|
||||
girq_result = MCHP_GIRQ_RESULT(config->girq_id);
|
||||
enabled_int = girq_result & data->pin_callback_enables;
|
||||
|
||||
/* Clear source register in aggregator before firing callbacks */
|
||||
REG32(MCHP_GIRQ_SRC_ADDR(config->girq_id)) = girq_result;
|
||||
|
||||
gpio_fire_callbacks(&data->callbacks, dev, enabled_int);
|
||||
gpio_fire_callbacks(&data->callbacks, dev, girq_result);
|
||||
}
|
||||
|
||||
static const struct gpio_driver_api gpio_xec_driver_api = {
|
||||
|
@ -332,8 +301,6 @@ static const struct gpio_driver_api gpio_xec_driver_api = {
|
|||
.port_toggle_bits = gpio_xec_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_xec_pin_interrupt_configure,
|
||||
.manage_callback = gpio_xec_manage_callback,
|
||||
.enable_callback = gpio_xec_enable_callback,
|
||||
.disable_callback = gpio_xec_disable_callback,
|
||||
};
|
||||
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_000_036), okay)
|
||||
|
|
|
@ -29,8 +29,6 @@ struct gpio_mcux_data {
|
|||
struct gpio_driver_data common;
|
||||
/* port ISR callback routine address */
|
||||
sys_slist_t callbacks;
|
||||
/* pin callback routine enable flags, by pin number */
|
||||
uint32_t pin_callback_enables;
|
||||
};
|
||||
|
||||
static int gpio_mcux_configure(struct device *dev,
|
||||
|
@ -191,7 +189,6 @@ static int gpio_mcux_pin_interrupt_configure(struct device *dev,
|
|||
const struct gpio_mcux_config *config = dev->config_info;
|
||||
GPIO_Type *gpio_base = config->gpio_base;
|
||||
PORT_Type *port_base = config->port_base;
|
||||
struct gpio_mcux_data *data = dev->driver_data;
|
||||
|
||||
/* Check for an invalid pin number */
|
||||
if (pin >= ARRAY_SIZE(port_base->PCR)) {
|
||||
|
@ -214,8 +211,6 @@ static int gpio_mcux_pin_interrupt_configure(struct device *dev,
|
|||
|
||||
port_base->PCR[pin] = (port_base->PCR[pin] & ~PORT_PCR_IRQC_MASK) | pcr;
|
||||
|
||||
WRITE_BIT(data->pin_callback_enables, pin, mode != GPIO_INT_DISABLE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -227,40 +222,19 @@ static int gpio_mcux_manage_callback(struct device *dev,
|
|||
return gpio_manage_callback(&data->callbacks, callback, set);
|
||||
}
|
||||
|
||||
static int gpio_mcux_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_mcux_data *data = dev->driver_data;
|
||||
|
||||
data->pin_callback_enables |= BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_mcux_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_mcux_data *data = dev->driver_data;
|
||||
|
||||
data->pin_callback_enables &= ~BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void gpio_mcux_port_isr(void *arg)
|
||||
{
|
||||
struct device *dev = (struct device *)arg;
|
||||
const struct gpio_mcux_config *config = dev->config_info;
|
||||
struct gpio_mcux_data *data = dev->driver_data;
|
||||
uint32_t enabled_int, int_status;
|
||||
uint32_t int_status;
|
||||
|
||||
int_status = config->port_base->ISFR;
|
||||
enabled_int = int_status & data->pin_callback_enables;
|
||||
|
||||
/* Clear the port interrupts */
|
||||
config->port_base->ISFR = enabled_int;
|
||||
config->port_base->ISFR = int_status;
|
||||
|
||||
gpio_fire_callbacks(&data->callbacks, dev, enabled_int);
|
||||
gpio_fire_callbacks(&data->callbacks, dev, int_status);
|
||||
}
|
||||
|
||||
|
||||
|
@ -273,8 +247,6 @@ static const struct gpio_driver_api gpio_mcux_driver_api = {
|
|||
.port_toggle_bits = gpio_mcux_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_mcux_pin_interrupt_configure,
|
||||
.manage_callback = gpio_mcux_manage_callback,
|
||||
.enable_callback = gpio_mcux_enable_callback,
|
||||
.disable_callback = gpio_mcux_disable_callback,
|
||||
};
|
||||
|
||||
#define GPIO_MCUX_IRQ_INIT(n) \
|
||||
|
|
|
@ -26,8 +26,6 @@ struct mcux_igpio_data {
|
|||
struct gpio_driver_data general;
|
||||
/* port ISR callback routine address */
|
||||
sys_slist_t callbacks;
|
||||
/* pin callback routine enable flags, by pin number */
|
||||
uint32_t pin_callback_enables;
|
||||
};
|
||||
|
||||
static int mcux_igpio_configure(struct device *dev,
|
||||
|
@ -117,7 +115,6 @@ static int mcux_igpio_pin_interrupt_configure(struct device *dev,
|
|||
enum gpio_int_trig trig)
|
||||
{
|
||||
const struct mcux_igpio_config *config = dev->config_info;
|
||||
struct mcux_igpio_data *data = dev->driver_data;
|
||||
GPIO_Type *base = config->base;
|
||||
unsigned int key;
|
||||
uint8_t icr;
|
||||
|
@ -127,7 +124,6 @@ static int mcux_igpio_pin_interrupt_configure(struct device *dev,
|
|||
key = irq_lock();
|
||||
|
||||
WRITE_BIT(base->IMR, pin, 0);
|
||||
WRITE_BIT(data->pin_callback_enables, pin, 0);
|
||||
|
||||
irq_unlock(key);
|
||||
|
||||
|
@ -161,7 +157,6 @@ static int mcux_igpio_pin_interrupt_configure(struct device *dev,
|
|||
WRITE_BIT(base->EDGE_SEL, pin, trig == GPIO_INT_TRIG_BOTH);
|
||||
WRITE_BIT(base->ISR, pin, 1);
|
||||
WRITE_BIT(base->IMR, pin, 1);
|
||||
WRITE_BIT(data->pin_callback_enables, pin, 1);
|
||||
|
||||
irq_unlock(key);
|
||||
|
||||
|
@ -176,39 +171,18 @@ static int mcux_igpio_manage_callback(struct device *dev,
|
|||
return gpio_manage_callback(&data->callbacks, callback, set);
|
||||
}
|
||||
|
||||
static int mcux_igpio_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct mcux_igpio_data *data = dev->driver_data;
|
||||
|
||||
data->pin_callback_enables |= BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mcux_igpio_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct mcux_igpio_data *data = dev->driver_data;
|
||||
|
||||
data->pin_callback_enables &= ~BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mcux_igpio_port_isr(void *arg)
|
||||
{
|
||||
struct device *dev = (struct device *)arg;
|
||||
const struct mcux_igpio_config *config = dev->config_info;
|
||||
struct mcux_igpio_data *data = dev->driver_data;
|
||||
GPIO_Type *base = config->base;
|
||||
uint32_t enabled_int, int_flags;
|
||||
uint32_t int_flags;
|
||||
|
||||
int_flags = base->ISR;
|
||||
enabled_int = int_flags & data->pin_callback_enables;
|
||||
base->ISR = enabled_int;
|
||||
base->ISR = int_flags;
|
||||
|
||||
gpio_fire_callbacks(&data->callbacks, dev, enabled_int);
|
||||
gpio_fire_callbacks(&data->callbacks, dev, int_flags);
|
||||
}
|
||||
|
||||
static const struct gpio_driver_api mcux_igpio_driver_api = {
|
||||
|
@ -220,8 +194,6 @@ static const struct gpio_driver_api mcux_igpio_driver_api = {
|
|||
.port_toggle_bits = mcux_igpio_port_toggle_bits,
|
||||
.pin_interrupt_configure = mcux_igpio_pin_interrupt_configure,
|
||||
.manage_callback = mcux_igpio_manage_callback,
|
||||
.enable_callback = mcux_igpio_enable_callback,
|
||||
.disable_callback = mcux_igpio_disable_callback,
|
||||
};
|
||||
|
||||
#define MCUX_IGPIO_IRQ_INIT(n, i) \
|
||||
|
|
|
@ -48,8 +48,6 @@ struct gpio_mcux_lpc_data {
|
|||
struct gpio_driver_data common;
|
||||
/* port ISR callback routine address */
|
||||
sys_slist_t callbacks;
|
||||
/* pin callback routine enable flags, by pin number */
|
||||
uint32_t pin_callback_enables;
|
||||
/* pin association with PINT id */
|
||||
pint_pin_int_t pint_id[32];
|
||||
/* ISR allocated in device tree to this port */
|
||||
|
@ -169,8 +167,7 @@ static void gpio_mcux_lpc_port_isr(void *arg)
|
|||
if (data->pint_id[pin] != NO_PINT_INT) {
|
||||
int_flags = PINT_PinInterruptGetStatus(
|
||||
config->pint_base, data->pint_id[pin]);
|
||||
enabled_int =
|
||||
(int_flags << pin) & data->pin_callback_enables;
|
||||
enabled_int = int_flags << pin;
|
||||
|
||||
PINT_PinInterruptClrStatus(config->pint_base,
|
||||
data->pint_id[pin]);
|
||||
|
@ -287,8 +284,6 @@ static int gpio_mcux_lpc_pin_interrupt_configure(struct device *dev,
|
|||
interruptMode,
|
||||
(pint_cb_t)gpio_mcux_lpc_port_isr);
|
||||
|
||||
WRITE_BIT(data->pin_callback_enables, pin, mode != GPIO_INT_DISABLE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -300,26 +295,6 @@ static int gpio_mcux_lpc_manage_cb(struct device *port,
|
|||
return gpio_manage_callback(&data->callbacks, callback, set);
|
||||
}
|
||||
|
||||
static int gpio_mcux_lpc_enable_cb(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_mcux_lpc_data *data = port->driver_data;
|
||||
|
||||
data->pin_callback_enables |= BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_mcux_lpc_disable_cb(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_mcux_lpc_data *data = port->driver_data;
|
||||
|
||||
data->pin_callback_enables &= ~BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_mcux_lpc_init(struct device *dev)
|
||||
{
|
||||
const struct gpio_mcux_lpc_config *config = dev->config_info;
|
||||
|
@ -346,8 +321,6 @@ static const struct gpio_driver_api gpio_mcux_lpc_driver_api = {
|
|||
.port_toggle_bits = gpio_mcux_lpc_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_mcux_lpc_pin_interrupt_configure,
|
||||
.manage_callback = gpio_mcux_lpc_manage_cb,
|
||||
.enable_callback = gpio_mcux_lpc_enable_cb,
|
||||
.disable_callback = gpio_mcux_lpc_disable_cb,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_GPIO_MCUX_LPC_PORT0
|
||||
|
|
|
@ -23,11 +23,6 @@ struct gpio_nrfx_data {
|
|||
*/
|
||||
uint32_t pin_int_en;
|
||||
|
||||
/* Mask holding information about which pins have enabled callbacks
|
||||
* using gpio_nrfx_enable_callback function.
|
||||
*/
|
||||
uint32_t int_en;
|
||||
|
||||
uint32_t int_active_level;
|
||||
uint32_t trig_edge;
|
||||
uint32_t double_edge;
|
||||
|
@ -110,10 +105,8 @@ static int gpiote_pin_int_cfg(struct device *port, uint32_t pin)
|
|||
gpiote_pin_cleanup(&gpiote_alloc_mask, abs_pin);
|
||||
nrf_gpio_cfg_sense_set(abs_pin, NRF_GPIO_PIN_NOSENSE);
|
||||
|
||||
/* Pins trigger interrupts only if pin has been configured to do so
|
||||
* and callback has been enabled for that pin.
|
||||
*/
|
||||
if ((data->pin_int_en & BIT(pin)) && (data->int_en & BIT(pin))) {
|
||||
/* Pins trigger interrupts only if pin has been configured to do so */
|
||||
if (data->pin_int_en & BIT(pin)) {
|
||||
if (data->trig_edge & BIT(pin)) {
|
||||
/* For edge triggering we use GPIOTE channels. */
|
||||
nrf_gpiote_polarity_t pol;
|
||||
|
@ -279,7 +272,6 @@ static int gpio_nrfx_pin_interrupt_configure(struct device *port,
|
|||
}
|
||||
|
||||
WRITE_BIT(data->pin_int_en, pin, mode != GPIO_INT_MODE_DISABLED);
|
||||
WRITE_BIT(data->int_en, pin, mode != GPIO_INT_MODE_DISABLED);
|
||||
WRITE_BIT(data->trig_edge, pin, mode == GPIO_INT_MODE_EDGE);
|
||||
WRITE_BIT(data->double_edge, pin, trig == GPIO_INT_TRIG_BOTH);
|
||||
WRITE_BIT(data->int_active_level, pin, trig == GPIO_INT_TRIG_HIGH);
|
||||
|
@ -295,29 +287,6 @@ static int gpio_nrfx_manage_callback(struct device *port,
|
|||
callback, set);
|
||||
}
|
||||
|
||||
static int gpio_nrfx_pin_manage_callback(struct device *port,
|
||||
uint32_t pin,
|
||||
bool enable)
|
||||
{
|
||||
struct gpio_nrfx_data *data = get_port_data(port);
|
||||
|
||||
WRITE_BIT(data->int_en, pin, enable);
|
||||
|
||||
return gpiote_pin_int_cfg(port, pin);
|
||||
}
|
||||
|
||||
static inline int gpio_nrfx_pin_enable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
return gpio_nrfx_pin_manage_callback(port, pin, true);
|
||||
}
|
||||
|
||||
static inline int gpio_nrfx_pin_disable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
return gpio_nrfx_pin_manage_callback(port, pin, false);
|
||||
}
|
||||
|
||||
static const struct gpio_driver_api gpio_nrfx_drv_api_funcs = {
|
||||
.pin_configure = gpio_nrfx_config,
|
||||
.port_get_raw = gpio_nrfx_port_get_raw,
|
||||
|
@ -327,8 +296,6 @@ static const struct gpio_driver_api gpio_nrfx_drv_api_funcs = {
|
|||
.port_toggle_bits = gpio_nrfx_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_nrfx_pin_interrupt_configure,
|
||||
.manage_callback = gpio_nrfx_manage_callback,
|
||||
.enable_callback = gpio_nrfx_pin_enable_callback,
|
||||
.disable_callback = gpio_nrfx_pin_disable_callback
|
||||
};
|
||||
|
||||
static inline uint32_t get_level_pins(struct device *port)
|
||||
|
@ -336,9 +303,9 @@ static inline uint32_t get_level_pins(struct device *port)
|
|||
struct gpio_nrfx_data *data = get_port_data(port);
|
||||
|
||||
/* Take into consideration only pins that were configured to
|
||||
* trigger interrupts and have callback enabled.
|
||||
* trigger interrupts.
|
||||
*/
|
||||
uint32_t out = data->int_en & data->pin_int_en;
|
||||
uint32_t out = data->pin_int_en;
|
||||
|
||||
/* Exclude pins that trigger interrupts by edge. */
|
||||
out &= ~data->trig_edge & ~data->double_edge;
|
||||
|
@ -418,23 +385,8 @@ static inline void fire_callbacks(struct device *port, uint32_t pins)
|
|||
{
|
||||
struct gpio_nrfx_data *data = get_port_data(port);
|
||||
sys_slist_t *list = &data->callbacks;
|
||||
struct gpio_callback *cb, *tmp;
|
||||
|
||||
/* Instead of calling the common gpio_fire_callbacks() function,
|
||||
* iterate the list of callbacks locally, to be able to perform
|
||||
* additional masking of the pins and to call handlers only for
|
||||
* the currently enabled callbacks.
|
||||
*/
|
||||
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(list, cb, tmp, node) {
|
||||
/* Check currently enabled callbacks (data->int_en) in each
|
||||
* iteration, as some callbacks may get disabled also in any
|
||||
* of the handlers called here.
|
||||
*/
|
||||
if ((cb->pin_mask & pins) & data->int_en) {
|
||||
__ASSERT(cb->handler, "No callback handler!");
|
||||
cb->handler(port, cb, cb->pin_mask & pins);
|
||||
}
|
||||
}
|
||||
gpio_fire_callbacks(list, port, pins);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GPIO_NRF_P0
|
||||
|
|
|
@ -34,8 +34,6 @@ struct gpio_rv32m1_data {
|
|||
struct gpio_driver_data common;
|
||||
/* port ISR callback routine address */
|
||||
sys_slist_t callbacks;
|
||||
/* pin callback routine enable flags, by pin number */
|
||||
uint32_t pin_callback_enables;
|
||||
};
|
||||
|
||||
static uint32_t get_port_pcr_irqc_value_from_flags(struct device *dev,
|
||||
|
@ -77,7 +75,6 @@ static int gpio_rv32m1_configure(struct device *dev,
|
|||
const struct gpio_rv32m1_config *config = dev->config_info;
|
||||
GPIO_Type *gpio_base = config->gpio_base;
|
||||
PORT_Type *port_base = config->port_base;
|
||||
struct gpio_rv32m1_data *data = dev->driver_data;
|
||||
uint32_t mask = 0U;
|
||||
uint32_t pcr = 0U;
|
||||
|
||||
|
@ -151,11 +148,10 @@ static int gpio_rv32m1_configure(struct device *dev,
|
|||
|
||||
/* Accessing by pin, we only need to write one PCR register. */
|
||||
port_base->PCR[pin] = (port_base->PCR[pin] & ~mask) | pcr;
|
||||
WRITE_BIT(data->pin_callback_enables, pin,
|
||||
flags & GPIO_INT_ENABLE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_rv32m1_port_get_raw(struct device *dev, uint32_t *value)
|
||||
{
|
||||
const struct gpio_rv32m1_config *config = dev->config_info;
|
||||
|
@ -213,7 +209,6 @@ static int gpio_rv32m1_pin_interrupt_configure(struct device *dev,
|
|||
{
|
||||
const struct gpio_rv32m1_config *config = dev->config_info;
|
||||
PORT_Type *port_base = config->port_base;
|
||||
struct gpio_rv32m1_data *data = dev->driver_data;
|
||||
|
||||
/* Check for an invalid pin number */
|
||||
if (pin >= ARRAY_SIZE(port_base->PCR)) {
|
||||
|
@ -230,8 +225,6 @@ static int gpio_rv32m1_pin_interrupt_configure(struct device *dev,
|
|||
|
||||
port_base->PCR[pin] = (port_base->PCR[pin] & ~PORT_PCR_IRQC_MASK) | pcr;
|
||||
|
||||
WRITE_BIT(data->pin_callback_enables, pin, mode != GPIO_INT_DISABLE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -246,41 +239,19 @@ static int gpio_rv32m1_manage_callback(struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_rv32m1_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_rv32m1_data *data = dev->driver_data;
|
||||
|
||||
data->pin_callback_enables |= BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_rv32m1_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_rv32m1_data *data = dev->driver_data;
|
||||
|
||||
data->pin_callback_enables &= ~BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void gpio_rv32m1_port_isr(void *arg)
|
||||
{
|
||||
struct device *dev = (struct device *)arg;
|
||||
const struct gpio_rv32m1_config *config = dev->config_info;
|
||||
struct gpio_rv32m1_data *data = dev->driver_data;
|
||||
uint32_t enabled_int, int_status;
|
||||
uint32_t int_status;
|
||||
|
||||
int_status = config->port_base->ISFR;
|
||||
enabled_int = int_status & data->pin_callback_enables;
|
||||
|
||||
/* Clear the port interrupts before invoking callbacks */
|
||||
config->port_base->ISFR = enabled_int;
|
||||
|
||||
gpio_fire_callbacks(&data->callbacks, dev, enabled_int);
|
||||
config->port_base->ISFR = int_status;
|
||||
|
||||
gpio_fire_callbacks(&data->callbacks, dev, int_status);
|
||||
}
|
||||
|
||||
static int gpio_rv32m1_init(struct device *dev)
|
||||
|
@ -314,8 +285,6 @@ static const struct gpio_driver_api gpio_rv32m1_driver_api = {
|
|||
.port_toggle_bits = gpio_rv32m1_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_rv32m1_pin_interrupt_configure,
|
||||
.manage_callback = gpio_rv32m1_manage_callback,
|
||||
.enable_callback = gpio_rv32m1_enable_callback,
|
||||
.disable_callback = gpio_rv32m1_disable_callback,
|
||||
};
|
||||
|
||||
#define INST_DT_PORT_ADDR(n) \
|
||||
|
|
|
@ -282,28 +282,6 @@ static int gpio_sam_manage_callback(struct device *port,
|
|||
return gpio_manage_callback(&context->cb, callback, set);
|
||||
}
|
||||
|
||||
static int gpio_sam_enable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_sam_config * const cfg = DEV_CFG(port);
|
||||
Pio * const pio = cfg->regs;
|
||||
|
||||
pio->PIO_IER |= BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_sam_disable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_sam_config * const cfg = DEV_CFG(port);
|
||||
Pio * const pio = cfg->regs;
|
||||
|
||||
pio->PIO_IDR |= BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct gpio_driver_api gpio_sam_api = {
|
||||
.pin_configure = gpio_sam_config,
|
||||
.port_get_raw = gpio_sam_port_get_raw,
|
||||
|
@ -313,8 +291,6 @@ static const struct gpio_driver_api gpio_sam_api = {
|
|||
.port_toggle_bits = gpio_sam_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_sam_pin_interrupt_configure,
|
||||
.manage_callback = gpio_sam_manage_callback,
|
||||
.enable_callback = gpio_sam_enable_callback,
|
||||
.disable_callback = gpio_sam_disable_callback,
|
||||
};
|
||||
|
||||
int gpio_sam_init(struct device *dev)
|
||||
|
|
|
@ -260,20 +260,6 @@ static int gpio_sam0_manage_callback(struct device *dev,
|
|||
return gpio_manage_callback(&data->callbacks, callback, set);
|
||||
}
|
||||
|
||||
int gpio_sam0_enable_callback(struct device *dev, gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_sam0_config *config = DEV_CFG(dev);
|
||||
|
||||
return sam0_eic_enable_interrupt(config->id, pin);
|
||||
}
|
||||
|
||||
int gpio_sam0_disable_callback(struct device *dev, gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_sam0_config *config = DEV_CFG(dev);
|
||||
|
||||
return sam0_eic_disable_interrupt(config->id, pin);
|
||||
}
|
||||
|
||||
static uint32_t gpio_sam0_get_pending_int(struct device *dev)
|
||||
{
|
||||
const struct gpio_sam0_config *config = DEV_CFG(dev);
|
||||
|
@ -293,8 +279,6 @@ static const struct gpio_driver_api gpio_sam0_api = {
|
|||
#ifdef CONFIG_SAM0_EIC
|
||||
.pin_interrupt_configure = gpio_sam0_pin_interrupt_configure,
|
||||
.manage_callback = gpio_sam0_manage_callback,
|
||||
.enable_callback = gpio_sam0_enable_callback,
|
||||
.disable_callback = gpio_sam0_disable_callback,
|
||||
.get_pending_int = gpio_sam0_get_pending_int,
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -304,36 +304,6 @@ static int gpio_sifive_manage_callback(struct device *dev,
|
|||
return gpio_manage_callback(&data->cb, callback, set);
|
||||
}
|
||||
|
||||
static int gpio_sifive_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_sifive_config *cfg = DEV_GPIO_CFG(dev);
|
||||
|
||||
if (pin >= SIFIVE_PINMUX_PINS) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Enable interrupt for the pin at PLIC (level 2) */
|
||||
irq_enable(cfg->gpio_irq_base + (pin << 8));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_sifive_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_sifive_config *cfg = DEV_GPIO_CFG(dev);
|
||||
|
||||
if (pin >= SIFIVE_PINMUX_PINS) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Disable interrupt for the pin at PLIC (level 2) */
|
||||
irq_disable(cfg->gpio_irq_base + (pin << 8));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct gpio_driver_api gpio_sifive_driver = {
|
||||
.pin_configure = gpio_sifive_config,
|
||||
.port_get_raw = gpio_sifive_port_get_raw,
|
||||
|
@ -343,8 +313,6 @@ static const struct gpio_driver_api gpio_sifive_driver = {
|
|||
.port_toggle_bits = gpio_sifive_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_sifive_pin_interrupt_configure,
|
||||
.manage_callback = gpio_sifive_manage_callback,
|
||||
.enable_callback = gpio_sifive_enable_callback,
|
||||
.disable_callback = gpio_sifive_disable_callback,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -209,28 +209,6 @@ static int gpio_stellaris_init(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_stellaris_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_stellaris_config * const cfg = DEV_CFG(dev);
|
||||
uint32_t base = cfg->base;
|
||||
|
||||
sys_set_bit(GPIO_REG_ADDR(base, GPIO_IM_OFFSET), pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_stellaris_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_stellaris_config * const cfg = DEV_CFG(dev);
|
||||
uint32_t base = cfg->base;
|
||||
|
||||
sys_clear_bit(GPIO_REG_ADDR(base, GPIO_IM_OFFSET), pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_stellaris_manage_callback(struct device *dev,
|
||||
struct gpio_callback *callback,
|
||||
bool set)
|
||||
|
@ -251,8 +229,6 @@ static const struct gpio_driver_api gpio_stellaris_driver_api = {
|
|||
.port_toggle_bits = gpio_stellaris_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_stellaris_pin_interrupt_configure,
|
||||
.manage_callback = gpio_stellaris_manage_callback,
|
||||
.enable_callback = gpio_stellaris_enable_callback,
|
||||
.disable_callback = gpio_stellaris_disable_callback,
|
||||
};
|
||||
|
||||
#define STELLARIS_GPIO_DEVICE(n) \
|
||||
|
|
|
@ -33,9 +33,7 @@ static void gpio_stm32_isr(int line, void *arg)
|
|||
struct device *dev = arg;
|
||||
struct gpio_stm32_data *data = dev->driver_data;
|
||||
|
||||
if ((BIT(line) & data->cb_pins) != 0) {
|
||||
gpio_fire_callbacks(&data->cb, dev, BIT(line));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -429,7 +427,6 @@ static int gpio_stm32_pin_interrupt_configure(struct device *dev,
|
|||
enum gpio_int_trig trig)
|
||||
{
|
||||
const struct gpio_stm32_config *cfg = dev->config_info;
|
||||
struct gpio_stm32_data *data = dev->driver_data;
|
||||
int edge = 0;
|
||||
int err = 0;
|
||||
|
||||
|
@ -443,7 +440,6 @@ static int gpio_stm32_pin_interrupt_configure(struct device *dev,
|
|||
stm32_exti_disable(pin);
|
||||
stm32_exti_unset_callback(pin);
|
||||
stm32_exti_trigger(pin, STM32_EXTI_TRIG_NONE);
|
||||
data->cb_pins &= ~BIT(pin);
|
||||
}
|
||||
/* else: No irq source configured for pin. Nothing to disable */
|
||||
goto release_lock;
|
||||
|
@ -460,8 +456,6 @@ static int gpio_stm32_pin_interrupt_configure(struct device *dev,
|
|||
goto release_lock;
|
||||
}
|
||||
|
||||
data->cb_pins |= BIT(pin);
|
||||
|
||||
gpio_stm32_enable_int(cfg->port, pin);
|
||||
|
||||
switch (trig) {
|
||||
|
@ -497,26 +491,6 @@ static int gpio_stm32_manage_callback(struct device *dev,
|
|||
return gpio_manage_callback(&data->cb, callback, set);
|
||||
}
|
||||
|
||||
static int gpio_stm32_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_stm32_data *data = dev->driver_data;
|
||||
|
||||
data->cb_pins |= BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_stm32_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct gpio_stm32_data *data = dev->driver_data;
|
||||
|
||||
data->cb_pins &= ~BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct gpio_driver_api gpio_stm32_driver = {
|
||||
.pin_configure = gpio_stm32_config,
|
||||
.port_get_raw = gpio_stm32_port_get_raw,
|
||||
|
@ -526,9 +500,6 @@ static const struct gpio_driver_api gpio_stm32_driver = {
|
|||
.port_toggle_bits = gpio_stm32_port_toggle_bits,
|
||||
.pin_interrupt_configure = gpio_stm32_pin_interrupt_configure,
|
||||
.manage_callback = gpio_stm32_manage_callback,
|
||||
.enable_callback = gpio_stm32_enable_callback,
|
||||
.disable_callback = gpio_stm32_disable_callback,
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -218,8 +218,6 @@ struct gpio_stm32_config {
|
|||
struct gpio_stm32_data {
|
||||
/* gpio_driver_data needs to be first */
|
||||
struct gpio_driver_data common;
|
||||
/* Enabled INT pins generating a cb */
|
||||
uint32_t cb_pins;
|
||||
/* user ISR cb */
|
||||
sys_slist_t cb;
|
||||
};
|
||||
|
|
|
@ -73,8 +73,6 @@ struct sx1509b_drv_data {
|
|||
struct device *dev;
|
||||
/* user ISR cb */
|
||||
sys_slist_t cb;
|
||||
/* Enabled INT pins generating a cb */
|
||||
uint16_t cb_pins;
|
||||
#endif /* CONFIG_GPIO_SX1509B_INTERRUPT */
|
||||
|
||||
};
|
||||
|
@ -203,8 +201,7 @@ static int sx1509b_handle_interrupt(void *arg)
|
|||
out:
|
||||
k_sem_give(&drv_data->lock);
|
||||
|
||||
if ((ret == 0)
|
||||
&& ((int_source & drv_data->cb_pins) != 0)) {
|
||||
if (ret == 0) {
|
||||
gpio_fire_callbacks(&drv_data->cb, dev, int_source);
|
||||
}
|
||||
|
||||
|
@ -499,10 +496,8 @@ static int pin_interrupt_configure(struct device *dev,
|
|||
|
||||
irq->interrupt_sense &= ~(SX1509B_EDGE_BOTH << (pin * 2));
|
||||
if (mode == GPIO_INT_MODE_DISABLED) {
|
||||
drv_data->cb_pins &= ~BIT(pin);
|
||||
irq->interrupt_mask |= BIT(pin);
|
||||
} else { /* GPIO_INT_MODE_EDGE */
|
||||
drv_data->cb_pins |= BIT(pin);
|
||||
irq->interrupt_mask &= ~BIT(pin);
|
||||
if (trig == GPIO_INT_TRIG_BOTH) {
|
||||
irq->interrupt_sense |= (SX1509B_EDGE_BOTH <<
|
||||
|
@ -567,7 +562,6 @@ static int sx1509b_init(struct device *dev)
|
|||
gpio_init_callback(&drv_data->gpio_cb, sx1509_int_cb,
|
||||
BIT(cfg->gpio_pin));
|
||||
gpio_add_callback(drv_data->gpio_int, &drv_data->gpio_cb);
|
||||
gpio_enable_callback(drv_data->gpio_int, cfg->gpio_pin);
|
||||
|
||||
drv_data->irq_state = (struct sx1509b_irq_state) {
|
||||
.interrupt_mask = ALL_PINS,
|
||||
|
@ -638,26 +632,6 @@ static int gpio_sx1509b_manage_callback(struct device *dev,
|
|||
|
||||
return gpio_manage_callback(&data->cb, callback, set);
|
||||
}
|
||||
|
||||
static int gpio_sx1509b_enable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct sx1509b_drv_data *data = dev->driver_data;
|
||||
|
||||
data->cb_pins |= BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_sx1509b_disable_callback(struct device *dev,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
struct sx1509b_drv_data *data = dev->driver_data;
|
||||
|
||||
data->cb_pins &= ~BIT(pin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct gpio_driver_api api_table = {
|
||||
|
@ -670,8 +644,6 @@ static const struct gpio_driver_api api_table = {
|
|||
.pin_interrupt_configure = pin_interrupt_configure,
|
||||
#ifdef CONFIG_GPIO_SX1509B_INTERRUPT
|
||||
.manage_callback = gpio_sx1509b_manage_callback,
|
||||
.enable_callback = gpio_sx1509b_enable_callback,
|
||||
.disable_callback = gpio_sx1509b_disable_callback,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -258,142 +258,6 @@ extern "C" {
|
|||
#define GPIO_DIR_MASK (GPIO_INPUT | GPIO_OUTPUT)
|
||||
/** @endcond */
|
||||
|
||||
/** @name Deprecated Flags
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Legacy flag indicating pin is configured as input only.
|
||||
*
|
||||
* @deprecated Replace with `GPIO_INPUT`.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#undef GPIO_DIR_IN
|
||||
#define GPIO_DIR_IN __DEPRECATED_MACRO GPIO_INPUT
|
||||
|
||||
/** Legacy flag indicating pin is configured as output.
|
||||
*
|
||||
* @deprecated Replace with `GPIO_OUTPUT`.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#undef GPIO_DIR_OUT
|
||||
#define GPIO_DIR_OUT __DEPRECATED_MACRO GPIO_OUTPUT
|
||||
|
||||
/** Legacy flag indicating pin is disconnected when GPIO pin output is low.
|
||||
*
|
||||
* @deprecated Replace with `GPIO_OPEN_SOURCE`.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#define GPIO_DS_DISCONNECT_LOW __DEPRECATED_MACRO GPIO_OPEN_SOURCE
|
||||
|
||||
/** Legacy flag indicating pin is disconnected when GPIO pin output is high.
|
||||
*
|
||||
* @deprecated Replace with `GPIO_OPEN_DRAIN`.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#define GPIO_DS_DISCONNECT_HIGH __DEPRECATED_MACRO GPIO_OPEN_DRAIN
|
||||
|
||||
/** @cond INTERNAL_HIDDEN */
|
||||
#define GPIO_PUD_SHIFT 4
|
||||
#define GPIO_PUD_MASK (0x3U << GPIO_PUD_SHIFT)
|
||||
/** @endcond */
|
||||
|
||||
/** Pin is neither pull-up nor pull-down.
|
||||
*
|
||||
* @deprecated Not used any more
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#define GPIO_PUD_NORMAL __DEPRECATED_MACRO 0U
|
||||
|
||||
/** Enable GPIO pin pull-up.
|
||||
*
|
||||
* @deprecated Replace with `GPIO_PULL_UP`.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#undef GPIO_PUD_PULL_UP
|
||||
#define GPIO_PUD_PULL_UP __DEPRECATED_MACRO GPIO_PULL_UP
|
||||
|
||||
/** Enable GPIO pin pull-down.
|
||||
*
|
||||
* @deprecated Replace with `GPIO_PULL_DOWN`.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#undef GPIO_PUD_PULL_DOWN
|
||||
#define GPIO_PUD_PULL_DOWN __DEPRECATED_MACRO GPIO_PULL_DOWN
|
||||
|
||||
/** Legacy flag indicating that interrupt is enabled.
|
||||
*
|
||||
* @deprecated Replace with `GPIO_INT_ENABLE`.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#define GPIO_INT __DEPRECATED_MACRO GPIO_INT_ENABLE
|
||||
|
||||
/** Legacy flag indicating that interrupt is level sensitive.
|
||||
*
|
||||
* @deprecated Replace with `GPIO_INT_LEVEL_LOW`, `GPIO_INT_LEVEL_HIGH`.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#define GPIO_INT_LEVEL __DEPRECATED_MACRO (0U << 14)
|
||||
|
||||
/** Legacy flag setting indicating signal or interrupt active level.
|
||||
*
|
||||
* This flag was used both to indicate a signal's active level, and to
|
||||
* indicate the level associated with an interrupt on a signal. As
|
||||
* active level is also relevant to output signals the two
|
||||
* interpretations have been separated. The legacy value supports
|
||||
* testing for interrupt level as this is the most common use in
|
||||
* existing code.
|
||||
*
|
||||
* @deprecated Replace with `GPIO_ACTIVE_LOW` or `GPIO_INT_LOW_0`
|
||||
* depending on intent.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#undef GPIO_INT_ACTIVE_LOW
|
||||
#define GPIO_INT_ACTIVE_LOW __DEPRECATED_MACRO GPIO_INT_LOW_0
|
||||
|
||||
/** Legacy flag setting indicating signal or interrupt active level.
|
||||
*
|
||||
* This flag was used both to indicate a signal's active level, and to
|
||||
* indicate the level associated with an interrupt on a signal. As
|
||||
* active level is also relevant to output signals the two
|
||||
* interpretations have been separated. The legacy value supports
|
||||
* testing for interrupt level as this is the most common use in
|
||||
* existing code.
|
||||
*
|
||||
* @deprecated Replace with `GPIO_ACTIVE_HIGH` or `GPIO_INT_HIGH_1`
|
||||
* depending on intent.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#undef GPIO_INT_ACTIVE_HIGH
|
||||
#define GPIO_INT_ACTIVE_HIGH __DEPRECATED_MACRO GPIO_INT_HIGH_1
|
||||
|
||||
/** Legacy flag indicating interrupt triggers on both rising and falling edge.
|
||||
*
|
||||
* @deprecated Replace with `GPIO_INT_EDGE_BOTH`.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#define GPIO_INT_DOUBLE_EDGE __DEPRECATED_MACRO GPIO_INT_EDGE_BOTH
|
||||
|
||||
/** @cond INTERNAL_HIDDEN */
|
||||
#define GPIO_POL_SHIFT 0
|
||||
#define GPIO_POL_MASK (1U << GPIO_POL_SHIFT)
|
||||
/** @endcond */
|
||||
|
||||
/** Legacy flag indicating that GPIO pin polarity is normal.
|
||||
*
|
||||
* @deprecated Replace with `GPIO_ACTIVE_HIGH`.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#define GPIO_POL_NORMAL __DEPRECATED_MACRO GPIO_ACTIVE_HIGH
|
||||
|
||||
/** Legacy flag indicating that GPIO pin polarity is inverted.
|
||||
*
|
||||
* @deprecated Replace with `GPIO_ACTIVE_LOW`.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
#define GPIO_POL_INV __DEPRECATED_MACRO GPIO_ACTIVE_LOW
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Identifies a set of pins associated with a port.
|
||||
*
|
||||
|
@ -557,8 +421,6 @@ __subsystem struct gpio_driver_api {
|
|||
enum gpio_int_mode, enum gpio_int_trig);
|
||||
int (*manage_callback)(struct device *port, struct gpio_callback *cb,
|
||||
bool set);
|
||||
int (*enable_callback)(struct device *port, gpio_pin_t pin);
|
||||
int (*disable_callback)(struct device *port, gpio_pin_t pin);
|
||||
uint32_t (*get_pending_int)(struct device *dev);
|
||||
};
|
||||
|
||||
|
@ -574,47 +436,6 @@ static inline int z_impl_gpio_config(struct device *port,
|
|||
return api->pin_configure(port, pin, flags);
|
||||
}
|
||||
|
||||
__syscall int gpio_enable_callback(struct device *port, gpio_pin_t pin);
|
||||
|
||||
static inline int z_impl_gpio_enable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_driver_api *api =
|
||||
(const struct gpio_driver_api *)port->driver_api;
|
||||
const struct gpio_driver_config *const cfg =
|
||||
(const struct gpio_driver_config *)port->config_info;
|
||||
|
||||
(void)cfg;
|
||||
__ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U,
|
||||
"Unsupported pin");
|
||||
|
||||
if (api->enable_callback == NULL) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
return api->enable_callback(port, pin);
|
||||
}
|
||||
|
||||
__syscall int gpio_disable_callback(struct device *port, gpio_pin_t pin);
|
||||
|
||||
static inline int z_impl_gpio_disable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
const struct gpio_driver_api *api =
|
||||
(const struct gpio_driver_api *)port->driver_api;
|
||||
const struct gpio_driver_config *const cfg =
|
||||
(const struct gpio_driver_config *)port->config_info;
|
||||
|
||||
(void)cfg;
|
||||
__ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U,
|
||||
"Unsupported pin");
|
||||
|
||||
if (api->disable_callback == NULL) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
return api->disable_callback(port, pin);
|
||||
}
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
@ -1191,53 +1012,6 @@ static inline int gpio_pin_toggle(struct device *port, gpio_pin_t pin)
|
|||
return gpio_port_toggle_bits(port, (gpio_port_pins_t)BIT(pin));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write the data value to a single pin.
|
||||
* @param port Pointer to the device structure for the driver instance.
|
||||
* @param pin Pin number where the data is written.
|
||||
* @param value Value set on the pin.
|
||||
* @return 0 if successful, negative errno code on failure.
|
||||
*
|
||||
* @deprecated Replace with gpio_pin_set assuming active level is
|
||||
* handled correctly. gpio_pin_set_raw() may be more correct for some
|
||||
* drivers.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
__deprecated static inline int gpio_pin_write(struct device *port,
|
||||
gpio_pin_t pin,
|
||||
uint32_t value)
|
||||
{
|
||||
return gpio_pin_set(port, pin, value != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read the data value of a single pin.
|
||||
*
|
||||
* Read the input state of a pin, returning the value 0 or 1.
|
||||
*
|
||||
* @param port Pointer to the device structure for the driver instance.
|
||||
* @param pin Pin number where data is read.
|
||||
* @param value Integer pointer to receive the data values from the pin.
|
||||
* @return 0 if successful, negative errno code on failure.
|
||||
*
|
||||
* @deprecated Replace with gpio_pin_get() assuming active level is
|
||||
* handled correctly. gpio_pin_get_raw() may be more correct for some
|
||||
* drivers.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
__deprecated static inline int gpio_pin_read(struct device *port,
|
||||
gpio_pin_t pin,
|
||||
uint32_t *value)
|
||||
{
|
||||
int rv = gpio_pin_get(port, pin);
|
||||
|
||||
if (rv >= 0) {
|
||||
*value = rv;
|
||||
rv = 0;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Helper to initialize a struct gpio_callback properly
|
||||
* @param callback A valid Application's callback structure pointer.
|
||||
|
@ -1309,42 +1083,6 @@ static inline int gpio_remove_callback(struct device *port,
|
|||
return api->manage_callback(port, callback, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable callback(s) for a single pin.
|
||||
* @param port Pointer to the device structure for the driver instance.
|
||||
* @param pin Pin number where the callback function is enabled.
|
||||
* @return 0 if successful, negative errno code on failure.
|
||||
*
|
||||
* Note: Depending on the driver implementation, this function will enable
|
||||
* the pin to trigger an interruption. So as a semantic detail, if no
|
||||
* callback is registered, of course none will be called.
|
||||
*
|
||||
* @deprecated Replace with ``gpio_pin_interrupt_configure()`` passing
|
||||
* interrupt configuration flags such as ``GPIO_INT_EDGE_TO_ACTIVE``.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
__deprecated static inline int gpio_pin_enable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
return gpio_enable_callback(port, pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable callback(s) for a single pin.
|
||||
* @param port Pointer to the device structure for the driver instance.
|
||||
* @param pin Pin number where the callback function is disabled.
|
||||
* @return 0 if successful, negative errno code on failure.
|
||||
*
|
||||
* @deprecated Replace with ``gpio_pin_interrupt_configure()`` with
|
||||
* ``GPIO_INT_DISABLE``.
|
||||
*/
|
||||
/* Deprecated in 2.2 release */
|
||||
__deprecated static inline int gpio_pin_disable_callback(struct device *port,
|
||||
gpio_pin_t pin)
|
||||
{
|
||||
return gpio_disable_callback(port, pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function to get pending interrupts
|
||||
*
|
||||
|
|
|
@ -76,19 +76,6 @@
|
|||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @cond INTERNAL_HIDDEN
|
||||
*
|
||||
* Following defines are deprecated and shouldn't be used in DTS files.
|
||||
*/
|
||||
#define GPIO_DIR_IN (1 << 8) /* GPIO_INPUT */
|
||||
#define GPIO_DIR_OUT (1 << 9) /* GPIO_OUTPUT */
|
||||
#define GPIO_PUD_PULL_UP GPIO_PULL_UP
|
||||
#define GPIO_PUD_PULL_DOWN GPIO_PULL_DOWN
|
||||
#define GPIO_INT_ACTIVE_LOW (1 << 17) /* GPIO_INT_LOW_0 */
|
||||
#define GPIO_INT_ACTIVE_HIGH (1 << 18) /* GPIO_INT_HIGH_1 */
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -126,7 +126,6 @@ void test_main(void)
|
|||
ztest_unit_test(test_gpio_callback_add_remove),
|
||||
ztest_unit_test(test_gpio_callback_self_remove),
|
||||
ztest_unit_test(test_gpio_callback_enable_disable),
|
||||
ztest_unit_test(test_gpio_callback_variants),
|
||||
ztest_unit_test(test_gpio_deprecated));
|
||||
ztest_unit_test(test_gpio_callback_variants));
|
||||
ztest_run_test_suite(gpio_basic_test);
|
||||
}
|
||||
|
|
|
@ -1,167 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* Avoid CI warnings about use of deprecated API. The purpose of this
|
||||
* module is to test that the deprecated API still works.
|
||||
*/
|
||||
#undef __deprecated
|
||||
#define __deprecated
|
||||
#undef __DEPRECATED_MACRO
|
||||
#define __DEPRECATED_MACRO
|
||||
|
||||
#include "test_gpio.h"
|
||||
|
||||
static struct drv_data data;
|
||||
static int cb_cnt;
|
||||
|
||||
static void callback(struct device *dev,
|
||||
struct gpio_callback *gpio_cb, uint32_t pins)
|
||||
{
|
||||
int rc;
|
||||
const struct drv_data *dd = CONTAINER_OF(gpio_cb,
|
||||
struct drv_data, gpio_cb);
|
||||
|
||||
/*= checkpoint: pins should be marked with correct pin number bit =*/
|
||||
zassert_equal(pins, BIT(PIN_IN),
|
||||
"unexpected pins %x", pins);
|
||||
++cb_cnt;
|
||||
TC_PRINT("callback triggered: %d\n", cb_cnt);
|
||||
if ((cb_cnt == 1)
|
||||
&& (dd->mode == GPIO_INT_DOUBLE_EDGE)) {
|
||||
gpio_pin_write(dev, PIN_OUT, dd->aux);
|
||||
}
|
||||
if (cb_cnt >= MAX_INT_CNT) {
|
||||
gpio_pin_write(dev, PIN_OUT, dd->aux);
|
||||
|
||||
/* NB: The legacy idiom for disabling interrupts is to
|
||||
* pass GPIO_DIR_IN without any interrupt-related
|
||||
* flags. In the new API this leaves the interrupt
|
||||
* configuration of the pin unchanged, which causes
|
||||
* level interrupts to repeat forever. To prevent hangs
|
||||
* it's necessary to explicitly disable the interrupt.
|
||||
*/
|
||||
rc = gpio_pin_configure(dev, PIN_IN, GPIO_DIR_IN
|
||||
| GPIO_INT_DISABLE);
|
||||
zassert_equal(rc, 0,
|
||||
"disable interrupts failed: %d", rc);
|
||||
}
|
||||
}
|
||||
|
||||
static int test_callback(gpio_flags_t int_flags)
|
||||
{
|
||||
struct device *dev = device_get_binding(DEV_NAME);
|
||||
struct drv_data *drv_data = &data;
|
||||
bool active_level = (int_flags & GPIO_INT_ACTIVE_HIGH) != 0;
|
||||
int rc;
|
||||
|
||||
gpio_pin_disable_callback(dev, PIN_IN);
|
||||
gpio_pin_disable_callback(dev, PIN_OUT);
|
||||
|
||||
/* 1. set PIN_OUT to non-active state */
|
||||
drv_data->aux = (active_level == false);
|
||||
|
||||
rc = gpio_pin_configure(dev, PIN_OUT, GPIO_DIR_OUT);
|
||||
if (rc == 0) {
|
||||
gpio_pin_write(dev, PIN_OUT, !active_level);
|
||||
}
|
||||
|
||||
if (rc != 0) {
|
||||
TC_ERROR("PIN_OUT config fail: %d", rc);
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
/* 2. configure PIN_IN callback and trigger condition */
|
||||
rc = gpio_pin_configure(dev, PIN_IN,
|
||||
GPIO_DIR_IN | GPIO_INT
|
||||
| GPIO_INT_DEBOUNCE
|
||||
| int_flags);
|
||||
if (rc == -ENOTSUP) {
|
||||
TC_PRINT("interrupt configuration not supported\n");
|
||||
return TC_PASS;
|
||||
} else if (rc != 0) {
|
||||
TC_ERROR("config PIN_IN fail: %d\n", rc);
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
drv_data->mode = int_flags;
|
||||
gpio_init_callback(&drv_data->gpio_cb, callback, BIT(PIN_IN));
|
||||
rc = gpio_add_callback(dev, &drv_data->gpio_cb);
|
||||
if (rc == -ENOTSUP) {
|
||||
TC_PRINT("interrupts not supported\n");
|
||||
return TC_PASS;
|
||||
} else if (rc != 0) {
|
||||
TC_ERROR("set PIN_IN callback fail: %d\n", rc);
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
/* 3. enable callback, trigger PIN_IN interrupt by operate PIN_OUT */
|
||||
cb_cnt = 0;
|
||||
rc = gpio_pin_enable_callback(dev, PIN_IN);
|
||||
if (rc == -ENOTSUP) {
|
||||
TC_PRINT("Mode %x not supported\n", int_flags);
|
||||
goto pass_exit;
|
||||
} else if (rc != 0) {
|
||||
TC_ERROR("enable PIN_IN interrupt fail: %d\n", rc);
|
||||
goto err_exit;
|
||||
}
|
||||
k_sleep(K_MSEC(100));
|
||||
gpio_pin_write(dev, PIN_OUT, active_level);
|
||||
k_sleep(K_MSEC(1000));
|
||||
(void)gpio_pin_disable_callback(dev, PIN_IN);
|
||||
(void)gpio_remove_callback(dev, &drv_data->gpio_cb);
|
||||
(void)gpio_pin_configure(dev, PIN_IN, GPIO_INT_DISABLE);
|
||||
|
||||
/*= checkpoint: check callback is triggered =*/
|
||||
TC_PRINT("INT cfg %x, cnt %d\n", int_flags, cb_cnt);
|
||||
if (int_flags == GPIO_INT_DOUBLE_EDGE) {
|
||||
if (cb_cnt != 2) {
|
||||
TC_ERROR("double edge not detected\n");
|
||||
goto err_exit;
|
||||
}
|
||||
goto pass_exit;
|
||||
}
|
||||
if ((int_flags & GPIO_INT_EDGE) == GPIO_INT_EDGE) {
|
||||
if (cb_cnt != 1) {
|
||||
TC_ERROR("edge not trigger callback correctly\n");
|
||||
goto err_exit;
|
||||
}
|
||||
goto pass_exit;
|
||||
} else {
|
||||
if (cb_cnt != MAX_INT_CNT) {
|
||||
TC_ERROR("level not trigger callback correctly\n");
|
||||
goto err_exit;
|
||||
}
|
||||
}
|
||||
|
||||
pass_exit:
|
||||
return TC_PASS;
|
||||
|
||||
err_exit:
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
static int test_callback_enable_disable(void)
|
||||
{
|
||||
return TC_PASS;
|
||||
}
|
||||
|
||||
/* export test cases */
|
||||
void test_gpio_deprecated(void)
|
||||
{
|
||||
zassert_equal(test_callback_enable_disable(),
|
||||
TC_PASS, "callback enable/disable failed");
|
||||
zassert_equal(test_callback(GPIO_INT_EDGE | GPIO_INT_ACTIVE_HIGH),
|
||||
TC_PASS, "rising edge failed");
|
||||
zassert_equal(test_callback(GPIO_INT_EDGE | GPIO_INT_ACTIVE_LOW),
|
||||
TC_PASS, "falling edge failed");
|
||||
zassert_equal(test_callback(GPIO_INT_EDGE_BOTH),
|
||||
TC_PASS, "double edge failed");
|
||||
zassert_equal(test_callback(GPIO_INT_LEVEL | GPIO_INT_ACTIVE_HIGH),
|
||||
TC_PASS, "level high failed");
|
||||
zassert_equal(test_callback(GPIO_INT_LEVEL | GPIO_INT_ACTIVE_LOW),
|
||||
TC_PASS, "level low failed");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue