1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2020, The Linux Foundation. All rights reserved.
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)
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
;
25 struct qcom_icc_bcm
**bcms
;
27 struct bcm_voter
*voter
;
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
46 #define MAX_BCM_PER_NODE 3
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
{
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
];
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
97 u64 vote_x
[QCOM_ICC_NUM_BUCKETS
];
98 u64 vote_y
[QCOM_ICC_NUM_BUCKETS
];
102 struct bcm_db aux_data
;
103 struct list_head list
;
104 struct list_head ws_list
;
106 struct qcom_icc_node
*nodes
[];
109 struct qcom_icc_fabric
{
110 struct qcom_icc_node
**nodes
;
114 struct qcom_icc_desc
{
115 struct qcom_icc_node
**nodes
;
117 struct qcom_icc_bcm
**bcms
;
121 #define DEFINE_QNODE(_name, _id, _channels, _buswidth, ...) \
122 static struct qcom_icc_node _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
);