18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2019 Linaro Ltd
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <dt-bindings/interconnect/qcom,qcs404.h>
78c2ecf20Sopenharmony_ci#include <linux/clk.h>
88c2ecf20Sopenharmony_ci#include <linux/device.h>
98c2ecf20Sopenharmony_ci#include <linux/interconnect-provider.h>
108c2ecf20Sopenharmony_ci#include <linux/io.h>
118c2ecf20Sopenharmony_ci#include <linux/module.h>
128c2ecf20Sopenharmony_ci#include <linux/of_device.h>
138c2ecf20Sopenharmony_ci#include <linux/of_platform.h>
148c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
158c2ecf20Sopenharmony_ci#include <linux/slab.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include "smd-rpm.h"
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define RPM_BUS_MASTER_REQ	0x73616d62
208c2ecf20Sopenharmony_ci#define RPM_BUS_SLAVE_REQ	0x766c7362
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cienum {
238c2ecf20Sopenharmony_ci	QCS404_MASTER_AMPSS_M0 = 1,
248c2ecf20Sopenharmony_ci	QCS404_MASTER_GRAPHICS_3D,
258c2ecf20Sopenharmony_ci	QCS404_MASTER_MDP_PORT0,
268c2ecf20Sopenharmony_ci	QCS404_SNOC_BIMC_1_MAS,
278c2ecf20Sopenharmony_ci	QCS404_MASTER_TCU_0,
288c2ecf20Sopenharmony_ci	QCS404_MASTER_SPDM,
298c2ecf20Sopenharmony_ci	QCS404_MASTER_BLSP_1,
308c2ecf20Sopenharmony_ci	QCS404_MASTER_BLSP_2,
318c2ecf20Sopenharmony_ci	QCS404_MASTER_XM_USB_HS1,
328c2ecf20Sopenharmony_ci	QCS404_MASTER_CRYPTO_CORE0,
338c2ecf20Sopenharmony_ci	QCS404_MASTER_SDCC_1,
348c2ecf20Sopenharmony_ci	QCS404_MASTER_SDCC_2,
358c2ecf20Sopenharmony_ci	QCS404_SNOC_PNOC_MAS,
368c2ecf20Sopenharmony_ci	QCS404_MASTER_QPIC,
378c2ecf20Sopenharmony_ci	QCS404_MASTER_QDSS_BAM,
388c2ecf20Sopenharmony_ci	QCS404_BIMC_SNOC_MAS,
398c2ecf20Sopenharmony_ci	QCS404_PNOC_SNOC_MAS,
408c2ecf20Sopenharmony_ci	QCS404_MASTER_QDSS_ETR,
418c2ecf20Sopenharmony_ci	QCS404_MASTER_EMAC,
428c2ecf20Sopenharmony_ci	QCS404_MASTER_PCIE,
438c2ecf20Sopenharmony_ci	QCS404_MASTER_USB3,
448c2ecf20Sopenharmony_ci	QCS404_PNOC_INT_0,
458c2ecf20Sopenharmony_ci	QCS404_PNOC_INT_2,
468c2ecf20Sopenharmony_ci	QCS404_PNOC_INT_3,
478c2ecf20Sopenharmony_ci	QCS404_PNOC_SLV_0,
488c2ecf20Sopenharmony_ci	QCS404_PNOC_SLV_1,
498c2ecf20Sopenharmony_ci	QCS404_PNOC_SLV_2,
508c2ecf20Sopenharmony_ci	QCS404_PNOC_SLV_3,
518c2ecf20Sopenharmony_ci	QCS404_PNOC_SLV_4,
528c2ecf20Sopenharmony_ci	QCS404_PNOC_SLV_6,
538c2ecf20Sopenharmony_ci	QCS404_PNOC_SLV_7,
548c2ecf20Sopenharmony_ci	QCS404_PNOC_SLV_8,
558c2ecf20Sopenharmony_ci	QCS404_PNOC_SLV_9,
568c2ecf20Sopenharmony_ci	QCS404_PNOC_SLV_10,
578c2ecf20Sopenharmony_ci	QCS404_PNOC_SLV_11,
588c2ecf20Sopenharmony_ci	QCS404_SNOC_QDSS_INT,
598c2ecf20Sopenharmony_ci	QCS404_SNOC_INT_0,
608c2ecf20Sopenharmony_ci	QCS404_SNOC_INT_1,
618c2ecf20Sopenharmony_ci	QCS404_SNOC_INT_2,
628c2ecf20Sopenharmony_ci	QCS404_SLAVE_EBI_CH0,
638c2ecf20Sopenharmony_ci	QCS404_BIMC_SNOC_SLV,
648c2ecf20Sopenharmony_ci	QCS404_SLAVE_SPDM_WRAPPER,
658c2ecf20Sopenharmony_ci	QCS404_SLAVE_PDM,
668c2ecf20Sopenharmony_ci	QCS404_SLAVE_PRNG,
678c2ecf20Sopenharmony_ci	QCS404_SLAVE_TCSR,
688c2ecf20Sopenharmony_ci	QCS404_SLAVE_SNOC_CFG,
698c2ecf20Sopenharmony_ci	QCS404_SLAVE_MESSAGE_RAM,
708c2ecf20Sopenharmony_ci	QCS404_SLAVE_DISPLAY_CFG,
718c2ecf20Sopenharmony_ci	QCS404_SLAVE_GRAPHICS_3D_CFG,
728c2ecf20Sopenharmony_ci	QCS404_SLAVE_BLSP_1,
738c2ecf20Sopenharmony_ci	QCS404_SLAVE_TLMM_NORTH,
748c2ecf20Sopenharmony_ci	QCS404_SLAVE_PCIE_1,
758c2ecf20Sopenharmony_ci	QCS404_SLAVE_EMAC_CFG,
768c2ecf20Sopenharmony_ci	QCS404_SLAVE_BLSP_2,
778c2ecf20Sopenharmony_ci	QCS404_SLAVE_TLMM_EAST,
788c2ecf20Sopenharmony_ci	QCS404_SLAVE_TCU,
798c2ecf20Sopenharmony_ci	QCS404_SLAVE_PMIC_ARB,
808c2ecf20Sopenharmony_ci	QCS404_SLAVE_SDCC_1,
818c2ecf20Sopenharmony_ci	QCS404_SLAVE_SDCC_2,
828c2ecf20Sopenharmony_ci	QCS404_SLAVE_TLMM_SOUTH,
838c2ecf20Sopenharmony_ci	QCS404_SLAVE_USB_HS,
848c2ecf20Sopenharmony_ci	QCS404_SLAVE_USB3,
858c2ecf20Sopenharmony_ci	QCS404_SLAVE_CRYPTO_0_CFG,
868c2ecf20Sopenharmony_ci	QCS404_PNOC_SNOC_SLV,
878c2ecf20Sopenharmony_ci	QCS404_SLAVE_APPSS,
888c2ecf20Sopenharmony_ci	QCS404_SLAVE_WCSS,
898c2ecf20Sopenharmony_ci	QCS404_SNOC_BIMC_1_SLV,
908c2ecf20Sopenharmony_ci	QCS404_SLAVE_OCIMEM,
918c2ecf20Sopenharmony_ci	QCS404_SNOC_PNOC_SLV,
928c2ecf20Sopenharmony_ci	QCS404_SLAVE_QDSS_STM,
938c2ecf20Sopenharmony_ci	QCS404_SLAVE_CATS_128,
948c2ecf20Sopenharmony_ci	QCS404_SLAVE_OCMEM_64,
958c2ecf20Sopenharmony_ci	QCS404_SLAVE_LPASS,
968c2ecf20Sopenharmony_ci};
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define to_qcom_provider(_provider) \
998c2ecf20Sopenharmony_ci	container_of(_provider, struct qcom_icc_provider, provider)
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_cistatic const struct clk_bulk_data bus_clocks[] = {
1028c2ecf20Sopenharmony_ci	{ .id = "bus" },
1038c2ecf20Sopenharmony_ci	{ .id = "bus_a" },
1048c2ecf20Sopenharmony_ci};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci/**
1078c2ecf20Sopenharmony_ci * struct qcom_icc_provider - Qualcomm specific interconnect provider
1088c2ecf20Sopenharmony_ci * @provider: generic interconnect provider
1098c2ecf20Sopenharmony_ci * @bus_clks: the clk_bulk_data table of bus clocks
1108c2ecf20Sopenharmony_ci * @num_clks: the total number of clk_bulk_data entries
1118c2ecf20Sopenharmony_ci */
1128c2ecf20Sopenharmony_cistruct qcom_icc_provider {
1138c2ecf20Sopenharmony_ci	struct icc_provider provider;
1148c2ecf20Sopenharmony_ci	struct clk_bulk_data *bus_clks;
1158c2ecf20Sopenharmony_ci	int num_clks;
1168c2ecf20Sopenharmony_ci};
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci#define QCS404_MAX_LINKS	12
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci/**
1218c2ecf20Sopenharmony_ci * struct qcom_icc_node - Qualcomm specific interconnect nodes
1228c2ecf20Sopenharmony_ci * @name: the node name used in debugfs
1238c2ecf20Sopenharmony_ci * @id: a unique node identifier
1248c2ecf20Sopenharmony_ci * @links: an array of nodes where we can go next while traversing
1258c2ecf20Sopenharmony_ci * @num_links: the total number of @links
1268c2ecf20Sopenharmony_ci * @buswidth: width of the interconnect between a node and the bus (bytes)
1278c2ecf20Sopenharmony_ci * @mas_rpm_id:	RPM id for devices that are bus masters
1288c2ecf20Sopenharmony_ci * @slv_rpm_id:	RPM id for devices that are bus slaves
1298c2ecf20Sopenharmony_ci * @rate: current bus clock rate in Hz
1308c2ecf20Sopenharmony_ci */
1318c2ecf20Sopenharmony_cistruct qcom_icc_node {
1328c2ecf20Sopenharmony_ci	unsigned char *name;
1338c2ecf20Sopenharmony_ci	u16 id;
1348c2ecf20Sopenharmony_ci	u16 links[QCS404_MAX_LINKS];
1358c2ecf20Sopenharmony_ci	u16 num_links;
1368c2ecf20Sopenharmony_ci	u16 buswidth;
1378c2ecf20Sopenharmony_ci	int mas_rpm_id;
1388c2ecf20Sopenharmony_ci	int slv_rpm_id;
1398c2ecf20Sopenharmony_ci	u64 rate;
1408c2ecf20Sopenharmony_ci};
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_cistruct qcom_icc_desc {
1438c2ecf20Sopenharmony_ci	struct qcom_icc_node **nodes;
1448c2ecf20Sopenharmony_ci	size_t num_nodes;
1458c2ecf20Sopenharmony_ci};
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci#define DEFINE_QNODE(_name, _id, _buswidth, _mas_rpm_id, _slv_rpm_id,	\
1488c2ecf20Sopenharmony_ci		     ...)						\
1498c2ecf20Sopenharmony_ci		static struct qcom_icc_node _name = {			\
1508c2ecf20Sopenharmony_ci		.name = #_name,						\
1518c2ecf20Sopenharmony_ci		.id = _id,						\
1528c2ecf20Sopenharmony_ci		.buswidth = _buswidth,					\
1538c2ecf20Sopenharmony_ci		.mas_rpm_id = _mas_rpm_id,				\
1548c2ecf20Sopenharmony_ci		.slv_rpm_id = _slv_rpm_id,				\
1558c2ecf20Sopenharmony_ci		.num_links = ARRAY_SIZE(((int[]){ __VA_ARGS__ })),	\
1568c2ecf20Sopenharmony_ci		.links = { __VA_ARGS__ },				\
1578c2ecf20Sopenharmony_ci	}
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_apps_proc, QCS404_MASTER_AMPSS_M0, 8, 0, -1, QCS404_SLAVE_EBI_CH0, QCS404_BIMC_SNOC_SLV);
1608c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_oxili, QCS404_MASTER_GRAPHICS_3D, 8, -1, -1, QCS404_SLAVE_EBI_CH0, QCS404_BIMC_SNOC_SLV);
1618c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_mdp, QCS404_MASTER_MDP_PORT0, 8, -1, -1, QCS404_SLAVE_EBI_CH0, QCS404_BIMC_SNOC_SLV);
1628c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_snoc_bimc_1, QCS404_SNOC_BIMC_1_MAS, 8, 76, -1, QCS404_SLAVE_EBI_CH0);
1638c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_tcu_0, QCS404_MASTER_TCU_0, 8, -1, -1, QCS404_SLAVE_EBI_CH0, QCS404_BIMC_SNOC_SLV);
1648c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_spdm, QCS404_MASTER_SPDM, 4, -1, -1, QCS404_PNOC_INT_3);
1658c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_blsp_1, QCS404_MASTER_BLSP_1, 4, 41, -1, QCS404_PNOC_INT_3);
1668c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_blsp_2, QCS404_MASTER_BLSP_2, 4, 39, -1, QCS404_PNOC_INT_3);
1678c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_xi_usb_hs1, QCS404_MASTER_XM_USB_HS1, 8, 138, -1, QCS404_PNOC_INT_0);
1688c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_crypto, QCS404_MASTER_CRYPTO_CORE0, 8, 23, -1, QCS404_PNOC_SNOC_SLV, QCS404_PNOC_INT_2);
1698c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_sdcc_1, QCS404_MASTER_SDCC_1, 8, 33, -1, QCS404_PNOC_INT_0);
1708c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_sdcc_2, QCS404_MASTER_SDCC_2, 8, 35, -1, QCS404_PNOC_INT_0);
1718c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_snoc_pcnoc, QCS404_SNOC_PNOC_MAS, 8, 77, -1, QCS404_PNOC_INT_2);
1728c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_qpic, QCS404_MASTER_QPIC, 4, -1, -1, QCS404_PNOC_INT_0);
1738c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_qdss_bam, QCS404_MASTER_QDSS_BAM, 4, -1, -1, QCS404_SNOC_QDSS_INT);
1748c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_bimc_snoc, QCS404_BIMC_SNOC_MAS, 8, 21, -1, QCS404_SLAVE_OCMEM_64, QCS404_SLAVE_CATS_128, QCS404_SNOC_INT_0, QCS404_SNOC_INT_1);
1758c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_pcnoc_snoc, QCS404_PNOC_SNOC_MAS, 8, 29, -1, QCS404_SNOC_BIMC_1_SLV, QCS404_SNOC_INT_2, QCS404_SNOC_INT_0);
1768c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_qdss_etr, QCS404_MASTER_QDSS_ETR, 8, -1, -1, QCS404_SNOC_QDSS_INT);
1778c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_emac, QCS404_MASTER_EMAC, 8, -1, -1, QCS404_SNOC_BIMC_1_SLV, QCS404_SNOC_INT_1);
1788c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_pcie, QCS404_MASTER_PCIE, 8, -1, -1, QCS404_SNOC_BIMC_1_SLV, QCS404_SNOC_INT_1);
1798c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_usb3, QCS404_MASTER_USB3, 8, -1, -1, QCS404_SNOC_BIMC_1_SLV, QCS404_SNOC_INT_1);
1808c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_int_0, QCS404_PNOC_INT_0, 8, 85, 114, QCS404_PNOC_SNOC_SLV, QCS404_PNOC_INT_2);
1818c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_int_2, QCS404_PNOC_INT_2, 8, 124, 184, QCS404_PNOC_SLV_10, QCS404_SLAVE_TCU, QCS404_PNOC_SLV_11, QCS404_PNOC_SLV_2, QCS404_PNOC_SLV_3, QCS404_PNOC_SLV_0, QCS404_PNOC_SLV_1, QCS404_PNOC_SLV_6, QCS404_PNOC_SLV_7, QCS404_PNOC_SLV_4, QCS404_PNOC_SLV_8, QCS404_PNOC_SLV_9);
1828c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_int_3, QCS404_PNOC_INT_3, 8, 125, 185, QCS404_PNOC_SNOC_SLV);
1838c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_0, QCS404_PNOC_SLV_0, 4, 89, 118, QCS404_SLAVE_PRNG, QCS404_SLAVE_SPDM_WRAPPER, QCS404_SLAVE_PDM);
1848c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_1, QCS404_PNOC_SLV_1, 4, 90, 119, QCS404_SLAVE_TCSR);
1858c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_2, QCS404_PNOC_SLV_2, 4, -1, -1, QCS404_SLAVE_GRAPHICS_3D_CFG);
1868c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_3, QCS404_PNOC_SLV_3, 4, 92, 121, QCS404_SLAVE_MESSAGE_RAM);
1878c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_4, QCS404_PNOC_SLV_4, 4, 93, 122, QCS404_SLAVE_SNOC_CFG);
1888c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_6, QCS404_PNOC_SLV_6, 4, 94, 123, QCS404_SLAVE_BLSP_1, QCS404_SLAVE_TLMM_NORTH, QCS404_SLAVE_EMAC_CFG);
1898c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_7, QCS404_PNOC_SLV_7, 4, 95, 124, QCS404_SLAVE_TLMM_SOUTH, QCS404_SLAVE_DISPLAY_CFG, QCS404_SLAVE_SDCC_1, QCS404_SLAVE_PCIE_1, QCS404_SLAVE_SDCC_2);
1908c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_8, QCS404_PNOC_SLV_8, 4, 96, 125, QCS404_SLAVE_CRYPTO_0_CFG);
1918c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_9, QCS404_PNOC_SLV_9, 4, 97, 126, QCS404_SLAVE_BLSP_2, QCS404_SLAVE_TLMM_EAST, QCS404_SLAVE_PMIC_ARB);
1928c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_10, QCS404_PNOC_SLV_10, 4, 157, -1, QCS404_SLAVE_USB_HS);
1938c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_11, QCS404_PNOC_SLV_11, 4, 158, 246, QCS404_SLAVE_USB3);
1948c2ecf20Sopenharmony_ciDEFINE_QNODE(qdss_int, QCS404_SNOC_QDSS_INT, 8, -1, -1, QCS404_SNOC_BIMC_1_SLV, QCS404_SNOC_INT_1);
1958c2ecf20Sopenharmony_ciDEFINE_QNODE(snoc_int_0, QCS404_SNOC_INT_0, 8, 99, 130, QCS404_SLAVE_LPASS, QCS404_SLAVE_APPSS, QCS404_SLAVE_WCSS);
1968c2ecf20Sopenharmony_ciDEFINE_QNODE(snoc_int_1, QCS404_SNOC_INT_1, 8, 100, 131, QCS404_SNOC_PNOC_SLV, QCS404_SNOC_INT_2);
1978c2ecf20Sopenharmony_ciDEFINE_QNODE(snoc_int_2, QCS404_SNOC_INT_2, 8, 134, 197, QCS404_SLAVE_QDSS_STM, QCS404_SLAVE_OCIMEM);
1988c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_ebi, QCS404_SLAVE_EBI_CH0, 8, -1, 0, 0);
1998c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_bimc_snoc, QCS404_BIMC_SNOC_SLV, 8, -1, 2, QCS404_BIMC_SNOC_MAS);
2008c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_spdm, QCS404_SLAVE_SPDM_WRAPPER, 4, -1, -1, 0);
2018c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_pdm, QCS404_SLAVE_PDM, 4, -1, 41, 0);
2028c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_prng, QCS404_SLAVE_PRNG, 4, -1, 44, 0);
2038c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_tcsr, QCS404_SLAVE_TCSR, 4, -1, 50, 0);
2048c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_snoc_cfg, QCS404_SLAVE_SNOC_CFG, 4, -1, 70, 0);
2058c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_message_ram, QCS404_SLAVE_MESSAGE_RAM, 4, -1, 55, 0);
2068c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_disp_ss_cfg, QCS404_SLAVE_DISPLAY_CFG, 4, -1, -1, 0);
2078c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_gpu_cfg, QCS404_SLAVE_GRAPHICS_3D_CFG, 4, -1, -1, 0);
2088c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_blsp_1, QCS404_SLAVE_BLSP_1, 4, -1, 39, 0);
2098c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_tlmm_north, QCS404_SLAVE_TLMM_NORTH, 4, -1, 214, 0);
2108c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_pcie, QCS404_SLAVE_PCIE_1, 4, -1, -1, 0);
2118c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_ethernet, QCS404_SLAVE_EMAC_CFG, 4, -1, -1, 0);
2128c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_blsp_2, QCS404_SLAVE_BLSP_2, 4, -1, 37, 0);
2138c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_tlmm_east, QCS404_SLAVE_TLMM_EAST, 4, -1, 213, 0);
2148c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_tcu, QCS404_SLAVE_TCU, 8, -1, -1, 0);
2158c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_pmic_arb, QCS404_SLAVE_PMIC_ARB, 4, -1, 59, 0);
2168c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_sdcc_1, QCS404_SLAVE_SDCC_1, 4, -1, 31, 0);
2178c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_sdcc_2, QCS404_SLAVE_SDCC_2, 4, -1, 33, 0);
2188c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_tlmm_south, QCS404_SLAVE_TLMM_SOUTH, 4, -1, -1, 0);
2198c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_usb_hs, QCS404_SLAVE_USB_HS, 4, -1, 40, 0);
2208c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_usb3, QCS404_SLAVE_USB3, 4, -1, 22, 0);
2218c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_crypto_0_cfg, QCS404_SLAVE_CRYPTO_0_CFG, 4, -1, 52, 0);
2228c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_pcnoc_snoc, QCS404_PNOC_SNOC_SLV, 8, -1, 45, QCS404_PNOC_SNOC_MAS);
2238c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_kpss_ahb, QCS404_SLAVE_APPSS, 4, -1, -1, 0);
2248c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_wcss, QCS404_SLAVE_WCSS, 4, -1, 23, 0);
2258c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_snoc_bimc_1, QCS404_SNOC_BIMC_1_SLV, 8, -1, 104, QCS404_SNOC_BIMC_1_MAS);
2268c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_imem, QCS404_SLAVE_OCIMEM, 8, -1, 26, 0);
2278c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_snoc_pcnoc, QCS404_SNOC_PNOC_SLV, 8, -1, 28, QCS404_SNOC_PNOC_MAS);
2288c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_qdss_stm, QCS404_SLAVE_QDSS_STM, 4, -1, 30, 0);
2298c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_cats_0, QCS404_SLAVE_CATS_128, 16, -1, -1, 0);
2308c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_cats_1, QCS404_SLAVE_OCMEM_64, 8, -1, -1, 0);
2318c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_lpass, QCS404_SLAVE_LPASS, 4, -1, -1, 0);
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_cistatic struct qcom_icc_node *qcs404_bimc_nodes[] = {
2348c2ecf20Sopenharmony_ci	[MASTER_AMPSS_M0] = &mas_apps_proc,
2358c2ecf20Sopenharmony_ci	[MASTER_OXILI] = &mas_oxili,
2368c2ecf20Sopenharmony_ci	[MASTER_MDP_PORT0] = &mas_mdp,
2378c2ecf20Sopenharmony_ci	[MASTER_SNOC_BIMC_1] = &mas_snoc_bimc_1,
2388c2ecf20Sopenharmony_ci	[MASTER_TCU_0] = &mas_tcu_0,
2398c2ecf20Sopenharmony_ci	[SLAVE_EBI_CH0] = &slv_ebi,
2408c2ecf20Sopenharmony_ci	[SLAVE_BIMC_SNOC] = &slv_bimc_snoc,
2418c2ecf20Sopenharmony_ci};
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_cistatic struct qcom_icc_desc qcs404_bimc = {
2448c2ecf20Sopenharmony_ci	.nodes = qcs404_bimc_nodes,
2458c2ecf20Sopenharmony_ci	.num_nodes = ARRAY_SIZE(qcs404_bimc_nodes),
2468c2ecf20Sopenharmony_ci};
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_cistatic struct qcom_icc_node *qcs404_pcnoc_nodes[] = {
2498c2ecf20Sopenharmony_ci	[MASTER_SPDM] = &mas_spdm,
2508c2ecf20Sopenharmony_ci	[MASTER_BLSP_1] = &mas_blsp_1,
2518c2ecf20Sopenharmony_ci	[MASTER_BLSP_2] = &mas_blsp_2,
2528c2ecf20Sopenharmony_ci	[MASTER_XI_USB_HS1] = &mas_xi_usb_hs1,
2538c2ecf20Sopenharmony_ci	[MASTER_CRYPT0] = &mas_crypto,
2548c2ecf20Sopenharmony_ci	[MASTER_SDCC_1] = &mas_sdcc_1,
2558c2ecf20Sopenharmony_ci	[MASTER_SDCC_2] = &mas_sdcc_2,
2568c2ecf20Sopenharmony_ci	[MASTER_SNOC_PCNOC] = &mas_snoc_pcnoc,
2578c2ecf20Sopenharmony_ci	[MASTER_QPIC] = &mas_qpic,
2588c2ecf20Sopenharmony_ci	[PCNOC_INT_0] = &pcnoc_int_0,
2598c2ecf20Sopenharmony_ci	[PCNOC_INT_2] = &pcnoc_int_2,
2608c2ecf20Sopenharmony_ci	[PCNOC_INT_3] = &pcnoc_int_3,
2618c2ecf20Sopenharmony_ci	[PCNOC_S_0] = &pcnoc_s_0,
2628c2ecf20Sopenharmony_ci	[PCNOC_S_1] = &pcnoc_s_1,
2638c2ecf20Sopenharmony_ci	[PCNOC_S_2] = &pcnoc_s_2,
2648c2ecf20Sopenharmony_ci	[PCNOC_S_3] = &pcnoc_s_3,
2658c2ecf20Sopenharmony_ci	[PCNOC_S_4] = &pcnoc_s_4,
2668c2ecf20Sopenharmony_ci	[PCNOC_S_6] = &pcnoc_s_6,
2678c2ecf20Sopenharmony_ci	[PCNOC_S_7] = &pcnoc_s_7,
2688c2ecf20Sopenharmony_ci	[PCNOC_S_8] = &pcnoc_s_8,
2698c2ecf20Sopenharmony_ci	[PCNOC_S_9] = &pcnoc_s_9,
2708c2ecf20Sopenharmony_ci	[PCNOC_S_10] = &pcnoc_s_10,
2718c2ecf20Sopenharmony_ci	[PCNOC_S_11] = &pcnoc_s_11,
2728c2ecf20Sopenharmony_ci	[SLAVE_SPDM] = &slv_spdm,
2738c2ecf20Sopenharmony_ci	[SLAVE_PDM] = &slv_pdm,
2748c2ecf20Sopenharmony_ci	[SLAVE_PRNG] = &slv_prng,
2758c2ecf20Sopenharmony_ci	[SLAVE_TCSR] = &slv_tcsr,
2768c2ecf20Sopenharmony_ci	[SLAVE_SNOC_CFG] = &slv_snoc_cfg,
2778c2ecf20Sopenharmony_ci	[SLAVE_MESSAGE_RAM] = &slv_message_ram,
2788c2ecf20Sopenharmony_ci	[SLAVE_DISP_SS_CFG] = &slv_disp_ss_cfg,
2798c2ecf20Sopenharmony_ci	[SLAVE_GPU_CFG] = &slv_gpu_cfg,
2808c2ecf20Sopenharmony_ci	[SLAVE_BLSP_1] = &slv_blsp_1,
2818c2ecf20Sopenharmony_ci	[SLAVE_BLSP_2] = &slv_blsp_2,
2828c2ecf20Sopenharmony_ci	[SLAVE_TLMM_NORTH] = &slv_tlmm_north,
2838c2ecf20Sopenharmony_ci	[SLAVE_PCIE] = &slv_pcie,
2848c2ecf20Sopenharmony_ci	[SLAVE_ETHERNET] = &slv_ethernet,
2858c2ecf20Sopenharmony_ci	[SLAVE_TLMM_EAST] = &slv_tlmm_east,
2868c2ecf20Sopenharmony_ci	[SLAVE_TCU] = &slv_tcu,
2878c2ecf20Sopenharmony_ci	[SLAVE_PMIC_ARB] = &slv_pmic_arb,
2888c2ecf20Sopenharmony_ci	[SLAVE_SDCC_1] = &slv_sdcc_1,
2898c2ecf20Sopenharmony_ci	[SLAVE_SDCC_2] = &slv_sdcc_2,
2908c2ecf20Sopenharmony_ci	[SLAVE_TLMM_SOUTH] = &slv_tlmm_south,
2918c2ecf20Sopenharmony_ci	[SLAVE_USB_HS] = &slv_usb_hs,
2928c2ecf20Sopenharmony_ci	[SLAVE_USB3] = &slv_usb3,
2938c2ecf20Sopenharmony_ci	[SLAVE_CRYPTO_0_CFG] = &slv_crypto_0_cfg,
2948c2ecf20Sopenharmony_ci	[SLAVE_PCNOC_SNOC] = &slv_pcnoc_snoc,
2958c2ecf20Sopenharmony_ci};
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_cistatic struct qcom_icc_desc qcs404_pcnoc = {
2988c2ecf20Sopenharmony_ci	.nodes = qcs404_pcnoc_nodes,
2998c2ecf20Sopenharmony_ci	.num_nodes = ARRAY_SIZE(qcs404_pcnoc_nodes),
3008c2ecf20Sopenharmony_ci};
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_cistatic struct qcom_icc_node *qcs404_snoc_nodes[] = {
3038c2ecf20Sopenharmony_ci	[MASTER_QDSS_BAM] = &mas_qdss_bam,
3048c2ecf20Sopenharmony_ci	[MASTER_BIMC_SNOC] = &mas_bimc_snoc,
3058c2ecf20Sopenharmony_ci	[MASTER_PCNOC_SNOC] = &mas_pcnoc_snoc,
3068c2ecf20Sopenharmony_ci	[MASTER_QDSS_ETR] = &mas_qdss_etr,
3078c2ecf20Sopenharmony_ci	[MASTER_EMAC] = &mas_emac,
3088c2ecf20Sopenharmony_ci	[MASTER_PCIE] = &mas_pcie,
3098c2ecf20Sopenharmony_ci	[MASTER_USB3] = &mas_usb3,
3108c2ecf20Sopenharmony_ci	[QDSS_INT] = &qdss_int,
3118c2ecf20Sopenharmony_ci	[SNOC_INT_0] = &snoc_int_0,
3128c2ecf20Sopenharmony_ci	[SNOC_INT_1] = &snoc_int_1,
3138c2ecf20Sopenharmony_ci	[SNOC_INT_2] = &snoc_int_2,
3148c2ecf20Sopenharmony_ci	[SLAVE_KPSS_AHB] = &slv_kpss_ahb,
3158c2ecf20Sopenharmony_ci	[SLAVE_WCSS] = &slv_wcss,
3168c2ecf20Sopenharmony_ci	[SLAVE_SNOC_BIMC_1] = &slv_snoc_bimc_1,
3178c2ecf20Sopenharmony_ci	[SLAVE_IMEM] = &slv_imem,
3188c2ecf20Sopenharmony_ci	[SLAVE_SNOC_PCNOC] = &slv_snoc_pcnoc,
3198c2ecf20Sopenharmony_ci	[SLAVE_QDSS_STM] = &slv_qdss_stm,
3208c2ecf20Sopenharmony_ci	[SLAVE_CATS_0] = &slv_cats_0,
3218c2ecf20Sopenharmony_ci	[SLAVE_CATS_1] = &slv_cats_1,
3228c2ecf20Sopenharmony_ci	[SLAVE_LPASS] = &slv_lpass,
3238c2ecf20Sopenharmony_ci};
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_cistatic struct qcom_icc_desc qcs404_snoc = {
3268c2ecf20Sopenharmony_ci	.nodes = qcs404_snoc_nodes,
3278c2ecf20Sopenharmony_ci	.num_nodes = ARRAY_SIZE(qcs404_snoc_nodes),
3288c2ecf20Sopenharmony_ci};
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_cistatic int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
3318c2ecf20Sopenharmony_ci{
3328c2ecf20Sopenharmony_ci	struct qcom_icc_provider *qp;
3338c2ecf20Sopenharmony_ci	struct qcom_icc_node *qn;
3348c2ecf20Sopenharmony_ci	struct icc_provider *provider;
3358c2ecf20Sopenharmony_ci	struct icc_node *n;
3368c2ecf20Sopenharmony_ci	u64 sum_bw;
3378c2ecf20Sopenharmony_ci	u64 max_peak_bw;
3388c2ecf20Sopenharmony_ci	u64 rate;
3398c2ecf20Sopenharmony_ci	u32 agg_avg = 0;
3408c2ecf20Sopenharmony_ci	u32 agg_peak = 0;
3418c2ecf20Sopenharmony_ci	int ret, i;
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci	qn = src->data;
3448c2ecf20Sopenharmony_ci	provider = src->provider;
3458c2ecf20Sopenharmony_ci	qp = to_qcom_provider(provider);
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci	list_for_each_entry(n, &provider->nodes, node_list)
3488c2ecf20Sopenharmony_ci		provider->aggregate(n, 0, n->avg_bw, n->peak_bw,
3498c2ecf20Sopenharmony_ci				    &agg_avg, &agg_peak);
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci	sum_bw = icc_units_to_bps(agg_avg);
3528c2ecf20Sopenharmony_ci	max_peak_bw = icc_units_to_bps(agg_peak);
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci	/* send bandwidth request message to the RPM processor */
3558c2ecf20Sopenharmony_ci	if (qn->mas_rpm_id != -1) {
3568c2ecf20Sopenharmony_ci		ret = qcom_icc_rpm_smd_send(QCOM_SMD_RPM_ACTIVE_STATE,
3578c2ecf20Sopenharmony_ci					    RPM_BUS_MASTER_REQ,
3588c2ecf20Sopenharmony_ci					    qn->mas_rpm_id,
3598c2ecf20Sopenharmony_ci					    sum_bw);
3608c2ecf20Sopenharmony_ci		if (ret) {
3618c2ecf20Sopenharmony_ci			pr_err("qcom_icc_rpm_smd_send mas %d error %d\n",
3628c2ecf20Sopenharmony_ci			       qn->mas_rpm_id, ret);
3638c2ecf20Sopenharmony_ci			return ret;
3648c2ecf20Sopenharmony_ci		}
3658c2ecf20Sopenharmony_ci	}
3668c2ecf20Sopenharmony_ci
3678c2ecf20Sopenharmony_ci	if (qn->slv_rpm_id != -1) {
3688c2ecf20Sopenharmony_ci		ret = qcom_icc_rpm_smd_send(QCOM_SMD_RPM_ACTIVE_STATE,
3698c2ecf20Sopenharmony_ci					    RPM_BUS_SLAVE_REQ,
3708c2ecf20Sopenharmony_ci					    qn->slv_rpm_id,
3718c2ecf20Sopenharmony_ci					    sum_bw);
3728c2ecf20Sopenharmony_ci		if (ret) {
3738c2ecf20Sopenharmony_ci			pr_err("qcom_icc_rpm_smd_send slv error %d\n",
3748c2ecf20Sopenharmony_ci			       ret);
3758c2ecf20Sopenharmony_ci			return ret;
3768c2ecf20Sopenharmony_ci		}
3778c2ecf20Sopenharmony_ci	}
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci	rate = max(sum_bw, max_peak_bw);
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci	do_div(rate, qn->buswidth);
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_ci	if (qn->rate == rate)
3848c2ecf20Sopenharmony_ci		return 0;
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci	for (i = 0; i < qp->num_clks; i++) {
3878c2ecf20Sopenharmony_ci		ret = clk_set_rate(qp->bus_clks[i].clk, rate);
3888c2ecf20Sopenharmony_ci		if (ret) {
3898c2ecf20Sopenharmony_ci			pr_err("%s clk_set_rate error: %d\n",
3908c2ecf20Sopenharmony_ci			       qp->bus_clks[i].id, ret);
3918c2ecf20Sopenharmony_ci			return ret;
3928c2ecf20Sopenharmony_ci		}
3938c2ecf20Sopenharmony_ci	}
3948c2ecf20Sopenharmony_ci
3958c2ecf20Sopenharmony_ci	qn->rate = rate;
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci	return 0;
3988c2ecf20Sopenharmony_ci}
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_cistatic int qnoc_probe(struct platform_device *pdev)
4018c2ecf20Sopenharmony_ci{
4028c2ecf20Sopenharmony_ci	struct device *dev = &pdev->dev;
4038c2ecf20Sopenharmony_ci	const struct qcom_icc_desc *desc;
4048c2ecf20Sopenharmony_ci	struct icc_onecell_data *data;
4058c2ecf20Sopenharmony_ci	struct icc_provider *provider;
4068c2ecf20Sopenharmony_ci	struct qcom_icc_node **qnodes;
4078c2ecf20Sopenharmony_ci	struct qcom_icc_provider *qp;
4088c2ecf20Sopenharmony_ci	struct icc_node *node;
4098c2ecf20Sopenharmony_ci	size_t num_nodes, i;
4108c2ecf20Sopenharmony_ci	int ret;
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ci	/* wait for the RPM proxy */
4138c2ecf20Sopenharmony_ci	if (!qcom_icc_rpm_smd_available())
4148c2ecf20Sopenharmony_ci		return -EPROBE_DEFER;
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_ci	desc = of_device_get_match_data(dev);
4178c2ecf20Sopenharmony_ci	if (!desc)
4188c2ecf20Sopenharmony_ci		return -EINVAL;
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_ci	qnodes = desc->nodes;
4218c2ecf20Sopenharmony_ci	num_nodes = desc->num_nodes;
4228c2ecf20Sopenharmony_ci
4238c2ecf20Sopenharmony_ci	qp = devm_kzalloc(dev, sizeof(*qp), GFP_KERNEL);
4248c2ecf20Sopenharmony_ci	if (!qp)
4258c2ecf20Sopenharmony_ci		return -ENOMEM;
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_ci	data = devm_kzalloc(dev, struct_size(data, nodes, num_nodes),
4288c2ecf20Sopenharmony_ci			    GFP_KERNEL);
4298c2ecf20Sopenharmony_ci	if (!data)
4308c2ecf20Sopenharmony_ci		return -ENOMEM;
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_ci	qp->bus_clks = devm_kmemdup(dev, bus_clocks, sizeof(bus_clocks),
4338c2ecf20Sopenharmony_ci				    GFP_KERNEL);
4348c2ecf20Sopenharmony_ci	if (!qp->bus_clks)
4358c2ecf20Sopenharmony_ci		return -ENOMEM;
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci	qp->num_clks = ARRAY_SIZE(bus_clocks);
4388c2ecf20Sopenharmony_ci	ret = devm_clk_bulk_get(dev, qp->num_clks, qp->bus_clks);
4398c2ecf20Sopenharmony_ci	if (ret)
4408c2ecf20Sopenharmony_ci		return ret;
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci	ret = clk_bulk_prepare_enable(qp->num_clks, qp->bus_clks);
4438c2ecf20Sopenharmony_ci	if (ret)
4448c2ecf20Sopenharmony_ci		return ret;
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci	provider = &qp->provider;
4478c2ecf20Sopenharmony_ci	INIT_LIST_HEAD(&provider->nodes);
4488c2ecf20Sopenharmony_ci	provider->dev = dev;
4498c2ecf20Sopenharmony_ci	provider->set = qcom_icc_set;
4508c2ecf20Sopenharmony_ci	provider->aggregate = icc_std_aggregate;
4518c2ecf20Sopenharmony_ci	provider->xlate = of_icc_xlate_onecell;
4528c2ecf20Sopenharmony_ci	provider->data = data;
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci	ret = icc_provider_add(provider);
4558c2ecf20Sopenharmony_ci	if (ret) {
4568c2ecf20Sopenharmony_ci		dev_err(dev, "error adding interconnect provider: %d\n", ret);
4578c2ecf20Sopenharmony_ci		clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
4588c2ecf20Sopenharmony_ci		return ret;
4598c2ecf20Sopenharmony_ci	}
4608c2ecf20Sopenharmony_ci
4618c2ecf20Sopenharmony_ci	for (i = 0; i < num_nodes; i++) {
4628c2ecf20Sopenharmony_ci		size_t j;
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_ci		node = icc_node_create(qnodes[i]->id);
4658c2ecf20Sopenharmony_ci		if (IS_ERR(node)) {
4668c2ecf20Sopenharmony_ci			ret = PTR_ERR(node);
4678c2ecf20Sopenharmony_ci			goto err;
4688c2ecf20Sopenharmony_ci		}
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_ci		node->name = qnodes[i]->name;
4718c2ecf20Sopenharmony_ci		node->data = qnodes[i];
4728c2ecf20Sopenharmony_ci		icc_node_add(node, provider);
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_ci		dev_dbg(dev, "registered node %s\n", node->name);
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci		/* populate links */
4778c2ecf20Sopenharmony_ci		for (j = 0; j < qnodes[i]->num_links; j++)
4788c2ecf20Sopenharmony_ci			icc_link_create(node, qnodes[i]->links[j]);
4798c2ecf20Sopenharmony_ci
4808c2ecf20Sopenharmony_ci		data->nodes[i] = node;
4818c2ecf20Sopenharmony_ci	}
4828c2ecf20Sopenharmony_ci	data->num_nodes = num_nodes;
4838c2ecf20Sopenharmony_ci
4848c2ecf20Sopenharmony_ci	platform_set_drvdata(pdev, qp);
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci	return 0;
4878c2ecf20Sopenharmony_cierr:
4888c2ecf20Sopenharmony_ci	icc_nodes_remove(provider);
4898c2ecf20Sopenharmony_ci	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
4908c2ecf20Sopenharmony_ci	icc_provider_del(provider);
4918c2ecf20Sopenharmony_ci
4928c2ecf20Sopenharmony_ci	return ret;
4938c2ecf20Sopenharmony_ci}
4948c2ecf20Sopenharmony_ci
4958c2ecf20Sopenharmony_cistatic int qnoc_remove(struct platform_device *pdev)
4968c2ecf20Sopenharmony_ci{
4978c2ecf20Sopenharmony_ci	struct qcom_icc_provider *qp = platform_get_drvdata(pdev);
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ci	icc_nodes_remove(&qp->provider);
5008c2ecf20Sopenharmony_ci	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
5018c2ecf20Sopenharmony_ci	return icc_provider_del(&qp->provider);
5028c2ecf20Sopenharmony_ci}
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_cistatic const struct of_device_id qcs404_noc_of_match[] = {
5058c2ecf20Sopenharmony_ci	{ .compatible = "qcom,qcs404-bimc", .data = &qcs404_bimc },
5068c2ecf20Sopenharmony_ci	{ .compatible = "qcom,qcs404-pcnoc", .data = &qcs404_pcnoc },
5078c2ecf20Sopenharmony_ci	{ .compatible = "qcom,qcs404-snoc", .data = &qcs404_snoc },
5088c2ecf20Sopenharmony_ci	{ },
5098c2ecf20Sopenharmony_ci};
5108c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, qcs404_noc_of_match);
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_cistatic struct platform_driver qcs404_noc_driver = {
5138c2ecf20Sopenharmony_ci	.probe = qnoc_probe,
5148c2ecf20Sopenharmony_ci	.remove = qnoc_remove,
5158c2ecf20Sopenharmony_ci	.driver = {
5168c2ecf20Sopenharmony_ci		.name = "qnoc-qcs404",
5178c2ecf20Sopenharmony_ci		.of_match_table = qcs404_noc_of_match,
5188c2ecf20Sopenharmony_ci	},
5198c2ecf20Sopenharmony_ci};
5208c2ecf20Sopenharmony_cimodule_platform_driver(qcs404_noc_driver);
5218c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Qualcomm QCS404 NoC driver");
5228c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2");
523