18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2018-2020 Linaro Ltd 48c2ecf20Sopenharmony_ci * Author: Georgi Djakov <georgi.djakov@linaro.org> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 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/platform_device.h> 138c2ecf20Sopenharmony_ci#include <linux/of_device.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <dt-bindings/interconnect/qcom,msm8916.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 MSM8916_BIMC_SNOC_MAS = 1, 248c2ecf20Sopenharmony_ci MSM8916_BIMC_SNOC_SLV, 258c2ecf20Sopenharmony_ci MSM8916_MASTER_AMPSS_M0, 268c2ecf20Sopenharmony_ci MSM8916_MASTER_LPASS, 278c2ecf20Sopenharmony_ci MSM8916_MASTER_BLSP_1, 288c2ecf20Sopenharmony_ci MSM8916_MASTER_DEHR, 298c2ecf20Sopenharmony_ci MSM8916_MASTER_GRAPHICS_3D, 308c2ecf20Sopenharmony_ci MSM8916_MASTER_JPEG, 318c2ecf20Sopenharmony_ci MSM8916_MASTER_MDP_PORT0, 328c2ecf20Sopenharmony_ci MSM8916_MASTER_CRYPTO_CORE0, 338c2ecf20Sopenharmony_ci MSM8916_MASTER_SDCC_1, 348c2ecf20Sopenharmony_ci MSM8916_MASTER_SDCC_2, 358c2ecf20Sopenharmony_ci MSM8916_MASTER_QDSS_BAM, 368c2ecf20Sopenharmony_ci MSM8916_MASTER_QDSS_ETR, 378c2ecf20Sopenharmony_ci MSM8916_MASTER_SNOC_CFG, 388c2ecf20Sopenharmony_ci MSM8916_MASTER_SPDM, 398c2ecf20Sopenharmony_ci MSM8916_MASTER_TCU0, 408c2ecf20Sopenharmony_ci MSM8916_MASTER_TCU1, 418c2ecf20Sopenharmony_ci MSM8916_MASTER_USB_HS, 428c2ecf20Sopenharmony_ci MSM8916_MASTER_VFE, 438c2ecf20Sopenharmony_ci MSM8916_MASTER_VIDEO_P0, 448c2ecf20Sopenharmony_ci MSM8916_SNOC_MM_INT_0, 458c2ecf20Sopenharmony_ci MSM8916_SNOC_MM_INT_1, 468c2ecf20Sopenharmony_ci MSM8916_SNOC_MM_INT_2, 478c2ecf20Sopenharmony_ci MSM8916_SNOC_MM_INT_BIMC, 488c2ecf20Sopenharmony_ci MSM8916_PNOC_INT_0, 498c2ecf20Sopenharmony_ci MSM8916_PNOC_INT_1, 508c2ecf20Sopenharmony_ci MSM8916_PNOC_MAS_0, 518c2ecf20Sopenharmony_ci MSM8916_PNOC_MAS_1, 528c2ecf20Sopenharmony_ci MSM8916_PNOC_SLV_0, 538c2ecf20Sopenharmony_ci MSM8916_PNOC_SLV_1, 548c2ecf20Sopenharmony_ci MSM8916_PNOC_SLV_2, 558c2ecf20Sopenharmony_ci MSM8916_PNOC_SLV_3, 568c2ecf20Sopenharmony_ci MSM8916_PNOC_SLV_4, 578c2ecf20Sopenharmony_ci MSM8916_PNOC_SLV_8, 588c2ecf20Sopenharmony_ci MSM8916_PNOC_SLV_9, 598c2ecf20Sopenharmony_ci MSM8916_PNOC_SNOC_MAS, 608c2ecf20Sopenharmony_ci MSM8916_PNOC_SNOC_SLV, 618c2ecf20Sopenharmony_ci MSM8916_SNOC_QDSS_INT, 628c2ecf20Sopenharmony_ci MSM8916_SLAVE_AMPSS_L2, 638c2ecf20Sopenharmony_ci MSM8916_SLAVE_APSS, 648c2ecf20Sopenharmony_ci MSM8916_SLAVE_LPASS, 658c2ecf20Sopenharmony_ci MSM8916_SLAVE_BIMC_CFG, 668c2ecf20Sopenharmony_ci MSM8916_SLAVE_BLSP_1, 678c2ecf20Sopenharmony_ci MSM8916_SLAVE_BOOT_ROM, 688c2ecf20Sopenharmony_ci MSM8916_SLAVE_CAMERA_CFG, 698c2ecf20Sopenharmony_ci MSM8916_SLAVE_CATS_128, 708c2ecf20Sopenharmony_ci MSM8916_SLAVE_OCMEM_64, 718c2ecf20Sopenharmony_ci MSM8916_SLAVE_CLK_CTL, 728c2ecf20Sopenharmony_ci MSM8916_SLAVE_CRYPTO_0_CFG, 738c2ecf20Sopenharmony_ci MSM8916_SLAVE_DEHR_CFG, 748c2ecf20Sopenharmony_ci MSM8916_SLAVE_DISPLAY_CFG, 758c2ecf20Sopenharmony_ci MSM8916_SLAVE_EBI_CH0, 768c2ecf20Sopenharmony_ci MSM8916_SLAVE_GRAPHICS_3D_CFG, 778c2ecf20Sopenharmony_ci MSM8916_SLAVE_IMEM_CFG, 788c2ecf20Sopenharmony_ci MSM8916_SLAVE_IMEM, 798c2ecf20Sopenharmony_ci MSM8916_SLAVE_MPM, 808c2ecf20Sopenharmony_ci MSM8916_SLAVE_MSG_RAM, 818c2ecf20Sopenharmony_ci MSM8916_SLAVE_MSS, 828c2ecf20Sopenharmony_ci MSM8916_SLAVE_PDM, 838c2ecf20Sopenharmony_ci MSM8916_SLAVE_PMIC_ARB, 848c2ecf20Sopenharmony_ci MSM8916_SLAVE_PNOC_CFG, 858c2ecf20Sopenharmony_ci MSM8916_SLAVE_PRNG, 868c2ecf20Sopenharmony_ci MSM8916_SLAVE_QDSS_CFG, 878c2ecf20Sopenharmony_ci MSM8916_SLAVE_QDSS_STM, 888c2ecf20Sopenharmony_ci MSM8916_SLAVE_RBCPR_CFG, 898c2ecf20Sopenharmony_ci MSM8916_SLAVE_SDCC_1, 908c2ecf20Sopenharmony_ci MSM8916_SLAVE_SDCC_2, 918c2ecf20Sopenharmony_ci MSM8916_SLAVE_SECURITY, 928c2ecf20Sopenharmony_ci MSM8916_SLAVE_SNOC_CFG, 938c2ecf20Sopenharmony_ci MSM8916_SLAVE_SPDM, 948c2ecf20Sopenharmony_ci MSM8916_SLAVE_SRVC_SNOC, 958c2ecf20Sopenharmony_ci MSM8916_SLAVE_TCSR, 968c2ecf20Sopenharmony_ci MSM8916_SLAVE_TLMM, 978c2ecf20Sopenharmony_ci MSM8916_SLAVE_USB_HS, 988c2ecf20Sopenharmony_ci MSM8916_SLAVE_VENUS_CFG, 998c2ecf20Sopenharmony_ci MSM8916_SNOC_BIMC_0_MAS, 1008c2ecf20Sopenharmony_ci MSM8916_SNOC_BIMC_0_SLV, 1018c2ecf20Sopenharmony_ci MSM8916_SNOC_BIMC_1_MAS, 1028c2ecf20Sopenharmony_ci MSM8916_SNOC_BIMC_1_SLV, 1038c2ecf20Sopenharmony_ci MSM8916_SNOC_INT_0, 1048c2ecf20Sopenharmony_ci MSM8916_SNOC_INT_1, 1058c2ecf20Sopenharmony_ci MSM8916_SNOC_INT_BIMC, 1068c2ecf20Sopenharmony_ci MSM8916_SNOC_PNOC_MAS, 1078c2ecf20Sopenharmony_ci MSM8916_SNOC_PNOC_SLV, 1088c2ecf20Sopenharmony_ci}; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci#define to_msm8916_provider(_provider) \ 1118c2ecf20Sopenharmony_ci container_of(_provider, struct msm8916_icc_provider, provider) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_cistatic const struct clk_bulk_data msm8916_bus_clocks[] = { 1148c2ecf20Sopenharmony_ci { .id = "bus" }, 1158c2ecf20Sopenharmony_ci { .id = "bus_a" }, 1168c2ecf20Sopenharmony_ci}; 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci/** 1198c2ecf20Sopenharmony_ci * struct msm8916_icc_provider - Qualcomm specific interconnect provider 1208c2ecf20Sopenharmony_ci * @provider: generic interconnect provider 1218c2ecf20Sopenharmony_ci * @bus_clks: the clk_bulk_data table of bus clocks 1228c2ecf20Sopenharmony_ci * @num_clks: the total number of clk_bulk_data entries 1238c2ecf20Sopenharmony_ci */ 1248c2ecf20Sopenharmony_cistruct msm8916_icc_provider { 1258c2ecf20Sopenharmony_ci struct icc_provider provider; 1268c2ecf20Sopenharmony_ci struct clk_bulk_data *bus_clks; 1278c2ecf20Sopenharmony_ci int num_clks; 1288c2ecf20Sopenharmony_ci}; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci#define MSM8916_MAX_LINKS 8 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci/** 1338c2ecf20Sopenharmony_ci * struct msm8916_icc_node - Qualcomm specific interconnect nodes 1348c2ecf20Sopenharmony_ci * @name: the node name used in debugfs 1358c2ecf20Sopenharmony_ci * @id: a unique node identifier 1368c2ecf20Sopenharmony_ci * @links: an array of nodes where we can go next while traversing 1378c2ecf20Sopenharmony_ci * @num_links: the total number of @links 1388c2ecf20Sopenharmony_ci * @buswidth: width of the interconnect between a node and the bus (bytes) 1398c2ecf20Sopenharmony_ci * @mas_rpm_id: RPM ID for devices that are bus masters 1408c2ecf20Sopenharmony_ci * @slv_rpm_id: RPM ID for devices that are bus slaves 1418c2ecf20Sopenharmony_ci * @rate: current bus clock rate in Hz 1428c2ecf20Sopenharmony_ci */ 1438c2ecf20Sopenharmony_cistruct msm8916_icc_node { 1448c2ecf20Sopenharmony_ci unsigned char *name; 1458c2ecf20Sopenharmony_ci u16 id; 1468c2ecf20Sopenharmony_ci u16 links[MSM8916_MAX_LINKS]; 1478c2ecf20Sopenharmony_ci u16 num_links; 1488c2ecf20Sopenharmony_ci u16 buswidth; 1498c2ecf20Sopenharmony_ci int mas_rpm_id; 1508c2ecf20Sopenharmony_ci int slv_rpm_id; 1518c2ecf20Sopenharmony_ci u64 rate; 1528c2ecf20Sopenharmony_ci}; 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_cistruct msm8916_icc_desc { 1558c2ecf20Sopenharmony_ci struct msm8916_icc_node **nodes; 1568c2ecf20Sopenharmony_ci size_t num_nodes; 1578c2ecf20Sopenharmony_ci}; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci#define DEFINE_QNODE(_name, _id, _buswidth, _mas_rpm_id, _slv_rpm_id, \ 1608c2ecf20Sopenharmony_ci ...) \ 1618c2ecf20Sopenharmony_ci static struct msm8916_icc_node _name = { \ 1628c2ecf20Sopenharmony_ci .name = #_name, \ 1638c2ecf20Sopenharmony_ci .id = _id, \ 1648c2ecf20Sopenharmony_ci .buswidth = _buswidth, \ 1658c2ecf20Sopenharmony_ci .mas_rpm_id = _mas_rpm_id, \ 1668c2ecf20Sopenharmony_ci .slv_rpm_id = _slv_rpm_id, \ 1678c2ecf20Sopenharmony_ci .num_links = ARRAY_SIZE(((int[]){ __VA_ARGS__ })), \ 1688c2ecf20Sopenharmony_ci .links = { __VA_ARGS__ }, \ 1698c2ecf20Sopenharmony_ci } 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ciDEFINE_QNODE(bimc_snoc_mas, MSM8916_BIMC_SNOC_MAS, 8, -1, -1, MSM8916_BIMC_SNOC_SLV); 1728c2ecf20Sopenharmony_ciDEFINE_QNODE(bimc_snoc_slv, MSM8916_BIMC_SNOC_SLV, 8, -1, -1, MSM8916_SNOC_INT_0, MSM8916_SNOC_INT_1); 1738c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_apss, MSM8916_MASTER_AMPSS_M0, 8, -1, -1, MSM8916_SLAVE_EBI_CH0, MSM8916_BIMC_SNOC_MAS, MSM8916_SLAVE_AMPSS_L2); 1748c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_audio, MSM8916_MASTER_LPASS, 4, -1, -1, MSM8916_PNOC_MAS_0); 1758c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_blsp_1, MSM8916_MASTER_BLSP_1, 4, -1, -1, MSM8916_PNOC_MAS_1); 1768c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_dehr, MSM8916_MASTER_DEHR, 4, -1, -1, MSM8916_PNOC_MAS_0); 1778c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_gfx, MSM8916_MASTER_GRAPHICS_3D, 8, -1, -1, MSM8916_SLAVE_EBI_CH0, MSM8916_BIMC_SNOC_MAS, MSM8916_SLAVE_AMPSS_L2); 1788c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_jpeg, MSM8916_MASTER_JPEG, 16, -1, -1, MSM8916_SNOC_MM_INT_0, MSM8916_SNOC_MM_INT_2); 1798c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_mdp, MSM8916_MASTER_MDP_PORT0, 16, -1, -1, MSM8916_SNOC_MM_INT_0, MSM8916_SNOC_MM_INT_2); 1808c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_pcnoc_crypto_0, MSM8916_MASTER_CRYPTO_CORE0, 8, -1, -1, MSM8916_PNOC_INT_1); 1818c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_pcnoc_sdcc_1, MSM8916_MASTER_SDCC_1, 8, -1, -1, MSM8916_PNOC_INT_1); 1828c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_pcnoc_sdcc_2, MSM8916_MASTER_SDCC_2, 8, -1, -1, MSM8916_PNOC_INT_1); 1838c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_qdss_bam, MSM8916_MASTER_QDSS_BAM, 8, -1, -1, MSM8916_SNOC_QDSS_INT); 1848c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_qdss_etr, MSM8916_MASTER_QDSS_ETR, 8, -1, -1, MSM8916_SNOC_QDSS_INT); 1858c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_snoc_cfg, MSM8916_MASTER_SNOC_CFG, 4, -1, -1, MSM8916_SNOC_QDSS_INT); 1868c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_spdm, MSM8916_MASTER_SPDM, 4, -1, -1, MSM8916_PNOC_MAS_0); 1878c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_tcu0, MSM8916_MASTER_TCU0, 8, -1, -1, MSM8916_SLAVE_EBI_CH0, MSM8916_BIMC_SNOC_MAS, MSM8916_SLAVE_AMPSS_L2); 1888c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_tcu1, MSM8916_MASTER_TCU1, 8, -1, -1, MSM8916_SLAVE_EBI_CH0, MSM8916_BIMC_SNOC_MAS, MSM8916_SLAVE_AMPSS_L2); 1898c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_usb_hs, MSM8916_MASTER_USB_HS, 4, -1, -1, MSM8916_PNOC_MAS_1); 1908c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_vfe, MSM8916_MASTER_VFE, 16, -1, -1, MSM8916_SNOC_MM_INT_1, MSM8916_SNOC_MM_INT_2); 1918c2ecf20Sopenharmony_ciDEFINE_QNODE(mas_video, MSM8916_MASTER_VIDEO_P0, 16, -1, -1, MSM8916_SNOC_MM_INT_0, MSM8916_SNOC_MM_INT_2); 1928c2ecf20Sopenharmony_ciDEFINE_QNODE(mm_int_0, MSM8916_SNOC_MM_INT_0, 16, -1, -1, MSM8916_SNOC_MM_INT_BIMC); 1938c2ecf20Sopenharmony_ciDEFINE_QNODE(mm_int_1, MSM8916_SNOC_MM_INT_1, 16, -1, -1, MSM8916_SNOC_MM_INT_BIMC); 1948c2ecf20Sopenharmony_ciDEFINE_QNODE(mm_int_2, MSM8916_SNOC_MM_INT_2, 16, -1, -1, MSM8916_SNOC_INT_0); 1958c2ecf20Sopenharmony_ciDEFINE_QNODE(mm_int_bimc, MSM8916_SNOC_MM_INT_BIMC, 16, -1, -1, MSM8916_SNOC_BIMC_1_MAS); 1968c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_int_0, MSM8916_PNOC_INT_0, 8, -1, -1, MSM8916_PNOC_SNOC_MAS, MSM8916_PNOC_SLV_0, MSM8916_PNOC_SLV_1, MSM8916_PNOC_SLV_2, MSM8916_PNOC_SLV_3, MSM8916_PNOC_SLV_4, MSM8916_PNOC_SLV_8, MSM8916_PNOC_SLV_9); 1978c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_int_1, MSM8916_PNOC_INT_1, 8, -1, -1, MSM8916_PNOC_SNOC_MAS); 1988c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_m_0, MSM8916_PNOC_MAS_0, 8, -1, -1, MSM8916_PNOC_INT_0); 1998c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_m_1, MSM8916_PNOC_MAS_1, 8, -1, -1, MSM8916_PNOC_SNOC_MAS); 2008c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_0, MSM8916_PNOC_SLV_0, 4, -1, -1, MSM8916_SLAVE_CLK_CTL, MSM8916_SLAVE_TLMM, MSM8916_SLAVE_TCSR, MSM8916_SLAVE_SECURITY, MSM8916_SLAVE_MSS); 2018c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_1, MSM8916_PNOC_SLV_1, 4, -1, -1, MSM8916_SLAVE_IMEM_CFG, MSM8916_SLAVE_CRYPTO_0_CFG, MSM8916_SLAVE_MSG_RAM, MSM8916_SLAVE_PDM, MSM8916_SLAVE_PRNG); 2028c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_2, MSM8916_PNOC_SLV_2, 4, -1, -1, MSM8916_SLAVE_SPDM, MSM8916_SLAVE_BOOT_ROM, MSM8916_SLAVE_BIMC_CFG, MSM8916_SLAVE_PNOC_CFG, MSM8916_SLAVE_PMIC_ARB); 2038c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_3, MSM8916_PNOC_SLV_3, 4, -1, -1, MSM8916_SLAVE_MPM, MSM8916_SLAVE_SNOC_CFG, MSM8916_SLAVE_RBCPR_CFG, MSM8916_SLAVE_QDSS_CFG, MSM8916_SLAVE_DEHR_CFG); 2048c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_4, MSM8916_PNOC_SLV_4, 4, -1, -1, MSM8916_SLAVE_VENUS_CFG, MSM8916_SLAVE_CAMERA_CFG, MSM8916_SLAVE_DISPLAY_CFG); 2058c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_8, MSM8916_PNOC_SLV_8, 4, -1, -1, MSM8916_SLAVE_USB_HS, MSM8916_SLAVE_SDCC_1, MSM8916_SLAVE_BLSP_1); 2068c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_s_9, MSM8916_PNOC_SLV_9, 4, -1, -1, MSM8916_SLAVE_SDCC_2, MSM8916_SLAVE_LPASS, MSM8916_SLAVE_GRAPHICS_3D_CFG); 2078c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_snoc_mas, MSM8916_PNOC_SNOC_MAS, 8, 29, -1, MSM8916_PNOC_SNOC_SLV); 2088c2ecf20Sopenharmony_ciDEFINE_QNODE(pcnoc_snoc_slv, MSM8916_PNOC_SNOC_SLV, 8, -1, 45, MSM8916_SNOC_INT_0, MSM8916_SNOC_INT_BIMC, MSM8916_SNOC_INT_1); 2098c2ecf20Sopenharmony_ciDEFINE_QNODE(qdss_int, MSM8916_SNOC_QDSS_INT, 8, -1, -1, MSM8916_SNOC_INT_0, MSM8916_SNOC_INT_BIMC); 2108c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_apps_l2, MSM8916_SLAVE_AMPSS_L2, 8, -1, -1, 0); 2118c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_apss, MSM8916_SLAVE_APSS, 4, -1, -1, 0); 2128c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_audio, MSM8916_SLAVE_LPASS, 4, -1, -1, 0); 2138c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_bimc_cfg, MSM8916_SLAVE_BIMC_CFG, 4, -1, -1, 0); 2148c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_blsp_1, MSM8916_SLAVE_BLSP_1, 4, -1, -1, 0); 2158c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_boot_rom, MSM8916_SLAVE_BOOT_ROM, 4, -1, -1, 0); 2168c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_camera_cfg, MSM8916_SLAVE_CAMERA_CFG, 4, -1, -1, 0); 2178c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_cats_0, MSM8916_SLAVE_CATS_128, 16, -1, -1, 0); 2188c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_cats_1, MSM8916_SLAVE_OCMEM_64, 8, -1, -1, 0); 2198c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_clk_ctl, MSM8916_SLAVE_CLK_CTL, 4, -1, -1, 0); 2208c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_crypto_0_cfg, MSM8916_SLAVE_CRYPTO_0_CFG, 4, -1, -1, 0); 2218c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_dehr_cfg, MSM8916_SLAVE_DEHR_CFG, 4, -1, -1, 0); 2228c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_display_cfg, MSM8916_SLAVE_DISPLAY_CFG, 4, -1, -1, 0); 2238c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_ebi_ch0, MSM8916_SLAVE_EBI_CH0, 8, -1, 0, 0); 2248c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_gfx_cfg, MSM8916_SLAVE_GRAPHICS_3D_CFG, 4, -1, -1, 0); 2258c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_imem_cfg, MSM8916_SLAVE_IMEM_CFG, 4, -1, -1, 0); 2268c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_imem, MSM8916_SLAVE_IMEM, 8, -1, 26, 0); 2278c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_mpm, MSM8916_SLAVE_MPM, 4, -1, -1, 0); 2288c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_msg_ram, MSM8916_SLAVE_MSG_RAM, 4, -1, -1, 0); 2298c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_mss, MSM8916_SLAVE_MSS, 4, -1, -1, 0); 2308c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_pdm, MSM8916_SLAVE_PDM, 4, -1, -1, 0); 2318c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_pmic_arb, MSM8916_SLAVE_PMIC_ARB, 4, -1, -1, 0); 2328c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_pcnoc_cfg, MSM8916_SLAVE_PNOC_CFG, 4, -1, -1, 0); 2338c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_prng, MSM8916_SLAVE_PRNG, 4, -1, -1, 0); 2348c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_qdss_cfg, MSM8916_SLAVE_QDSS_CFG, 4, -1, -1, 0); 2358c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_qdss_stm, MSM8916_SLAVE_QDSS_STM, 4, -1, 30, 0); 2368c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_rbcpr_cfg, MSM8916_SLAVE_RBCPR_CFG, 4, -1, -1, 0); 2378c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_sdcc_1, MSM8916_SLAVE_SDCC_1, 4, -1, -1, 0); 2388c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_sdcc_2, MSM8916_SLAVE_SDCC_2, 4, -1, -1, 0); 2398c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_security, MSM8916_SLAVE_SECURITY, 4, -1, -1, 0); 2408c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_snoc_cfg, MSM8916_SLAVE_SNOC_CFG, 4, -1, -1, 0); 2418c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_spdm, MSM8916_SLAVE_SPDM, 4, -1, -1, 0); 2428c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_srvc_snoc, MSM8916_SLAVE_SRVC_SNOC, 8, -1, -1, 0); 2438c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_tcsr, MSM8916_SLAVE_TCSR, 4, -1, -1, 0); 2448c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_tlmm, MSM8916_SLAVE_TLMM, 4, -1, -1, 0); 2458c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_usb_hs, MSM8916_SLAVE_USB_HS, 4, -1, -1, 0); 2468c2ecf20Sopenharmony_ciDEFINE_QNODE(slv_venus_cfg, MSM8916_SLAVE_VENUS_CFG, 4, -1, -1, 0); 2478c2ecf20Sopenharmony_ciDEFINE_QNODE(snoc_bimc_0_mas, MSM8916_SNOC_BIMC_0_MAS, 8, 3, -1, MSM8916_SNOC_BIMC_0_SLV); 2488c2ecf20Sopenharmony_ciDEFINE_QNODE(snoc_bimc_0_slv, MSM8916_SNOC_BIMC_0_SLV, 8, -1, 24, MSM8916_SLAVE_EBI_CH0); 2498c2ecf20Sopenharmony_ciDEFINE_QNODE(snoc_bimc_1_mas, MSM8916_SNOC_BIMC_1_MAS, 16, -1, -1, MSM8916_SNOC_BIMC_1_SLV); 2508c2ecf20Sopenharmony_ciDEFINE_QNODE(snoc_bimc_1_slv, MSM8916_SNOC_BIMC_1_SLV, 8, -1, -1, MSM8916_SLAVE_EBI_CH0); 2518c2ecf20Sopenharmony_ciDEFINE_QNODE(snoc_int_0, MSM8916_SNOC_INT_0, 8, 99, 130, MSM8916_SLAVE_QDSS_STM, MSM8916_SLAVE_IMEM, MSM8916_SNOC_PNOC_MAS); 2528c2ecf20Sopenharmony_ciDEFINE_QNODE(snoc_int_1, MSM8916_SNOC_INT_1, 8, -1, -1, MSM8916_SLAVE_APSS, MSM8916_SLAVE_CATS_128, MSM8916_SLAVE_OCMEM_64); 2538c2ecf20Sopenharmony_ciDEFINE_QNODE(snoc_int_bimc, MSM8916_SNOC_INT_BIMC, 8, 101, 132, MSM8916_SNOC_BIMC_0_MAS); 2548c2ecf20Sopenharmony_ciDEFINE_QNODE(snoc_pcnoc_mas, MSM8916_SNOC_PNOC_MAS, 8, -1, -1, MSM8916_SNOC_PNOC_SLV); 2558c2ecf20Sopenharmony_ciDEFINE_QNODE(snoc_pcnoc_slv, MSM8916_SNOC_PNOC_SLV, 8, -1, -1, MSM8916_PNOC_INT_0); 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_cistatic struct msm8916_icc_node *msm8916_snoc_nodes[] = { 2588c2ecf20Sopenharmony_ci [BIMC_SNOC_SLV] = &bimc_snoc_slv, 2598c2ecf20Sopenharmony_ci [MASTER_JPEG] = &mas_jpeg, 2608c2ecf20Sopenharmony_ci [MASTER_MDP_PORT0] = &mas_mdp, 2618c2ecf20Sopenharmony_ci [MASTER_QDSS_BAM] = &mas_qdss_bam, 2628c2ecf20Sopenharmony_ci [MASTER_QDSS_ETR] = &mas_qdss_etr, 2638c2ecf20Sopenharmony_ci [MASTER_SNOC_CFG] = &mas_snoc_cfg, 2648c2ecf20Sopenharmony_ci [MASTER_VFE] = &mas_vfe, 2658c2ecf20Sopenharmony_ci [MASTER_VIDEO_P0] = &mas_video, 2668c2ecf20Sopenharmony_ci [SNOC_MM_INT_0] = &mm_int_0, 2678c2ecf20Sopenharmony_ci [SNOC_MM_INT_1] = &mm_int_1, 2688c2ecf20Sopenharmony_ci [SNOC_MM_INT_2] = &mm_int_2, 2698c2ecf20Sopenharmony_ci [SNOC_MM_INT_BIMC] = &mm_int_bimc, 2708c2ecf20Sopenharmony_ci [PCNOC_SNOC_SLV] = &pcnoc_snoc_slv, 2718c2ecf20Sopenharmony_ci [SLAVE_APSS] = &slv_apss, 2728c2ecf20Sopenharmony_ci [SLAVE_CATS_128] = &slv_cats_0, 2738c2ecf20Sopenharmony_ci [SLAVE_OCMEM_64] = &slv_cats_1, 2748c2ecf20Sopenharmony_ci [SLAVE_IMEM] = &slv_imem, 2758c2ecf20Sopenharmony_ci [SLAVE_QDSS_STM] = &slv_qdss_stm, 2768c2ecf20Sopenharmony_ci [SLAVE_SRVC_SNOC] = &slv_srvc_snoc, 2778c2ecf20Sopenharmony_ci [SNOC_BIMC_0_MAS] = &snoc_bimc_0_mas, 2788c2ecf20Sopenharmony_ci [SNOC_BIMC_1_MAS] = &snoc_bimc_1_mas, 2798c2ecf20Sopenharmony_ci [SNOC_INT_0] = &snoc_int_0, 2808c2ecf20Sopenharmony_ci [SNOC_INT_1] = &snoc_int_1, 2818c2ecf20Sopenharmony_ci [SNOC_INT_BIMC] = &snoc_int_bimc, 2828c2ecf20Sopenharmony_ci [SNOC_PCNOC_MAS] = &snoc_pcnoc_mas, 2838c2ecf20Sopenharmony_ci [SNOC_QDSS_INT] = &qdss_int, 2848c2ecf20Sopenharmony_ci}; 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_cistatic struct msm8916_icc_desc msm8916_snoc = { 2878c2ecf20Sopenharmony_ci .nodes = msm8916_snoc_nodes, 2888c2ecf20Sopenharmony_ci .num_nodes = ARRAY_SIZE(msm8916_snoc_nodes), 2898c2ecf20Sopenharmony_ci}; 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_cistatic struct msm8916_icc_node *msm8916_bimc_nodes[] = { 2928c2ecf20Sopenharmony_ci [BIMC_SNOC_MAS] = &bimc_snoc_mas, 2938c2ecf20Sopenharmony_ci [MASTER_AMPSS_M0] = &mas_apss, 2948c2ecf20Sopenharmony_ci [MASTER_GRAPHICS_3D] = &mas_gfx, 2958c2ecf20Sopenharmony_ci [MASTER_TCU0] = &mas_tcu0, 2968c2ecf20Sopenharmony_ci [MASTER_TCU1] = &mas_tcu1, 2978c2ecf20Sopenharmony_ci [SLAVE_AMPSS_L2] = &slv_apps_l2, 2988c2ecf20Sopenharmony_ci [SLAVE_EBI_CH0] = &slv_ebi_ch0, 2998c2ecf20Sopenharmony_ci [SNOC_BIMC_0_SLV] = &snoc_bimc_0_slv, 3008c2ecf20Sopenharmony_ci [SNOC_BIMC_1_SLV] = &snoc_bimc_1_slv, 3018c2ecf20Sopenharmony_ci}; 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_cistatic struct msm8916_icc_desc msm8916_bimc = { 3048c2ecf20Sopenharmony_ci .nodes = msm8916_bimc_nodes, 3058c2ecf20Sopenharmony_ci .num_nodes = ARRAY_SIZE(msm8916_bimc_nodes), 3068c2ecf20Sopenharmony_ci}; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_cistatic struct msm8916_icc_node *msm8916_pcnoc_nodes[] = { 3098c2ecf20Sopenharmony_ci [MASTER_BLSP_1] = &mas_blsp_1, 3108c2ecf20Sopenharmony_ci [MASTER_DEHR] = &mas_dehr, 3118c2ecf20Sopenharmony_ci [MASTER_LPASS] = &mas_audio, 3128c2ecf20Sopenharmony_ci [MASTER_CRYPTO_CORE0] = &mas_pcnoc_crypto_0, 3138c2ecf20Sopenharmony_ci [MASTER_SDCC_1] = &mas_pcnoc_sdcc_1, 3148c2ecf20Sopenharmony_ci [MASTER_SDCC_2] = &mas_pcnoc_sdcc_2, 3158c2ecf20Sopenharmony_ci [MASTER_SPDM] = &mas_spdm, 3168c2ecf20Sopenharmony_ci [MASTER_USB_HS] = &mas_usb_hs, 3178c2ecf20Sopenharmony_ci [PCNOC_INT_0] = &pcnoc_int_0, 3188c2ecf20Sopenharmony_ci [PCNOC_INT_1] = &pcnoc_int_1, 3198c2ecf20Sopenharmony_ci [PCNOC_MAS_0] = &pcnoc_m_0, 3208c2ecf20Sopenharmony_ci [PCNOC_MAS_1] = &pcnoc_m_1, 3218c2ecf20Sopenharmony_ci [PCNOC_SLV_0] = &pcnoc_s_0, 3228c2ecf20Sopenharmony_ci [PCNOC_SLV_1] = &pcnoc_s_1, 3238c2ecf20Sopenharmony_ci [PCNOC_SLV_2] = &pcnoc_s_2, 3248c2ecf20Sopenharmony_ci [PCNOC_SLV_3] = &pcnoc_s_3, 3258c2ecf20Sopenharmony_ci [PCNOC_SLV_4] = &pcnoc_s_4, 3268c2ecf20Sopenharmony_ci [PCNOC_SLV_8] = &pcnoc_s_8, 3278c2ecf20Sopenharmony_ci [PCNOC_SLV_9] = &pcnoc_s_9, 3288c2ecf20Sopenharmony_ci [PCNOC_SNOC_MAS] = &pcnoc_snoc_mas, 3298c2ecf20Sopenharmony_ci [SLAVE_BIMC_CFG] = &slv_bimc_cfg, 3308c2ecf20Sopenharmony_ci [SLAVE_BLSP_1] = &slv_blsp_1, 3318c2ecf20Sopenharmony_ci [SLAVE_BOOT_ROM] = &slv_boot_rom, 3328c2ecf20Sopenharmony_ci [SLAVE_CAMERA_CFG] = &slv_camera_cfg, 3338c2ecf20Sopenharmony_ci [SLAVE_CLK_CTL] = &slv_clk_ctl, 3348c2ecf20Sopenharmony_ci [SLAVE_CRYPTO_0_CFG] = &slv_crypto_0_cfg, 3358c2ecf20Sopenharmony_ci [SLAVE_DEHR_CFG] = &slv_dehr_cfg, 3368c2ecf20Sopenharmony_ci [SLAVE_DISPLAY_CFG] = &slv_display_cfg, 3378c2ecf20Sopenharmony_ci [SLAVE_GRAPHICS_3D_CFG] = &slv_gfx_cfg, 3388c2ecf20Sopenharmony_ci [SLAVE_IMEM_CFG] = &slv_imem_cfg, 3398c2ecf20Sopenharmony_ci [SLAVE_LPASS] = &slv_audio, 3408c2ecf20Sopenharmony_ci [SLAVE_MPM] = &slv_mpm, 3418c2ecf20Sopenharmony_ci [SLAVE_MSG_RAM] = &slv_msg_ram, 3428c2ecf20Sopenharmony_ci [SLAVE_MSS] = &slv_mss, 3438c2ecf20Sopenharmony_ci [SLAVE_PDM] = &slv_pdm, 3448c2ecf20Sopenharmony_ci [SLAVE_PMIC_ARB] = &slv_pmic_arb, 3458c2ecf20Sopenharmony_ci [SLAVE_PCNOC_CFG] = &slv_pcnoc_cfg, 3468c2ecf20Sopenharmony_ci [SLAVE_PRNG] = &slv_prng, 3478c2ecf20Sopenharmony_ci [SLAVE_QDSS_CFG] = &slv_qdss_cfg, 3488c2ecf20Sopenharmony_ci [SLAVE_RBCPR_CFG] = &slv_rbcpr_cfg, 3498c2ecf20Sopenharmony_ci [SLAVE_SDCC_1] = &slv_sdcc_1, 3508c2ecf20Sopenharmony_ci [SLAVE_SDCC_2] = &slv_sdcc_2, 3518c2ecf20Sopenharmony_ci [SLAVE_SECURITY] = &slv_security, 3528c2ecf20Sopenharmony_ci [SLAVE_SNOC_CFG] = &slv_snoc_cfg, 3538c2ecf20Sopenharmony_ci [SLAVE_SPDM] = &slv_spdm, 3548c2ecf20Sopenharmony_ci [SLAVE_TCSR] = &slv_tcsr, 3558c2ecf20Sopenharmony_ci [SLAVE_TLMM] = &slv_tlmm, 3568c2ecf20Sopenharmony_ci [SLAVE_USB_HS] = &slv_usb_hs, 3578c2ecf20Sopenharmony_ci [SLAVE_VENUS_CFG] = &slv_venus_cfg, 3588c2ecf20Sopenharmony_ci [SNOC_PCNOC_SLV] = &snoc_pcnoc_slv, 3598c2ecf20Sopenharmony_ci}; 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_cistatic struct msm8916_icc_desc msm8916_pcnoc = { 3628c2ecf20Sopenharmony_ci .nodes = msm8916_pcnoc_nodes, 3638c2ecf20Sopenharmony_ci .num_nodes = ARRAY_SIZE(msm8916_pcnoc_nodes), 3648c2ecf20Sopenharmony_ci}; 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_cistatic int msm8916_icc_set(struct icc_node *src, struct icc_node *dst) 3678c2ecf20Sopenharmony_ci{ 3688c2ecf20Sopenharmony_ci struct msm8916_icc_provider *qp; 3698c2ecf20Sopenharmony_ci struct msm8916_icc_node *qn; 3708c2ecf20Sopenharmony_ci u64 sum_bw, max_peak_bw, rate; 3718c2ecf20Sopenharmony_ci u32 agg_avg = 0, agg_peak = 0; 3728c2ecf20Sopenharmony_ci struct icc_provider *provider; 3738c2ecf20Sopenharmony_ci struct icc_node *n; 3748c2ecf20Sopenharmony_ci int ret, i; 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ci qn = src->data; 3778c2ecf20Sopenharmony_ci provider = src->provider; 3788c2ecf20Sopenharmony_ci qp = to_msm8916_provider(provider); 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci list_for_each_entry(n, &provider->nodes, node_list) 3818c2ecf20Sopenharmony_ci provider->aggregate(n, 0, n->avg_bw, n->peak_bw, 3828c2ecf20Sopenharmony_ci &agg_avg, &agg_peak); 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci sum_bw = icc_units_to_bps(agg_avg); 3858c2ecf20Sopenharmony_ci max_peak_bw = icc_units_to_bps(agg_peak); 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_ci /* send bandwidth request message to the RPM processor */ 3888c2ecf20Sopenharmony_ci if (qn->mas_rpm_id != -1) { 3898c2ecf20Sopenharmony_ci ret = qcom_icc_rpm_smd_send(QCOM_SMD_RPM_ACTIVE_STATE, 3908c2ecf20Sopenharmony_ci RPM_BUS_MASTER_REQ, 3918c2ecf20Sopenharmony_ci qn->mas_rpm_id, 3928c2ecf20Sopenharmony_ci sum_bw); 3938c2ecf20Sopenharmony_ci if (ret) { 3948c2ecf20Sopenharmony_ci pr_err("qcom_icc_rpm_smd_send mas %d error %d\n", 3958c2ecf20Sopenharmony_ci qn->mas_rpm_id, ret); 3968c2ecf20Sopenharmony_ci return ret; 3978c2ecf20Sopenharmony_ci } 3988c2ecf20Sopenharmony_ci } 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci if (qn->slv_rpm_id != -1) { 4018c2ecf20Sopenharmony_ci ret = qcom_icc_rpm_smd_send(QCOM_SMD_RPM_ACTIVE_STATE, 4028c2ecf20Sopenharmony_ci RPM_BUS_SLAVE_REQ, 4038c2ecf20Sopenharmony_ci qn->slv_rpm_id, 4048c2ecf20Sopenharmony_ci sum_bw); 4058c2ecf20Sopenharmony_ci if (ret) { 4068c2ecf20Sopenharmony_ci pr_err("qcom_icc_rpm_smd_send slv error %d\n", 4078c2ecf20Sopenharmony_ci ret); 4088c2ecf20Sopenharmony_ci return ret; 4098c2ecf20Sopenharmony_ci } 4108c2ecf20Sopenharmony_ci } 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci rate = max(sum_bw, max_peak_bw); 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci do_div(rate, qn->buswidth); 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_ci if (qn->rate == rate) 4178c2ecf20Sopenharmony_ci return 0; 4188c2ecf20Sopenharmony_ci 4198c2ecf20Sopenharmony_ci for (i = 0; i < qp->num_clks; i++) { 4208c2ecf20Sopenharmony_ci ret = clk_set_rate(qp->bus_clks[i].clk, rate); 4218c2ecf20Sopenharmony_ci if (ret) { 4228c2ecf20Sopenharmony_ci pr_err("%s clk_set_rate error: %d\n", 4238c2ecf20Sopenharmony_ci qp->bus_clks[i].id, ret); 4248c2ecf20Sopenharmony_ci return ret; 4258c2ecf20Sopenharmony_ci } 4268c2ecf20Sopenharmony_ci } 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ci qn->rate = rate; 4298c2ecf20Sopenharmony_ci 4308c2ecf20Sopenharmony_ci return 0; 4318c2ecf20Sopenharmony_ci} 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_cistatic int msm8916_qnoc_probe(struct platform_device *pdev) 4348c2ecf20Sopenharmony_ci{ 4358c2ecf20Sopenharmony_ci const struct msm8916_icc_desc *desc; 4368c2ecf20Sopenharmony_ci struct msm8916_icc_node **qnodes; 4378c2ecf20Sopenharmony_ci struct msm8916_icc_provider *qp; 4388c2ecf20Sopenharmony_ci struct device *dev = &pdev->dev; 4398c2ecf20Sopenharmony_ci struct icc_onecell_data *data; 4408c2ecf20Sopenharmony_ci struct icc_provider *provider; 4418c2ecf20Sopenharmony_ci struct icc_node *node; 4428c2ecf20Sopenharmony_ci size_t num_nodes, i; 4438c2ecf20Sopenharmony_ci int ret; 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_ci /* wait for the RPM proxy */ 4468c2ecf20Sopenharmony_ci if (!qcom_icc_rpm_smd_available()) 4478c2ecf20Sopenharmony_ci return -EPROBE_DEFER; 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_ci desc = of_device_get_match_data(dev); 4508c2ecf20Sopenharmony_ci if (!desc) 4518c2ecf20Sopenharmony_ci return -EINVAL; 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_ci qnodes = desc->nodes; 4548c2ecf20Sopenharmony_ci num_nodes = desc->num_nodes; 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_ci qp = devm_kzalloc(dev, sizeof(*qp), GFP_KERNEL); 4578c2ecf20Sopenharmony_ci if (!qp) 4588c2ecf20Sopenharmony_ci return -ENOMEM; 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_ci data = devm_kzalloc(dev, struct_size(data, nodes, num_nodes), 4618c2ecf20Sopenharmony_ci GFP_KERNEL); 4628c2ecf20Sopenharmony_ci if (!data) 4638c2ecf20Sopenharmony_ci return -ENOMEM; 4648c2ecf20Sopenharmony_ci 4658c2ecf20Sopenharmony_ci qp->bus_clks = devm_kmemdup(dev, msm8916_bus_clocks, 4668c2ecf20Sopenharmony_ci sizeof(msm8916_bus_clocks), GFP_KERNEL); 4678c2ecf20Sopenharmony_ci if (!qp->bus_clks) 4688c2ecf20Sopenharmony_ci return -ENOMEM; 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci qp->num_clks = ARRAY_SIZE(msm8916_bus_clocks); 4718c2ecf20Sopenharmony_ci ret = devm_clk_bulk_get(dev, qp->num_clks, qp->bus_clks); 4728c2ecf20Sopenharmony_ci if (ret) 4738c2ecf20Sopenharmony_ci return ret; 4748c2ecf20Sopenharmony_ci 4758c2ecf20Sopenharmony_ci ret = clk_bulk_prepare_enable(qp->num_clks, qp->bus_clks); 4768c2ecf20Sopenharmony_ci if (ret) 4778c2ecf20Sopenharmony_ci return ret; 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci provider = &qp->provider; 4808c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&provider->nodes); 4818c2ecf20Sopenharmony_ci provider->dev = dev; 4828c2ecf20Sopenharmony_ci provider->set = msm8916_icc_set; 4838c2ecf20Sopenharmony_ci provider->aggregate = icc_std_aggregate; 4848c2ecf20Sopenharmony_ci provider->xlate = of_icc_xlate_onecell; 4858c2ecf20Sopenharmony_ci provider->data = data; 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_ci ret = icc_provider_add(provider); 4888c2ecf20Sopenharmony_ci if (ret) { 4898c2ecf20Sopenharmony_ci dev_err(dev, "error adding interconnect provider: %d\n", ret); 4908c2ecf20Sopenharmony_ci clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks); 4918c2ecf20Sopenharmony_ci return ret; 4928c2ecf20Sopenharmony_ci } 4938c2ecf20Sopenharmony_ci 4948c2ecf20Sopenharmony_ci for (i = 0; i < num_nodes; i++) { 4958c2ecf20Sopenharmony_ci size_t j; 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ci node = icc_node_create(qnodes[i]->id); 4988c2ecf20Sopenharmony_ci if (IS_ERR(node)) { 4998c2ecf20Sopenharmony_ci ret = PTR_ERR(node); 5008c2ecf20Sopenharmony_ci goto err; 5018c2ecf20Sopenharmony_ci } 5028c2ecf20Sopenharmony_ci 5038c2ecf20Sopenharmony_ci node->name = qnodes[i]->name; 5048c2ecf20Sopenharmony_ci node->data = qnodes[i]; 5058c2ecf20Sopenharmony_ci icc_node_add(node, provider); 5068c2ecf20Sopenharmony_ci 5078c2ecf20Sopenharmony_ci for (j = 0; j < qnodes[i]->num_links; j++) 5088c2ecf20Sopenharmony_ci icc_link_create(node, qnodes[i]->links[j]); 5098c2ecf20Sopenharmony_ci 5108c2ecf20Sopenharmony_ci data->nodes[i] = node; 5118c2ecf20Sopenharmony_ci } 5128c2ecf20Sopenharmony_ci data->num_nodes = num_nodes; 5138c2ecf20Sopenharmony_ci 5148c2ecf20Sopenharmony_ci platform_set_drvdata(pdev, qp); 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci return 0; 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_cierr: 5198c2ecf20Sopenharmony_ci icc_nodes_remove(provider); 5208c2ecf20Sopenharmony_ci icc_provider_del(provider); 5218c2ecf20Sopenharmony_ci clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks); 5228c2ecf20Sopenharmony_ci 5238c2ecf20Sopenharmony_ci return ret; 5248c2ecf20Sopenharmony_ci} 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_cistatic int msm8916_qnoc_remove(struct platform_device *pdev) 5278c2ecf20Sopenharmony_ci{ 5288c2ecf20Sopenharmony_ci struct msm8916_icc_provider *qp = platform_get_drvdata(pdev); 5298c2ecf20Sopenharmony_ci 5308c2ecf20Sopenharmony_ci icc_nodes_remove(&qp->provider); 5318c2ecf20Sopenharmony_ci clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks); 5328c2ecf20Sopenharmony_ci return icc_provider_del(&qp->provider); 5338c2ecf20Sopenharmony_ci} 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_cistatic const struct of_device_id msm8916_noc_of_match[] = { 5368c2ecf20Sopenharmony_ci { .compatible = "qcom,msm8916-bimc", .data = &msm8916_bimc }, 5378c2ecf20Sopenharmony_ci { .compatible = "qcom,msm8916-pcnoc", .data = &msm8916_pcnoc }, 5388c2ecf20Sopenharmony_ci { .compatible = "qcom,msm8916-snoc", .data = &msm8916_snoc }, 5398c2ecf20Sopenharmony_ci { } 5408c2ecf20Sopenharmony_ci}; 5418c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, msm8916_noc_of_match); 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_cistatic struct platform_driver msm8916_noc_driver = { 5448c2ecf20Sopenharmony_ci .probe = msm8916_qnoc_probe, 5458c2ecf20Sopenharmony_ci .remove = msm8916_qnoc_remove, 5468c2ecf20Sopenharmony_ci .driver = { 5478c2ecf20Sopenharmony_ci .name = "qnoc-msm8916", 5488c2ecf20Sopenharmony_ci .of_match_table = msm8916_noc_of_match, 5498c2ecf20Sopenharmony_ci }, 5508c2ecf20Sopenharmony_ci}; 5518c2ecf20Sopenharmony_cimodule_platform_driver(msm8916_noc_driver); 5528c2ecf20Sopenharmony_ciMODULE_AUTHOR("Georgi Djakov <georgi.djakov@linaro.org>"); 5538c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Qualcomm MSM8916 NoC driver"); 5548c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2"); 555