xref: /linux/include/linux/interconnect.h (revision 87e3031b6fbd83ea83adf1bf9602bcce313ee787)
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);
30*87e3031bSGeorgi Djakov struct icc_path *of_icc_get(struct device *dev, const char *name);
3111f1cecaSGeorgi Djakov void icc_put(struct icc_path *path);
3211f1cecaSGeorgi Djakov int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw);
3311f1cecaSGeorgi Djakov 
3411f1cecaSGeorgi Djakov #else
3511f1cecaSGeorgi Djakov 
3611f1cecaSGeorgi Djakov static inline struct icc_path *icc_get(struct device *dev, const int src_id,
3711f1cecaSGeorgi Djakov 				       const int dst_id)
3811f1cecaSGeorgi Djakov {
3911f1cecaSGeorgi Djakov 	return NULL;
4011f1cecaSGeorgi Djakov }
4111f1cecaSGeorgi Djakov 
42*87e3031bSGeorgi Djakov static inline struct icc_path *of_icc_get(struct device *dev,
43*87e3031bSGeorgi Djakov 					  const char *name)
44*87e3031bSGeorgi Djakov {
45*87e3031bSGeorgi Djakov 	return NULL;
46*87e3031bSGeorgi Djakov }
47*87e3031bSGeorgi Djakov 
4811f1cecaSGeorgi Djakov static inline void icc_put(struct icc_path *path)
4911f1cecaSGeorgi Djakov {
5011f1cecaSGeorgi Djakov }
5111f1cecaSGeorgi Djakov 
5211f1cecaSGeorgi Djakov static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw)
5311f1cecaSGeorgi Djakov {
5411f1cecaSGeorgi Djakov 	return 0;
5511f1cecaSGeorgi Djakov }
5611f1cecaSGeorgi Djakov 
5711f1cecaSGeorgi Djakov #endif /* CONFIG_INTERCONNECT */
5811f1cecaSGeorgi Djakov 
5911f1cecaSGeorgi Djakov #endif /* __LINUX_INTERCONNECT_H */
60