Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
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  * struct qcom_icc_provider - Qualcomm specific interconnect provider
0016  * @provider: generic interconnect provider
0017  * @dev: reference to the NoC device
0018  * @bcms: list of bcms that maps to the provider
0019  * @num_bcms: number of @bcms
0020  * @voter: bcm voter targeted by this provider
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  * struct bcm_db - Auxiliary data pertaining to each Bus Clock Manager (BCM)
0032  * @unit: divisor used to convert bytes/sec bw value to an RPMh msg
0033  * @width: multiplier used to convert bytes/sec bw value to an RPMh msg
0034  * @vcd: virtual clock domain that this bcm belongs to
0035  * @reserved: reserved field
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  * struct qcom_icc_node - Qualcomm specific interconnect nodes
0051  * @name: the node name used in debugfs
0052  * @links: an array of nodes where we can go next while traversing
0053  * @id: a unique node identifier
0054  * @num_links: the total number of @links
0055  * @channels: num of channels at this node
0056  * @buswidth: width of the interconnect between a node and the bus
0057  * @sum_avg: current sum aggregate value of all avg bw requests
0058  * @max_peak: current max aggregate value of all peak bw requests
0059  * @bcms: list of bcms associated with this logical node
0060  * @num_bcms: num of @bcms
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  * struct qcom_icc_bcm - Qualcomm specific hardware accelerator nodes
0077  * known as Bus Clock Manager (BCM)
0078  * @name: the bcm node name used to fetch BCM data from command db
0079  * @type: latency or bandwidth bcm
0080  * @addr: address offsets used when voting to RPMH
0081  * @vote_x: aggregated threshold values, represents sum_bw when @type is bw bcm
0082  * @vote_y: aggregated threshold values, represents peak_bw when @type is bw bcm
0083  * @vote_scale: scaling factor for vote_x and vote_y
0084  * @dirty: flag used to indicate whether the bcm needs to be committed
0085  * @keepalive: flag used to indicate whether a keepalive is required
0086  * @aux_data: auxiliary data used when calculating threshold values and
0087  * communicating with RPMh
0088  * @list: used to link to other bcms when compiling lists for commit
0089  * @ws_list: used to keep track of bcms that may transition between wake/sleep
0090  * @num_nodes: total number of @num_nodes
0091  * @nodes: list of qcom_icc_nodes that this BCM encapsulates
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