1 /* SPDX-License-Identifier: GPL-2.0 */ 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 2 /* 3 * Copyright (c) 2018-2019, Linaro Ltd. 3 * Copyright (c) 2018-2019, Linaro Ltd. 4 * Author: Georgi Djakov <georgi.djakov@linaro 4 * Author: Georgi Djakov <georgi.djakov@linaro.org> 5 */ 5 */ 6 6 7 #ifndef __LINUX_INTERCONNECT_H 7 #ifndef __LINUX_INTERCONNECT_H 8 #define __LINUX_INTERCONNECT_H 8 #define __LINUX_INTERCONNECT_H 9 9 10 #include <linux/mutex.h> 10 #include <linux/mutex.h> 11 #include <linux/types.h> 11 #include <linux/types.h> 12 12 13 /* macros for converting to icc units */ 13 /* macros for converting to icc units */ 14 #define Bps_to_icc(x) ((x) / 1000) 14 #define Bps_to_icc(x) ((x) / 1000) 15 #define kBps_to_icc(x) (x) 15 #define kBps_to_icc(x) (x) 16 #define MBps_to_icc(x) ((x) * 1000) 16 #define MBps_to_icc(x) ((x) * 1000) 17 #define GBps_to_icc(x) ((x) * 1000 * 1000) 17 #define GBps_to_icc(x) ((x) * 1000 * 1000) 18 #define bps_to_icc(x) (1) 18 #define bps_to_icc(x) (1) 19 #define kbps_to_icc(x) ((x) / 8 + ((x) % 8 ? 19 #define kbps_to_icc(x) ((x) / 8 + ((x) % 8 ? 1 : 0)) 20 #define Mbps_to_icc(x) ((x) * 1000 / 8) 20 #define Mbps_to_icc(x) ((x) * 1000 / 8) 21 #define Gbps_to_icc(x) ((x) * 1000 * 1000 / 8 21 #define Gbps_to_icc(x) ((x) * 1000 * 1000 / 8) 22 22 23 struct icc_path; 23 struct icc_path; 24 struct device; 24 struct device; 25 25 26 /** 26 /** 27 * struct icc_bulk_data - Data used for bulk i 27 * struct icc_bulk_data - Data used for bulk icc operations. 28 * 28 * 29 * @path: reference to the interconnect path ( 29 * @path: reference to the interconnect path (internal use) 30 * @name: the name from the "interconnect-name 30 * @name: the name from the "interconnect-names" DT property 31 * @avg_bw: average bandwidth in icc units 31 * @avg_bw: average bandwidth in icc units 32 * @peak_bw: peak bandwidth in icc units 32 * @peak_bw: peak bandwidth in icc units 33 */ 33 */ 34 struct icc_bulk_data { 34 struct icc_bulk_data { 35 struct icc_path *path; 35 struct icc_path *path; 36 const char *name; 36 const char *name; 37 u32 avg_bw; 37 u32 avg_bw; 38 u32 peak_bw; 38 u32 peak_bw; 39 }; 39 }; 40 40 41 #if IS_ENABLED(CONFIG_INTERCONNECT) 41 #if IS_ENABLED(CONFIG_INTERCONNECT) 42 42 >> 43 struct icc_path *icc_get(struct device *dev, const int src_id, >> 44 const int dst_id); 43 struct icc_path *of_icc_get(struct device *dev 45 struct icc_path *of_icc_get(struct device *dev, const char *name); 44 struct icc_path *devm_of_icc_get(struct device 46 struct icc_path *devm_of_icc_get(struct device *dev, const char *name); 45 int devm_of_icc_bulk_get(struct device *dev, i 47 int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths); 46 struct icc_path *of_icc_get_by_index(struct de 48 struct icc_path *of_icc_get_by_index(struct device *dev, int idx); 47 void icc_put(struct icc_path *path); 49 void icc_put(struct icc_path *path); 48 int icc_enable(struct icc_path *path); 50 int icc_enable(struct icc_path *path); 49 int icc_disable(struct icc_path *path); 51 int icc_disable(struct icc_path *path); 50 int icc_set_bw(struct icc_path *path, u32 avg_ 52 int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw); 51 void icc_set_tag(struct icc_path *path, u32 ta 53 void icc_set_tag(struct icc_path *path, u32 tag); 52 const char *icc_get_name(struct icc_path *path 54 const char *icc_get_name(struct icc_path *path); 53 int __must_check of_icc_bulk_get(struct device 55 int __must_check of_icc_bulk_get(struct device *dev, int num_paths, 54 struct icc_bu 56 struct icc_bulk_data *paths); 55 void icc_bulk_put(int num_paths, struct icc_bu 57 void icc_bulk_put(int num_paths, struct icc_bulk_data *paths); 56 int icc_bulk_set_bw(int num_paths, const struc 58 int icc_bulk_set_bw(int num_paths, const struct icc_bulk_data *paths); 57 int icc_bulk_enable(int num_paths, const struc 59 int icc_bulk_enable(int num_paths, const struct icc_bulk_data *paths); 58 void icc_bulk_disable(int num_paths, const str 60 void icc_bulk_disable(int num_paths, const struct icc_bulk_data *paths); 59 61 60 #else 62 #else >> 63 >> 64 static inline struct icc_path *icc_get(struct device *dev, const int src_id, >> 65 const int dst_id) >> 66 { >> 67 return NULL; >> 68 } 61 69 62 static inline struct icc_path *of_icc_get(stru 70 static inline struct icc_path *of_icc_get(struct device *dev, 63 cons 71 const char *name) 64 { 72 { 65 return NULL; 73 return NULL; 66 } 74 } 67 75 68 static inline struct icc_path *devm_of_icc_get 76 static inline struct icc_path *devm_of_icc_get(struct device *dev, 69 77 const char *name) 70 { 78 { 71 return NULL; 79 return NULL; 72 } 80 } 73 81 74 static inline struct icc_path *of_icc_get_by_i 82 static inline struct icc_path *of_icc_get_by_index(struct device *dev, int idx) 75 { 83 { 76 return NULL; 84 return NULL; 77 } 85 } 78 86 79 static inline void icc_put(struct icc_path *pa 87 static inline void icc_put(struct icc_path *path) 80 { 88 { 81 } 89 } 82 90 83 static inline int icc_enable(struct icc_path * 91 static inline int icc_enable(struct icc_path *path) 84 { 92 { 85 return 0; 93 return 0; 86 } 94 } 87 95 88 static inline int icc_disable(struct icc_path 96 static inline int icc_disable(struct icc_path *path) 89 { 97 { 90 return 0; 98 return 0; 91 } 99 } 92 100 93 static inline int icc_set_bw(struct icc_path * 101 static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw) 94 { 102 { 95 return 0; 103 return 0; 96 } 104 } 97 105 98 static inline void icc_set_tag(struct icc_path 106 static inline void icc_set_tag(struct icc_path *path, u32 tag) 99 { 107 { 100 } 108 } 101 109 102 static inline const char *icc_get_name(struct 110 static inline const char *icc_get_name(struct icc_path *path) 103 { 111 { 104 return NULL; 112 return NULL; 105 } 113 } 106 114 107 static inline int of_icc_bulk_get(struct devic 115 static inline int of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths) 108 { 116 { 109 return 0; 117 return 0; 110 } 118 } 111 119 112 static inline int devm_of_icc_bulk_get(struct 120 static inline int devm_of_icc_bulk_get(struct device *dev, int num_paths, 113 struct 121 struct icc_bulk_data *paths) 114 { 122 { 115 return 0; 123 return 0; 116 } 124 } 117 125 118 static inline void icc_bulk_put(int num_paths, 126 static inline void icc_bulk_put(int num_paths, struct icc_bulk_data *paths) 119 { 127 { 120 } 128 } 121 129 122 static inline int icc_bulk_set_bw(int num_path 130 static inline int icc_bulk_set_bw(int num_paths, const struct icc_bulk_data *paths) 123 { 131 { 124 return 0; 132 return 0; 125 } 133 } 126 134 127 static inline int icc_bulk_enable(int num_path 135 static inline int icc_bulk_enable(int num_paths, const struct icc_bulk_data *paths) 128 { 136 { 129 return 0; 137 return 0; 130 } 138 } 131 139 132 static inline void icc_bulk_disable(int num_pa 140 static inline void icc_bulk_disable(int num_paths, const struct icc_bulk_data *paths) 133 { 141 { 134 } 142 } 135 143 136 #endif /* CONFIG_INTERCONNECT */ 144 #endif /* CONFIG_INTERCONNECT */ 137 145 138 #endif /* __LINUX_INTERCONNECT_H */ 146 #endif /* __LINUX_INTERCONNECT_H */ 139 147
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.