cpufreq: dt: Add support for interconnect bandwidth scaling
[linux-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);
1597d453 31struct icc_path *of_icc_get_by_index(struct device *dev, int idx);
11f1ceca
GD
32void icc_put(struct icc_path *path);
33int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw);
127ab2cc 34void icc_set_tag(struct icc_path *path, u32 tag);
11f1ceca
GD
35
36#else
37
38static inline struct icc_path *icc_get(struct device *dev, const int src_id,
39 const int dst_id)
40{
41 return NULL;
42}
43
87e3031b
GD
44static inline struct icc_path *of_icc_get(struct device *dev,
45 const char *name)
46{
47 return NULL;
48}
49
1597d453
GD
50static inline struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
51{
52 return NULL;
53}
54
11f1ceca
GD
55static inline void icc_put(struct icc_path *path)
56{
57}
58
59static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw)
60{
61 return 0;
62}
63
127ab2cc
GD
64static inline void icc_set_tag(struct icc_path *path, u32 tag)
65{
66}
67
11f1ceca
GD
68#endif /* CONFIG_INTERCONNECT */
69
70#endif /* __LINUX_INTERCONNECT_H */