1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2018, Linaro Ltd.
4 * Author: Georgi Djakov <georgi.djakov@linaro.org>
7 #ifndef __LINUX_INTERCONNECT_PROVIDER_H
8 #define __LINUX_INTERCONNECT_PROVIDER_H
10 #include <linux/interconnect.h>
12 #define icc_units_to_bps(bw) ((bw) * 1000ULL)
15 struct of_phandle_args;
18 * struct icc_onecell_data - driver data for onecell interconnect providers
20 * @num_nodes: number of nodes in this device
21 * @nodes: array of pointers to the nodes in this device
23 struct icc_onecell_data {
24 unsigned int num_nodes;
25 struct icc_node *nodes[];
28 struct icc_node *of_icc_xlate_onecell(struct of_phandle_args *spec,
32 * struct icc_provider - interconnect provider (controller) entity that might
33 * provide multiple interconnect controls
35 * @provider_list: list of the registered interconnect providers
36 * @nodes: internal list of the interconnect provider nodes
37 * @set: pointer to device specific set operation function
38 * @aggregate: pointer to device specific aggregate operation function
39 * @xlate: provider-specific callback for mapping nodes from phandle arguments
40 * @dev: the device this interconnect provider belongs to
41 * @users: count of active users
42 * @data: pointer to private data
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);
57 * struct icc_node - entity that is part of the interconnect topology
59 * @id: platform specific node id
60 * @name: node name used in debugfs
61 * @links: a list of targets pointing to where we can go next when traversing
62 * @num_links: number of links to other interconnect nodes
63 * @provider: points to the interconnect provider of this node
64 * @node_list: the list entry in the parent provider's "nodes" list
65 * @search_list: list used when walking the nodes graph
66 * @reverse: pointer to previous node when walking the nodes graph
67 * @is_traversed: flag that is used when walking the nodes graph
68 * @req_list: a list of QoS constraint requests associated with this node
69 * @avg_bw: aggregated value of average bandwidth requests from all consumers
70 * @peak_bw: aggregated value of peak bandwidth requests from all consumers
71 * @data: pointer to private data
76 struct icc_node **links;
79 struct icc_provider *provider;
80 struct list_head node_list;
81 struct list_head search_list;
82 struct icc_node *reverse;
84 struct hlist_head req_list;
90 #if IS_ENABLED(CONFIG_INTERCONNECT)
92 struct icc_node *icc_node_create(int id);
93 void icc_node_destroy(int id);
94 int icc_link_create(struct icc_node *node, const int dst_id);
95 int icc_link_destroy(struct icc_node *src, struct icc_node *dst);
96 void icc_node_add(struct icc_node *node, struct icc_provider *provider);
97 void icc_node_del(struct icc_node *node);
98 int icc_provider_add(struct icc_provider *provider);
99 int icc_provider_del(struct icc_provider *provider);
103 static inline struct icc_node *icc_node_create(int id)
105 return ERR_PTR(-ENOTSUPP);
108 void icc_node_destroy(int id)
112 static inline int icc_link_create(struct icc_node *node, const int dst_id)
117 int icc_link_destroy(struct icc_node *src, struct icc_node *dst)
122 void icc_node_add(struct icc_node *node, struct icc_provider *provider)
126 void icc_node_del(struct icc_node *node)
130 static inline int icc_provider_add(struct icc_provider *provider)
135 static inline int icc_provider_del(struct icc_provider *provider)
140 #endif /* CONFIG_INTERCONNECT */
142 #endif /* __LINUX_INTERCONNECT_PROVIDER_H */