driver: gpio: gecko: Add support for Gecko Series 2 SoC
Use the GPIO API from emlib instead of accessing the register directly: The emlib API is doing the checks and uses the proper registers depending on the SoC used. Signed-off-by: Steven Lemaire <steven.lemaire@zii.aero>
This commit is contained in:
parent
da076456b1
commit
deba608921
1 changed files with 14 additions and 20 deletions
|
@ -52,7 +52,6 @@ struct gpio_gecko_common_data {
|
|||
struct gpio_gecko_config {
|
||||
/* gpio_driver_config needs to be first */
|
||||
struct gpio_driver_config common;
|
||||
GPIO_P_TypeDef *gpio_base;
|
||||
GPIO_Port_TypeDef gpio_index;
|
||||
};
|
||||
|
||||
|
@ -128,9 +127,9 @@ static int gpio_gecko_configure(struct device *dev,
|
|||
static int gpio_gecko_port_get_raw(struct device *dev, uint32_t *value)
|
||||
{
|
||||
const struct gpio_gecko_config *config = dev->config_info;
|
||||
GPIO_P_TypeDef *gpio_base = config->gpio_base;
|
||||
GPIO_Port_TypeDef gpio_index = config->gpio_index;
|
||||
|
||||
*value = gpio_base->DIN;
|
||||
*value = GPIO_PortInGet(gpio_index);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -139,9 +138,9 @@ static int gpio_gecko_port_set_masked_raw(struct device *dev, uint32_t mask,
|
|||
uint32_t value)
|
||||
{
|
||||
const struct gpio_gecko_config *config = dev->config_info;
|
||||
GPIO_P_TypeDef *gpio_base = config->gpio_base;
|
||||
GPIO_Port_TypeDef gpio_index = config->gpio_index;
|
||||
|
||||
gpio_base->DOUT = (gpio_base->DOUT & ~mask) | (mask & value);
|
||||
GPIO_PortOutSetVal(gpio_index, value, mask);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -149,13 +148,9 @@ static int gpio_gecko_port_set_masked_raw(struct device *dev, uint32_t mask,
|
|||
static int gpio_gecko_port_set_bits_raw(struct device *dev, uint32_t mask)
|
||||
{
|
||||
const struct gpio_gecko_config *config = dev->config_info;
|
||||
GPIO_P_TypeDef *gpio_base = config->gpio_base;
|
||||
GPIO_Port_TypeDef gpio_index = config->gpio_index;
|
||||
|
||||
#if defined(_GPIO_P_DOUTSET_MASK)
|
||||
gpio_base->DOUTSET = mask;
|
||||
#else
|
||||
BUS_RegMaskedSet(&gpio_base->DOUT, mask);
|
||||
#endif
|
||||
GPIO_PortOutSet(gpio_index, mask);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -163,13 +158,9 @@ static int gpio_gecko_port_set_bits_raw(struct device *dev, uint32_t mask)
|
|||
static int gpio_gecko_port_clear_bits_raw(struct device *dev, uint32_t mask)
|
||||
{
|
||||
const struct gpio_gecko_config *config = dev->config_info;
|
||||
GPIO_P_TypeDef *gpio_base = config->gpio_base;
|
||||
GPIO_Port_TypeDef gpio_index = config->gpio_index;
|
||||
|
||||
#if defined(_GPIO_P_DOUTCLR_MASK)
|
||||
gpio_base->DOUTCLR = mask;
|
||||
#else
|
||||
BUS_RegMaskedClear(&gpio_base->DOUT, mask);
|
||||
#endif
|
||||
GPIO_PortOutClear(gpio_index, mask);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -177,9 +168,9 @@ static int gpio_gecko_port_clear_bits_raw(struct device *dev, uint32_t mask)
|
|||
static int gpio_gecko_port_toggle_bits(struct device *dev, uint32_t mask)
|
||||
{
|
||||
const struct gpio_gecko_config *config = dev->config_info;
|
||||
GPIO_P_TypeDef *gpio_base = config->gpio_base;
|
||||
GPIO_Port_TypeDef gpio_index = config->gpio_index;
|
||||
|
||||
gpio_base->DOUTTGL = mask;
|
||||
GPIO_PortOutToggle(gpio_index, mask);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -254,7 +245,11 @@ static void gpio_gecko_common_isr(void *arg)
|
|||
enabled_int = int_status & port_data->int_enabled_mask;
|
||||
if (enabled_int != 0) {
|
||||
int_status &= ~enabled_int;
|
||||
#if defined(_SILICON_LABS_32B_SERIES_2)
|
||||
GPIO->IF_CLR = enabled_int;
|
||||
#else
|
||||
GPIO->IFC = enabled_int;
|
||||
#endif
|
||||
gpio_fire_callbacks(&port_data->callbacks, port_dev,
|
||||
enabled_int);
|
||||
}
|
||||
|
@ -313,7 +308,6 @@ static const struct gpio_gecko_config gpio_gecko_port##idx##_config = { \
|
|||
.common = { \
|
||||
.port_pin_mask = (gpio_port_pins_t)(-1), \
|
||||
}, \
|
||||
.gpio_base = (GPIO_P_TypeDef *)DT_INST_REG_ADDR(idx), \
|
||||
.gpio_index = DT_INST_PROP(idx, peripheral_id), \
|
||||
}; \
|
||||
\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue