2018-03-02 16:14:16 -08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 Justin Watson
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2020-03-24 15:42:05 -05:00
|
|
|
#define DT_DRV_COMPAT atmel_sam_gpio
|
|
|
|
|
2018-03-02 16:14:16 -08:00
|
|
|
#include <errno.h>
|
|
|
|
#include <kernel.h>
|
|
|
|
#include <device.h>
|
|
|
|
#include <init.h>
|
|
|
|
#include <soc.h>
|
2019-06-25 15:53:52 -04:00
|
|
|
#include <drivers/gpio.h>
|
2018-03-02 16:14:16 -08:00
|
|
|
|
|
|
|
#include "gpio_utils.h"
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
typedef void (*config_func_t)(const struct device *dev);
|
2018-03-02 16:14:16 -08:00
|
|
|
|
|
|
|
struct gpio_sam_config {
|
2019-12-11 11:08:12 -06:00
|
|
|
/* gpio_driver_config needs to be first */
|
|
|
|
struct gpio_driver_config common;
|
2018-03-02 16:14:16 -08:00
|
|
|
Pio *regs;
|
|
|
|
config_func_t config_func;
|
2020-05-27 11:26:57 -05:00
|
|
|
uint32_t periph_id;
|
2018-03-02 16:14:16 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct gpio_sam_runtime {
|
2019-09-18 08:37:52 -05:00
|
|
|
/* gpio_driver_data needs to be first */
|
|
|
|
struct gpio_driver_data common;
|
2018-03-02 16:14:16 -08:00
|
|
|
sys_slist_t cb;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DEV_CFG(dev) \
|
2020-05-28 20:44:16 +02:00
|
|
|
((const struct gpio_sam_config * const)(dev)->config)
|
2019-01-29 02:39:43 +01:00
|
|
|
#define DEV_DATA(dev) \
|
2020-05-28 21:23:02 +02:00
|
|
|
((struct gpio_sam_runtime * const)(dev)->data)
|
2018-03-02 16:14:16 -08:00
|
|
|
|
2019-01-29 02:39:43 +01:00
|
|
|
#define GPIO_SAM_ALL_PINS 0xFFFFFFFF
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_sam_port_configure(const struct device *dev, uint32_t mask,
|
2020-01-30 12:12:39 -06:00
|
|
|
gpio_flags_t flags)
|
2018-03-02 16:14:16 -08:00
|
|
|
{
|
2019-01-29 02:39:43 +01:00
|
|
|
const struct gpio_sam_config * const cfg = DEV_CFG(dev);
|
|
|
|
Pio * const pio = cfg->regs;
|
|
|
|
|
|
|
|
if (flags & GPIO_SINGLE_ENDED) {
|
|
|
|
/* TODO: Add support for Open Source, Open Drain mode */
|
|
|
|
return -ENOTSUP;
|
2018-03-02 16:14:16 -08:00
|
|
|
}
|
|
|
|
|
2019-01-29 02:39:43 +01:00
|
|
|
if (!(flags & (GPIO_OUTPUT | GPIO_INPUT))) {
|
|
|
|
/* Neither input nor output mode is selected */
|
2018-09-03 20:23:33 +05:30
|
|
|
|
2019-01-29 02:39:43 +01:00
|
|
|
/* Disable the interrupt. */
|
|
|
|
pio->PIO_IDR = mask;
|
|
|
|
/* Disable pull-up. */
|
|
|
|
pio->PIO_PUDR = mask;
|
2020-02-07 22:59:55 -03:00
|
|
|
#if defined(CONFIG_SOC_SERIES_SAM4S) || \
|
|
|
|
defined(CONFIG_SOC_SERIES_SAM4E) || \
|
|
|
|
defined(CONFIG_SOC_SERIES_SAME70) || \
|
|
|
|
defined(CONFIG_SOC_SERIES_SAMV71)
|
2019-01-29 02:39:43 +01:00
|
|
|
/* Disable pull-down. */
|
|
|
|
pio->PIO_PPDDR = mask;
|
|
|
|
#endif
|
|
|
|
/* Let the PIO control the pin (instead of a peripheral). */
|
|
|
|
pio->PIO_PER = mask;
|
|
|
|
/* Disable output. */
|
|
|
|
pio->PIO_ODR = mask;
|
2018-03-02 16:14:16 -08:00
|
|
|
|
2019-01-29 02:39:43 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2018-03-02 16:14:16 -08:00
|
|
|
|
2019-01-29 02:39:43 +01:00
|
|
|
/* Setup the pin direcion. */
|
|
|
|
if (flags & GPIO_OUTPUT) {
|
|
|
|
if (flags & GPIO_OUTPUT_INIT_HIGH) {
|
|
|
|
/* Set the pin. */
|
|
|
|
pio->PIO_SODR = mask;
|
2018-03-02 16:14:16 -08:00
|
|
|
}
|
2019-01-29 02:39:43 +01:00
|
|
|
if (flags & GPIO_OUTPUT_INIT_LOW) {
|
|
|
|
/* Clear the pin. */
|
|
|
|
pio->PIO_CODR = mask;
|
2018-03-02 16:14:16 -08:00
|
|
|
}
|
2019-01-29 02:39:43 +01:00
|
|
|
/* Enable the output */
|
|
|
|
pio->PIO_OER = mask;
|
|
|
|
/* Enable direct control of output level via PIO_ODSR */
|
|
|
|
pio->PIO_OWER = mask;
|
2018-03-02 16:14:16 -08:00
|
|
|
} else {
|
2019-01-29 02:39:43 +01:00
|
|
|
/* Disable the output */
|
|
|
|
pio->PIO_ODR = mask;
|
|
|
|
}
|
2018-03-02 16:14:16 -08:00
|
|
|
|
2019-01-29 02:39:43 +01:00
|
|
|
/* Note: Input is always enabled. */
|
|
|
|
|
2019-10-30 05:35:59 -05:00
|
|
|
/* Setup selected Pull resistor.
|
|
|
|
*
|
|
|
|
* A pull cannot be enabled if the opposite pull is enabled.
|
|
|
|
* Clear both pulls, then enable the one we need.
|
|
|
|
*/
|
|
|
|
pio->PIO_PUDR = mask;
|
2020-02-07 22:59:55 -03:00
|
|
|
#if defined(CONFIG_SOC_SERIES_SAM4S) || \
|
|
|
|
defined(CONFIG_SOC_SERIES_SAM4E) || \
|
|
|
|
defined(CONFIG_SOC_SERIES_SAME70) || \
|
|
|
|
defined(CONFIG_SOC_SERIES_SAMV71)
|
2019-10-30 05:35:59 -05:00
|
|
|
pio->PIO_PPDDR = mask;
|
|
|
|
#endif
|
2019-01-29 02:39:43 +01:00
|
|
|
if (flags & GPIO_PULL_UP) {
|
2018-03-02 16:14:16 -08:00
|
|
|
/* Enable pull-up. */
|
|
|
|
pio->PIO_PUER = mask;
|
2019-11-17 20:41:22 -03:00
|
|
|
#if defined(CONFIG_SOC_SERIES_SAM4S) || \
|
2020-02-01 15:40:49 -03:00
|
|
|
defined(CONFIG_SOC_SERIES_SAM4E) || \
|
2019-11-17 20:41:22 -03:00
|
|
|
defined(CONFIG_SOC_SERIES_SAME70) || \
|
|
|
|
defined(CONFIG_SOC_SERIES_SAMV71)
|
2020-02-01 15:40:49 -03:00
|
|
|
|
2018-03-02 16:14:16 -08:00
|
|
|
/* Setup Pull-down resistor. */
|
2019-10-30 05:35:59 -05:00
|
|
|
} else if (flags & GPIO_PULL_DOWN) {
|
|
|
|
/* Enable pull-down. */
|
2018-03-02 16:14:16 -08:00
|
|
|
pio->PIO_PPDER = mask;
|
2019-09-10 08:17:31 +02:00
|
|
|
#endif
|
2019-10-30 05:35:59 -05:00
|
|
|
}
|
2018-03-02 16:14:16 -08:00
|
|
|
|
2019-09-10 08:17:31 +02:00
|
|
|
#if defined(CONFIG_SOC_SERIES_SAM3X)
|
2018-03-02 16:14:16 -08:00
|
|
|
/* Setup debounce. */
|
|
|
|
if (flags & GPIO_INT_DEBOUNCE) {
|
|
|
|
pio->PIO_DIFSR = mask;
|
|
|
|
} else {
|
|
|
|
pio->PIO_SCIFSR = mask;
|
|
|
|
}
|
2019-11-17 20:41:22 -03:00
|
|
|
#elif defined(CONFIG_SOC_SERIES_SAM4S) || \
|
2020-02-01 15:40:49 -03:00
|
|
|
defined(CONFIG_SOC_SERIES_SAM4E) || \
|
2019-11-17 20:41:22 -03:00
|
|
|
defined(CONFIG_SOC_SERIES_SAME70) || \
|
|
|
|
defined(CONFIG_SOC_SERIES_SAMV71)
|
2020-02-01 15:40:49 -03:00
|
|
|
|
2018-03-02 16:14:16 -08:00
|
|
|
/* Setup debounce. */
|
|
|
|
if (flags & GPIO_INT_DEBOUNCE) {
|
|
|
|
pio->PIO_IFSCER = mask;
|
|
|
|
} else {
|
|
|
|
pio->PIO_IFSCDR = mask;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Enable the PIO to control the pin (instead of a peripheral). */
|
|
|
|
pio->PIO_PER = mask;
|
|
|
|
|
2019-09-18 08:37:52 -05:00
|
|
|
return 0;
|
2018-03-02 16:14:16 -08:00
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_sam_config(const struct device *dev, gpio_pin_t pin,
|
2020-01-30 12:12:39 -06:00
|
|
|
gpio_flags_t flags)
|
2018-09-29 11:20:05 +08:00
|
|
|
{
|
2020-01-30 09:31:07 -06:00
|
|
|
return gpio_sam_port_configure(dev, BIT(pin), flags);
|
2018-09-29 11:20:05 +08:00
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_sam_port_get_raw(const struct device *dev, uint32_t *value)
|
2019-01-29 02:39:43 +01:00
|
|
|
{
|
|
|
|
const struct gpio_sam_config * const cfg = DEV_CFG(dev);
|
|
|
|
Pio * const pio = cfg->regs;
|
|
|
|
|
|
|
|
*value = pio->PIO_PDSR;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_sam_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 02:39:43 +01:00
|
|
|
{
|
|
|
|
const struct gpio_sam_config * const cfg = DEV_CFG(dev);
|
|
|
|
Pio * const pio = cfg->regs;
|
|
|
|
|
|
|
|
pio->PIO_ODSR = (pio->PIO_ODSR & ~mask) | (mask & value);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_sam_port_set_bits_raw(const struct device *dev, uint32_t mask)
|
2019-01-29 02:39:43 +01:00
|
|
|
{
|
|
|
|
const struct gpio_sam_config * const cfg = DEV_CFG(dev);
|
|
|
|
Pio * const pio = cfg->regs;
|
|
|
|
|
|
|
|
/* Set pins. */
|
|
|
|
pio->PIO_SODR = mask;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_sam_port_clear_bits_raw(const struct device *dev,
|
|
|
|
uint32_t mask)
|
2019-01-29 02:39:43 +01:00
|
|
|
{
|
|
|
|
const struct gpio_sam_config * const cfg = DEV_CFG(dev);
|
|
|
|
Pio * const pio = cfg->regs;
|
|
|
|
|
|
|
|
/* Clear pins. */
|
|
|
|
pio->PIO_CODR = mask;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_sam_port_toggle_bits(const struct device *dev, uint32_t mask)
|
2019-01-29 02:39:43 +01:00
|
|
|
{
|
|
|
|
const struct gpio_sam_config * const cfg = DEV_CFG(dev);
|
|
|
|
Pio * const pio = cfg->regs;
|
|
|
|
|
|
|
|
/* Toggle pins. */
|
|
|
|
pio->PIO_ODSR ^= mask;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_sam_port_interrupt_configure(const struct device *dev,
|
|
|
|
uint32_t mask,
|
2019-09-18 08:37:52 -05:00
|
|
|
enum gpio_int_mode mode,
|
|
|
|
enum gpio_int_trig trig)
|
2019-01-29 02:39:43 +01:00
|
|
|
{
|
|
|
|
const struct gpio_sam_config * const cfg = DEV_CFG(dev);
|
|
|
|
Pio * const pio = cfg->regs;
|
|
|
|
|
|
|
|
/* Disable the interrupt. */
|
|
|
|
pio->PIO_IDR = mask;
|
|
|
|
/* Disable additional interrupt modes. */
|
|
|
|
pio->PIO_AIMDR = mask;
|
|
|
|
|
2019-09-18 08:37:52 -05:00
|
|
|
if (trig != GPIO_INT_TRIG_BOTH) {
|
2019-01-29 02:39:43 +01:00
|
|
|
/* Enable additional interrupt modes to support single
|
|
|
|
* edge/level detection.
|
|
|
|
*/
|
|
|
|
pio->PIO_AIMER = mask;
|
|
|
|
|
2019-09-18 08:37:52 -05:00
|
|
|
if (mode == GPIO_INT_MODE_EDGE) {
|
2019-01-29 02:39:43 +01:00
|
|
|
pio->PIO_ESR = mask;
|
|
|
|
} else {
|
|
|
|
pio->PIO_LSR = mask;
|
|
|
|
}
|
|
|
|
|
2020-05-27 11:26:57 -05:00
|
|
|
uint32_t rising_edge;
|
2019-01-29 02:39:43 +01:00
|
|
|
|
2019-09-18 08:37:52 -05:00
|
|
|
if (trig == GPIO_INT_TRIG_HIGH) {
|
2019-01-29 02:39:43 +01:00
|
|
|
rising_edge = mask;
|
|
|
|
} else {
|
|
|
|
rising_edge = ~mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set to high-level or rising edge. */
|
|
|
|
pio->PIO_REHLSR = rising_edge & mask;
|
|
|
|
/* Set to low-level or falling edge. */
|
|
|
|
pio->PIO_FELLSR = ~rising_edge & mask;
|
|
|
|
}
|
|
|
|
|
2019-09-18 08:37:52 -05:00
|
|
|
if (mode != GPIO_INT_MODE_DISABLED) {
|
2019-01-29 02:39:43 +01:00
|
|
|
/* Clear any pending interrupts */
|
|
|
|
(void)pio->PIO_ISR;
|
|
|
|
/* Enable the interrupt. */
|
|
|
|
pio->PIO_IER = mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_sam_pin_interrupt_configure(const struct device *dev,
|
|
|
|
gpio_pin_t pin,
|
|
|
|
enum gpio_int_mode mode,
|
|
|
|
enum gpio_int_trig trig)
|
2019-01-29 02:39:43 +01:00
|
|
|
{
|
2019-09-18 08:37:52 -05:00
|
|
|
return gpio_sam_port_interrupt_configure(dev, BIT(pin), mode, trig);
|
2019-01-29 02:39:43 +01:00
|
|
|
}
|
|
|
|
|
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_sam_isr(const struct device *dev)
|
2018-03-02 16:14:16 -08:00
|
|
|
{
|
|
|
|
const struct gpio_sam_config * const cfg = DEV_CFG(dev);
|
2019-01-29 02:39:43 +01:00
|
|
|
Pio * const pio = cfg->regs;
|
2020-05-28 21:23:02 +02:00
|
|
|
struct gpio_sam_runtime *context = dev->data;
|
2020-05-27 11:26:57 -05:00
|
|
|
uint32_t int_stat;
|
2018-03-02 16:14:16 -08:00
|
|
|
|
|
|
|
int_stat = pio->PIO_ISR;
|
|
|
|
|
2019-03-12 15:15:42 -06:00
|
|
|
gpio_fire_callbacks(&context->cb, dev, int_stat);
|
2018-03-02 16:14:16 -08:00
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_sam_manage_callback(const struct device *port,
|
2018-03-02 16:14:16 -08:00
|
|
|
struct gpio_callback *callback,
|
|
|
|
bool set)
|
|
|
|
{
|
2020-05-28 21:23:02 +02:00
|
|
|
struct gpio_sam_runtime *context = port->data;
|
2018-03-02 16:14:16 -08:00
|
|
|
|
2019-03-12 15:15:42 -06:00
|
|
|
return gpio_manage_callback(&context->cb, callback, set);
|
2018-03-02 16:14:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct gpio_driver_api gpio_sam_api = {
|
2020-01-30 12:12:39 -06:00
|
|
|
.pin_configure = gpio_sam_config,
|
2019-01-29 02:39:43 +01:00
|
|
|
.port_get_raw = gpio_sam_port_get_raw,
|
|
|
|
.port_set_masked_raw = gpio_sam_port_set_masked_raw,
|
|
|
|
.port_set_bits_raw = gpio_sam_port_set_bits_raw,
|
|
|
|
.port_clear_bits_raw = gpio_sam_port_clear_bits_raw,
|
|
|
|
.port_toggle_bits = gpio_sam_port_toggle_bits,
|
|
|
|
.pin_interrupt_configure = gpio_sam_pin_interrupt_configure,
|
2018-03-02 16:14:16 -08:00
|
|
|
.manage_callback = gpio_sam_manage_callback,
|
|
|
|
};
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
int gpio_sam_init(const struct device *dev)
|
2018-03-02 16:14:16 -08:00
|
|
|
{
|
|
|
|
const struct gpio_sam_config * const cfg = DEV_CFG(dev);
|
|
|
|
|
|
|
|
/* The peripheral clock must be enabled for the interrupts to work. */
|
|
|
|
soc_pmc_peripheral_enable(cfg->periph_id);
|
|
|
|
|
|
|
|
cfg->config_func(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-21 17:58:19 -05:00
|
|
|
#define GPIO_SAM_INIT(n) \
|
2020-07-14 17:02:00 +02:00
|
|
|
static void port_##n##_sam_config_func(const struct device *dev); \
|
2020-04-21 17:58:19 -05:00
|
|
|
\
|
|
|
|
static const struct gpio_sam_config port_##n##_sam_config = { \
|
|
|
|
.common = { \
|
|
|
|
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(n),\
|
|
|
|
}, \
|
|
|
|
.regs = (Pio *)DT_INST_REG_ADDR(n), \
|
|
|
|
.periph_id = DT_INST_PROP(n, peripheral_id), \
|
|
|
|
.config_func = port_##n##_sam_config_func, \
|
|
|
|
}; \
|
|
|
|
\
|
|
|
|
static struct gpio_sam_runtime port_##n##_sam_runtime; \
|
|
|
|
\
|
2021-04-28 10:55:48 +02:00
|
|
|
DEVICE_DT_INST_DEFINE(n, gpio_sam_init, NULL, \
|
2020-12-10 10:20:42 -06:00
|
|
|
&port_##n##_sam_runtime, \
|
2021-12-04 13:00:59 -08:00
|
|
|
&port_##n##_sam_config, PRE_KERNEL_1, \
|
2021-11-05 16:58:21 -05:00
|
|
|
CONFIG_GPIO_INIT_PRIORITY, \
|
2020-04-21 17:58:19 -05:00
|
|
|
&gpio_sam_api); \
|
|
|
|
\
|
2020-07-14 17:02:00 +02:00
|
|
|
static void port_##n##_sam_config_func(const struct device *dev) \
|
2020-04-21 17:58:19 -05:00
|
|
|
{ \
|
|
|
|
IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), \
|
|
|
|
gpio_sam_isr, \
|
2020-12-10 10:20:42 -06:00
|
|
|
DEVICE_DT_INST_GET(n), 0); \
|
2020-04-21 17:58:19 -05:00
|
|
|
irq_enable(DT_INST_IRQN(n)); \
|
|
|
|
}
|
2018-03-02 16:14:16 -08:00
|
|
|
|
2020-05-06 11:23:07 -07:00
|
|
|
DT_INST_FOREACH_STATUS_OKAY(GPIO_SAM_INIT)
|