1
2
3
4
5
6
7#ifndef __LINUX_INTERCONNECT_PROVIDER_H
8#define __LINUX_INTERCONNECT_PROVIDER_H
9
10#include <linux/interconnect.h>
11
12#define icc_units_to_bps(bw) ((bw) * 1000ULL)
13
14struct icc_node;
15struct of_phandle_args;
16
17
18
19
20
21
22
23struct icc_node_data {
24 struct icc_node *node;
25 u32 tag;
26};
27
28
29
30
31
32
33
34struct icc_onecell_data {
35 unsigned int num_nodes;
36 struct icc_node *nodes[];
37};
38
39struct icc_node *of_icc_xlate_onecell(struct of_phandle_args *spec,
40 void *data);
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60struct icc_provider {
61 struct list_head provider_list;
62 struct list_head nodes;
63 int (*set)(struct icc_node *src, struct icc_node *dst);
64 int (*aggregate)(struct icc_node *node, u32 tag, u32 avg_bw,
65 u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
66 void (*pre_aggregate)(struct icc_node *node);
67 int (*get_bw)(struct icc_node *node, u32 *avg, u32 *peak);
68 struct icc_node* (*xlate)(struct of_phandle_args *spec, void *data);
69 struct icc_node_data* (*xlate_extended)(struct of_phandle_args *spec, void *data);
70 struct device *dev;
71 int users;
72 bool inter_set;
73 void *data;
74};
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95struct icc_node {
96 int id;
97 const char *name;
98 struct icc_node **links;
99 size_t num_links;
100
101 struct icc_provider *provider;
102 struct list_head node_list;
103 struct list_head search_list;
104 struct icc_node *reverse;
105 u8 is_traversed:1;
106 struct hlist_head req_list;
107 u32 avg_bw;
108 u32 peak_bw;
109 u32 init_avg;
110 u32 init_peak;
111 void *data;
112};
113
114#if IS_ENABLED(CONFIG_INTERCONNECT)
115
116int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
117 u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
118struct icc_node *icc_node_create(int id);
119void icc_node_destroy(int id);
120int icc_link_create(struct icc_node *node, const int dst_id);
121int icc_link_destroy(struct icc_node *src, struct icc_node *dst);
122void icc_node_add(struct icc_node *node, struct icc_provider *provider);
123void icc_node_del(struct icc_node *node);
124int icc_nodes_remove(struct icc_provider *provider);
125int icc_provider_add(struct icc_provider *provider);
126int icc_provider_del(struct icc_provider *provider);
127struct icc_node_data *of_icc_get_from_provider(struct of_phandle_args *spec);
128void icc_sync_state(struct device *dev);
129
130#else
131
132static inline int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
133 u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
134{
135 return -ENOTSUPP;
136}
137
138static inline struct icc_node *icc_node_create(int id)
139{
140 return ERR_PTR(-ENOTSUPP);
141}
142
143static inline void icc_node_destroy(int id)
144{
145}
146
147static inline int icc_link_create(struct icc_node *node, const int dst_id)
148{
149 return -ENOTSUPP;
150}
151
152static inline int icc_link_destroy(struct icc_node *src, struct icc_node *dst)
153{
154 return -ENOTSUPP;
155}
156
157static inline void icc_node_add(struct icc_node *node, struct icc_provider *provider)
158{
159}
160
161static inline void icc_node_del(struct icc_node *node)
162{
163}
164
165static inline int icc_nodes_remove(struct icc_provider *provider)
166{
167 return -ENOTSUPP;
168}
169
170static inline int icc_provider_add(struct icc_provider *provider)
171{
172 return -ENOTSUPP;
173}
174
175static inline int icc_provider_del(struct icc_provider *provider)
176{
177 return -ENOTSUPP;
178}
179
180static inline struct icc_node_data *of_icc_get_from_provider(struct of_phandle_args *spec)
181{
182 return ERR_PTR(-ENOTSUPP);
183}
184
185#endif
186
187#endif
188