2018-06-20 16:30:55 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef COMMON_IRQ_H
|
|
|
|
#define COMMON_IRQ_H
|
|
|
|
|
2018-08-16 20:21:11 +08:00
|
|
|
#define IRQF_NONE (0U)
|
|
|
|
#define IRQF_LEVEL (1U << 1U) /* 1: level trigger; 0: edge trigger */
|
|
|
|
#define IRQF_PT (1U << 2U) /* 1: for passthrough dev */
|
|
|
|
|
2018-06-20 16:30:55 +08:00
|
|
|
|
2018-08-22 11:12:37 +08:00
|
|
|
typedef void (*irq_action_t)(uint32_t irq, void *priv_data);
|
2018-06-20 16:30:55 +08:00
|
|
|
|
2018-10-31 15:12:33 +08:00
|
|
|
/**
|
|
|
|
* @brief Interrupt descriptor
|
|
|
|
*
|
|
|
|
* Any field change in below required lock protection with irqsave
|
|
|
|
*/
|
2018-06-20 16:30:55 +08:00
|
|
|
struct irq_desc {
|
2018-10-31 15:12:33 +08:00
|
|
|
uint32_t irq; /**< index to irq_desc_base */
|
|
|
|
uint32_t vector; /**< assigned vector */
|
2018-08-07 14:33:02 +08:00
|
|
|
|
2018-10-31 15:12:33 +08:00
|
|
|
irq_action_t action; /**< callback registered from component */
|
|
|
|
void *priv_data; /**< irq_action private data */
|
|
|
|
uint32_t flags; /**< flags for trigger mode/ptdev */
|
2018-08-07 14:33:02 +08:00
|
|
|
|
2018-08-16 15:05:46 +08:00
|
|
|
spinlock_t lock;
|
2018-10-23 07:39:41 +08:00
|
|
|
#ifdef PROFILING_ON
|
|
|
|
uint64_t ctx_rip;
|
|
|
|
uint64_t ctx_rflags;
|
|
|
|
uint64_t ctx_cs;
|
|
|
|
#endif
|
2018-06-20 16:30:55 +08:00
|
|
|
};
|
|
|
|
|
2018-10-31 15:12:33 +08:00
|
|
|
/**
|
|
|
|
* @brief Request an interrupt
|
|
|
|
*
|
|
|
|
* Request interrupt num if not specified, and register irq action for the
|
|
|
|
* specified/allocated irq.
|
|
|
|
*
|
|
|
|
* @param[in] req_irq irq_num to request, if IRQ_INVALID, a free irq
|
|
|
|
* number will be allocated
|
|
|
|
* @param[in] action_fn Function to be called when the IRQ occurs
|
|
|
|
* @param[in] priv_data Private data for action function.
|
|
|
|
* @param[in] flags Interrupt type flags, including:
|
|
|
|
* IRQF_NONE;
|
|
|
|
* IRQF_LEVEL - 1: level trigger; 0: edge trigger;
|
|
|
|
* IRQF_PT - 1: for passthrough dev
|
|
|
|
*
|
2018-11-21 17:28:28 +08:00
|
|
|
* @retval >=0 on success
|
|
|
|
* @retval IRQ_INVALID on failure
|
2018-10-31 15:12:33 +08:00
|
|
|
*/
|
2018-08-20 15:32:14 +08:00
|
|
|
int32_t request_irq(uint32_t req_irq, irq_action_t action_fn, void *priv_data,
|
|
|
|
uint32_t flags);
|
2018-08-07 14:33:02 +08:00
|
|
|
|
2018-10-31 15:12:33 +08:00
|
|
|
/**
|
|
|
|
* @brief Free an interrupt
|
|
|
|
*
|
|
|
|
* Free irq num and unregister the irq action.
|
|
|
|
*
|
|
|
|
* @param[in] irq irq_num to be freed
|
|
|
|
*/
|
2018-08-05 23:29:02 +08:00
|
|
|
void free_irq(uint32_t irq);
|
2018-06-20 16:30:55 +08:00
|
|
|
|
2018-10-31 15:12:33 +08:00
|
|
|
/**
|
|
|
|
* @brief Set interrupt trigger mode
|
|
|
|
*
|
|
|
|
* Set the irq trigger mode: edge-triggered or level-triggered
|
|
|
|
*
|
|
|
|
* @param[in] irq irq_num of interupt to be set
|
|
|
|
* @param[in] is_level_triggered Trigger mode to set
|
|
|
|
*/
|
|
|
|
void set_irq_trigger_mode(uint32_t irq, bool is_level_triggered);
|
2018-06-20 16:30:55 +08:00
|
|
|
#endif /* COMMON_IRQ_H */
|