xref: /linux/include/linux/interconnect.h (revision 11f1ceca7031deefc1a34236ab7b94360016b71d)
1*11f1cecaSGeorgi Djakov /* SPDX-License-Identifier: GPL-2.0 */
2*11f1cecaSGeorgi Djakov /*
3*11f1cecaSGeorgi Djakov  * Copyright (c) 2018-2019, Linaro Ltd.
4*11f1cecaSGeorgi Djakov  * Author: Georgi Djakov <georgi.djakov@linaro.org>
5*11f1cecaSGeorgi Djakov  */
6*11f1cecaSGeorgi Djakov 
7*11f1cecaSGeorgi Djakov #ifndef __LINUX_INTERCONNECT_H
8*11f1cecaSGeorgi Djakov #define __LINUX_INTERCONNECT_H
9*11f1cecaSGeorgi Djakov 
10*11f1cecaSGeorgi Djakov #include <linux/mutex.h>
11*11f1cecaSGeorgi Djakov #include <linux/types.h>
12*11f1cecaSGeorgi Djakov 
13*11f1cecaSGeorgi Djakov /* macros for converting to icc units */
14*11f1cecaSGeorgi Djakov #define Bps_to_icc(x)	((x) / 1000)
15*11f1cecaSGeorgi Djakov #define kBps_to_icc(x)	(x)
16*11f1cecaSGeorgi Djakov #define MBps_to_icc(x)	((x) * 1000)
17*11f1cecaSGeorgi Djakov #define GBps_to_icc(x)	((x) * 1000 * 1000)
18*11f1cecaSGeorgi Djakov #define bps_to_icc(x)	(1)
19*11f1cecaSGeorgi Djakov #define kbps_to_icc(x)	((x) / 8 + ((x) % 8 ? 1 : 0))
20*11f1cecaSGeorgi Djakov #define Mbps_to_icc(x)	((x) * 1000 / 8)
21*11f1cecaSGeorgi Djakov #define Gbps_to_icc(x)	((x) * 1000 * 1000 / 8)
22*11f1cecaSGeorgi Djakov 
23*11f1cecaSGeorgi Djakov struct icc_path;
24*11f1cecaSGeorgi Djakov struct device;
25*11f1cecaSGeorgi Djakov 
26*11f1cecaSGeorgi Djakov #if IS_ENABLED(CONFIG_INTERCONNECT)
27*11f1cecaSGeorgi Djakov 
28*11f1cecaSGeorgi Djakov struct icc_path *icc_get(struct device *dev, const int src_id,
29*11f1cecaSGeorgi Djakov 			 const int dst_id);
30*11f1cecaSGeorgi Djakov void icc_put(struct icc_path *path);
31*11f1cecaSGeorgi Djakov int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw);
32*11f1cecaSGeorgi Djakov 
33*11f1cecaSGeorgi Djakov #else
34*11f1cecaSGeorgi Djakov 
35*11f1cecaSGeorgi Djakov static inline struct icc_path *icc_get(struct device *dev, const int src_id,
36*11f1cecaSGeorgi Djakov 				       const int dst_id)
37*11f1cecaSGeorgi Djakov {
38*11f1cecaSGeorgi Djakov 	return NULL;
39*11f1cecaSGeorgi Djakov }
40*11f1cecaSGeorgi Djakov 
41*11f1cecaSGeorgi Djakov static inline void icc_put(struct icc_path *path)
42*11f1cecaSGeorgi Djakov {
43*11f1cecaSGeorgi Djakov }
44*11f1cecaSGeorgi Djakov 
45*11f1cecaSGeorgi Djakov static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw)
46*11f1cecaSGeorgi Djakov {
47*11f1cecaSGeorgi Djakov 	return 0;
48*11f1cecaSGeorgi Djakov }
49*11f1cecaSGeorgi Djakov 
50*11f1cecaSGeorgi Djakov #endif /* CONFIG_INTERCONNECT */
51*11f1cecaSGeorgi Djakov 
52*11f1cecaSGeorgi Djakov #endif /* __LINUX_INTERCONNECT_H */
53