-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drivers: intc: Add initial intc headers
Add intc headers for creating direct IRQ macros Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
- Loading branch information
1 parent
0bc7691
commit 3cc749e
Showing
1 changed file
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* Copyright (c) 2023 Bjarki Arge Andreasen | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef ZEPHYR_INCLUDE_DRIVERS_INTC_DIRECT_IRQ_HANDLER_H_ | ||
#define ZEPHYR_INCLUDE_DRIVERS_INTC_DIRECT_IRQ_HANDLER_H_ | ||
|
||
#include <zephyr/drivers/intc.h> | ||
|
||
#define INTC_DIRECT_IRQ_HANDLER_FLAG_PM BIT(0) | ||
#define INTC_DIRECT_IRQ_HANDLER_FLAG_SWAP BIT(1) | ||
|
||
/** | ||
* brief Get the interrupt controller's architecture | ||
* | ||
* @param node_id Interrupt controller's devicetree node identifier | ||
* | ||
* Expands to ARCH_<arch> | ||
*/ | ||
#define INTC_DT_ARCH(node_id) \ | ||
DT_STRING_UPPER_TOKEN_BY_IDX(node_id, compatible, 0) | ||
|
||
/** | ||
* @brief Expands to interrupt controller's arch devicetree namespace | ||
* | ||
* @param node_id Interrupt controller's devicetree node identifier | ||
* @param name Name to namespace | ||
* | ||
* Expands to INTC_DT_<arch>_<name> | ||
*/ | ||
#define INTC_DT_ARCH_NAMESPACE(node_id, name) \ | ||
UTIL_CAT(UTIL_CAT(UTIL_CAT(INTC_DT_, INTC_DT_ARCH(node_id)), _), name) | ||
|
||
/** | ||
* @brief Expands to interrupt controller's | ||
* | ||
* @param node_id Interrupt controller's devicetree node identifier | ||
* @param name Name to namespace | ||
* | ||
* Expands to INTC_DT_<arch>_<name> | ||
*/ | ||
#define INTC_DT_DIRECT_IRQ_HANDLER_NAME(node_id) \ | ||
INTC_DT_ARCH_NAMESPACE(node_id, DIRECT_IRQ_HANDLER_DEFINE) | ||
|
||
/** | ||
* @brief Define direct interrupt request handler by node identifier | ||
* | ||
* @param node_id Interrupt generating device's node identifier | ||
*/ | ||
#define INTC_DT_DIRECT_IRQ_HANDLER_DEFINE(node_id) \ | ||
INTC_DT_DIRECT_IRQ_HANDLER_NAME(DT_IRQ_INTC(node_id))( \ | ||
INTC_DT_IRQ_HANDLER_NAME( \ | ||
DT_IRQ_INTC(node_id), \ | ||
DT_IRQ(node_id, irq) \ | ||
) \ | ||
) | ||
|
||
/** | ||
* @brief Define direct interrupt request handler by node identifier and idx | ||
* | ||
* @param node_id Interrupt generating device's node identifier | ||
* @param idx Index of the IRQ within interrupt generating device | ||
* | ||
* Expands to INTC_DT_<arch>_IRQ_HANDLER_DEFINE(node_id, irq) | ||
*/ | ||
#define INTC_DT_DIRECT_IRQ_HANDLER_DEFINE_BY_IDX(node_id, idx) \ | ||
INTC_DT_DIRECT_IRQ_HANDLER_NAME(DT_IRQ_INTC_BY_IDX(node_id, idx))( \ | ||
INTC_DT_IRQ_HANDLER_NAME( \ | ||
DT_IRQ_INTC_BY_IDX(node_id, idx), \ | ||
DT_IRQ_BY_IDX(node_id, idx, irq) \ | ||
) \ | ||
) | ||
|
||
/** | ||
* @brief Define direct interrupt request handler by node identifier and idx | ||
* | ||
* @param node_id Interrupt generating device's node identifier | ||
* @param idx Index of the IRQ within interrupt generating device | ||
* | ||
* Expands to INTC_DT_<arch>_IRQ_HANDLER_DEFINE(node_id, irq) | ||
*/ | ||
#define INTC_DT_DIRECT_IRQ_HANDLER_DEFINE_BY_NAME(node_id, name) \ | ||
INTC_DT_DIRECT_IRQ_HANDLER_NAME(DT_IRQ_INTC_BY_NAME(node_id, name))( \ | ||
INTC_DT_IRQ_HANDLER_NAME( \ | ||
DT_IRQ_INTC_BY_NAME(node_id, name), \ | ||
DT_IRQ_BY_NAME(node_id, name, irq) \ | ||
) \ | ||
) | ||
|
||
#define INTC_DT_INST_DIRECT_IRQ_HANDLER_DEFINE(inst) \ | ||
INTC_DT_DIRECT_IRQ_HANDLER_DEFINE(DT_DRV_INST(inst)) | ||
|
||
#define INTC_DT_INST_DIRECT_IRQ_HANDLER_DEFINE_BY_IDX(inst, idx) \ | ||
INTC_DT_DIRECT_IRQ_HANDLER_DEFINE_BY_IDX(DT_DRV_INST(inst), idx) | ||
|
||
#define INTC_DT_INST_DIRECT_IRQ_HANDLER_DEFINE_BY_NAME(inst, name) \ | ||
INTC_DT_DIRECT_IRQ_HANDLER_DEFINE_BY_NAME(DT_DRV_INST(inst), name) | ||
|
||
/** Architecture specific implementations of direct IRQ handlers are included here */ | ||
|
||
#endif /* ZEPHYR_INCLUDE_DRIVERS_INTC_DIRECT_IRQ_HANDLER_H_ */ |