interrupt_controller: Add GICv3 ITS API

Add driver API for the Interrupt Translation Service GICv3 module.

The Interrupt Translation Service (ITS) translates an input EventID
from a device, identified by its DeviceID, and determines the
corresponding INTID for this input and target Redistributor + target
PE for that INTID to be delivered as LPI interrupt.

The API permits :
- allocating a new unique LPI interrupt number
- initializing support for a new DeviceID and the required EventIDs
- mapping a DeviceID + EventID to a LPI interrupt number
- triggering an LPI with a DeviceID + EventID

This API will be used by the PCIe MSI/MSI-X logic in another patchset.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
This commit is contained in:
Neil Armstrong 2021-08-06 16:11:05 +02:00 committed by Christopher Friedt
commit 340a8697d2

View file

@ -0,0 +1,67 @@
/*
* Copyright (c) 2021 BayLibre, SAS
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief Driver for ARM Generic Interrupt Controller V3 Interrupt Translation Service
*
* The Generic Interrupt Controller (GIC) Interrupt Translation Service translates an input
* EventID from a device, identified by its DeviceID, determines a corresponding INTID for
* this input and the target Redistributor and, through this, the target PE for that INTID.
*/
#ifndef ZEPHYR_INCLUDE_DRIVERS_GICV3_ITS_H_
#define ZEPHYR_INCLUDE_DRIVERS_GICV3_ITS_H_
typedef unsigned int (*its_api_alloc_intid_t)(const struct device *dev);
typedef int (*its_api_setup_deviceid_t)(const struct device *dev, uint32_t device_id,
unsigned int nites);
typedef int (*its_api_map_intid_t)(const struct device *dev, uint32_t device_id,
uint32_t event_id, unsigned int intid);
typedef int (*its_api_send_int_t)(const struct device *dev, uint32_t device_id, uint32_t event_id);
__subsystem struct its_driver_api {
its_api_alloc_intid_t alloc_intid;
its_api_setup_deviceid_t setup_deviceid;
its_api_map_intid_t map_intid;
its_api_send_int_t send_int;
};
static inline int its_alloc_intid(const struct device *dev)
{
const struct its_driver_api *api =
(const struct its_driver_api *)dev->api;
return api->alloc_intid(dev);
}
static inline int its_setup_deviceid(const struct device *dev, uint32_t device_id,
unsigned int nites)
{
const struct its_driver_api *api =
(const struct its_driver_api *)dev->api;
return api->setup_deviceid(dev, device_id, nites);
}
static inline int its_map_intid(const struct device *dev, uint32_t device_id,
uint32_t event_id, unsigned int intid)
{
const struct its_driver_api *api =
(const struct its_driver_api *)dev->api;
return api->map_intid(dev, device_id, event_id, intid);
}
static inline int its_send_int(const struct device *dev, uint32_t device_id, uint32_t event_id)
{
const struct its_driver_api *api =
(const struct its_driver_api *)dev->api;
return api->send_int(dev, device_id, event_id);
}
#endif /* ZEPHYR_INCLUDE_DRIVERS_GICV3_ITS_H_ */