blob: 26dad006034fd783760cb861b2b53b42ac6d8452 [file] [log] [blame]
Jun Nie62feb142020-12-04 15:53:41 +08001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2020 Linaro Ltd
4 */
5
6#ifndef __DRIVERS_INTERCONNECT_QCOM_ICC_RPM_H
7#define __DRIVERS_INTERCONNECT_QCOM_ICC_RPM_H
8
9#define RPM_BUS_MASTER_REQ 0x73616d62
10#define RPM_BUS_SLAVE_REQ 0x766c7362
11
Jun Nie62feb142020-12-04 15:53:41 +080012#define to_qcom_provider(_provider) \
13 container_of(_provider, struct qcom_icc_provider, provider)
14
Shawn Guoe9d54c22021-12-15 08:23:20 +080015enum qcom_icc_type {
16 QCOM_ICC_NOC,
17 QCOM_ICC_BIMC,
Shawn Guo08c59042021-12-15 08:23:21 +080018 QCOM_ICC_QNOC,
Shawn Guoe9d54c22021-12-15 08:23:20 +080019};
20
Jun Nie62feb142020-12-04 15:53:41 +080021/**
22 * struct qcom_icc_provider - Qualcomm specific interconnect provider
23 * @provider: generic interconnect provider
24 * @bus_clks: the clk_bulk_data table of bus clocks
25 * @num_clks: the total number of clk_bulk_data entries
Shawn Guoe9d54c22021-12-15 08:23:20 +080026 * @type: the ICC provider type
Dmitry Baryshkov0788f4d2021-09-04 02:24:15 +030027 * @qos_offset: offset to QoS registers
Dmitry Baryshkov2b6c7d62021-09-04 02:24:14 +030028 * @regmap: regmap for QoS registers read/write access
Jun Nie62feb142020-12-04 15:53:41 +080029 */
30struct qcom_icc_provider {
31 struct icc_provider provider;
Jun Nie62feb142020-12-04 15:53:41 +080032 int num_clks;
Shawn Guoe9d54c22021-12-15 08:23:20 +080033 enum qcom_icc_type type;
Dmitry Baryshkov2b6c7d62021-09-04 02:24:14 +030034 struct regmap *regmap;
Dmitry Baryshkov0788f4d2021-09-04 02:24:15 +030035 unsigned int qos_offset;
Dmitry Baryshkov63e8ab62021-09-04 02:24:11 +030036 struct clk_bulk_data bus_clks[];
Jun Nie62feb142020-12-04 15:53:41 +080037};
38
39/**
Dmitry Baryshkov2b6c7d62021-09-04 02:24:14 +030040 * struct qcom_icc_qos - Qualcomm specific interconnect QoS parameters
41 * @areq_prio: node requests priority
42 * @prio_level: priority level for bus communication
43 * @limit_commands: activate/deactivate limiter mode during runtime
44 * @ap_owned: indicates if the node is owned by the AP or by the RPM
45 * @qos_mode: default qos mode for this node
46 * @qos_port: qos port number for finding qos registers of this node
Shawn Guo08c59042021-12-15 08:23:21 +080047 * @urg_fwd_en: enable urgent forwarding
Dmitry Baryshkov2b6c7d62021-09-04 02:24:14 +030048 */
49struct qcom_icc_qos {
50 u32 areq_prio;
51 u32 prio_level;
52 bool limit_commands;
53 bool ap_owned;
54 int qos_mode;
55 int qos_port;
Shawn Guo08c59042021-12-15 08:23:21 +080056 bool urg_fwd_en;
Dmitry Baryshkov2b6c7d62021-09-04 02:24:14 +030057};
58
59/**
Jun Nie62feb142020-12-04 15:53:41 +080060 * struct qcom_icc_node - Qualcomm specific interconnect nodes
61 * @name: the node name used in debugfs
62 * @id: a unique node identifier
63 * @links: an array of nodes where we can go next while traversing
64 * @num_links: the total number of @links
65 * @buswidth: width of the interconnect between a node and the bus (bytes)
66 * @mas_rpm_id: RPM id for devices that are bus masters
67 * @slv_rpm_id: RPM id for devices that are bus slaves
Dmitry Baryshkov2b6c7d62021-09-04 02:24:14 +030068 * @qos: NoC QoS setting parameters
Jun Nie62feb142020-12-04 15:53:41 +080069 * @rate: current bus clock rate in Hz
70 */
71struct qcom_icc_node {
72 unsigned char *name;
73 u16 id;
Dmitry Baryshkov2b6c7d62021-09-04 02:24:14 +030074 const u16 *links;
Jun Nie62feb142020-12-04 15:53:41 +080075 u16 num_links;
76 u16 buswidth;
77 int mas_rpm_id;
78 int slv_rpm_id;
Dmitry Baryshkov2b6c7d62021-09-04 02:24:14 +030079 struct qcom_icc_qos qos;
Jun Nie62feb142020-12-04 15:53:41 +080080 u64 rate;
81};
82
83struct qcom_icc_desc {
84 struct qcom_icc_node **nodes;
85 size_t num_nodes;
Dmitry Baryshkov2b6c7d62021-09-04 02:24:14 +030086 const char * const *clocks;
87 size_t num_clocks;
Yassine Oudjana7de109c2021-10-21 13:24:42 +000088 bool has_bus_pd;
Shawn Guoe9d54c22021-12-15 08:23:20 +080089 enum qcom_icc_type type;
Dmitry Baryshkov2b6c7d62021-09-04 02:24:14 +030090 const struct regmap_config *regmap_cfg;
Dmitry Baryshkov0788f4d2021-09-04 02:24:15 +030091 unsigned int qos_offset;
Jun Nie62feb142020-12-04 15:53:41 +080092};
93
Dmitry Baryshkov2b6c7d62021-09-04 02:24:14 +030094/* Valid for both NoC and BIMC */
95#define NOC_QOS_MODE_INVALID -1
96#define NOC_QOS_MODE_FIXED 0x0
97#define NOC_QOS_MODE_BYPASS 0x2
Jun Nie62feb142020-12-04 15:53:41 +080098
Dmitry Baryshkov63e8ab62021-09-04 02:24:11 +030099int qnoc_probe(struct platform_device *pdev);
Jun Nie62feb142020-12-04 15:53:41 +0800100int qnoc_remove(struct platform_device *pdev);
101
102#endif