1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020 Linaro Ltd
6 #ifndef __DRIVERS_INTERCONNECT_QCOM_ICC_RPM_H
7 #define __DRIVERS_INTERCONNECT_QCOM_ICC_RPM_H
9 #include <linux/soc/qcom/smd-rpm.h>
11 #include <dt-bindings/interconnect/qcom,rpm-icc.h>
12 #include <linux/clk.h>
13 #include <linux/interconnect-provider.h>
14 #include <linux/platform_device.h>
16 #define RPM_BUS_MASTER_REQ 0x73616d62
17 #define RPM_BUS_SLAVE_REQ 0x766c7362
19 #define to_qcom_provider(_provider) \
20 container_of(_provider, struct qcom_icc_provider, provider)
29 * struct rpm_clk_resource - RPM bus clock resource
30 * @resource_type: RPM resource type of the clock resource
31 * @clock_id: index of the clock resource of a specific resource type
32 * @branch: whether the resource represents a branch clock
34 struct rpm_clk_resource
{
41 * struct qcom_icc_provider - Qualcomm specific interconnect provider
42 * @provider: generic interconnect provider
43 * @num_intf_clks: the total number of intf_clks clk_bulk_data entries
44 * @type: the ICC provider type
45 * @regmap: regmap for QoS registers read/write access
46 * @qos_offset: offset to QoS registers
47 * @ab_coeff: a percentage-based coefficient for compensating the AB calculations
48 * @ib_coeff: an inverse-percentage-based coefficient for compensating the IB calculations
49 * @bus_clk_rate: bus clock rate in Hz
50 * @bus_clk_desc: a pointer to a rpm_clk_resource description of bus clocks
51 * @bus_clk: a pointer to a HLOS-owned bus clock
52 * @intf_clks: a clk_bulk_data array of interface clocks
53 * @keep_alive: whether to always keep a minimum vote on the bus clocks
54 * @is_on: whether the bus is powered on
56 struct qcom_icc_provider
{
57 struct icc_provider provider
;
59 enum qcom_icc_type type
;
60 struct regmap
*regmap
;
61 unsigned int qos_offset
;
64 u32 bus_clk_rate
[QCOM_SMD_RPM_STATE_NUM
];
65 const struct rpm_clk_resource
*bus_clk_desc
;
67 struct clk_bulk_data
*intf_clks
;
73 * struct qcom_icc_qos - Qualcomm specific interconnect QoS parameters
74 * @areq_prio: node requests priority
75 * @prio_level: priority level for bus communication
76 * @limit_commands: activate/deactivate limiter mode during runtime
77 * @ap_owned: indicates if the node is owned by the AP or by the RPM
78 * @qos_mode: default qos mode for this node
79 * @qos_port: qos port number for finding qos registers of this node
80 * @urg_fwd_en: enable urgent forwarding
93 * struct qcom_icc_node - Qualcomm specific interconnect nodes
94 * @name: the node name used in debugfs
95 * @id: a unique node identifier
96 * @links: an array of nodes where we can go next while traversing
97 * @num_links: the total number of @links
98 * @channels: number of channels at this node (e.g. DDR channels)
99 * @buswidth: width of the interconnect between a node and the bus (bytes)
100 * @bus_clk_desc: a pointer to a rpm_clk_resource description of bus clocks
101 * @sum_avg: current sum aggregate value of all avg bw requests
102 * @max_peak: current max aggregate value of all peak bw requests
103 * @mas_rpm_id: RPM id for devices that are bus masters
104 * @slv_rpm_id: RPM id for devices that are bus slaves
105 * @qos: NoC QoS setting parameters
106 * @ab_coeff: a percentage-based coefficient for compensating the AB calculations
107 * @ib_coeff: an inverse-percentage-based coefficient for compensating the IB calculations
108 * @bus_clk_rate: a pointer to an array containing bus clock rates in Hz
110 struct qcom_icc_node
{
117 const struct rpm_clk_resource
*bus_clk_desc
;
118 u64 sum_avg
[QCOM_SMD_RPM_STATE_NUM
];
119 u64 max_peak
[QCOM_SMD_RPM_STATE_NUM
];
122 struct qcom_icc_qos qos
;
125 u32 bus_clk_rate
[QCOM_SMD_RPM_STATE_NUM
];
128 struct qcom_icc_desc
{
129 struct qcom_icc_node
* const *nodes
;
131 const struct rpm_clk_resource
*bus_clk_desc
;
132 const char * const *intf_clocks
;
133 size_t num_intf_clocks
;
135 enum qcom_icc_type type
;
136 const struct regmap_config
*regmap_cfg
;
137 unsigned int qos_offset
;
142 /* Valid for all bus types */
144 NOC_QOS_MODE_INVALID
= 0,
149 extern const struct rpm_clk_resource aggre1_clk
;
150 extern const struct rpm_clk_resource aggre2_clk
;
151 extern const struct rpm_clk_resource bimc_clk
;
152 extern const struct rpm_clk_resource bus_0_clk
;
153 extern const struct rpm_clk_resource bus_1_clk
;
154 extern const struct rpm_clk_resource bus_2_clk
;
155 extern const struct rpm_clk_resource mem_1_clk
;
156 extern const struct rpm_clk_resource mmaxi_0_clk
;
157 extern const struct rpm_clk_resource mmaxi_1_clk
;
158 extern const struct rpm_clk_resource qup_clk
;
160 extern const struct rpm_clk_resource aggre1_branch_clk
;
161 extern const struct rpm_clk_resource aggre2_branch_clk
;
163 int qnoc_probe(struct platform_device
*pdev
);
164 void qnoc_remove(struct platform_device
*pdev
);
166 bool qcom_icc_rpm_smd_available(void);
167 int qcom_icc_rpm_smd_send(int ctx
, int rsc_type
, int id
, u32 val
);
168 int qcom_icc_rpm_set_bus_rate(const struct rpm_clk_resource
*clk
, int ctx
, u32 rate
);