18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright 2017 Broadcom 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <linux/err.h> 78c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 88c2ecf20Sopenharmony_ci#include <linux/of_device.h> 98c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <dt-bindings/clock/bcm-sr.h> 128c2ecf20Sopenharmony_ci#include "clk-iproc.h" 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define REG_VAL(o, s, w) { .offset = o, .shift = s, .width = w, } 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define AON_VAL(o, pw, ps, is) { .offset = o, .pwr_width = pw, \ 178c2ecf20Sopenharmony_ci .pwr_shift = ps, .iso_shift = is } 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define SW_CTRL_VAL(o, s) { .offset = o, .shift = s, } 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define RESET_VAL(o, rs, prs) { .offset = o, .reset_shift = rs, \ 228c2ecf20Sopenharmony_ci .p_reset_shift = prs } 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define DF_VAL(o, kis, kiw, kps, kpw, kas, kaw) { .offset = o, \ 258c2ecf20Sopenharmony_ci .ki_shift = kis, .ki_width = kiw, .kp_shift = kps, .kp_width = kpw, \ 268c2ecf20Sopenharmony_ci .ka_shift = kas, .ka_width = kaw } 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define VCO_CTRL_VAL(uo, lo) { .u_offset = uo, .l_offset = lo } 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define ENABLE_VAL(o, es, hs, bs) { .offset = o, .enable_shift = es, \ 318c2ecf20Sopenharmony_ci .hold_shift = hs, .bypass_shift = bs } 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistatic const struct iproc_pll_ctrl sr_genpll0 = { 358c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON | IPROC_CLK_PLL_HAS_NDIV_FRAC | 368c2ecf20Sopenharmony_ci IPROC_CLK_PLL_NEEDS_SW_CFG, 378c2ecf20Sopenharmony_ci .aon = AON_VAL(0x0, 5, 1, 0), 388c2ecf20Sopenharmony_ci .reset = RESET_VAL(0x0, 12, 11), 398c2ecf20Sopenharmony_ci .dig_filter = DF_VAL(0x0, 4, 3, 0, 4, 7, 3), 408c2ecf20Sopenharmony_ci .sw_ctrl = SW_CTRL_VAL(0x10, 31), 418c2ecf20Sopenharmony_ci .ndiv_int = REG_VAL(0x10, 20, 10), 428c2ecf20Sopenharmony_ci .ndiv_frac = REG_VAL(0x10, 0, 20), 438c2ecf20Sopenharmony_ci .pdiv = REG_VAL(0x14, 0, 4), 448c2ecf20Sopenharmony_ci .status = REG_VAL(0x30, 12, 1), 458c2ecf20Sopenharmony_ci}; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistatic const struct iproc_clk_ctrl sr_genpll0_clk[] = { 488c2ecf20Sopenharmony_ci [BCM_SR_GENPLL0_125M_CLK] = { 498c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL0_125M_CLK, 508c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 518c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 6, 0, 12), 528c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 0, 9), 538c2ecf20Sopenharmony_ci }, 548c2ecf20Sopenharmony_ci [BCM_SR_GENPLL0_SCR_CLK] = { 558c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL0_SCR_CLK, 568c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 578c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 7, 1, 13), 588c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 10, 9), 598c2ecf20Sopenharmony_ci }, 608c2ecf20Sopenharmony_ci [BCM_SR_GENPLL0_250M_CLK] = { 618c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL0_250M_CLK, 628c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 638c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 8, 2, 14), 648c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 20, 9), 658c2ecf20Sopenharmony_ci }, 668c2ecf20Sopenharmony_ci [BCM_SR_GENPLL0_PCIE_AXI_CLK] = { 678c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL0_PCIE_AXI_CLK, 688c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 698c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 9, 3, 15), 708c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x1c, 0, 9), 718c2ecf20Sopenharmony_ci }, 728c2ecf20Sopenharmony_ci [BCM_SR_GENPLL0_PAXC_AXI_X2_CLK] = { 738c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL0_PAXC_AXI_X2_CLK, 748c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 758c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 10, 4, 16), 768c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x1c, 10, 9), 778c2ecf20Sopenharmony_ci }, 788c2ecf20Sopenharmony_ci [BCM_SR_GENPLL0_PAXC_AXI_CLK] = { 798c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL0_PAXC_AXI_CLK, 808c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 818c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 11, 5, 17), 828c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x1c, 20, 9), 838c2ecf20Sopenharmony_ci }, 848c2ecf20Sopenharmony_ci}; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cistatic int sr_genpll0_clk_init(struct platform_device *pdev) 878c2ecf20Sopenharmony_ci{ 888c2ecf20Sopenharmony_ci iproc_pll_clk_setup(pdev->dev.of_node, 898c2ecf20Sopenharmony_ci &sr_genpll0, NULL, 0, sr_genpll0_clk, 908c2ecf20Sopenharmony_ci ARRAY_SIZE(sr_genpll0_clk)); 918c2ecf20Sopenharmony_ci return 0; 928c2ecf20Sopenharmony_ci} 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cistatic const struct iproc_pll_ctrl sr_genpll2 = { 958c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON | IPROC_CLK_PLL_HAS_NDIV_FRAC | 968c2ecf20Sopenharmony_ci IPROC_CLK_PLL_NEEDS_SW_CFG, 978c2ecf20Sopenharmony_ci .aon = AON_VAL(0x0, 1, 13, 12), 988c2ecf20Sopenharmony_ci .reset = RESET_VAL(0x0, 12, 11), 998c2ecf20Sopenharmony_ci .dig_filter = DF_VAL(0x0, 4, 3, 0, 4, 7, 3), 1008c2ecf20Sopenharmony_ci .sw_ctrl = SW_CTRL_VAL(0x10, 31), 1018c2ecf20Sopenharmony_ci .ndiv_int = REG_VAL(0x10, 20, 10), 1028c2ecf20Sopenharmony_ci .ndiv_frac = REG_VAL(0x10, 0, 20), 1038c2ecf20Sopenharmony_ci .pdiv = REG_VAL(0x14, 0, 4), 1048c2ecf20Sopenharmony_ci .status = REG_VAL(0x30, 12, 1), 1058c2ecf20Sopenharmony_ci}; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_cistatic const struct iproc_clk_ctrl sr_genpll2_clk[] = { 1088c2ecf20Sopenharmony_ci [BCM_SR_GENPLL2_NIC_CLK] = { 1098c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL2_NIC_CLK, 1108c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 1118c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 6, 0, 12), 1128c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 0, 9), 1138c2ecf20Sopenharmony_ci }, 1148c2ecf20Sopenharmony_ci [BCM_SR_GENPLL2_TS_500_CLK] = { 1158c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL2_TS_500_CLK, 1168c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 1178c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 7, 1, 13), 1188c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 10, 9), 1198c2ecf20Sopenharmony_ci }, 1208c2ecf20Sopenharmony_ci [BCM_SR_GENPLL2_125_NITRO_CLK] = { 1218c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL2_125_NITRO_CLK, 1228c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 1238c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 8, 2, 14), 1248c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 20, 9), 1258c2ecf20Sopenharmony_ci }, 1268c2ecf20Sopenharmony_ci [BCM_SR_GENPLL2_CHIMP_CLK] = { 1278c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL2_CHIMP_CLK, 1288c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 1298c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 9, 3, 15), 1308c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x1c, 0, 9), 1318c2ecf20Sopenharmony_ci }, 1328c2ecf20Sopenharmony_ci [BCM_SR_GENPLL2_NIC_FLASH_CLK] = { 1338c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL2_NIC_FLASH_CLK, 1348c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 1358c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 10, 4, 16), 1368c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x1c, 10, 9), 1378c2ecf20Sopenharmony_ci }, 1388c2ecf20Sopenharmony_ci [BCM_SR_GENPLL2_FS4_CLK] = { 1398c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL2_FS4_CLK, 1408c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 11, 5, 17), 1418c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x1c, 20, 9), 1428c2ecf20Sopenharmony_ci }, 1438c2ecf20Sopenharmony_ci}; 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_cistatic int sr_genpll2_clk_init(struct platform_device *pdev) 1468c2ecf20Sopenharmony_ci{ 1478c2ecf20Sopenharmony_ci iproc_pll_clk_setup(pdev->dev.of_node, 1488c2ecf20Sopenharmony_ci &sr_genpll2, NULL, 0, sr_genpll2_clk, 1498c2ecf20Sopenharmony_ci ARRAY_SIZE(sr_genpll2_clk)); 1508c2ecf20Sopenharmony_ci return 0; 1518c2ecf20Sopenharmony_ci} 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_cistatic const struct iproc_pll_ctrl sr_genpll3 = { 1548c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON | IPROC_CLK_PLL_HAS_NDIV_FRAC | 1558c2ecf20Sopenharmony_ci IPROC_CLK_PLL_NEEDS_SW_CFG, 1568c2ecf20Sopenharmony_ci .aon = AON_VAL(0x0, 1, 19, 18), 1578c2ecf20Sopenharmony_ci .reset = RESET_VAL(0x0, 12, 11), 1588c2ecf20Sopenharmony_ci .dig_filter = DF_VAL(0x0, 4, 3, 0, 4, 7, 3), 1598c2ecf20Sopenharmony_ci .sw_ctrl = SW_CTRL_VAL(0x10, 31), 1608c2ecf20Sopenharmony_ci .ndiv_int = REG_VAL(0x10, 20, 10), 1618c2ecf20Sopenharmony_ci .ndiv_frac = REG_VAL(0x10, 0, 20), 1628c2ecf20Sopenharmony_ci .pdiv = REG_VAL(0x14, 0, 4), 1638c2ecf20Sopenharmony_ci .status = REG_VAL(0x30, 12, 1), 1648c2ecf20Sopenharmony_ci}; 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_cistatic const struct iproc_clk_ctrl sr_genpll3_clk[] = { 1678c2ecf20Sopenharmony_ci [BCM_SR_GENPLL3_HSLS_CLK] = { 1688c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL3_HSLS_CLK, 1698c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 1708c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 6, 0, 12), 1718c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 0, 9), 1728c2ecf20Sopenharmony_ci }, 1738c2ecf20Sopenharmony_ci [BCM_SR_GENPLL3_SDIO_CLK] = { 1748c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL3_SDIO_CLK, 1758c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 1768c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 7, 1, 13), 1778c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 10, 9), 1788c2ecf20Sopenharmony_ci }, 1798c2ecf20Sopenharmony_ci}; 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_cistatic void sr_genpll3_clk_init(struct device_node *node) 1828c2ecf20Sopenharmony_ci{ 1838c2ecf20Sopenharmony_ci iproc_pll_clk_setup(node, &sr_genpll3, NULL, 0, sr_genpll3_clk, 1848c2ecf20Sopenharmony_ci ARRAY_SIZE(sr_genpll3_clk)); 1858c2ecf20Sopenharmony_ci} 1868c2ecf20Sopenharmony_ciCLK_OF_DECLARE(sr_genpll3_clk, "brcm,sr-genpll3", sr_genpll3_clk_init); 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_cistatic const struct iproc_pll_ctrl sr_genpll4 = { 1898c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON | IPROC_CLK_PLL_HAS_NDIV_FRAC | 1908c2ecf20Sopenharmony_ci IPROC_CLK_PLL_NEEDS_SW_CFG, 1918c2ecf20Sopenharmony_ci .aon = AON_VAL(0x0, 1, 25, 24), 1928c2ecf20Sopenharmony_ci .reset = RESET_VAL(0x0, 12, 11), 1938c2ecf20Sopenharmony_ci .dig_filter = DF_VAL(0x0, 4, 3, 0, 4, 7, 3), 1948c2ecf20Sopenharmony_ci .sw_ctrl = SW_CTRL_VAL(0x10, 31), 1958c2ecf20Sopenharmony_ci .ndiv_int = REG_VAL(0x10, 20, 10), 1968c2ecf20Sopenharmony_ci .ndiv_frac = REG_VAL(0x10, 0, 20), 1978c2ecf20Sopenharmony_ci .pdiv = REG_VAL(0x14, 0, 4), 1988c2ecf20Sopenharmony_ci .status = REG_VAL(0x30, 12, 1), 1998c2ecf20Sopenharmony_ci}; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_cistatic const struct iproc_clk_ctrl sr_genpll4_clk[] = { 2028c2ecf20Sopenharmony_ci [BCM_SR_GENPLL4_CCN_CLK] = { 2038c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL4_CCN_CLK, 2048c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 2058c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 6, 0, 12), 2068c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 0, 9), 2078c2ecf20Sopenharmony_ci }, 2088c2ecf20Sopenharmony_ci [BCM_SR_GENPLL4_TPIU_PLL_CLK] = { 2098c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL4_TPIU_PLL_CLK, 2108c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 2118c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 7, 1, 13), 2128c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 10, 9), 2138c2ecf20Sopenharmony_ci }, 2148c2ecf20Sopenharmony_ci [BCM_SR_GENPLL4_NOC_CLK] = { 2158c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL4_NOC_CLK, 2168c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 2178c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 8, 2, 14), 2188c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 20, 9), 2198c2ecf20Sopenharmony_ci }, 2208c2ecf20Sopenharmony_ci [BCM_SR_GENPLL4_CHCLK_FS4_CLK] = { 2218c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL4_CHCLK_FS4_CLK, 2228c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 2238c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 9, 3, 15), 2248c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x1c, 0, 9), 2258c2ecf20Sopenharmony_ci }, 2268c2ecf20Sopenharmony_ci [BCM_SR_GENPLL4_BRIDGE_FSCPU_CLK] = { 2278c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL4_BRIDGE_FSCPU_CLK, 2288c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 2298c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 10, 4, 16), 2308c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x1c, 10, 9), 2318c2ecf20Sopenharmony_ci }, 2328c2ecf20Sopenharmony_ci}; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_cistatic int sr_genpll4_clk_init(struct platform_device *pdev) 2358c2ecf20Sopenharmony_ci{ 2368c2ecf20Sopenharmony_ci iproc_pll_clk_setup(pdev->dev.of_node, 2378c2ecf20Sopenharmony_ci &sr_genpll4, NULL, 0, sr_genpll4_clk, 2388c2ecf20Sopenharmony_ci ARRAY_SIZE(sr_genpll4_clk)); 2398c2ecf20Sopenharmony_ci return 0; 2408c2ecf20Sopenharmony_ci} 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_cistatic const struct iproc_pll_ctrl sr_genpll5 = { 2438c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON | IPROC_CLK_PLL_HAS_NDIV_FRAC | 2448c2ecf20Sopenharmony_ci IPROC_CLK_PLL_NEEDS_SW_CFG, 2458c2ecf20Sopenharmony_ci .aon = AON_VAL(0x0, 1, 1, 0), 2468c2ecf20Sopenharmony_ci .reset = RESET_VAL(0x0, 12, 11), 2478c2ecf20Sopenharmony_ci .dig_filter = DF_VAL(0x0, 4, 3, 0, 4, 7, 3), 2488c2ecf20Sopenharmony_ci .sw_ctrl = SW_CTRL_VAL(0x10, 31), 2498c2ecf20Sopenharmony_ci .ndiv_int = REG_VAL(0x10, 20, 10), 2508c2ecf20Sopenharmony_ci .ndiv_frac = REG_VAL(0x10, 0, 20), 2518c2ecf20Sopenharmony_ci .pdiv = REG_VAL(0x14, 0, 4), 2528c2ecf20Sopenharmony_ci .status = REG_VAL(0x30, 12, 1), 2538c2ecf20Sopenharmony_ci}; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_cistatic const struct iproc_clk_ctrl sr_genpll5_clk[] = { 2568c2ecf20Sopenharmony_ci [BCM_SR_GENPLL5_FS4_HF_CLK] = { 2578c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL5_FS4_HF_CLK, 2588c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 6, 0, 12), 2598c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 0, 9), 2608c2ecf20Sopenharmony_ci }, 2618c2ecf20Sopenharmony_ci [BCM_SR_GENPLL5_CRYPTO_AE_CLK] = { 2628c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL5_CRYPTO_AE_CLK, 2638c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 7, 1, 12), 2648c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 10, 9), 2658c2ecf20Sopenharmony_ci }, 2668c2ecf20Sopenharmony_ci [BCM_SR_GENPLL5_RAID_AE_CLK] = { 2678c2ecf20Sopenharmony_ci .channel = BCM_SR_GENPLL5_RAID_AE_CLK, 2688c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x4, 8, 2, 14), 2698c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 20, 9), 2708c2ecf20Sopenharmony_ci }, 2718c2ecf20Sopenharmony_ci}; 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_cistatic int sr_genpll5_clk_init(struct platform_device *pdev) 2748c2ecf20Sopenharmony_ci{ 2758c2ecf20Sopenharmony_ci iproc_pll_clk_setup(pdev->dev.of_node, 2768c2ecf20Sopenharmony_ci &sr_genpll5, NULL, 0, sr_genpll5_clk, 2778c2ecf20Sopenharmony_ci ARRAY_SIZE(sr_genpll5_clk)); 2788c2ecf20Sopenharmony_ci return 0; 2798c2ecf20Sopenharmony_ci} 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_cistatic const struct iproc_pll_ctrl sr_lcpll0 = { 2828c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON | IPROC_CLK_PLL_NEEDS_SW_CFG, 2838c2ecf20Sopenharmony_ci .aon = AON_VAL(0x0, 2, 19, 18), 2848c2ecf20Sopenharmony_ci .reset = RESET_VAL(0x0, 31, 30), 2858c2ecf20Sopenharmony_ci .sw_ctrl = SW_CTRL_VAL(0x4, 31), 2868c2ecf20Sopenharmony_ci .ndiv_int = REG_VAL(0x4, 16, 10), 2878c2ecf20Sopenharmony_ci .pdiv = REG_VAL(0x4, 26, 4), 2888c2ecf20Sopenharmony_ci .status = REG_VAL(0x38, 12, 1), 2898c2ecf20Sopenharmony_ci}; 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_cistatic const struct iproc_clk_ctrl sr_lcpll0_clk[] = { 2928c2ecf20Sopenharmony_ci [BCM_SR_LCPLL0_SATA_REFP_CLK] = { 2938c2ecf20Sopenharmony_ci .channel = BCM_SR_LCPLL0_SATA_REFP_CLK, 2948c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 2958c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x0, 7, 1, 13), 2968c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x14, 0, 9), 2978c2ecf20Sopenharmony_ci }, 2988c2ecf20Sopenharmony_ci [BCM_SR_LCPLL0_SATA_REFN_CLK] = { 2998c2ecf20Sopenharmony_ci .channel = BCM_SR_LCPLL0_SATA_REFN_CLK, 3008c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 3018c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x0, 8, 2, 14), 3028c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x14, 10, 9), 3038c2ecf20Sopenharmony_ci }, 3048c2ecf20Sopenharmony_ci [BCM_SR_LCPLL0_SATA_350_CLK] = { 3058c2ecf20Sopenharmony_ci .channel = BCM_SR_LCPLL0_SATA_350_CLK, 3068c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 3078c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x0, 9, 3, 15), 3088c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x14, 20, 9), 3098c2ecf20Sopenharmony_ci }, 3108c2ecf20Sopenharmony_ci [BCM_SR_LCPLL0_SATA_500_CLK] = { 3118c2ecf20Sopenharmony_ci .channel = BCM_SR_LCPLL0_SATA_500_CLK, 3128c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 3138c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x0, 10, 4, 16), 3148c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x18, 0, 9), 3158c2ecf20Sopenharmony_ci }, 3168c2ecf20Sopenharmony_ci}; 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_cistatic int sr_lcpll0_clk_init(struct platform_device *pdev) 3198c2ecf20Sopenharmony_ci{ 3208c2ecf20Sopenharmony_ci iproc_pll_clk_setup(pdev->dev.of_node, 3218c2ecf20Sopenharmony_ci &sr_lcpll0, NULL, 0, sr_lcpll0_clk, 3228c2ecf20Sopenharmony_ci ARRAY_SIZE(sr_lcpll0_clk)); 3238c2ecf20Sopenharmony_ci return 0; 3248c2ecf20Sopenharmony_ci} 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_cistatic const struct iproc_pll_ctrl sr_lcpll1 = { 3278c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON | IPROC_CLK_PLL_NEEDS_SW_CFG, 3288c2ecf20Sopenharmony_ci .aon = AON_VAL(0x0, 2, 22, 21), 3298c2ecf20Sopenharmony_ci .reset = RESET_VAL(0x0, 31, 30), 3308c2ecf20Sopenharmony_ci .sw_ctrl = SW_CTRL_VAL(0x4, 31), 3318c2ecf20Sopenharmony_ci .ndiv_int = REG_VAL(0x4, 16, 10), 3328c2ecf20Sopenharmony_ci .pdiv = REG_VAL(0x4, 26, 4), 3338c2ecf20Sopenharmony_ci .status = REG_VAL(0x38, 12, 1), 3348c2ecf20Sopenharmony_ci}; 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_cistatic const struct iproc_clk_ctrl sr_lcpll1_clk[] = { 3378c2ecf20Sopenharmony_ci [BCM_SR_LCPLL1_WAN_CLK] = { 3388c2ecf20Sopenharmony_ci .channel = BCM_SR_LCPLL1_WAN_CLK, 3398c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 3408c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x0, 7, 1, 13), 3418c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x14, 0, 9), 3428c2ecf20Sopenharmony_ci }, 3438c2ecf20Sopenharmony_ci [BCM_SR_LCPLL1_USB_REF_CLK] = { 3448c2ecf20Sopenharmony_ci .channel = BCM_SR_LCPLL1_USB_REF_CLK, 3458c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 3468c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x0, 8, 2, 14), 3478c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x14, 10, 9), 3488c2ecf20Sopenharmony_ci }, 3498c2ecf20Sopenharmony_ci [BCM_SR_LCPLL1_CRMU_TS_CLK] = { 3508c2ecf20Sopenharmony_ci .channel = BCM_SR_LCPLL1_CRMU_TS_CLK, 3518c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 3528c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x0, 9, 3, 15), 3538c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x14, 20, 9), 3548c2ecf20Sopenharmony_ci }, 3558c2ecf20Sopenharmony_ci}; 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_cistatic int sr_lcpll1_clk_init(struct platform_device *pdev) 3588c2ecf20Sopenharmony_ci{ 3598c2ecf20Sopenharmony_ci iproc_pll_clk_setup(pdev->dev.of_node, 3608c2ecf20Sopenharmony_ci &sr_lcpll1, NULL, 0, sr_lcpll1_clk, 3618c2ecf20Sopenharmony_ci ARRAY_SIZE(sr_lcpll1_clk)); 3628c2ecf20Sopenharmony_ci return 0; 3638c2ecf20Sopenharmony_ci} 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_cistatic const struct iproc_pll_ctrl sr_lcpll_pcie = { 3668c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON | IPROC_CLK_PLL_NEEDS_SW_CFG, 3678c2ecf20Sopenharmony_ci .aon = AON_VAL(0x0, 2, 25, 24), 3688c2ecf20Sopenharmony_ci .reset = RESET_VAL(0x0, 31, 30), 3698c2ecf20Sopenharmony_ci .sw_ctrl = SW_CTRL_VAL(0x4, 31), 3708c2ecf20Sopenharmony_ci .ndiv_int = REG_VAL(0x4, 16, 10), 3718c2ecf20Sopenharmony_ci .pdiv = REG_VAL(0x4, 26, 4), 3728c2ecf20Sopenharmony_ci .status = REG_VAL(0x38, 12, 1), 3738c2ecf20Sopenharmony_ci}; 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_cistatic const struct iproc_clk_ctrl sr_lcpll_pcie_clk[] = { 3768c2ecf20Sopenharmony_ci [BCM_SR_LCPLL_PCIE_PHY_REF_CLK] = { 3778c2ecf20Sopenharmony_ci .channel = BCM_SR_LCPLL_PCIE_PHY_REF_CLK, 3788c2ecf20Sopenharmony_ci .flags = IPROC_CLK_AON, 3798c2ecf20Sopenharmony_ci .enable = ENABLE_VAL(0x0, 7, 1, 13), 3808c2ecf20Sopenharmony_ci .mdiv = REG_VAL(0x14, 0, 9), 3818c2ecf20Sopenharmony_ci }, 3828c2ecf20Sopenharmony_ci}; 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_cistatic int sr_lcpll_pcie_clk_init(struct platform_device *pdev) 3858c2ecf20Sopenharmony_ci{ 3868c2ecf20Sopenharmony_ci iproc_pll_clk_setup(pdev->dev.of_node, 3878c2ecf20Sopenharmony_ci &sr_lcpll_pcie, NULL, 0, sr_lcpll_pcie_clk, 3888c2ecf20Sopenharmony_ci ARRAY_SIZE(sr_lcpll_pcie_clk)); 3898c2ecf20Sopenharmony_ci return 0; 3908c2ecf20Sopenharmony_ci} 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_cistatic const struct of_device_id sr_clk_dt_ids[] = { 3938c2ecf20Sopenharmony_ci { .compatible = "brcm,sr-genpll0", .data = sr_genpll0_clk_init }, 3948c2ecf20Sopenharmony_ci { .compatible = "brcm,sr-genpll2", .data = sr_genpll2_clk_init }, 3958c2ecf20Sopenharmony_ci { .compatible = "brcm,sr-genpll4", .data = sr_genpll4_clk_init }, 3968c2ecf20Sopenharmony_ci { .compatible = "brcm,sr-genpll5", .data = sr_genpll5_clk_init }, 3978c2ecf20Sopenharmony_ci { .compatible = "brcm,sr-lcpll0", .data = sr_lcpll0_clk_init }, 3988c2ecf20Sopenharmony_ci { .compatible = "brcm,sr-lcpll1", .data = sr_lcpll1_clk_init }, 3998c2ecf20Sopenharmony_ci { .compatible = "brcm,sr-lcpll-pcie", .data = sr_lcpll_pcie_clk_init }, 4008c2ecf20Sopenharmony_ci { /* sentinel */ } 4018c2ecf20Sopenharmony_ci}; 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_cistatic int sr_clk_probe(struct platform_device *pdev) 4048c2ecf20Sopenharmony_ci{ 4058c2ecf20Sopenharmony_ci int (*probe_func)(struct platform_device *); 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_ci probe_func = of_device_get_match_data(&pdev->dev); 4088c2ecf20Sopenharmony_ci if (!probe_func) 4098c2ecf20Sopenharmony_ci return -ENODEV; 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci return probe_func(pdev); 4128c2ecf20Sopenharmony_ci} 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_cistatic struct platform_driver sr_clk_driver = { 4158c2ecf20Sopenharmony_ci .driver = { 4168c2ecf20Sopenharmony_ci .name = "sr-clk", 4178c2ecf20Sopenharmony_ci .of_match_table = sr_clk_dt_ids, 4188c2ecf20Sopenharmony_ci }, 4198c2ecf20Sopenharmony_ci .probe = sr_clk_probe, 4208c2ecf20Sopenharmony_ci}; 4218c2ecf20Sopenharmony_cibuiltin_platform_driver(sr_clk_driver); 422