0001
0002
0003
0004
0005
0006
0007 #ifndef __LINUX_INTERCONNECT_H
0008 #define __LINUX_INTERCONNECT_H
0009
0010 #include <linux/mutex.h>
0011 #include <linux/types.h>
0012
0013
0014 #define Bps_to_icc(x) ((x) / 1000)
0015 #define kBps_to_icc(x) (x)
0016 #define MBps_to_icc(x) ((x) * 1000)
0017 #define GBps_to_icc(x) ((x) * 1000 * 1000)
0018 #define bps_to_icc(x) (1)
0019 #define kbps_to_icc(x) ((x) / 8 + ((x) % 8 ? 1 : 0))
0020 #define Mbps_to_icc(x) ((x) * 1000 / 8)
0021 #define Gbps_to_icc(x) ((x) * 1000 * 1000 / 8)
0022
0023 struct icc_path;
0024 struct device;
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 struct icc_bulk_data {
0035 struct icc_path *path;
0036 const char *name;
0037 u32 avg_bw;
0038 u32 peak_bw;
0039 };
0040
0041 #if IS_ENABLED(CONFIG_INTERCONNECT)
0042
0043 struct icc_path *icc_get(struct device *dev, const int src_id,
0044 const int dst_id);
0045 struct icc_path *of_icc_get(struct device *dev, const char *name);
0046 struct icc_path *devm_of_icc_get(struct device *dev, const char *name);
0047 int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths);
0048 struct icc_path *of_icc_get_by_index(struct device *dev, int idx);
0049 void icc_put(struct icc_path *path);
0050 int icc_enable(struct icc_path *path);
0051 int icc_disable(struct icc_path *path);
0052 int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw);
0053 void icc_set_tag(struct icc_path *path, u32 tag);
0054 const char *icc_get_name(struct icc_path *path);
0055 int __must_check of_icc_bulk_get(struct device *dev, int num_paths,
0056 struct icc_bulk_data *paths);
0057 void icc_bulk_put(int num_paths, struct icc_bulk_data *paths);
0058 int icc_bulk_set_bw(int num_paths, const struct icc_bulk_data *paths);
0059 int icc_bulk_enable(int num_paths, const struct icc_bulk_data *paths);
0060 void icc_bulk_disable(int num_paths, const struct icc_bulk_data *paths);
0061
0062 #else
0063
0064 static inline struct icc_path *icc_get(struct device *dev, const int src_id,
0065 const int dst_id)
0066 {
0067 return NULL;
0068 }
0069
0070 static inline struct icc_path *of_icc_get(struct device *dev,
0071 const char *name)
0072 {
0073 return NULL;
0074 }
0075
0076 static inline struct icc_path *devm_of_icc_get(struct device *dev,
0077 const char *name)
0078 {
0079 return NULL;
0080 }
0081
0082 static inline struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
0083 {
0084 return NULL;
0085 }
0086
0087 static inline void icc_put(struct icc_path *path)
0088 {
0089 }
0090
0091 static inline int icc_enable(struct icc_path *path)
0092 {
0093 return 0;
0094 }
0095
0096 static inline int icc_disable(struct icc_path *path)
0097 {
0098 return 0;
0099 }
0100
0101 static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw)
0102 {
0103 return 0;
0104 }
0105
0106 static inline void icc_set_tag(struct icc_path *path, u32 tag)
0107 {
0108 }
0109
0110 static inline const char *icc_get_name(struct icc_path *path)
0111 {
0112 return NULL;
0113 }
0114
0115 static inline int of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths)
0116 {
0117 return 0;
0118 }
0119
0120 static inline int devm_of_icc_bulk_get(struct device *dev, int num_paths,
0121 struct icc_bulk_data *paths)
0122 {
0123 return 0;
0124 }
0125
0126 static inline void icc_bulk_put(int num_paths, struct icc_bulk_data *paths)
0127 {
0128 }
0129
0130 static inline int icc_bulk_set_bw(int num_paths, const struct icc_bulk_data *paths)
0131 {
0132 return 0;
0133 }
0134
0135 static inline int icc_bulk_enable(int num_paths, const struct icc_bulk_data *paths)
0136 {
0137 return 0;
0138 }
0139
0140 static inline void icc_bulk_disable(int num_paths, const struct icc_bulk_data *paths)
0141 {
0142 }
0143
0144 #endif
0145
0146 #endif