blob: 1495ec1749898239d30d7d3b08b40accf9837b87 [file] [log] [blame]
Rajavardhan Gundi74016bb2017-10-11 22:36:20 +05301/*
2 * Copyright (c) 2017 Intel corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/**
8 * @file
9 * @brief Public interface for configuring interrupts
10 */
11#ifndef _IRQ_NEXTLEVEL_H_
12#define _IRQ_NEXTLEVEL_H_
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/**
19 * @cond INTERNAL_HIDDEN
20 *
21 * These are for internal use only, so skip these in
22 * public documentation.
23 */
24typedef void (*irq_next_level_func_t)(struct device *dev, unsigned int irq);
25typedef unsigned int (*irq_next_level_get_state_t)(struct device *dev);
26
27struct irq_next_level_api {
28 irq_next_level_func_t intr_enable;
29 irq_next_level_func_t intr_disable;
30 irq_next_level_get_state_t intr_get_state;
31};
32/**
33 * @endcond
34 */
35
36/**
37 * @brief Enable an IRQ in the next level.
38 *
39 * This routine enables interrupts present in the interrupt controller.
40 *
41 * @param dev Pointer to the device structure for the driver instance.
42 * @param irq IRQ to be enabled.
43 *
44 * @return N/A
45 */
46static inline void irq_enable_next_level(struct device *dev, u32_t irq)
47{
48 const struct irq_next_level_api *api = dev->driver_api;
49
50 api->intr_enable(dev, irq);
51}
52
53/**
54 * @brief Disable an IRQ in the next level.
55 *
56 * This routine disables interrupts present in the interrupt controller.
57 *
58 * @param dev Pointer to the device structure for the driver instance.
59 * @param irq IRQ to be disabled.
60 *
61 * @return N/A
62 */
63static inline void irq_disable_next_level(struct device *dev, u32_t irq)
64{
65 const struct irq_next_level_api *api = dev->driver_api;
66
67 api->intr_disable(dev, irq);
68}
69
70/**
71 * @brief Get IRQ enable state.
72 *
73 * This routine indicates if any interrupts are enabled in the interrupt
74 * controller.
75 *
76 * @param dev Pointer to the device structure for the driver instance.
77 *
78 * @return interrupt enable state, true or false
79 */
80static inline unsigned int irq_is_enabled_next_level(struct device *dev)
81{
82 const struct irq_next_level_api *api = dev->driver_api;
83
84 return api->intr_get_state(dev);
85}
86
87/**
88 * @}
89 */
90
91#ifdef __cplusplus
92}
93#endif
94
95#endif /* _IRQ_NEXTLEVEL_H_ */