0001
0002
0003
0004
0005
0006 #ifndef __DRIVERS_INTERCONNECT_QCOM_ICC_RPMH_H__
0007 #define __DRIVERS_INTERCONNECT_QCOM_ICC_RPMH_H__
0008
0009 #include <dt-bindings/interconnect/qcom,icc.h>
0010
0011 #define to_qcom_provider(_provider) \
0012 container_of(_provider, struct qcom_icc_provider, provider)
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 struct qcom_icc_provider {
0023 struct icc_provider provider;
0024 struct device *dev;
0025 struct qcom_icc_bcm * const *bcms;
0026 size_t num_bcms;
0027 struct bcm_voter *voter;
0028 };
0029
0030
0031
0032
0033
0034
0035
0036
0037 struct bcm_db {
0038 __le32 unit;
0039 __le16 width;
0040 u8 vcd;
0041 u8 reserved;
0042 };
0043
0044 #define MAX_LINKS 128
0045 #define MAX_BCMS 64
0046 #define MAX_BCM_PER_NODE 3
0047 #define MAX_VCD 10
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 struct qcom_icc_node {
0063 const char *name;
0064 u16 links[MAX_LINKS];
0065 u16 id;
0066 u16 num_links;
0067 u16 channels;
0068 u16 buswidth;
0069 u64 sum_avg[QCOM_ICC_NUM_BUCKETS];
0070 u64 max_peak[QCOM_ICC_NUM_BUCKETS];
0071 struct qcom_icc_bcm *bcms[MAX_BCM_PER_NODE];
0072 size_t num_bcms;
0073 };
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 struct qcom_icc_bcm {
0094 const char *name;
0095 u32 type;
0096 u32 addr;
0097 u64 vote_x[QCOM_ICC_NUM_BUCKETS];
0098 u64 vote_y[QCOM_ICC_NUM_BUCKETS];
0099 u64 vote_scale;
0100 bool dirty;
0101 bool keepalive;
0102 struct bcm_db aux_data;
0103 struct list_head list;
0104 struct list_head ws_list;
0105 size_t num_nodes;
0106 struct qcom_icc_node *nodes[];
0107 };
0108
0109 struct qcom_icc_fabric {
0110 struct qcom_icc_node **nodes;
0111 size_t num_nodes;
0112 };
0113
0114 struct qcom_icc_desc {
0115 struct qcom_icc_node * const *nodes;
0116 size_t num_nodes;
0117 struct qcom_icc_bcm * const *bcms;
0118 size_t num_bcms;
0119 };
0120
0121 #define DEFINE_QNODE(_name, _id, _channels, _buswidth, ...) \
0122 static struct qcom_icc_node _name = { \
0123 .id = _id, \
0124 .name = #_name, \
0125 .channels = _channels, \
0126 .buswidth = _buswidth, \
0127 .num_links = ARRAY_SIZE(((int[]){ __VA_ARGS__ })), \
0128 .links = { __VA_ARGS__ }, \
0129 }
0130
0131 int qcom_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
0132 u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
0133 int qcom_icc_set(struct icc_node *src, struct icc_node *dst);
0134 int qcom_icc_bcm_init(struct qcom_icc_bcm *bcm, struct device *dev);
0135 void qcom_icc_pre_aggregate(struct icc_node *node);
0136 int qcom_icc_rpmh_probe(struct platform_device *pdev);
0137 int qcom_icc_rpmh_remove(struct platform_device *pdev);
0138
0139 #endif