xref: /linux/include/linux/interconnect.h (revision e145d9a184f23639edc864e2fa08fcc1853361a4)
111f1cecaSGeorgi Djakov /* SPDX-License-Identifier: GPL-2.0 */
211f1cecaSGeorgi Djakov /*
311f1cecaSGeorgi Djakov  * Copyright (c) 2018-2019, Linaro Ltd.
411f1cecaSGeorgi Djakov  * Author: Georgi Djakov <georgi.djakov@linaro.org>
511f1cecaSGeorgi Djakov  */
611f1cecaSGeorgi Djakov 
711f1cecaSGeorgi Djakov #ifndef __LINUX_INTERCONNECT_H
811f1cecaSGeorgi Djakov #define __LINUX_INTERCONNECT_H
911f1cecaSGeorgi Djakov 
1011f1cecaSGeorgi Djakov #include <linux/mutex.h>
1111f1cecaSGeorgi Djakov #include <linux/types.h>
1211f1cecaSGeorgi Djakov 
1311f1cecaSGeorgi Djakov /* macros for converting to icc units */
1411f1cecaSGeorgi Djakov #define Bps_to_icc(x)	((x) / 1000)
1511f1cecaSGeorgi Djakov #define kBps_to_icc(x)	(x)
1611f1cecaSGeorgi Djakov #define MBps_to_icc(x)	((x) * 1000)
1711f1cecaSGeorgi Djakov #define GBps_to_icc(x)	((x) * 1000 * 1000)
1811f1cecaSGeorgi Djakov #define bps_to_icc(x)	(1)
1911f1cecaSGeorgi Djakov #define kbps_to_icc(x)	((x) / 8 + ((x) % 8 ? 1 : 0))
2011f1cecaSGeorgi Djakov #define Mbps_to_icc(x)	((x) * 1000 / 8)
2111f1cecaSGeorgi Djakov #define Gbps_to_icc(x)	((x) * 1000 * 1000 / 8)
2211f1cecaSGeorgi Djakov 
2311f1cecaSGeorgi Djakov struct icc_path;
2411f1cecaSGeorgi Djakov struct device;
2511f1cecaSGeorgi Djakov 
2611f1cecaSGeorgi Djakov #if IS_ENABLED(CONFIG_INTERCONNECT)
2711f1cecaSGeorgi Djakov 
2811f1cecaSGeorgi Djakov struct icc_path *icc_get(struct device *dev, const int src_id,
2911f1cecaSGeorgi Djakov 			 const int dst_id);
3087e3031bSGeorgi Djakov struct icc_path *of_icc_get(struct device *dev, const char *name);
31*e145d9a1SAkash Asthana struct icc_path *devm_of_icc_get(struct device *dev, const char *name);
3211f1cecaSGeorgi Djakov void icc_put(struct icc_path *path);
3311f1cecaSGeorgi Djakov int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw);
34127ab2ccSGeorgi Djakov void icc_set_tag(struct icc_path *path, u32 tag);
3511f1cecaSGeorgi Djakov 
3611f1cecaSGeorgi Djakov #else
3711f1cecaSGeorgi Djakov 
3811f1cecaSGeorgi Djakov static inline struct icc_path *icc_get(struct device *dev, const int src_id,
3911f1cecaSGeorgi Djakov 				       const int dst_id)
4011f1cecaSGeorgi Djakov {
4111f1cecaSGeorgi Djakov 	return NULL;
4211f1cecaSGeorgi Djakov }
4311f1cecaSGeorgi Djakov 
4487e3031bSGeorgi Djakov static inline struct icc_path *of_icc_get(struct device *dev,
4587e3031bSGeorgi Djakov 					  const char *name)
4687e3031bSGeorgi Djakov {
4787e3031bSGeorgi Djakov 	return NULL;
4887e3031bSGeorgi Djakov }
4987e3031bSGeorgi Djakov 
50*e145d9a1SAkash Asthana static inline struct icc_path *devm_of_icc_get(struct device *dev,
51*e145d9a1SAkash Asthana 						const char *name)
52*e145d9a1SAkash Asthana {
53*e145d9a1SAkash Asthana 	return NULL;
54*e145d9a1SAkash Asthana }
55*e145d9a1SAkash Asthana 
5611f1cecaSGeorgi Djakov static inline void icc_put(struct icc_path *path)
5711f1cecaSGeorgi Djakov {
5811f1cecaSGeorgi Djakov }
5911f1cecaSGeorgi Djakov 
6011f1cecaSGeorgi Djakov static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw)
6111f1cecaSGeorgi Djakov {
6211f1cecaSGeorgi Djakov 	return 0;
6311f1cecaSGeorgi Djakov }
6411f1cecaSGeorgi Djakov 
65127ab2ccSGeorgi Djakov static inline void icc_set_tag(struct icc_path *path, u32 tag)
66127ab2ccSGeorgi Djakov {
67127ab2ccSGeorgi Djakov }
68127ab2ccSGeorgi Djakov 
6911f1cecaSGeorgi Djakov #endif /* CONFIG_INTERCONNECT */
7011f1cecaSGeorgi Djakov 
7111f1cecaSGeorgi Djakov #endif /* __LINUX_INTERCONNECT_H */
72