162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2020, The Linux Foundation. All rights reserved. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef __DRIVERS_INTERCONNECT_QCOM_ICC_RPMH_H__ 762306a36Sopenharmony_ci#define __DRIVERS_INTERCONNECT_QCOM_ICC_RPMH_H__ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#include <dt-bindings/interconnect/qcom,icc.h> 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#define to_qcom_provider(_provider) \ 1262306a36Sopenharmony_ci container_of(_provider, struct qcom_icc_provider, provider) 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci/** 1562306a36Sopenharmony_ci * struct qcom_icc_provider - Qualcomm specific interconnect provider 1662306a36Sopenharmony_ci * @provider: generic interconnect provider 1762306a36Sopenharmony_ci * @dev: reference to the NoC device 1862306a36Sopenharmony_ci * @bcms: list of bcms that maps to the provider 1962306a36Sopenharmony_ci * @num_bcms: number of @bcms 2062306a36Sopenharmony_ci * @voter: bcm voter targeted by this provider 2162306a36Sopenharmony_ci */ 2262306a36Sopenharmony_cistruct qcom_icc_provider { 2362306a36Sopenharmony_ci struct icc_provider provider; 2462306a36Sopenharmony_ci struct device *dev; 2562306a36Sopenharmony_ci struct qcom_icc_bcm * const *bcms; 2662306a36Sopenharmony_ci size_t num_bcms; 2762306a36Sopenharmony_ci struct bcm_voter *voter; 2862306a36Sopenharmony_ci}; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci/** 3162306a36Sopenharmony_ci * struct bcm_db - Auxiliary data pertaining to each Bus Clock Manager (BCM) 3262306a36Sopenharmony_ci * @unit: divisor used to convert bytes/sec bw value to an RPMh msg 3362306a36Sopenharmony_ci * @width: multiplier used to convert bytes/sec bw value to an RPMh msg 3462306a36Sopenharmony_ci * @vcd: virtual clock domain that this bcm belongs to 3562306a36Sopenharmony_ci * @reserved: reserved field 3662306a36Sopenharmony_ci */ 3762306a36Sopenharmony_cistruct bcm_db { 3862306a36Sopenharmony_ci __le32 unit; 3962306a36Sopenharmony_ci __le16 width; 4062306a36Sopenharmony_ci u8 vcd; 4162306a36Sopenharmony_ci u8 reserved; 4262306a36Sopenharmony_ci}; 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci#define MAX_LINKS 128 4562306a36Sopenharmony_ci#define MAX_BCMS 64 4662306a36Sopenharmony_ci#define MAX_BCM_PER_NODE 3 4762306a36Sopenharmony_ci#define MAX_VCD 10 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/** 5062306a36Sopenharmony_ci * struct qcom_icc_node - Qualcomm specific interconnect nodes 5162306a36Sopenharmony_ci * @name: the node name used in debugfs 5262306a36Sopenharmony_ci * @links: an array of nodes where we can go next while traversing 5362306a36Sopenharmony_ci * @id: a unique node identifier 5462306a36Sopenharmony_ci * @num_links: the total number of @links 5562306a36Sopenharmony_ci * @channels: num of channels at this node 5662306a36Sopenharmony_ci * @buswidth: width of the interconnect between a node and the bus 5762306a36Sopenharmony_ci * @sum_avg: current sum aggregate value of all avg bw requests 5862306a36Sopenharmony_ci * @max_peak: current max aggregate value of all peak bw requests 5962306a36Sopenharmony_ci * @bcms: list of bcms associated with this logical node 6062306a36Sopenharmony_ci * @num_bcms: num of @bcms 6162306a36Sopenharmony_ci */ 6262306a36Sopenharmony_cistruct qcom_icc_node { 6362306a36Sopenharmony_ci const char *name; 6462306a36Sopenharmony_ci u16 links[MAX_LINKS]; 6562306a36Sopenharmony_ci u16 id; 6662306a36Sopenharmony_ci u16 num_links; 6762306a36Sopenharmony_ci u16 channels; 6862306a36Sopenharmony_ci u16 buswidth; 6962306a36Sopenharmony_ci u64 sum_avg[QCOM_ICC_NUM_BUCKETS]; 7062306a36Sopenharmony_ci u64 max_peak[QCOM_ICC_NUM_BUCKETS]; 7162306a36Sopenharmony_ci struct qcom_icc_bcm *bcms[MAX_BCM_PER_NODE]; 7262306a36Sopenharmony_ci size_t num_bcms; 7362306a36Sopenharmony_ci}; 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci/** 7662306a36Sopenharmony_ci * struct qcom_icc_bcm - Qualcomm specific hardware accelerator nodes 7762306a36Sopenharmony_ci * known as Bus Clock Manager (BCM) 7862306a36Sopenharmony_ci * @name: the bcm node name used to fetch BCM data from command db 7962306a36Sopenharmony_ci * @type: latency or bandwidth bcm 8062306a36Sopenharmony_ci * @addr: address offsets used when voting to RPMH 8162306a36Sopenharmony_ci * @vote_x: aggregated threshold values, represents sum_bw when @type is bw bcm 8262306a36Sopenharmony_ci * @vote_y: aggregated threshold values, represents peak_bw when @type is bw bcm 8362306a36Sopenharmony_ci * @vote_scale: scaling factor for vote_x and vote_y 8462306a36Sopenharmony_ci * @enable_mask: optional mask to send as vote instead of vote_x/vote_y 8562306a36Sopenharmony_ci * @dirty: flag used to indicate whether the bcm needs to be committed 8662306a36Sopenharmony_ci * @keepalive: flag used to indicate whether a keepalive is required 8762306a36Sopenharmony_ci * @aux_data: auxiliary data used when calculating threshold values and 8862306a36Sopenharmony_ci * communicating with RPMh 8962306a36Sopenharmony_ci * @list: used to link to other bcms when compiling lists for commit 9062306a36Sopenharmony_ci * @ws_list: used to keep track of bcms that may transition between wake/sleep 9162306a36Sopenharmony_ci * @num_nodes: total number of @num_nodes 9262306a36Sopenharmony_ci * @nodes: list of qcom_icc_nodes that this BCM encapsulates 9362306a36Sopenharmony_ci */ 9462306a36Sopenharmony_cistruct qcom_icc_bcm { 9562306a36Sopenharmony_ci const char *name; 9662306a36Sopenharmony_ci u32 type; 9762306a36Sopenharmony_ci u32 addr; 9862306a36Sopenharmony_ci u64 vote_x[QCOM_ICC_NUM_BUCKETS]; 9962306a36Sopenharmony_ci u64 vote_y[QCOM_ICC_NUM_BUCKETS]; 10062306a36Sopenharmony_ci u64 vote_scale; 10162306a36Sopenharmony_ci u32 enable_mask; 10262306a36Sopenharmony_ci bool dirty; 10362306a36Sopenharmony_ci bool keepalive; 10462306a36Sopenharmony_ci struct bcm_db aux_data; 10562306a36Sopenharmony_ci struct list_head list; 10662306a36Sopenharmony_ci struct list_head ws_list; 10762306a36Sopenharmony_ci size_t num_nodes; 10862306a36Sopenharmony_ci struct qcom_icc_node *nodes[]; 10962306a36Sopenharmony_ci}; 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_cistruct qcom_icc_fabric { 11262306a36Sopenharmony_ci struct qcom_icc_node **nodes; 11362306a36Sopenharmony_ci size_t num_nodes; 11462306a36Sopenharmony_ci}; 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_cistruct qcom_icc_desc { 11762306a36Sopenharmony_ci struct qcom_icc_node * const *nodes; 11862306a36Sopenharmony_ci size_t num_nodes; 11962306a36Sopenharmony_ci struct qcom_icc_bcm * const *bcms; 12062306a36Sopenharmony_ci size_t num_bcms; 12162306a36Sopenharmony_ci}; 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ciint qcom_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw, 12462306a36Sopenharmony_ci u32 peak_bw, u32 *agg_avg, u32 *agg_peak); 12562306a36Sopenharmony_ciint qcom_icc_set(struct icc_node *src, struct icc_node *dst); 12662306a36Sopenharmony_ciint qcom_icc_bcm_init(struct qcom_icc_bcm *bcm, struct device *dev); 12762306a36Sopenharmony_civoid qcom_icc_pre_aggregate(struct icc_node *node); 12862306a36Sopenharmony_ciint qcom_icc_rpmh_probe(struct platform_device *pdev); 12962306a36Sopenharmony_ciint qcom_icc_rpmh_remove(struct platform_device *pdev); 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ci#endif 132