1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2018-2019, Linaro Ltd.
7 #ifndef __LINUX_INTERCONNECT_H
8 #define __LINUX_INTERCONNECT_H
10 #include <linux/mutex.h>
11 #include <linux/types.h>
13 /* macros for converting to icc units */
14 #define Bps_to_icc(x) ((x) / 1000)
15 #define kBps_to_icc(x) (x)
16 #define MBps_to_icc(x) ((x) * 1000)
17 #define GBps_to_icc(x) ((x) * 1000 * 1000)
18 #define bps_to_icc(x) (1)
19 #define kbps_to_icc(x) ((x) / 8 + ((x) % 8 ? 1 : 0))
20 #define Mbps_to_icc(x) ((x) * 1000 / 8)
21 #define Gbps_to_icc(x) ((x) * 1000 * 1000 / 8)
26 #if IS_ENABLED(CONFIG_INTERCONNECT)
28 struct icc_path *icc_get(struct device *dev, const int src_id,
30 struct icc_path *of_icc_get(struct device *dev, const char *name);
31 struct icc_path *of_icc_get_by_index(struct device *dev, int idx);
32 void icc_put(struct icc_path *path);
33 int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw);
34 void icc_set_tag(struct icc_path *path, u32 tag);
35 const char *icc_get_name(struct icc_path *path);
39 static inline struct icc_path *icc_get(struct device *dev, const int src_id,
45 static inline struct icc_path *of_icc_get(struct device *dev,
51 static inline struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
56 static inline void icc_put(struct icc_path *path)
60 static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw)
65 static inline void icc_set_tag(struct icc_path *path, u32 tag)
69 static inline const char *icc_get_name(struct icc_path *path)
74 #endif /* CONFIG_INTERCONNECT */
76 #endif /* __LINUX_INTERCONNECT_H */