1 /*
2 * Copyright (c) 2021 BayLibre, SAS
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 /**
8 * @file
9 * @brief Driver for ARM Generic Interrupt Controller V3 Interrupt Translation Service
10 *
11 * The Generic Interrupt Controller (GIC) Interrupt Translation Service translates an input
12 * EventID from a device, identified by its DeviceID, determines a corresponding INTID for
13 * this input and the target Redistributor and, through this, the target PE for that INTID.
14 */
15
16 #ifndef ZEPHYR_INCLUDE_DRIVERS_GICV3_ITS_H_
17 #define ZEPHYR_INCLUDE_DRIVERS_GICV3_ITS_H_
18
19 typedef unsigned int (*its_api_alloc_intid_t)(const struct device *dev);
20 typedef int (*its_api_setup_deviceid_t)(const struct device *dev, uint32_t device_id,
21 unsigned int nites);
22 typedef int (*its_api_map_intid_t)(const struct device *dev, uint32_t device_id,
23 uint32_t event_id, unsigned int intid);
24 typedef int (*its_api_send_int_t)(const struct device *dev, uint32_t device_id, uint32_t event_id);
25 typedef uint32_t (*its_api_get_msi_addr_t)(const struct device *dev);
26
27 __subsystem struct its_driver_api {
28 its_api_alloc_intid_t alloc_intid;
29 its_api_setup_deviceid_t setup_deviceid;
30 its_api_map_intid_t map_intid;
31 its_api_send_int_t send_int;
32 its_api_get_msi_addr_t get_msi_addr;
33 };
34
its_alloc_intid(const struct device * dev)35 static inline int its_alloc_intid(const struct device *dev)
36 {
37 const struct its_driver_api *api =
38 (const struct its_driver_api *)dev->api;
39
40 return api->alloc_intid(dev);
41 }
42
its_setup_deviceid(const struct device * dev,uint32_t device_id,unsigned int nites)43 static inline int its_setup_deviceid(const struct device *dev, uint32_t device_id,
44 unsigned int nites)
45 {
46 const struct its_driver_api *api =
47 (const struct its_driver_api *)dev->api;
48
49 return api->setup_deviceid(dev, device_id, nites);
50 }
51
its_map_intid(const struct device * dev,uint32_t device_id,uint32_t event_id,unsigned int intid)52 static inline int its_map_intid(const struct device *dev, uint32_t device_id,
53 uint32_t event_id, unsigned int intid)
54 {
55 const struct its_driver_api *api =
56 (const struct its_driver_api *)dev->api;
57
58 return api->map_intid(dev, device_id, event_id, intid);
59 }
60
its_send_int(const struct device * dev,uint32_t device_id,uint32_t event_id)61 static inline int its_send_int(const struct device *dev, uint32_t device_id, uint32_t event_id)
62 {
63 const struct its_driver_api *api =
64 (const struct its_driver_api *)dev->api;
65
66 return api->send_int(dev, device_id, event_id);
67 }
68
its_get_msi_addr(const struct device * dev)69 static inline uint32_t its_get_msi_addr(const struct device *dev)
70 {
71 const struct its_driver_api *api =
72 (const struct its_driver_api *)dev->api;
73
74 return api->get_msi_addr(dev);
75 }
76
77 #endif /* ZEPHYR_INCLUDE_DRIVERS_GICV3_ITS_H_ */
78