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); 31e145d9a1SAkash Asthana struct icc_path *devm_of_icc_get(struct device *dev, const char *name); 3211f1cecaSGeorgi Djakov void icc_put(struct icc_path *path); 33*7d374b20SGeorgi Djakov int icc_enable(struct icc_path *path); 34*7d374b20SGeorgi Djakov int icc_disable(struct icc_path *path); 3511f1cecaSGeorgi Djakov int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw); 36127ab2ccSGeorgi Djakov void icc_set_tag(struct icc_path *path, u32 tag); 3711f1cecaSGeorgi Djakov 3811f1cecaSGeorgi Djakov #else 3911f1cecaSGeorgi Djakov 4011f1cecaSGeorgi Djakov static inline struct icc_path *icc_get(struct device *dev, const int src_id, 4111f1cecaSGeorgi Djakov const int dst_id) 4211f1cecaSGeorgi Djakov { 4311f1cecaSGeorgi Djakov return NULL; 4411f1cecaSGeorgi Djakov } 4511f1cecaSGeorgi Djakov 4687e3031bSGeorgi Djakov static inline struct icc_path *of_icc_get(struct device *dev, 4787e3031bSGeorgi Djakov const char *name) 4887e3031bSGeorgi Djakov { 4987e3031bSGeorgi Djakov return NULL; 5087e3031bSGeorgi Djakov } 5187e3031bSGeorgi Djakov 52e145d9a1SAkash Asthana static inline struct icc_path *devm_of_icc_get(struct device *dev, 53e145d9a1SAkash Asthana const char *name) 54e145d9a1SAkash Asthana { 55e145d9a1SAkash Asthana return NULL; 56e145d9a1SAkash Asthana } 57e145d9a1SAkash Asthana 5811f1cecaSGeorgi Djakov static inline void icc_put(struct icc_path *path) 5911f1cecaSGeorgi Djakov { 6011f1cecaSGeorgi Djakov } 6111f1cecaSGeorgi Djakov 62*7d374b20SGeorgi Djakov static inline int icc_enable(struct icc_path *path) 63*7d374b20SGeorgi Djakov { 64*7d374b20SGeorgi Djakov return 0; 65*7d374b20SGeorgi Djakov } 66*7d374b20SGeorgi Djakov 67*7d374b20SGeorgi Djakov static inline int icc_disable(struct icc_path *path) 68*7d374b20SGeorgi Djakov { 69*7d374b20SGeorgi Djakov return 0; 70*7d374b20SGeorgi Djakov } 71*7d374b20SGeorgi Djakov 7211f1cecaSGeorgi Djakov static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw) 7311f1cecaSGeorgi Djakov { 7411f1cecaSGeorgi Djakov return 0; 7511f1cecaSGeorgi Djakov } 7611f1cecaSGeorgi Djakov 77127ab2ccSGeorgi Djakov static inline void icc_set_tag(struct icc_path *path, u32 tag) 78127ab2ccSGeorgi Djakov { 79127ab2ccSGeorgi Djakov } 80127ab2ccSGeorgi Djakov 8111f1cecaSGeorgi Djakov #endif /* CONFIG_INTERCONNECT */ 8211f1cecaSGeorgi Djakov 8311f1cecaSGeorgi Djakov #endif /* __LINUX_INTERCONNECT_H */ 84