xref: /linux/include/linux/interconnect.h (revision 0430b1d5704b0f0f1d237236dde9c143f8669e49)
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);
311597d453SGeorgi Djakov struct icc_path *of_icc_get_by_index(struct device *dev, int idx);
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);
35*0430b1d5SViresh Kumar const char *icc_get_name(struct icc_path *path);
3611f1cecaSGeorgi Djakov 
3711f1cecaSGeorgi Djakov #else
3811f1cecaSGeorgi Djakov 
3911f1cecaSGeorgi Djakov static inline struct icc_path *icc_get(struct device *dev, const int src_id,
4011f1cecaSGeorgi Djakov 				       const int dst_id)
4111f1cecaSGeorgi Djakov {
4211f1cecaSGeorgi Djakov 	return NULL;
4311f1cecaSGeorgi Djakov }
4411f1cecaSGeorgi Djakov 
4587e3031bSGeorgi Djakov static inline struct icc_path *of_icc_get(struct device *dev,
4687e3031bSGeorgi Djakov 					  const char *name)
4787e3031bSGeorgi Djakov {
4887e3031bSGeorgi Djakov 	return NULL;
4987e3031bSGeorgi Djakov }
5087e3031bSGeorgi Djakov 
511597d453SGeorgi Djakov static inline struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
521597d453SGeorgi Djakov {
531597d453SGeorgi Djakov 	return NULL;
541597d453SGeorgi Djakov }
551597d453SGeorgi Djakov 
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 
69*0430b1d5SViresh Kumar static inline const char *icc_get_name(struct icc_path *path)
70*0430b1d5SViresh Kumar {
71*0430b1d5SViresh Kumar 	return NULL;
72*0430b1d5SViresh Kumar }
73*0430b1d5SViresh Kumar 
7411f1cecaSGeorgi Djakov #endif /* CONFIG_INTERCONNECT */
7511f1cecaSGeorgi Djakov 
7611f1cecaSGeorgi Djakov #endif /* __LINUX_INTERCONNECT_H */
77