blob: 835c5503ba36d2c55c9a136c54b01355a3a2d0cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef ZEPHYR_SHIM_INCLUDE_GPIO_GPIO_INT_H_
#define ZEPHYR_SHIM_INCLUDE_GPIO_GPIO_INT_H_
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
/*
* Zephyr based interrupt handling.
* Uses device tree to configure the interrupt handling.
*/
/*
* Creates an internal name for the interrupt config block.
*/
#define GPIO_INT_FROM_NODE(id) DT_CAT(gpio_interrupt_, id)
/*
* Maps nodelabel of interrupt node to internal configuration block.
*/
#define GPIO_INT_FROM_NODELABEL(lbl) (GPIO_INT_FROM_NODE(DT_NODELABEL(lbl)))
/*
* Unique enum name for the interrupt.
*/
#define GPIO_INT_ENUM(id) DT_CAT(INT_ENUM_, id)
/*
* Create an enum list of the interrupts
*/
enum gpio_interrupts {
#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_gpio_interrupts)
DT_FOREACH_CHILD_SEP(
DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_gpio_interrupts),
GPIO_INT_ENUM, (, )),
#endif
GPIO_INT_COUNT
};
/*
* Forward reference to avoiding exposing internal structure
* defined in gpio_int.c
*/
struct gpio_int_config;
/*
* Enable the interrupt.
*
* Interrupts are not automatically enabled, so
* each interrupt will need a call to activate the interrupt e.g
*
* ... // set up device
* gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(my_interrupt_node));
*/
int gpio_enable_dt_interrupt(const struct gpio_int_config *const ic);
/*
* Disable the interrupt.
*/
int gpio_disable_dt_interrupt(const struct gpio_int_config *const ic);
/*
* Get the interrupt config for this interrupt.
*/
const struct gpio_int_config *
gpio_interrupt_get_config(enum gpio_interrupts intr);
/*
* Declare interrupt configuration data structures.
*/
#define GPIO_INT_DECLARE(id) \
extern const struct gpio_int_config *const GPIO_INT_FROM_NODE(id);
#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_gpio_interrupts)
DT_FOREACH_CHILD(DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_gpio_interrupts),
GPIO_INT_DECLARE)
#endif
#undef GPIO_INT_DECLARE
#undef GPIO_INT_DECLARE_NODE
#endif /* ZEPHYR_SHIM_INCLUDE_GPIO_GPIO_INT_H_ */
|