2015-09-29 23:42:22 +08:00
|
|
|
/* shared_irq - Shared interrupt driver */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Intel corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-09-29 23:42:22 +08:00
|
|
|
*/
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#ifndef ZEPHYR_INCLUDE_SHARED_IRQ_H_
|
|
|
|
#define ZEPHYR_INCLUDE_SHARED_IRQ_H_
|
2015-09-29 23:42:22 +08:00
|
|
|
|
|
|
|
#include <autoconf.h>
|
|
|
|
|
2016-01-23 01:38:49 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-05-01 02:33:38 +08:00
|
|
|
typedef int (*isr_t)(const struct device *dev);
|
2015-09-29 23:42:22 +08:00
|
|
|
|
|
|
|
/* driver API definition */
|
2020-05-01 02:33:38 +08:00
|
|
|
typedef int (*shared_irq_register_t)(const struct device *dev,
|
|
|
|
isr_t isr_func,
|
|
|
|
const struct device *isr_dev);
|
|
|
|
typedef int (*shared_irq_enable_t)(const struct device *dev,
|
|
|
|
const struct device *isr_dev);
|
|
|
|
typedef int (*shared_irq_disable_t)(const struct device *dev,
|
|
|
|
const struct device *isr_dev);
|
2015-09-29 23:42:22 +08:00
|
|
|
|
|
|
|
struct shared_irq_driver_api {
|
|
|
|
shared_irq_register_t isr_register;
|
|
|
|
shared_irq_enable_t enable;
|
|
|
|
shared_irq_disable_t disable;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Register a device ISR
|
|
|
|
* @param dev Pointer to device structure for SHARED_IRQ driver instance.
|
|
|
|
* @param isr_func Pointer to the ISR function for the device.
|
|
|
|
* @param isr_dev Pointer to the device that will service the interrupt.
|
|
|
|
*/
|
2020-05-01 02:33:38 +08:00
|
|
|
static inline int shared_irq_isr_register(const struct device *dev,
|
|
|
|
isr_t isr_func,
|
|
|
|
const struct device *isr_dev)
|
2015-09-29 23:42:22 +08:00
|
|
|
{
|
2019-12-16 18:56:17 +08:00
|
|
|
const struct shared_irq_driver_api *api =
|
2020-05-29 03:23:02 +08:00
|
|
|
(const struct shared_irq_driver_api *)dev->api;
|
2015-09-29 23:42:22 +08:00
|
|
|
|
|
|
|
return api->isr_register(dev, isr_func, isr_dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Enable ISR for device
|
|
|
|
* @param dev Pointer to device structure for SHARED_IRQ driver instance.
|
|
|
|
* @param isr_dev Pointer to the device that will service the interrupt.
|
|
|
|
*/
|
2020-05-01 02:33:38 +08:00
|
|
|
static inline int shared_irq_enable(const struct device *dev,
|
|
|
|
const struct device *isr_dev)
|
2015-09-29 23:42:22 +08:00
|
|
|
{
|
2019-12-16 18:56:17 +08:00
|
|
|
const struct shared_irq_driver_api *api =
|
2020-05-29 03:23:02 +08:00
|
|
|
(const struct shared_irq_driver_api *)dev->api;
|
2015-09-29 23:42:22 +08:00
|
|
|
|
|
|
|
return api->enable(dev, isr_dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable ISR for device
|
|
|
|
* @param dev Pointer to device structure for SHARED_IRQ driver instance.
|
|
|
|
* @param isr_dev Pointer to the device that will service the interrupt.
|
|
|
|
*/
|
2020-05-01 02:33:38 +08:00
|
|
|
static inline int shared_irq_disable(const struct device *dev,
|
|
|
|
const struct device *isr_dev)
|
2015-09-29 23:42:22 +08:00
|
|
|
{
|
2019-12-16 18:56:17 +08:00
|
|
|
const struct shared_irq_driver_api *api =
|
2020-05-29 03:23:02 +08:00
|
|
|
(const struct shared_irq_driver_api *)dev->api;
|
2015-09-29 23:42:22 +08:00
|
|
|
|
|
|
|
return api->disable(dev, isr_dev);
|
|
|
|
}
|
|
|
|
|
2016-01-23 01:38:49 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#endif /* ZEPHYR_INCLUDE_SHARED_IRQ_H_ */
|