162feb14eSJun Nie /* SPDX-License-Identifier: GPL-2.0 */ 262feb14eSJun Nie /* 362feb14eSJun Nie * Copyright (C) 2020 Linaro Ltd 462feb14eSJun Nie */ 562feb14eSJun Nie 662feb14eSJun Nie #ifndef __DRIVERS_INTERCONNECT_QCOM_ICC_RPM_H 762feb14eSJun Nie #define __DRIVERS_INTERCONNECT_QCOM_ICC_RPM_H 862feb14eSJun Nie 9dcbce7b0SLeo Yan #include <dt-bindings/interconnect/qcom,icc.h> 10*40cdeed6SKonrad Dybcio #include <linux/clk.h> 11*40cdeed6SKonrad Dybcio #include <linux/interconnect-provider.h> 12*40cdeed6SKonrad Dybcio #include <linux/platform_device.h> 13dcbce7b0SLeo Yan 1462feb14eSJun Nie #define RPM_BUS_MASTER_REQ 0x73616d62 1562feb14eSJun Nie #define RPM_BUS_SLAVE_REQ 0x766c7362 1662feb14eSJun Nie 1762feb14eSJun Nie #define to_qcom_provider(_provider) \ 1862feb14eSJun Nie container_of(_provider, struct qcom_icc_provider, provider) 1962feb14eSJun Nie 20e9d54c26SShawn Guo enum qcom_icc_type { 21e9d54c26SShawn Guo QCOM_ICC_NOC, 22e9d54c26SShawn Guo QCOM_ICC_BIMC, 2308c59040SShawn Guo QCOM_ICC_QNOC, 24e9d54c26SShawn Guo }; 25e9d54c26SShawn Guo 262e2113c8SKonrad Dybcio #define NUM_BUS_CLKS 2 272e2113c8SKonrad Dybcio 2862feb14eSJun Nie /** 2962feb14eSJun Nie * struct qcom_icc_provider - Qualcomm specific interconnect provider 3062feb14eSJun Nie * @provider: generic interconnect provider 31a867cf9bSKonrad Dybcio * @num_bus_clks: the total number of bus_clks clk_bulk_data entries (0 or 2) 322e2113c8SKonrad Dybcio * @num_intf_clks: the total number of intf_clks clk_bulk_data entries 33e9d54c26SShawn Guo * @type: the ICC provider type 342b6c7d64SDmitry Baryshkov * @regmap: regmap for QoS registers read/write access 3582a4b285SKonrad Dybcio * @qos_offset: offset to QoS registers 3665fac3b3SLeo Yan * @bus_clk_rate: bus clock rate in Hz 3782a4b285SKonrad Dybcio * @bus_clks: the clk_bulk_data table of bus clocks 382e2113c8SKonrad Dybcio * @intf_clks: a clk_bulk_data array of interface clocks 39b979049cSKonrad Dybcio * @keep_alive: whether to always keep a minimum vote on the bus clocks 402e2113c8SKonrad Dybcio * @is_on: whether the bus is powered on 4162feb14eSJun Nie */ 4262feb14eSJun Nie struct qcom_icc_provider { 4362feb14eSJun Nie struct icc_provider provider; 441a12928eSKonrad Dybcio int num_bus_clks; 452e2113c8SKonrad Dybcio int num_intf_clks; 46e9d54c26SShawn Guo enum qcom_icc_type type; 472b6c7d64SDmitry Baryshkov struct regmap *regmap; 480788f4d5SDmitry Baryshkov unsigned int qos_offset; 492e2113c8SKonrad Dybcio u64 bus_clk_rate[NUM_BUS_CLKS]; 502e2113c8SKonrad Dybcio struct clk_bulk_data bus_clks[NUM_BUS_CLKS]; 512e2113c8SKonrad Dybcio struct clk_bulk_data *intf_clks; 52b979049cSKonrad Dybcio bool keep_alive; 532e2113c8SKonrad Dybcio bool is_on; 5462feb14eSJun Nie }; 5562feb14eSJun Nie 5662feb14eSJun Nie /** 572b6c7d64SDmitry Baryshkov * struct qcom_icc_qos - Qualcomm specific interconnect QoS parameters 582b6c7d64SDmitry Baryshkov * @areq_prio: node requests priority 592b6c7d64SDmitry Baryshkov * @prio_level: priority level for bus communication 602b6c7d64SDmitry Baryshkov * @limit_commands: activate/deactivate limiter mode during runtime 612b6c7d64SDmitry Baryshkov * @ap_owned: indicates if the node is owned by the AP or by the RPM 622b6c7d64SDmitry Baryshkov * @qos_mode: default qos mode for this node 632b6c7d64SDmitry Baryshkov * @qos_port: qos port number for finding qos registers of this node 6408c59040SShawn Guo * @urg_fwd_en: enable urgent forwarding 652b6c7d64SDmitry Baryshkov */ 662b6c7d64SDmitry Baryshkov struct qcom_icc_qos { 672b6c7d64SDmitry Baryshkov u32 areq_prio; 682b6c7d64SDmitry Baryshkov u32 prio_level; 692b6c7d64SDmitry Baryshkov bool limit_commands; 702b6c7d64SDmitry Baryshkov bool ap_owned; 712b6c7d64SDmitry Baryshkov int qos_mode; 722b6c7d64SDmitry Baryshkov int qos_port; 7308c59040SShawn Guo bool urg_fwd_en; 742b6c7d64SDmitry Baryshkov }; 752b6c7d64SDmitry Baryshkov 762b6c7d64SDmitry Baryshkov /** 7762feb14eSJun Nie * struct qcom_icc_node - Qualcomm specific interconnect nodes 7862feb14eSJun Nie * @name: the node name used in debugfs 7962feb14eSJun Nie * @id: a unique node identifier 8062feb14eSJun Nie * @links: an array of nodes where we can go next while traversing 8162feb14eSJun Nie * @num_links: the total number of @links 8202819953SKonrad Dybcio * @channels: number of channels at this node (e.g. DDR channels) 8362feb14eSJun Nie * @buswidth: width of the interconnect between a node and the bus (bytes) 84dcbce7b0SLeo Yan * @sum_avg: current sum aggregate value of all avg bw requests 85dcbce7b0SLeo Yan * @max_peak: current max aggregate value of all peak bw requests 8662feb14eSJun Nie * @mas_rpm_id: RPM id for devices that are bus masters 8762feb14eSJun Nie * @slv_rpm_id: RPM id for devices that are bus slaves 882b6c7d64SDmitry Baryshkov * @qos: NoC QoS setting parameters 8962feb14eSJun Nie */ 9062feb14eSJun Nie struct qcom_icc_node { 9162feb14eSJun Nie unsigned char *name; 9262feb14eSJun Nie u16 id; 932b6c7d64SDmitry Baryshkov const u16 *links; 9462feb14eSJun Nie u16 num_links; 9502819953SKonrad Dybcio u16 channels; 9662feb14eSJun Nie u16 buswidth; 97dcbce7b0SLeo Yan u64 sum_avg[QCOM_ICC_NUM_BUCKETS]; 98dcbce7b0SLeo Yan u64 max_peak[QCOM_ICC_NUM_BUCKETS]; 9962feb14eSJun Nie int mas_rpm_id; 10062feb14eSJun Nie int slv_rpm_id; 1012b6c7d64SDmitry Baryshkov struct qcom_icc_qos qos; 10262feb14eSJun Nie }; 10362feb14eSJun Nie 10462feb14eSJun Nie struct qcom_icc_desc { 1052ccf33c0SKrzysztof Kozlowski struct qcom_icc_node * const *nodes; 10662feb14eSJun Nie size_t num_nodes; 1076643b532SKonrad Dybcio const char * const *bus_clocks; 1082e2113c8SKonrad Dybcio const char * const *intf_clocks; 1092e2113c8SKonrad Dybcio size_t num_intf_clocks; 110b979049cSKonrad Dybcio bool keep_alive; 111a867cf9bSKonrad Dybcio bool no_clk_scaling; 112e9d54c26SShawn Guo enum qcom_icc_type type; 1132b6c7d64SDmitry Baryshkov const struct regmap_config *regmap_cfg; 1140788f4d5SDmitry Baryshkov unsigned int qos_offset; 11562feb14eSJun Nie }; 11662feb14eSJun Nie 1171d779317SKonrad Dybcio /* Valid for all bus types */ 1181d779317SKonrad Dybcio enum qos_mode { 1191d779317SKonrad Dybcio NOC_QOS_MODE_INVALID = 0, 1201d779317SKonrad Dybcio NOC_QOS_MODE_FIXED, 1211d779317SKonrad Dybcio NOC_QOS_MODE_BYPASS, 1221d779317SKonrad Dybcio }; 12362feb14eSJun Nie 12463e8ab61SDmitry Baryshkov int qnoc_probe(struct platform_device *pdev); 12562feb14eSJun Nie int qnoc_remove(struct platform_device *pdev); 12662feb14eSJun Nie 12762feb14eSJun Nie #endif 128