Merge tag 'mt76-for-kvalo-2020-06-07' of https://github.com/nbd168/wireless
[linux-2.6-block.git] / include / linux / interconnect.h
CommitLineData
11f1ceca
GD
1/* 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);
87e3031b 30struct icc_path *of_icc_get(struct device *dev, const char *name);
e145d9a1 31struct icc_path *devm_of_icc_get(struct device *dev, const char *name);
1597d453 32struct icc_path *of_icc_get_by_index(struct device *dev, int idx);
11f1ceca 33void icc_put(struct icc_path *path);
7d374b20
GD
34int icc_enable(struct icc_path *path);
35int icc_disable(struct icc_path *path);
11f1ceca 36int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw);
127ab2cc 37void icc_set_tag(struct icc_path *path, u32 tag);
0430b1d5 38const char *icc_get_name(struct icc_path *path);
11f1ceca
GD
39
40#else
41
42static inline struct icc_path *icc_get(struct device *dev, const int src_id,
43 const int dst_id)
44{
45 return NULL;
46}
47
87e3031b
GD
48static inline struct icc_path *of_icc_get(struct device *dev,
49 const char *name)
50{
51 return NULL;
52}
53
e145d9a1
AA
54static inline struct icc_path *devm_of_icc_get(struct device *dev,
55 const char *name)
56{
57 return NULL;
58}
59
1597d453
GD
60static inline struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
61{
62 return NULL;
63}
64
11f1ceca
GD
65static inline void icc_put(struct icc_path *path)
66{
67}
68
7d374b20
GD
69static inline int icc_enable(struct icc_path *path)
70{
71 return 0;
72}
73
74static inline int icc_disable(struct icc_path *path)
75{
76 return 0;
77}
78
11f1ceca
GD
79static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw)
80{
81 return 0;
82}
83
127ab2cc
GD
84static inline void icc_set_tag(struct icc_path *path, u32 tag)
85{
86}
87
0430b1d5
VK
88static inline const char *icc_get_name(struct icc_path *path)
89{
90 return NULL;
91}
92
11f1ceca
GD
93#endif /* CONFIG_INTERCONNECT */
94
95#endif /* __LINUX_INTERCONNECT_H */