1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2018-2019, Linaro Ltd. 4 * Author: Georgi Djakov <[email protected]> 5 */ 6 7 #ifndef __LINUX_INTERCONNECT_H 8 #define __LINUX_INTERCONNECT_H 9 10 #include <linux/mutex.h> 11 #include <linux/types.h> 12 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) 22 23 struct icc_path; 24 struct device; 25 26 #if IS_ENABLED(CONFIG_INTERCONNECT) 27 28 struct icc_path *icc_get(struct device *dev, const int src_id, 29 const int dst_id); 30 struct icc_path *of_icc_get(struct device *dev, const char *name); 31 struct icc_path *devm_of_icc_get(struct device *dev, const char *name); 32 struct icc_path *of_icc_get_by_index(struct device *dev, int idx); 33 void icc_put(struct icc_path *path); 34 int icc_enable(struct icc_path *path); 35 int icc_disable(struct icc_path *path); 36 int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw); 37 void icc_set_tag(struct icc_path *path, u32 tag); 38 39 #else 40 41 static inline struct icc_path *icc_get(struct device *dev, const int src_id, 42 const int dst_id) 43 { 44 return NULL; 45 } 46 47 static inline struct icc_path *of_icc_get(struct device *dev, 48 const char *name) 49 { 50 return NULL; 51 } 52 53 static inline struct icc_path *devm_of_icc_get(struct device *dev, 54 const char *name) 55 { 56 return NULL; 57 } 58 59 static inline struct icc_path *of_icc_get_by_index(struct device *dev, int idx) 60 { 61 return NULL; 62 } 63 64 static inline void icc_put(struct icc_path *path) 65 { 66 } 67 68 static inline int icc_enable(struct icc_path *path) 69 { 70 return 0; 71 } 72 73 static inline int icc_disable(struct icc_path *path) 74 { 75 return 0; 76 } 77 78 static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw) 79 { 80 return 0; 81 } 82 83 static inline void icc_set_tag(struct icc_path *path, u32 tag) 84 { 85 } 86 87 #endif /* CONFIG_INTERCONNECT */ 88 89 #endif /* __LINUX_INTERCONNECT_H */ 90