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
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SHIRQ_H_
|
|
|
|
#define _SHIRQ_H_
|
|
|
|
|
|
|
|
#include <autoconf.h>
|
|
|
|
|
2016-01-23 01:38:49 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-09-29 23:42:22 +08:00
|
|
|
typedef int (*isr_t)(struct device *dev);
|
|
|
|
|
|
|
|
/* driver API definition */
|
|
|
|
typedef int (*shared_irq_register_t)(struct device *dev,
|
|
|
|
isr_t isr_func,
|
|
|
|
struct device *isr_dev);
|
|
|
|
typedef int (*shared_irq_enable_t)(struct device *dev, struct device *isr_dev);
|
|
|
|
typedef int (*shared_irq_disable_t)(struct device *dev, struct device *isr_dev);
|
|
|
|
|
|
|
|
struct shared_irq_driver_api {
|
|
|
|
shared_irq_register_t isr_register;
|
|
|
|
shared_irq_enable_t enable;
|
|
|
|
shared_irq_disable_t disable;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern int shared_irq_initialize(struct device *port);
|
|
|
|
|
2016-01-08 16:46:14 +08:00
|
|
|
typedef void (*shared_irq_config_irq_t)(void);
|
2015-09-29 23:42:22 +08:00
|
|
|
|
|
|
|
struct shared_irq_config {
|
|
|
|
uint32_t irq_num;
|
|
|
|
shared_irq_config_irq_t config;
|
|
|
|
uint32_t client_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct shared_irq_client {
|
|
|
|
struct device *isr_dev;
|
|
|
|
isr_t isr_func;
|
|
|
|
uint32_t enabled;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct shared_irq_runtime {
|
|
|
|
struct shared_irq_client client[CONFIG_SHARED_IRQ_NUM_CLIENTS];
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
static inline int shared_irq_isr_register(struct device *dev, isr_t isr_func,
|
|
|
|
struct device *isr_dev)
|
|
|
|
{
|
2016-10-22 17:00:14 +08:00
|
|
|
const struct shared_irq_driver_api *api = dev->driver_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.
|
|
|
|
*/
|
|
|
|
static inline int shared_irq_enable(struct device *dev, struct device *isr_dev)
|
|
|
|
{
|
2016-10-22 17:00:14 +08:00
|
|
|
const struct shared_irq_driver_api *api = dev->driver_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.
|
|
|
|
*/
|
|
|
|
static inline int shared_irq_disable(struct device *dev, struct device *isr_dev)
|
|
|
|
{
|
2016-10-22 17:00:14 +08:00
|
|
|
const struct shared_irq_driver_api *api = dev->driver_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
|
|
|
|
|
2015-09-29 23:42:22 +08:00
|
|
|
#endif /* _SHARED_IRQ_H_ */
|