WIP FPC-III support
[linux/fpc-iii.git] / drivers / interconnect / qcom / icc-rpmh.h
blobe5f61ab989e71c62cb4e6c87d03799bfb9952e35
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (c) 2020, The Linux Foundation. All rights reserved.
4 */
6 #ifndef __DRIVERS_INTERCONNECT_QCOM_ICC_RPMH_H__
7 #define __DRIVERS_INTERCONNECT_QCOM_ICC_RPMH_H__
9 #include <dt-bindings/interconnect/qcom,icc.h>
11 #define to_qcom_provider(_provider) \
12 container_of(_provider, struct qcom_icc_provider, provider)
14 /**
15 * struct qcom_icc_provider - Qualcomm specific interconnect provider
16 * @provider: generic interconnect provider
17 * @dev: reference to the NoC device
18 * @bcms: list of bcms that maps to the provider
19 * @num_bcms: number of @bcms
20 * @voter: bcm voter targeted by this provider
22 struct qcom_icc_provider {
23 struct icc_provider provider;
24 struct device *dev;
25 struct qcom_icc_bcm **bcms;
26 size_t num_bcms;
27 struct bcm_voter *voter;
30 /**
31 * struct bcm_db - Auxiliary data pertaining to each Bus Clock Manager (BCM)
32 * @unit: divisor used to convert bytes/sec bw value to an RPMh msg
33 * @width: multiplier used to convert bytes/sec bw value to an RPMh msg
34 * @vcd: virtual clock domain that this bcm belongs to
35 * @reserved: reserved field
37 struct bcm_db {
38 __le32 unit;
39 __le16 width;
40 u8 vcd;
41 u8 reserved;
44 #define MAX_LINKS 128
45 #define MAX_BCMS 64
46 #define MAX_BCM_PER_NODE 3
47 #define MAX_VCD 10
49 /**
50 * struct qcom_icc_node - Qualcomm specific interconnect nodes
51 * @name: the node name used in debugfs
52 * @links: an array of nodes where we can go next while traversing
53 * @id: a unique node identifier
54 * @num_links: the total number of @links
55 * @channels: num of channels at this node
56 * @buswidth: width of the interconnect between a node and the bus
57 * @sum_avg: current sum aggregate value of all avg bw requests
58 * @max_peak: current max aggregate value of all peak bw requests
59 * @bcms: list of bcms associated with this logical node
60 * @num_bcms: num of @bcms
62 struct qcom_icc_node {
63 const char *name;
64 u16 links[MAX_LINKS];
65 u16 id;
66 u16 num_links;
67 u16 channels;
68 u16 buswidth;
69 u64 sum_avg[QCOM_ICC_NUM_BUCKETS];
70 u64 max_peak[QCOM_ICC_NUM_BUCKETS];
71 struct qcom_icc_bcm *bcms[MAX_BCM_PER_NODE];
72 size_t num_bcms;
75 /**
76 * struct qcom_icc_bcm - Qualcomm specific hardware accelerator nodes
77 * known as Bus Clock Manager (BCM)
78 * @name: the bcm node name used to fetch BCM data from command db
79 * @type: latency or bandwidth bcm
80 * @addr: address offsets used when voting to RPMH
81 * @vote_x: aggregated threshold values, represents sum_bw when @type is bw bcm
82 * @vote_y: aggregated threshold values, represents peak_bw when @type is bw bcm
83 * @vote_scale: scaling factor for vote_x and vote_y
84 * @dirty: flag used to indicate whether the bcm needs to be committed
85 * @keepalive: flag used to indicate whether a keepalive is required
86 * @aux_data: auxiliary data used when calculating threshold values and
87 * communicating with RPMh
88 * @list: used to link to other bcms when compiling lists for commit
89 * @ws_list: used to keep track of bcms that may transition between wake/sleep
90 * @num_nodes: total number of @num_nodes
91 * @nodes: list of qcom_icc_nodes that this BCM encapsulates
93 struct qcom_icc_bcm {
94 const char *name;
95 u32 type;
96 u32 addr;
97 u64 vote_x[QCOM_ICC_NUM_BUCKETS];
98 u64 vote_y[QCOM_ICC_NUM_BUCKETS];
99 u64 vote_scale;
100 bool dirty;
101 bool keepalive;
102 struct bcm_db aux_data;
103 struct list_head list;
104 struct list_head ws_list;
105 size_t num_nodes;
106 struct qcom_icc_node *nodes[];
109 struct qcom_icc_fabric {
110 struct qcom_icc_node **nodes;
111 size_t num_nodes;
114 struct qcom_icc_desc {
115 struct qcom_icc_node **nodes;
116 size_t num_nodes;
117 struct qcom_icc_bcm **bcms;
118 size_t num_bcms;
121 #define DEFINE_QNODE(_name, _id, _channels, _buswidth, ...) \
122 static struct qcom_icc_node _name = { \
123 .id = _id, \
124 .name = #_name, \
125 .channels = _channels, \
126 .buswidth = _buswidth, \
127 .num_links = ARRAY_SIZE(((int[]){ __VA_ARGS__ })), \
128 .links = { __VA_ARGS__ }, \
131 int qcom_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
132 u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
133 int qcom_icc_set(struct icc_node *src, struct icc_node *dst);
134 struct icc_node_data *qcom_icc_xlate_extended(struct of_phandle_args *spec, void *data);
135 int qcom_icc_bcm_init(struct qcom_icc_bcm *bcm, struct device *dev);
136 void qcom_icc_pre_aggregate(struct icc_node *node);
138 #endif