blob: d70a914cba118fa5009707597877ddb5cc24a25d [file] [log] [blame]
Georgi Djakov11f1cec2019-01-16 18:10:56 +02001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (c) 2018-2019, Linaro Ltd.
4 * Author: Georgi Djakov <georgi.djakov@linaro.org>
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
23struct icc_path;
24struct device;
25
26#if IS_ENABLED(CONFIG_INTERCONNECT)
27
28struct icc_path *icc_get(struct device *dev, const int src_id,
29 const int dst_id);
Georgi Djakov87e30312019-01-16 18:10:58 +020030struct icc_path *of_icc_get(struct device *dev, const char *name);
Georgi Djakov11f1cec2019-01-16 18:10:56 +020031void icc_put(struct icc_path *path);
32int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw);
Georgi Djakov127ab2c2019-08-09 15:13:23 +030033void icc_set_tag(struct icc_path *path, u32 tag);
Georgi Djakov11f1cec2019-01-16 18:10:56 +020034
35#else
36
37static inline struct icc_path *icc_get(struct device *dev, const int src_id,
38 const int dst_id)
39{
40 return NULL;
41}
42
Georgi Djakov87e30312019-01-16 18:10:58 +020043static inline struct icc_path *of_icc_get(struct device *dev,
44 const char *name)
45{
46 return NULL;
47}
48
Georgi Djakov11f1cec2019-01-16 18:10:56 +020049static inline void icc_put(struct icc_path *path)
50{
51}
52
53static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw)
54{
55 return 0;
56}
57
Georgi Djakov127ab2c2019-08-09 15:13:23 +030058static inline void icc_set_tag(struct icc_path *path, u32 tag)
59{
60}
61
Georgi Djakov11f1cec2019-01-16 18:10:56 +020062#endif /* CONFIG_INTERCONNECT */
63
64#endif /* __LINUX_INTERCONNECT_H */