Sound Open Firmware
Loading...
Searching...
No Matches
interrupt.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2022 Intel Corporation. All rights reserved.
4 *
5 * TODO: IMX support, today IRQ is supported via SOF xtos API.
6 */
7
8#ifndef __ZEPHYR_RTOS_INTERRUPT_H__
9#define __ZEPHYR_RTOS_INTERRUPT_H__
10
11/* TODO: to be removed completely when the following platforms are switched
12 * to native drivers.
13 */
14#if defined(CONFIG_AMD) && !defined(CONFIG_ZEPHYR_NATIVE_DRIVERS)
15/* imx currently has no IRQ driver in Zephyr so we force to xtos IRQ */
17#else
18
19#include <zephyr/device.h>
20#include <zephyr/kernel.h>
21#include <stdint.h>
22
23#include <sof/trace/trace.h>
24
25extern struct tr_ctx zephyr_tr;
26
27static inline int interrupt_register(uint32_t irq, void(*handler)(void *arg), void *arg)
28{
29#ifdef CONFIG_DYNAMIC_INTERRUPTS
30 return arch_irq_connect_dynamic(irq, 0, (void (*)(const void *))handler,
31 arg, 0);
32#else
33 LOG_MODULE_DECLARE(zephyr, CONFIG_SOF_LOG_LEVEL);
34 tr_err(&zephyr_tr, "Cannot register handler for IRQ %u: dynamic IRQs are disabled",
35 irq);
36 return -EOPNOTSUPP;
37#endif
38}
39
40/* unregister an IRQ handler - matches on IRQ number and data ptr */
41static inline void interrupt_unregister(uint32_t irq, const void *arg)
42{
43 /*
44 * There is no "unregister" (or "disconnect") for
45 * interrupts in Zephyr.
46 */
47 irq_disable(irq);
48}
49
50static inline int interrupt_get_irq(unsigned int irq, const char *cascade)
51{
52 return irq;
53}
54
55/* enable an interrupt source - IRQ needs mapped to Zephyr,
56 * arg is used to match.
57 */
58static inline uint32_t interrupt_enable(uint32_t irq, void *arg)
59{
60 irq_enable(irq);
61
62 return 0;
63}
64
65/* disable interrupt */
66static inline uint32_t interrupt_disable(uint32_t irq, void *arg)
67{
68 irq_disable(irq);
69
70 return 0;
71}
72
73/* TODO: using SOF versions */
74void interrupt_mask(uint32_t irq, unsigned int cpu);
75void interrupt_unmask(uint32_t irq, unsigned int cpu);
76void interrupt_clear_mask(uint32_t irq, uint32_t mask);
77
78/* handled by Zephyr */
79static inline void platform_interrupt_init(void) {}
80
81/* disables all IRQ sources on current core */
82#define irq_local_disable(flags) \
83 (flags = arch_irq_lock())
84
85/* re-enables IRQ sources on current core */
86#define irq_local_enable(flags) \
87 arch_irq_unlock(flags)
88
89#endif /* CONFIG_AMD && !CONFIG_ZEPHYR_NATIVE_DRIVERS */
90
91#endif /* __ZEPHYR_RTOS_INTERRUPT_H__ */
#define LOG_MODULE_DECLARE(ctx, level)
Definition trace.h:163
Definition trace.h:135
#define tr_err(ctx, fmt,...)
Definition trace-soflogger.h:337
void interrupt_unregister(uint32_t irq, const void *arg)
void platform_interrupt_init(void)
uint32_t interrupt_enable(uint32_t irq, void *arg)
void interrupt_mask(uint32_t irq, unsigned int cpu)
int interrupt_register(uint32_t irq, void(*handler)(void *arg), void *arg)
uint32_t interrupt_disable(uint32_t irq, void *arg)
void interrupt_unmask(uint32_t irq, unsigned int cpu)
int interrupt_get_irq(unsigned int irq, const char *cascade)
static void interrupt_clear_mask(int irq, uint32_t mask)
Definition interrupt.h:168
struct tr_ctx zephyr_tr