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_onecell_data {
24 unsigned int num_nodes;
25 struct icc_node *nodes[];
26};
27
28struct icc_node *of_icc_xlate_onecell(struct of_phandle_args *spec,
29 void *data);
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44struct icc_provider {
45 struct list_head provider_list;
46 struct list_head nodes;
47 int (*set)(struct icc_node *src, struct icc_node *dst);
48 int (*aggregate)(struct icc_node *node, u32 avg_bw, u32 peak_bw,
49 u32 *agg_avg, u32 *agg_peak);
50 struct icc_node* (*xlate)(struct of_phandle_args *spec, void *data);
51 struct device *dev;
52 int users;
53 void *data;
54};
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73struct icc_node {
74 int id;
75 const char *name;
76 struct icc_node **links;
77 size_t num_links;
78
79 struct icc_provider *provider;
80 struct list_head node_list;
81 struct list_head search_list;
82 struct icc_node *reverse;
83 u8 is_traversed:1;
84 struct hlist_head req_list;
85 u32 avg_bw;
86 u32 peak_bw;
87 void *data;
88};
89
90#if IS_ENABLED(CONFIG_INTERCONNECT)
91
92struct icc_node *icc_node_create(int id);
93void icc_node_destroy(int id);
94int icc_link_create(struct icc_node *node, const int dst_id);
95int icc_link_destroy(struct icc_node *src, struct icc_node *dst);
96void icc_node_add(struct icc_node *node, struct icc_provider *provider);
97void icc_node_del(struct icc_node *node);
98int icc_provider_add(struct icc_provider *provider);
99int icc_provider_del(struct icc_provider *provider);
100
101#else
102
103static inline struct icc_node *icc_node_create(int id)
104{
105 return ERR_PTR(-ENOTSUPP);
106}
107
108void icc_node_destroy(int id)
109{
110}
111
112static inline int icc_link_create(struct icc_node *node, const int dst_id)
113{
114 return -ENOTSUPP;
115}
116
117int icc_link_destroy(struct icc_node *src, struct icc_node *dst)
118{
119 return -ENOTSUPP;
120}
121
122void icc_node_add(struct icc_node *node, struct icc_provider *provider)
123{
124}
125
126void icc_node_del(struct icc_node *node)
127{
128}
129
130static inline int icc_provider_add(struct icc_provider *provider)
131{
132 return -ENOTSUPP;
133}
134
135static inline int icc_provider_del(struct icc_provider *provider)
136{
137 return -ENOTSUPP;
138}
139
140#endif
141
142#endif
143