2017-04-05 19:02:45 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017, Christian Taedcke
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2020-03-26 17:39:59 -05:00
|
|
|
#define DT_DRV_COMPAT silabs_gecko_gpio_port
|
|
|
|
|
2017-04-05 19:02:45 +02:00
|
|
|
#include <errno.h>
|
2019-06-25 15:53:52 -04:00
|
|
|
#include <drivers/gpio.h>
|
2017-04-05 19:02:45 +02:00
|
|
|
#include <soc.h>
|
|
|
|
#include <em_gpio.h>
|
|
|
|
|
|
|
|
#include "gpio_utils.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Macros to set the GPIO MODE registers
|
|
|
|
*
|
|
|
|
* See https://www.silabs.com/documents/public/reference-manuals/EFM32WG-RM.pdf
|
|
|
|
* pages 972 and 982.
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @brief Create the value to set the GPIO MODEL register
|
|
|
|
* @param[in] pin The index of the pin. Valid values are 0..7.
|
|
|
|
* @param[in] mode The mode that should be set.
|
|
|
|
* @return The value that can be set into the GPIO MODEL register.
|
|
|
|
*/
|
|
|
|
#define GECKO_GPIO_MODEL(pin, mode) (mode << (pin * 4))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Create the value to set the GPIO MODEH register
|
|
|
|
* @param[in] pin The index of the pin. Valid values are 8..15.
|
|
|
|
* @param[in] mode The mode that should be set.
|
|
|
|
* @return The value that can be set into the GPIO MODEH register.
|
|
|
|
*/
|
|
|
|
#define GECKO_GPIO_MODEH(pin, mode) (mode << ((pin - 8) * 4))
|
|
|
|
|
|
|
|
|
|
|
|
#define member_size(type, member) sizeof(((type *)0)->member)
|
|
|
|
#define NUMBER_OF_PORTS (member_size(GPIO_TypeDef, P) / \
|
|
|
|
member_size(GPIO_TypeDef, P[0]))
|
|
|
|
|
|
|
|
struct gpio_gecko_common_config {
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gpio_gecko_common_data {
|
|
|
|
/* a list of all ports */
|
2020-04-30 20:33:38 +02:00
|
|
|
const struct device *ports[NUMBER_OF_PORTS];
|
2017-04-05 19:02:45 +02:00
|
|
|
size_t count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gpio_gecko_config {
|
2019-12-11 10:15:53 -06:00
|
|
|
/* gpio_driver_config needs to be first */
|
|
|
|
struct gpio_driver_config common;
|
2017-04-05 19:02:45 +02:00
|
|
|
GPIO_Port_TypeDef gpio_index;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gpio_gecko_data {
|
2019-09-18 08:34:51 -05:00
|
|
|
/* gpio_driver_data needs to be first */
|
|
|
|
struct gpio_driver_data common;
|
2017-04-05 19:02:45 +02:00
|
|
|
/* port ISR callback routine address */
|
|
|
|
sys_slist_t callbacks;
|
2020-06-13 02:07:29 +02:00
|
|
|
/* mask of pins on which interrupt is enabled */
|
|
|
|
uint32_t int_enabled_mask;
|
2017-04-05 19:02:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void gpio_gecko_add_port(struct gpio_gecko_common_data *data,
|
2020-04-30 20:33:38 +02:00
|
|
|
const struct device *dev)
|
2017-04-05 19:02:45 +02:00
|
|
|
{
|
|
|
|
__ASSERT(dev, "No port device!");
|
|
|
|
data->ports[data->count++] = dev;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_gecko_configure(const struct device *dev,
|
2020-01-30 12:12:39 -06:00
|
|
|
gpio_pin_t pin,
|
|
|
|
gpio_flags_t flags)
|
2017-04-05 19:02:45 +02:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_gecko_config *config = dev->config;
|
2017-04-05 19:02:45 +02:00
|
|
|
GPIO_Port_TypeDef gpio_index = config->gpio_index;
|
|
|
|
GPIO_Mode_TypeDef mode;
|
2018-11-29 11:12:22 -08:00
|
|
|
unsigned int out = 0U;
|
2017-04-05 19:02:45 +02:00
|
|
|
|
2019-01-29 00:30:28 +01:00
|
|
|
if (flags & GPIO_OUTPUT) {
|
|
|
|
/* Following modes enable both output and input */
|
|
|
|
if (flags & GPIO_SINGLE_ENDED) {
|
|
|
|
if (flags & GPIO_LINE_OPEN_DRAIN) {
|
|
|
|
mode = gpioModeWiredAnd;
|
|
|
|
} else {
|
|
|
|
mode = gpioModeWiredOr;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mode = gpioModePushPull;
|
|
|
|
}
|
|
|
|
if (flags & GPIO_OUTPUT_INIT_HIGH) {
|
|
|
|
out = 1U;
|
|
|
|
} else if (flags & GPIO_OUTPUT_INIT_LOW) {
|
|
|
|
out = 0U;
|
|
|
|
} else {
|
|
|
|
out = GPIO_PinOutGet(gpio_index, pin);
|
|
|
|
}
|
|
|
|
} else if (flags & GPIO_INPUT) {
|
|
|
|
if (flags & GPIO_PULL_UP) {
|
2017-04-05 19:02:45 +02:00
|
|
|
mode = gpioModeInputPull;
|
2018-11-29 11:12:22 -08:00
|
|
|
out = 1U; /* pull-up*/
|
2019-01-29 00:30:28 +01:00
|
|
|
} else if (flags & GPIO_PULL_DOWN) {
|
2017-04-05 19:02:45 +02:00
|
|
|
mode = gpioModeInputPull;
|
|
|
|
/* out = 0 means pull-down*/
|
2017-10-23 12:47:52 -07:00
|
|
|
} else {
|
|
|
|
mode = gpioModeInput;
|
2017-04-05 19:02:45 +02:00
|
|
|
}
|
2019-01-29 00:30:28 +01:00
|
|
|
} else {
|
|
|
|
/* Neither input nor output mode is selected */
|
|
|
|
mode = gpioModeDisabled;
|
2017-04-05 19:02:45 +02:00
|
|
|
}
|
|
|
|
/* The flags contain options that require touching registers in the
|
|
|
|
* GPIO module and the corresponding PORT module.
|
|
|
|
*
|
|
|
|
* Start with the GPIO module and set up the pin direction register.
|
|
|
|
* 0 - pin is input, 1 - pin is output
|
|
|
|
*/
|
|
|
|
|
2020-01-30 09:31:07 -06:00
|
|
|
GPIO_PinModeSet(gpio_index, pin, mode, out);
|
2017-04-05 19:02:45 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_gecko_port_get_raw(const struct device *dev, uint32_t *value)
|
2019-01-29 00:30:28 +01:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_gecko_config *config = dev->config;
|
2020-07-14 11:22:27 +02:00
|
|
|
GPIO_Port_TypeDef gpio_index = config->gpio_index;
|
2019-01-29 00:30:28 +01:00
|
|
|
|
2020-07-14 11:22:27 +02:00
|
|
|
*value = GPIO_PortInGet(gpio_index);
|
2019-01-29 00:30:28 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_gecko_port_set_masked_raw(const struct device *dev,
|
|
|
|
uint32_t mask,
|
2020-05-27 11:26:57 -05:00
|
|
|
uint32_t value)
|
2019-01-29 00:30:28 +01:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_gecko_config *config = dev->config;
|
2020-07-14 11:22:27 +02:00
|
|
|
GPIO_Port_TypeDef gpio_index = config->gpio_index;
|
2019-01-29 00:30:28 +01:00
|
|
|
|
2020-07-14 11:22:27 +02:00
|
|
|
GPIO_PortOutSetVal(gpio_index, value, mask);
|
2019-01-29 00:30:28 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_gecko_port_set_bits_raw(const struct device *dev,
|
|
|
|
uint32_t mask)
|
2019-01-29 00:30:28 +01:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_gecko_config *config = dev->config;
|
2020-07-14 11:22:27 +02:00
|
|
|
GPIO_Port_TypeDef gpio_index = config->gpio_index;
|
2019-01-29 00:30:28 +01:00
|
|
|
|
2020-07-14 11:22:27 +02:00
|
|
|
GPIO_PortOutSet(gpio_index, mask);
|
2019-01-29 00:30:28 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_gecko_port_clear_bits_raw(const struct device *dev,
|
|
|
|
uint32_t mask)
|
2019-01-29 00:30:28 +01:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_gecko_config *config = dev->config;
|
2020-07-14 11:22:27 +02:00
|
|
|
GPIO_Port_TypeDef gpio_index = config->gpio_index;
|
2019-01-29 00:30:28 +01:00
|
|
|
|
2020-07-14 11:22:27 +02:00
|
|
|
GPIO_PortOutClear(gpio_index, mask);
|
2019-01-29 00:30:28 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_gecko_port_toggle_bits(const struct device *dev,
|
|
|
|
uint32_t mask)
|
2019-01-29 00:30:28 +01:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_gecko_config *config = dev->config;
|
2020-07-14 11:22:27 +02:00
|
|
|
GPIO_Port_TypeDef gpio_index = config->gpio_index;
|
2019-01-29 00:30:28 +01:00
|
|
|
|
2020-07-14 11:22:27 +02:00
|
|
|
GPIO_PortOutToggle(gpio_index, mask);
|
2019-01-29 00:30:28 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_gecko_pin_interrupt_configure(const struct device *dev,
|
|
|
|
gpio_pin_t pin,
|
|
|
|
enum gpio_int_mode mode,
|
|
|
|
enum gpio_int_trig trig)
|
2019-01-29 00:30:28 +01:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_gecko_config *config = dev->config;
|
2020-05-28 21:23:02 +02:00
|
|
|
struct gpio_gecko_data *data = dev->data;
|
2019-01-29 00:30:28 +01:00
|
|
|
|
2019-09-18 08:34:51 -05:00
|
|
|
/* Interrupt on static level is not supported by the hardware */
|
|
|
|
if (mode == GPIO_INT_MODE_LEVEL) {
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
2019-01-29 00:30:28 +01:00
|
|
|
|
2019-09-18 08:34:51 -05:00
|
|
|
if (mode == GPIO_INT_MODE_DISABLED) {
|
|
|
|
GPIO_IntDisable(BIT(pin));
|
|
|
|
} else {
|
2019-01-29 00:30:28 +01:00
|
|
|
/* Interrupt line is already in use */
|
|
|
|
if ((GPIO->IEN & BIT(pin)) != 0) {
|
|
|
|
/* TODO: Return an error only if request is done for
|
|
|
|
* a pin from a different port.
|
|
|
|
*/
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
2019-09-18 08:34:51 -05:00
|
|
|
bool rising_edge = true;
|
|
|
|
bool falling_edge = true;
|
|
|
|
|
|
|
|
if (trig == GPIO_INT_TRIG_LOW) {
|
|
|
|
rising_edge = false;
|
|
|
|
falling_edge = true;
|
|
|
|
} else if (trig == GPIO_INT_TRIG_HIGH) {
|
|
|
|
rising_edge = true;
|
|
|
|
falling_edge = false;
|
|
|
|
} /* default is GPIO_INT_TRIG_BOTH */
|
2019-01-29 00:30:28 +01:00
|
|
|
|
|
|
|
GPIO_IntConfig(config->gpio_index, pin,
|
|
|
|
rising_edge, falling_edge, true);
|
|
|
|
}
|
|
|
|
|
2020-06-13 02:07:29 +02:00
|
|
|
WRITE_BIT(data->int_enabled_mask, pin, mode != GPIO_INT_DISABLE);
|
2019-01-29 00:30:28 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_gecko_manage_callback(const struct device *dev,
|
2017-04-05 19:02:45 +02:00
|
|
|
struct gpio_callback *callback, bool set)
|
|
|
|
{
|
2020-05-28 21:23:02 +02:00
|
|
|
struct gpio_gecko_data *data = dev->data;
|
2017-04-05 19:02:45 +02:00
|
|
|
|
2019-03-12 15:15:42 -06:00
|
|
|
return gpio_manage_callback(&data->callbacks, callback, set);
|
2017-04-05 19:02:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler for both odd and even pin interrupts
|
|
|
|
*/
|
isr: Normalize usage of device instance through ISR
The goal of this patch is to replace the 'void *' parameter by 'struct
device *' if they use such variable or just 'const void *' on all
relevant ISRs
This will avoid not-so-nice const qualifier tweaks when device instances
will be constant.
Note that only the ISR passed to IRQ_CONNECT are of interest here.
In order to do so, the script fix_isr.py below is necessary:
from pathlib import Path
import subprocess
import pickle
import mmap
import sys
import re
import os
cocci_template = """
@r_fix_isr_0
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
...
(
const struct device *D = (const struct device *)P;
|
const struct device *D = P;
)
...
}
@r_fix_isr_1
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
...
const struct device *D;
...
(
D = (const struct device *)P;
|
D = P;
)
...
}
@r_fix_isr_2
@
type ret_type;
identifier A;
@@
-ret_type <!fn!>(void *A)
+ret_type <!fn!>(const void *A)
{
...
}
@r_fix_isr_3
@
const struct device *D;
@@
-<!fn!>((void *)D);
+<!fn!>(D);
@r_fix_isr_4
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
...
(
-const struct device *D = (const struct device *)P;
|
-const struct device *D = P;
)
...
}
@r_fix_isr_5
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
...
-const struct device *D;
...
(
-D = (const struct device *)P;
|
-D = P;
)
...
}
"""
def find_isr(fn):
db = []
data = None
start = 0
try:
with open(fn, 'r+') as f:
data = str(mmap.mmap(f.fileno(), 0).read())
except Exception as e:
return db
while True:
isr = ""
irq = data.find('IRQ_CONNECT', start)
while irq > -1:
p = 1
arg = 1
p_o = data.find('(', irq)
if p_o < 0:
irq = -1
break;
pos = p_o + 1
while p > 0:
if data[pos] == ')':
p -= 1
elif data[pos] == '(':
p += 1
elif data[pos] == ',' and p == 1:
arg += 1
if arg == 3:
isr += data[pos]
pos += 1
isr = isr.strip(',\\n\\t ')
if isr not in db and len(isr) > 0:
db.append(isr)
start = pos
break
if irq < 0:
break
return db
def patch_isr(fn, isr_list):
if len(isr_list) <= 0:
return
for isr in isr_list:
tmplt = cocci_template.replace('<!fn!>', isr)
with open('/tmp/isr_fix.cocci', 'w') as f:
f.write(tmplt)
cmd = ['spatch', '--sp-file', '/tmp/isr_fix.cocci', '--in-place', fn]
subprocess.run(cmd)
def process_files(path):
if path.is_file() and path.suffix in ['.h', '.c']:
p = str(path.parent) + '/' + path.name
isr_list = find_isr(p)
patch_isr(p, isr_list)
elif path.is_dir():
for p in path.iterdir():
process_files(p)
if len(sys.argv) < 2:
print("You need to provide a dir/file path")
sys.exit(1)
process_files(Path(sys.argv[1]))
And is run: ./fix_isr.py <zephyr root directory>
Finally, some files needed manual fixes such.
Fixes #27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-06-17 14:58:56 +02:00
|
|
|
static void gpio_gecko_common_isr(const struct device *dev)
|
2017-04-05 19:02:45 +02:00
|
|
|
{
|
2020-05-28 21:23:02 +02:00
|
|
|
struct gpio_gecko_common_data *data = dev->data;
|
2020-05-27 11:26:57 -05:00
|
|
|
uint32_t enabled_int, int_status;
|
2020-04-30 20:33:38 +02:00
|
|
|
const struct device *port_dev;
|
2017-04-05 19:02:45 +02:00
|
|
|
struct gpio_gecko_data *port_data;
|
|
|
|
|
|
|
|
int_status = GPIO->IF;
|
|
|
|
|
|
|
|
for (unsigned int i = 0; int_status && (i < data->count); i++) {
|
|
|
|
port_dev = data->ports[i];
|
2020-05-28 21:23:02 +02:00
|
|
|
port_data = port_dev->data;
|
2020-06-13 02:07:29 +02:00
|
|
|
enabled_int = int_status & port_data->int_enabled_mask;
|
2019-10-30 05:48:01 -05:00
|
|
|
if (enabled_int != 0) {
|
|
|
|
int_status &= ~enabled_int;
|
2020-07-14 11:22:27 +02:00
|
|
|
#if defined(_SILICON_LABS_32B_SERIES_2)
|
|
|
|
GPIO->IF_CLR = enabled_int;
|
|
|
|
#else
|
2019-10-30 05:48:01 -05:00
|
|
|
GPIO->IFC = enabled_int;
|
2020-07-14 11:22:27 +02:00
|
|
|
#endif
|
2019-10-30 05:48:01 -05:00
|
|
|
gpio_fire_callbacks(&port_data->callbacks, port_dev,
|
|
|
|
enabled_int);
|
|
|
|
}
|
2017-04-05 19:02:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct gpio_driver_api gpio_gecko_driver_api = {
|
2020-01-30 12:12:39 -06:00
|
|
|
.pin_configure = gpio_gecko_configure,
|
2019-01-29 00:30:28 +01:00
|
|
|
.port_get_raw = gpio_gecko_port_get_raw,
|
|
|
|
.port_set_masked_raw = gpio_gecko_port_set_masked_raw,
|
|
|
|
.port_set_bits_raw = gpio_gecko_port_set_bits_raw,
|
|
|
|
.port_clear_bits_raw = gpio_gecko_port_clear_bits_raw,
|
|
|
|
.port_toggle_bits = gpio_gecko_port_toggle_bits,
|
|
|
|
.pin_interrupt_configure = gpio_gecko_pin_interrupt_configure,
|
2017-04-05 19:02:45 +02:00
|
|
|
.manage_callback = gpio_gecko_manage_callback,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct gpio_driver_api gpio_gecko_common_driver_api = {
|
|
|
|
.manage_callback = gpio_gecko_manage_callback,
|
|
|
|
};
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_gecko_common_init(const struct device *dev);
|
2017-04-05 19:02:45 +02:00
|
|
|
|
|
|
|
static const struct gpio_gecko_common_config gpio_gecko_common_config = {
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct gpio_gecko_common_data gpio_gecko_common_data;
|
|
|
|
|
2020-12-10 10:20:42 -06:00
|
|
|
DEVICE_DT_DEFINE(DT_INST(0, silabs_gecko_gpio),
|
2017-04-05 19:02:45 +02:00
|
|
|
gpio_gecko_common_init,
|
2020-12-10 10:20:42 -06:00
|
|
|
device_pm_control_nop,
|
2017-04-05 19:02:45 +02:00
|
|
|
&gpio_gecko_common_data, &gpio_gecko_common_config,
|
|
|
|
POST_KERNEL, CONFIG_GPIO_GECKO_COMMON_INIT_PRIORITY,
|
|
|
|
&gpio_gecko_common_driver_api);
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_gecko_common_init(const struct device *dev)
|
2017-04-05 19:02:45 +02:00
|
|
|
{
|
|
|
|
gpio_gecko_common_data.count = 0;
|
2020-03-23 00:47:15 +01:00
|
|
|
IRQ_CONNECT(GPIO_EVEN_IRQn,
|
2020-03-26 17:39:59 -05:00
|
|
|
DT_IRQ_BY_NAME(DT_INST(0, silabs_gecko_gpio), gpio_even, priority),
|
2020-12-10 10:20:42 -06:00
|
|
|
gpio_gecko_common_isr,
|
|
|
|
DEVICE_DT_GET(DT_INST(0, silabs_gecko_gpio)), 0);
|
2017-04-05 19:02:45 +02:00
|
|
|
|
2020-03-23 00:47:15 +01:00
|
|
|
IRQ_CONNECT(GPIO_ODD_IRQn,
|
2020-03-26 17:39:59 -05:00
|
|
|
DT_IRQ_BY_NAME(DT_INST(0, silabs_gecko_gpio), gpio_odd, priority),
|
2020-12-10 10:20:42 -06:00
|
|
|
gpio_gecko_common_isr,
|
|
|
|
DEVICE_DT_GET(DT_INST(0, silabs_gecko_gpio)), 0);
|
2017-04-05 19:02:45 +02:00
|
|
|
|
|
|
|
irq_enable(GPIO_EVEN_IRQn);
|
|
|
|
irq_enable(GPIO_ODD_IRQn);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-03-23 00:47:15 +01:00
|
|
|
#define GPIO_PORT_INIT(idx) \
|
2020-07-14 17:02:00 +02:00
|
|
|
static int gpio_gecko_port##idx##_init(const struct device *dev); \
|
2019-10-28 10:54:35 +01:00
|
|
|
\
|
2020-03-23 00:47:15 +01:00
|
|
|
static const struct gpio_gecko_config gpio_gecko_port##idx##_config = { \
|
2019-12-11 10:15:53 -06:00
|
|
|
.common = { \
|
|
|
|
.port_pin_mask = (gpio_port_pins_t)(-1), \
|
|
|
|
}, \
|
2020-03-26 17:39:59 -05:00
|
|
|
.gpio_index = DT_INST_PROP(idx, peripheral_id), \
|
2019-10-28 10:54:35 +01:00
|
|
|
}; \
|
|
|
|
\
|
2020-03-23 00:47:15 +01:00
|
|
|
static struct gpio_gecko_data gpio_gecko_port##idx##_data; \
|
2019-10-28 10:54:35 +01:00
|
|
|
\
|
2020-12-10 10:20:42 -06:00
|
|
|
DEVICE_DT_INST_DEFINE(idx, \
|
2020-03-23 00:47:15 +01:00
|
|
|
gpio_gecko_port##idx##_init, \
|
2020-12-10 10:20:42 -06:00
|
|
|
device_pm_control_nop, \
|
2020-03-23 00:47:15 +01:00
|
|
|
&gpio_gecko_port##idx##_data, \
|
|
|
|
&gpio_gecko_port##idx##_config, \
|
2019-10-28 10:54:35 +01:00
|
|
|
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
|
|
|
|
&gpio_gecko_driver_api); \
|
|
|
|
\
|
2020-07-14 17:02:00 +02:00
|
|
|
static int gpio_gecko_port##idx##_init(const struct device *dev) \
|
2019-10-28 10:54:35 +01:00
|
|
|
{ \
|
|
|
|
gpio_gecko_add_port(&gpio_gecko_common_data, dev); \
|
|
|
|
return 0; \
|
|
|
|
}
|
2017-04-05 19:02:45 +02:00
|
|
|
|
2020-05-06 11:23:07 -07:00
|
|
|
DT_INST_FOREACH_STATUS_OKAY(GPIO_PORT_INIT)
|