18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright 2012-2013 Freescale Semiconductor, Inc. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <linux/of_address.h> 78c2ecf20Sopenharmony_ci#include <linux/bits.h> 88c2ecf20Sopenharmony_ci#include <linux/clk.h> 98c2ecf20Sopenharmony_ci#include <linux/syscore_ops.h> 108c2ecf20Sopenharmony_ci#include <dt-bindings/clock/vf610-clock.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include "clk.h" 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define CCM_CCR (ccm_base + 0x00) 158c2ecf20Sopenharmony_ci#define CCM_CSR (ccm_base + 0x04) 168c2ecf20Sopenharmony_ci#define CCM_CCSR (ccm_base + 0x08) 178c2ecf20Sopenharmony_ci#define CCM_CACRR (ccm_base + 0x0c) 188c2ecf20Sopenharmony_ci#define CCM_CSCMR1 (ccm_base + 0x10) 198c2ecf20Sopenharmony_ci#define CCM_CSCDR1 (ccm_base + 0x14) 208c2ecf20Sopenharmony_ci#define CCM_CSCDR2 (ccm_base + 0x18) 218c2ecf20Sopenharmony_ci#define CCM_CSCDR3 (ccm_base + 0x1c) 228c2ecf20Sopenharmony_ci#define CCM_CSCMR2 (ccm_base + 0x20) 238c2ecf20Sopenharmony_ci#define CCM_CSCDR4 (ccm_base + 0x24) 248c2ecf20Sopenharmony_ci#define CCM_CLPCR (ccm_base + 0x2c) 258c2ecf20Sopenharmony_ci#define CCM_CISR (ccm_base + 0x30) 268c2ecf20Sopenharmony_ci#define CCM_CIMR (ccm_base + 0x34) 278c2ecf20Sopenharmony_ci#define CCM_CGPR (ccm_base + 0x3c) 288c2ecf20Sopenharmony_ci#define CCM_CCGR0 (ccm_base + 0x40) 298c2ecf20Sopenharmony_ci#define CCM_CCGR1 (ccm_base + 0x44) 308c2ecf20Sopenharmony_ci#define CCM_CCGR2 (ccm_base + 0x48) 318c2ecf20Sopenharmony_ci#define CCM_CCGR3 (ccm_base + 0x4c) 328c2ecf20Sopenharmony_ci#define CCM_CCGR4 (ccm_base + 0x50) 338c2ecf20Sopenharmony_ci#define CCM_CCGR5 (ccm_base + 0x54) 348c2ecf20Sopenharmony_ci#define CCM_CCGR6 (ccm_base + 0x58) 358c2ecf20Sopenharmony_ci#define CCM_CCGR7 (ccm_base + 0x5c) 368c2ecf20Sopenharmony_ci#define CCM_CCGR8 (ccm_base + 0x60) 378c2ecf20Sopenharmony_ci#define CCM_CCGR9 (ccm_base + 0x64) 388c2ecf20Sopenharmony_ci#define CCM_CCGR10 (ccm_base + 0x68) 398c2ecf20Sopenharmony_ci#define CCM_CCGR11 (ccm_base + 0x6c) 408c2ecf20Sopenharmony_ci#define CCM_CCGRx(x) (CCM_CCGR0 + (x) * 4) 418c2ecf20Sopenharmony_ci#define CCM_CMEOR0 (ccm_base + 0x70) 428c2ecf20Sopenharmony_ci#define CCM_CMEOR1 (ccm_base + 0x74) 438c2ecf20Sopenharmony_ci#define CCM_CMEOR2 (ccm_base + 0x78) 448c2ecf20Sopenharmony_ci#define CCM_CMEOR3 (ccm_base + 0x7c) 458c2ecf20Sopenharmony_ci#define CCM_CMEOR4 (ccm_base + 0x80) 468c2ecf20Sopenharmony_ci#define CCM_CMEOR5 (ccm_base + 0x84) 478c2ecf20Sopenharmony_ci#define CCM_CPPDSR (ccm_base + 0x88) 488c2ecf20Sopenharmony_ci#define CCM_CCOWR (ccm_base + 0x8c) 498c2ecf20Sopenharmony_ci#define CCM_CCPGR0 (ccm_base + 0x90) 508c2ecf20Sopenharmony_ci#define CCM_CCPGR1 (ccm_base + 0x94) 518c2ecf20Sopenharmony_ci#define CCM_CCPGR2 (ccm_base + 0x98) 528c2ecf20Sopenharmony_ci#define CCM_CCPGR3 (ccm_base + 0x9c) 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define CCM_CCGRx_CGn(n) ((n) * 2) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define PFD_PLL1_BASE (anatop_base + 0x2b0) 578c2ecf20Sopenharmony_ci#define PFD_PLL2_BASE (anatop_base + 0x100) 588c2ecf20Sopenharmony_ci#define PFD_PLL3_BASE (anatop_base + 0xf0) 598c2ecf20Sopenharmony_ci#define PLL1_CTRL (anatop_base + 0x270) 608c2ecf20Sopenharmony_ci#define PLL2_CTRL (anatop_base + 0x30) 618c2ecf20Sopenharmony_ci#define PLL3_CTRL (anatop_base + 0x10) 628c2ecf20Sopenharmony_ci#define PLL4_CTRL (anatop_base + 0x70) 638c2ecf20Sopenharmony_ci#define PLL5_CTRL (anatop_base + 0xe0) 648c2ecf20Sopenharmony_ci#define PLL6_CTRL (anatop_base + 0xa0) 658c2ecf20Sopenharmony_ci#define PLL7_CTRL (anatop_base + 0x20) 668c2ecf20Sopenharmony_ci#define ANA_MISC1 (anatop_base + 0x160) 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistatic void __iomem *anatop_base; 698c2ecf20Sopenharmony_cistatic void __iomem *ccm_base; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/* sources for multiplexer clocks, this is used multiple times */ 728c2ecf20Sopenharmony_cistatic const char *fast_sels[] = { "firc", "fxosc", }; 738c2ecf20Sopenharmony_cistatic const char *slow_sels[] = { "sirc_32k", "sxosc", }; 748c2ecf20Sopenharmony_cistatic const char *pll1_sels[] = { "pll1_sys", "pll1_pfd1", "pll1_pfd2", "pll1_pfd3", "pll1_pfd4", }; 758c2ecf20Sopenharmony_cistatic const char *pll2_sels[] = { "pll2_bus", "pll2_pfd1", "pll2_pfd2", "pll2_pfd3", "pll2_pfd4", }; 768c2ecf20Sopenharmony_cistatic const char *pll_bypass_src_sels[] = { "fast_clk_sel", "lvds1_in", }; 778c2ecf20Sopenharmony_cistatic const char *pll1_bypass_sels[] = { "pll1", "pll1_bypass_src", }; 788c2ecf20Sopenharmony_cistatic const char *pll2_bypass_sels[] = { "pll2", "pll2_bypass_src", }; 798c2ecf20Sopenharmony_cistatic const char *pll3_bypass_sels[] = { "pll3", "pll3_bypass_src", }; 808c2ecf20Sopenharmony_cistatic const char *pll4_bypass_sels[] = { "pll4", "pll4_bypass_src", }; 818c2ecf20Sopenharmony_cistatic const char *pll5_bypass_sels[] = { "pll5", "pll5_bypass_src", }; 828c2ecf20Sopenharmony_cistatic const char *pll6_bypass_sels[] = { "pll6", "pll6_bypass_src", }; 838c2ecf20Sopenharmony_cistatic const char *pll7_bypass_sels[] = { "pll7", "pll7_bypass_src", }; 848c2ecf20Sopenharmony_cistatic const char *sys_sels[] = { "fast_clk_sel", "slow_clk_sel", "pll2_pfd_sel", "pll2_bus", "pll1_pfd_sel", "pll3_usb_otg", }; 858c2ecf20Sopenharmony_cistatic const char *ddr_sels[] = { "pll2_pfd2", "sys_sel", }; 868c2ecf20Sopenharmony_cistatic const char *rmii_sels[] = { "enet_ext", "audio_ext", "enet_50m", "enet_25m", }; 878c2ecf20Sopenharmony_cistatic const char *enet_ts_sels[] = { "enet_ext", "fxosc", "audio_ext", "usb", "enet_ts", "enet_25m", "enet_50m", }; 888c2ecf20Sopenharmony_cistatic const char *esai_sels[] = { "audio_ext", "mlb", "spdif_rx", "pll4_audio_div", }; 898c2ecf20Sopenharmony_cistatic const char *sai_sels[] = { "audio_ext", "mlb", "spdif_rx", "pll4_audio_div", }; 908c2ecf20Sopenharmony_cistatic const char *nfc_sels[] = { "platform_bus", "pll1_pfd1", "pll3_pfd1", "pll3_pfd3", }; 918c2ecf20Sopenharmony_cistatic const char *qspi_sels[] = { "pll3_usb_otg", "pll3_pfd4", "pll2_pfd4", "pll1_pfd4", }; 928c2ecf20Sopenharmony_cistatic const char *esdhc_sels[] = { "pll3_usb_otg", "pll3_pfd3", "pll1_pfd3", "platform_bus", }; 938c2ecf20Sopenharmony_cistatic const char *dcu_sels[] = { "pll1_pfd2", "pll3_usb_otg", }; 948c2ecf20Sopenharmony_cistatic const char *gpu_sels[] = { "pll2_pfd2", "pll3_pfd2", }; 958c2ecf20Sopenharmony_cistatic const char *vadc_sels[] = { "pll6_video_div", "pll3_usb_otg_div", "pll3_usb_otg", }; 968c2ecf20Sopenharmony_ci/* FTM counter clock source, not module clock */ 978c2ecf20Sopenharmony_cistatic const char *ftm_ext_sels[] = {"sirc_128k", "sxosc", "fxosc_half", "audio_ext", }; 988c2ecf20Sopenharmony_cistatic const char *ftm_fix_sels[] = { "sxosc", "ipg_bus", }; 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_cistatic const struct clk_div_table pll4_audio_div_table[] = { 1028c2ecf20Sopenharmony_ci { .val = 0, .div = 1 }, 1038c2ecf20Sopenharmony_ci { .val = 1, .div = 2 }, 1048c2ecf20Sopenharmony_ci { .val = 2, .div = 6 }, 1058c2ecf20Sopenharmony_ci { .val = 3, .div = 8 }, 1068c2ecf20Sopenharmony_ci { .val = 4, .div = 10 }, 1078c2ecf20Sopenharmony_ci { .val = 5, .div = 12 }, 1088c2ecf20Sopenharmony_ci { .val = 6, .div = 14 }, 1098c2ecf20Sopenharmony_ci { .val = 7, .div = 16 }, 1108c2ecf20Sopenharmony_ci { } 1118c2ecf20Sopenharmony_ci}; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_cistatic struct clk *clk[VF610_CLK_END]; 1148c2ecf20Sopenharmony_cistatic struct clk_onecell_data clk_data; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_cistatic u32 cscmr1; 1178c2ecf20Sopenharmony_cistatic u32 cscmr2; 1188c2ecf20Sopenharmony_cistatic u32 cscdr1; 1198c2ecf20Sopenharmony_cistatic u32 cscdr2; 1208c2ecf20Sopenharmony_cistatic u32 cscdr3; 1218c2ecf20Sopenharmony_cistatic u32 ccgr[12]; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cistatic unsigned int const clks_init_on[] __initconst = { 1248c2ecf20Sopenharmony_ci VF610_CLK_SYS_BUS, 1258c2ecf20Sopenharmony_ci VF610_CLK_DDR_SEL, 1268c2ecf20Sopenharmony_ci VF610_CLK_DAP, 1278c2ecf20Sopenharmony_ci VF610_CLK_DDRMC, 1288c2ecf20Sopenharmony_ci VF610_CLK_WKPU, 1298c2ecf20Sopenharmony_ci}; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_cistatic struct clk * __init vf610_get_fixed_clock( 1328c2ecf20Sopenharmony_ci struct device_node *ccm_node, const char *name) 1338c2ecf20Sopenharmony_ci{ 1348c2ecf20Sopenharmony_ci struct clk *clk = of_clk_get_by_name(ccm_node, name); 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci /* Backward compatibility if device tree is missing clks assignments */ 1378c2ecf20Sopenharmony_ci if (IS_ERR(clk)) 1388c2ecf20Sopenharmony_ci clk = imx_obtain_fixed_clock(name, 0); 1398c2ecf20Sopenharmony_ci return clk; 1408c2ecf20Sopenharmony_ci}; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_cistatic int vf610_clk_suspend(void) 1438c2ecf20Sopenharmony_ci{ 1448c2ecf20Sopenharmony_ci int i; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci cscmr1 = readl_relaxed(CCM_CSCMR1); 1478c2ecf20Sopenharmony_ci cscmr2 = readl_relaxed(CCM_CSCMR2); 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci cscdr1 = readl_relaxed(CCM_CSCDR1); 1508c2ecf20Sopenharmony_ci cscdr2 = readl_relaxed(CCM_CSCDR2); 1518c2ecf20Sopenharmony_ci cscdr3 = readl_relaxed(CCM_CSCDR3); 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci for (i = 0; i < 12; i++) 1548c2ecf20Sopenharmony_ci ccgr[i] = readl_relaxed(CCM_CCGRx(i)); 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci return 0; 1578c2ecf20Sopenharmony_ci} 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_cistatic void vf610_clk_resume(void) 1608c2ecf20Sopenharmony_ci{ 1618c2ecf20Sopenharmony_ci int i; 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci writel_relaxed(cscmr1, CCM_CSCMR1); 1648c2ecf20Sopenharmony_ci writel_relaxed(cscmr2, CCM_CSCMR2); 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci writel_relaxed(cscdr1, CCM_CSCDR1); 1678c2ecf20Sopenharmony_ci writel_relaxed(cscdr2, CCM_CSCDR2); 1688c2ecf20Sopenharmony_ci writel_relaxed(cscdr3, CCM_CSCDR3); 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci for (i = 0; i < 12; i++) 1718c2ecf20Sopenharmony_ci writel_relaxed(ccgr[i], CCM_CCGRx(i)); 1728c2ecf20Sopenharmony_ci} 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_cistatic struct syscore_ops vf610_clk_syscore_ops = { 1758c2ecf20Sopenharmony_ci .suspend = vf610_clk_suspend, 1768c2ecf20Sopenharmony_ci .resume = vf610_clk_resume, 1778c2ecf20Sopenharmony_ci}; 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_cistatic void __init vf610_clocks_init(struct device_node *ccm_node) 1808c2ecf20Sopenharmony_ci{ 1818c2ecf20Sopenharmony_ci struct device_node *np; 1828c2ecf20Sopenharmony_ci int i; 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci clk[VF610_CLK_DUMMY] = imx_clk_fixed("dummy", 0); 1858c2ecf20Sopenharmony_ci clk[VF610_CLK_SIRC_128K] = imx_clk_fixed("sirc_128k", 128000); 1868c2ecf20Sopenharmony_ci clk[VF610_CLK_SIRC_32K] = imx_clk_fixed("sirc_32k", 32000); 1878c2ecf20Sopenharmony_ci clk[VF610_CLK_FIRC] = imx_clk_fixed("firc", 24000000); 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci clk[VF610_CLK_SXOSC] = vf610_get_fixed_clock(ccm_node, "sxosc"); 1908c2ecf20Sopenharmony_ci clk[VF610_CLK_FXOSC] = vf610_get_fixed_clock(ccm_node, "fxosc"); 1918c2ecf20Sopenharmony_ci clk[VF610_CLK_AUDIO_EXT] = vf610_get_fixed_clock(ccm_node, "audio_ext"); 1928c2ecf20Sopenharmony_ci clk[VF610_CLK_ENET_EXT] = vf610_get_fixed_clock(ccm_node, "enet_ext"); 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci /* Clock source from external clock via LVDs PAD */ 1958c2ecf20Sopenharmony_ci clk[VF610_CLK_ANACLK1] = vf610_get_fixed_clock(ccm_node, "anaclk1"); 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci clk[VF610_CLK_FXOSC_HALF] = imx_clk_fixed_factor("fxosc_half", "fxosc", 1, 2); 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci np = of_find_compatible_node(NULL, NULL, "fsl,vf610-anatop"); 2008c2ecf20Sopenharmony_ci anatop_base = of_iomap(np, 0); 2018c2ecf20Sopenharmony_ci BUG_ON(!anatop_base); 2028c2ecf20Sopenharmony_ci of_node_put(np); 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci np = ccm_node; 2058c2ecf20Sopenharmony_ci ccm_base = of_iomap(np, 0); 2068c2ecf20Sopenharmony_ci BUG_ON(!ccm_base); 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci clk[VF610_CLK_SLOW_CLK_SEL] = imx_clk_mux("slow_clk_sel", CCM_CCSR, 4, 1, slow_sels, ARRAY_SIZE(slow_sels)); 2098c2ecf20Sopenharmony_ci clk[VF610_CLK_FASK_CLK_SEL] = imx_clk_mux("fast_clk_sel", CCM_CCSR, 5, 1, fast_sels, ARRAY_SIZE(fast_sels)); 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL1_BYPASS_SRC] = imx_clk_mux("pll1_bypass_src", PLL1_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels)); 2128c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL2_BYPASS_SRC] = imx_clk_mux("pll2_bypass_src", PLL2_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels)); 2138c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL3_BYPASS_SRC] = imx_clk_mux("pll3_bypass_src", PLL3_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels)); 2148c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL4_BYPASS_SRC] = imx_clk_mux("pll4_bypass_src", PLL4_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels)); 2158c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL5_BYPASS_SRC] = imx_clk_mux("pll5_bypass_src", PLL5_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels)); 2168c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL6_BYPASS_SRC] = imx_clk_mux("pll6_bypass_src", PLL6_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels)); 2178c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL7_BYPASS_SRC] = imx_clk_mux("pll7_bypass_src", PLL7_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels)); 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL1] = imx_clk_pllv3(IMX_PLLV3_SYS_VF610, "pll1", "pll1_bypass_src", PLL1_CTRL, 0x1); 2208c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL2] = imx_clk_pllv3(IMX_PLLV3_SYS_VF610, "pll2", "pll2_bypass_src", PLL2_CTRL, 0x1); 2218c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL3] = imx_clk_pllv3(IMX_PLLV3_USB_VF610, "pll3", "pll3_bypass_src", PLL3_CTRL, 0x2); 2228c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL4] = imx_clk_pllv3(IMX_PLLV3_AV, "pll4", "pll4_bypass_src", PLL4_CTRL, 0x7f); 2238c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL5] = imx_clk_pllv3(IMX_PLLV3_ENET, "pll5", "pll5_bypass_src", PLL5_CTRL, 0x3); 2248c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL6] = imx_clk_pllv3(IMX_PLLV3_AV, "pll6", "pll6_bypass_src", PLL6_CTRL, 0x7f); 2258c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL7] = imx_clk_pllv3(IMX_PLLV3_USB_VF610, "pll7", "pll7_bypass_src", PLL7_CTRL, 0x2); 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci clk[VF610_PLL1_BYPASS] = imx_clk_mux_flags("pll1_bypass", PLL1_CTRL, 16, 1, pll1_bypass_sels, ARRAY_SIZE(pll1_bypass_sels), CLK_SET_RATE_PARENT); 2288c2ecf20Sopenharmony_ci clk[VF610_PLL2_BYPASS] = imx_clk_mux_flags("pll2_bypass", PLL2_CTRL, 16, 1, pll2_bypass_sels, ARRAY_SIZE(pll2_bypass_sels), CLK_SET_RATE_PARENT); 2298c2ecf20Sopenharmony_ci clk[VF610_PLL3_BYPASS] = imx_clk_mux_flags("pll3_bypass", PLL3_CTRL, 16, 1, pll3_bypass_sels, ARRAY_SIZE(pll3_bypass_sels), CLK_SET_RATE_PARENT); 2308c2ecf20Sopenharmony_ci clk[VF610_PLL4_BYPASS] = imx_clk_mux_flags("pll4_bypass", PLL4_CTRL, 16, 1, pll4_bypass_sels, ARRAY_SIZE(pll4_bypass_sels), CLK_SET_RATE_PARENT); 2318c2ecf20Sopenharmony_ci clk[VF610_PLL5_BYPASS] = imx_clk_mux_flags("pll5_bypass", PLL5_CTRL, 16, 1, pll5_bypass_sels, ARRAY_SIZE(pll5_bypass_sels), CLK_SET_RATE_PARENT); 2328c2ecf20Sopenharmony_ci clk[VF610_PLL6_BYPASS] = imx_clk_mux_flags("pll6_bypass", PLL6_CTRL, 16, 1, pll6_bypass_sels, ARRAY_SIZE(pll6_bypass_sels), CLK_SET_RATE_PARENT); 2338c2ecf20Sopenharmony_ci clk[VF610_PLL7_BYPASS] = imx_clk_mux_flags("pll7_bypass", PLL7_CTRL, 16, 1, pll7_bypass_sels, ARRAY_SIZE(pll7_bypass_sels), CLK_SET_RATE_PARENT); 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci /* Do not bypass PLLs initially */ 2368c2ecf20Sopenharmony_ci clk_set_parent(clk[VF610_PLL1_BYPASS], clk[VF610_CLK_PLL1]); 2378c2ecf20Sopenharmony_ci clk_set_parent(clk[VF610_PLL2_BYPASS], clk[VF610_CLK_PLL2]); 2388c2ecf20Sopenharmony_ci clk_set_parent(clk[VF610_PLL3_BYPASS], clk[VF610_CLK_PLL3]); 2398c2ecf20Sopenharmony_ci clk_set_parent(clk[VF610_PLL4_BYPASS], clk[VF610_CLK_PLL4]); 2408c2ecf20Sopenharmony_ci clk_set_parent(clk[VF610_PLL5_BYPASS], clk[VF610_CLK_PLL5]); 2418c2ecf20Sopenharmony_ci clk_set_parent(clk[VF610_PLL6_BYPASS], clk[VF610_CLK_PLL6]); 2428c2ecf20Sopenharmony_ci clk_set_parent(clk[VF610_PLL7_BYPASS], clk[VF610_CLK_PLL7]); 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL1_SYS] = imx_clk_gate("pll1_sys", "pll1_bypass", PLL1_CTRL, 13); 2458c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL2_BUS] = imx_clk_gate("pll2_bus", "pll2_bypass", PLL2_CTRL, 13); 2468c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL3_USB_OTG] = imx_clk_gate("pll3_usb_otg", "pll3_bypass", PLL3_CTRL, 13); 2478c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL4_AUDIO] = imx_clk_gate("pll4_audio", "pll4_bypass", PLL4_CTRL, 13); 2488c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL5_ENET] = imx_clk_gate("pll5_enet", "pll5_bypass", PLL5_CTRL, 13); 2498c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL6_VIDEO] = imx_clk_gate("pll6_video", "pll6_bypass", PLL6_CTRL, 13); 2508c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL7_USB_HOST] = imx_clk_gate("pll7_usb_host", "pll7_bypass", PLL7_CTRL, 13); 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci clk[VF610_CLK_LVDS1_IN] = imx_clk_gate_exclusive("lvds1_in", "anaclk1", ANA_MISC1, 12, BIT(10)); 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL1_PFD1] = imx_clk_pfd("pll1_pfd1", "pll1_sys", PFD_PLL1_BASE, 0); 2558c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL1_PFD2] = imx_clk_pfd("pll1_pfd2", "pll1_sys", PFD_PLL1_BASE, 1); 2568c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL1_PFD3] = imx_clk_pfd("pll1_pfd3", "pll1_sys", PFD_PLL1_BASE, 2); 2578c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL1_PFD4] = imx_clk_pfd("pll1_pfd4", "pll1_sys", PFD_PLL1_BASE, 3); 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL2_PFD1] = imx_clk_pfd("pll2_pfd1", "pll2_bus", PFD_PLL2_BASE, 0); 2608c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL2_PFD2] = imx_clk_pfd("pll2_pfd2", "pll2_bus", PFD_PLL2_BASE, 1); 2618c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL2_PFD3] = imx_clk_pfd("pll2_pfd3", "pll2_bus", PFD_PLL2_BASE, 2); 2628c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL2_PFD4] = imx_clk_pfd("pll2_pfd4", "pll2_bus", PFD_PLL2_BASE, 3); 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL3_PFD1] = imx_clk_pfd("pll3_pfd1", "pll3_usb_otg", PFD_PLL3_BASE, 0); 2658c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL3_PFD2] = imx_clk_pfd("pll3_pfd2", "pll3_usb_otg", PFD_PLL3_BASE, 1); 2668c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL3_PFD3] = imx_clk_pfd("pll3_pfd3", "pll3_usb_otg", PFD_PLL3_BASE, 2); 2678c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL3_PFD4] = imx_clk_pfd("pll3_pfd4", "pll3_usb_otg", PFD_PLL3_BASE, 3); 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL1_PFD_SEL] = imx_clk_mux("pll1_pfd_sel", CCM_CCSR, 16, 3, pll1_sels, 5); 2708c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL2_PFD_SEL] = imx_clk_mux("pll2_pfd_sel", CCM_CCSR, 19, 3, pll2_sels, 5); 2718c2ecf20Sopenharmony_ci clk[VF610_CLK_SYS_SEL] = imx_clk_mux("sys_sel", CCM_CCSR, 0, 3, sys_sels, ARRAY_SIZE(sys_sels)); 2728c2ecf20Sopenharmony_ci clk[VF610_CLK_DDR_SEL] = imx_clk_mux("ddr_sel", CCM_CCSR, 6, 1, ddr_sels, ARRAY_SIZE(ddr_sels)); 2738c2ecf20Sopenharmony_ci clk[VF610_CLK_SYS_BUS] = imx_clk_divider("sys_bus", "sys_sel", CCM_CACRR, 0, 3); 2748c2ecf20Sopenharmony_ci clk[VF610_CLK_PLATFORM_BUS] = imx_clk_divider("platform_bus", "sys_bus", CCM_CACRR, 3, 3); 2758c2ecf20Sopenharmony_ci clk[VF610_CLK_IPG_BUS] = imx_clk_divider("ipg_bus", "platform_bus", CCM_CACRR, 11, 2); 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL3_MAIN_DIV] = imx_clk_divider("pll3_usb_otg_div", "pll3_usb_otg", CCM_CACRR, 20, 1); 2788c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL4_MAIN_DIV] = clk_register_divider_table(NULL, "pll4_audio_div", "pll4_audio", 0, CCM_CACRR, 6, 3, 0, pll4_audio_div_table, &imx_ccm_lock); 2798c2ecf20Sopenharmony_ci clk[VF610_CLK_PLL6_MAIN_DIV] = imx_clk_divider("pll6_video_div", "pll6_video", CCM_CACRR, 21, 1); 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci clk[VF610_CLK_DDRMC] = imx_clk_gate2_cgr("ddrmc", "ddr_sel", CCM_CCGR6, CCM_CCGRx_CGn(14), 0x2); 2828c2ecf20Sopenharmony_ci clk[VF610_CLK_WKPU] = imx_clk_gate2_cgr("wkpu", "ipg_bus", CCM_CCGR4, CCM_CCGRx_CGn(10), 0x2); 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci clk[VF610_CLK_USBPHY0] = imx_clk_gate("usbphy0", "pll3_usb_otg", PLL3_CTRL, 6); 2858c2ecf20Sopenharmony_ci clk[VF610_CLK_USBPHY1] = imx_clk_gate("usbphy1", "pll7_usb_host", PLL7_CTRL, 6); 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ci clk[VF610_CLK_USBC0] = imx_clk_gate2("usbc0", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(4)); 2888c2ecf20Sopenharmony_ci clk[VF610_CLK_USBC1] = imx_clk_gate2("usbc1", "ipg_bus", CCM_CCGR7, CCM_CCGRx_CGn(4)); 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci clk[VF610_CLK_QSPI0_SEL] = imx_clk_mux("qspi0_sel", CCM_CSCMR1, 22, 2, qspi_sels, 4); 2918c2ecf20Sopenharmony_ci clk[VF610_CLK_QSPI0_EN] = imx_clk_gate("qspi0_en", "qspi0_sel", CCM_CSCDR3, 4); 2928c2ecf20Sopenharmony_ci clk[VF610_CLK_QSPI0_X4_DIV] = imx_clk_divider("qspi0_x4", "qspi0_en", CCM_CSCDR3, 0, 2); 2938c2ecf20Sopenharmony_ci clk[VF610_CLK_QSPI0_X2_DIV] = imx_clk_divider("qspi0_x2", "qspi0_x4", CCM_CSCDR3, 2, 1); 2948c2ecf20Sopenharmony_ci clk[VF610_CLK_QSPI0_X1_DIV] = imx_clk_divider("qspi0_x1", "qspi0_x2", CCM_CSCDR3, 3, 1); 2958c2ecf20Sopenharmony_ci clk[VF610_CLK_QSPI0] = imx_clk_gate2("qspi0", "qspi0_x1", CCM_CCGR2, CCM_CCGRx_CGn(4)); 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci clk[VF610_CLK_QSPI1_SEL] = imx_clk_mux("qspi1_sel", CCM_CSCMR1, 24, 2, qspi_sels, 4); 2988c2ecf20Sopenharmony_ci clk[VF610_CLK_QSPI1_EN] = imx_clk_gate("qspi1_en", "qspi1_sel", CCM_CSCDR3, 12); 2998c2ecf20Sopenharmony_ci clk[VF610_CLK_QSPI1_X4_DIV] = imx_clk_divider("qspi1_x4", "qspi1_en", CCM_CSCDR3, 8, 2); 3008c2ecf20Sopenharmony_ci clk[VF610_CLK_QSPI1_X2_DIV] = imx_clk_divider("qspi1_x2", "qspi1_x4", CCM_CSCDR3, 10, 1); 3018c2ecf20Sopenharmony_ci clk[VF610_CLK_QSPI1_X1_DIV] = imx_clk_divider("qspi1_x1", "qspi1_x2", CCM_CSCDR3, 11, 1); 3028c2ecf20Sopenharmony_ci clk[VF610_CLK_QSPI1] = imx_clk_gate2("qspi1", "qspi1_x1", CCM_CCGR8, CCM_CCGRx_CGn(4)); 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci clk[VF610_CLK_ENET_50M] = imx_clk_fixed_factor("enet_50m", "pll5_enet", 1, 10); 3058c2ecf20Sopenharmony_ci clk[VF610_CLK_ENET_25M] = imx_clk_fixed_factor("enet_25m", "pll5_enet", 1, 20); 3068c2ecf20Sopenharmony_ci clk[VF610_CLK_ENET_SEL] = imx_clk_mux("enet_sel", CCM_CSCMR2, 4, 2, rmii_sels, 4); 3078c2ecf20Sopenharmony_ci clk[VF610_CLK_ENET_TS_SEL] = imx_clk_mux("enet_ts_sel", CCM_CSCMR2, 0, 3, enet_ts_sels, 7); 3088c2ecf20Sopenharmony_ci clk[VF610_CLK_ENET] = imx_clk_gate("enet", "enet_sel", CCM_CSCDR1, 24); 3098c2ecf20Sopenharmony_ci clk[VF610_CLK_ENET_TS] = imx_clk_gate("enet_ts", "enet_ts_sel", CCM_CSCDR1, 23); 3108c2ecf20Sopenharmony_ci clk[VF610_CLK_ENET0] = imx_clk_gate2("enet0", "ipg_bus", CCM_CCGR9, CCM_CCGRx_CGn(0)); 3118c2ecf20Sopenharmony_ci clk[VF610_CLK_ENET1] = imx_clk_gate2("enet1", "ipg_bus", CCM_CCGR9, CCM_CCGRx_CGn(1)); 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci clk[VF610_CLK_PIT] = imx_clk_gate2("pit", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(7)); 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci clk[VF610_CLK_UART0] = imx_clk_gate2_cgr("uart0", "ipg_bus", CCM_CCGR0, CCM_CCGRx_CGn(7), 0x2); 3168c2ecf20Sopenharmony_ci clk[VF610_CLK_UART1] = imx_clk_gate2_cgr("uart1", "ipg_bus", CCM_CCGR0, CCM_CCGRx_CGn(8), 0x2); 3178c2ecf20Sopenharmony_ci clk[VF610_CLK_UART2] = imx_clk_gate2_cgr("uart2", "ipg_bus", CCM_CCGR0, CCM_CCGRx_CGn(9), 0x2); 3188c2ecf20Sopenharmony_ci clk[VF610_CLK_UART3] = imx_clk_gate2_cgr("uart3", "ipg_bus", CCM_CCGR0, CCM_CCGRx_CGn(10), 0x2); 3198c2ecf20Sopenharmony_ci clk[VF610_CLK_UART4] = imx_clk_gate2_cgr("uart4", "ipg_bus", CCM_CCGR6, CCM_CCGRx_CGn(9), 0x2); 3208c2ecf20Sopenharmony_ci clk[VF610_CLK_UART5] = imx_clk_gate2_cgr("uart5", "ipg_bus", CCM_CCGR6, CCM_CCGRx_CGn(10), 0x2); 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci clk[VF610_CLK_I2C0] = imx_clk_gate2("i2c0", "ipg_bus", CCM_CCGR4, CCM_CCGRx_CGn(6)); 3238c2ecf20Sopenharmony_ci clk[VF610_CLK_I2C1] = imx_clk_gate2("i2c1", "ipg_bus", CCM_CCGR4, CCM_CCGRx_CGn(7)); 3248c2ecf20Sopenharmony_ci clk[VF610_CLK_I2C2] = imx_clk_gate2("i2c2", "ipg_bus", CCM_CCGR10, CCM_CCGRx_CGn(6)); 3258c2ecf20Sopenharmony_ci clk[VF610_CLK_I2C3] = imx_clk_gate2("i2c3", "ipg_bus", CCM_CCGR10, CCM_CCGRx_CGn(7)); 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci clk[VF610_CLK_DSPI0] = imx_clk_gate2("dspi0", "ipg_bus", CCM_CCGR0, CCM_CCGRx_CGn(12)); 3288c2ecf20Sopenharmony_ci clk[VF610_CLK_DSPI1] = imx_clk_gate2("dspi1", "ipg_bus", CCM_CCGR0, CCM_CCGRx_CGn(13)); 3298c2ecf20Sopenharmony_ci clk[VF610_CLK_DSPI2] = imx_clk_gate2("dspi2", "ipg_bus", CCM_CCGR6, CCM_CCGRx_CGn(12)); 3308c2ecf20Sopenharmony_ci clk[VF610_CLK_DSPI3] = imx_clk_gate2("dspi3", "ipg_bus", CCM_CCGR6, CCM_CCGRx_CGn(13)); 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci clk[VF610_CLK_CRC] = imx_clk_gate2("crc", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(3)); 3338c2ecf20Sopenharmony_ci clk[VF610_CLK_WDT] = imx_clk_gate2("wdt", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(14)); 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci clk[VF610_CLK_ESDHC0_SEL] = imx_clk_mux("esdhc0_sel", CCM_CSCMR1, 16, 2, esdhc_sels, 4); 3368c2ecf20Sopenharmony_ci clk[VF610_CLK_ESDHC0_EN] = imx_clk_gate("esdhc0_en", "esdhc0_sel", CCM_CSCDR2, 28); 3378c2ecf20Sopenharmony_ci clk[VF610_CLK_ESDHC0_DIV] = imx_clk_divider("esdhc0_div", "esdhc0_en", CCM_CSCDR2, 16, 4); 3388c2ecf20Sopenharmony_ci clk[VF610_CLK_ESDHC0] = imx_clk_gate2("eshc0", "esdhc0_div", CCM_CCGR7, CCM_CCGRx_CGn(1)); 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci clk[VF610_CLK_ESDHC1_SEL] = imx_clk_mux("esdhc1_sel", CCM_CSCMR1, 18, 2, esdhc_sels, 4); 3418c2ecf20Sopenharmony_ci clk[VF610_CLK_ESDHC1_EN] = imx_clk_gate("esdhc1_en", "esdhc1_sel", CCM_CSCDR2, 29); 3428c2ecf20Sopenharmony_ci clk[VF610_CLK_ESDHC1_DIV] = imx_clk_divider("esdhc1_div", "esdhc1_en", CCM_CSCDR2, 20, 4); 3438c2ecf20Sopenharmony_ci clk[VF610_CLK_ESDHC1] = imx_clk_gate2("eshc1", "esdhc1_div", CCM_CCGR7, CCM_CCGRx_CGn(2)); 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ci /* 3468c2ecf20Sopenharmony_ci * ftm_ext_clk and ftm_fix_clk are FTM timer counter's 3478c2ecf20Sopenharmony_ci * selectable clock sources, both use a common enable bit 3488c2ecf20Sopenharmony_ci * in CCM_CSCDR1, selecting "dummy" clock as parent of 3498c2ecf20Sopenharmony_ci * "ftm0_ext_fix" make it serve only for enable/disable. 3508c2ecf20Sopenharmony_ci */ 3518c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM0_EXT_SEL] = imx_clk_mux("ftm0_ext_sel", CCM_CSCMR2, 6, 2, ftm_ext_sels, 4); 3528c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM0_FIX_SEL] = imx_clk_mux("ftm0_fix_sel", CCM_CSCMR2, 14, 1, ftm_fix_sels, 2); 3538c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM0_EXT_FIX_EN] = imx_clk_gate("ftm0_ext_fix_en", "dummy", CCM_CSCDR1, 25); 3548c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM1_EXT_SEL] = imx_clk_mux("ftm1_ext_sel", CCM_CSCMR2, 8, 2, ftm_ext_sels, 4); 3558c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM1_FIX_SEL] = imx_clk_mux("ftm1_fix_sel", CCM_CSCMR2, 15, 1, ftm_fix_sels, 2); 3568c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM1_EXT_FIX_EN] = imx_clk_gate("ftm1_ext_fix_en", "dummy", CCM_CSCDR1, 26); 3578c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM2_EXT_SEL] = imx_clk_mux("ftm2_ext_sel", CCM_CSCMR2, 10, 2, ftm_ext_sels, 4); 3588c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM2_FIX_SEL] = imx_clk_mux("ftm2_fix_sel", CCM_CSCMR2, 16, 1, ftm_fix_sels, 2); 3598c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM2_EXT_FIX_EN] = imx_clk_gate("ftm2_ext_fix_en", "dummy", CCM_CSCDR1, 27); 3608c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM3_EXT_SEL] = imx_clk_mux("ftm3_ext_sel", CCM_CSCMR2, 12, 2, ftm_ext_sels, 4); 3618c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM3_FIX_SEL] = imx_clk_mux("ftm3_fix_sel", CCM_CSCMR2, 17, 1, ftm_fix_sels, 2); 3628c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM3_EXT_FIX_EN] = imx_clk_gate("ftm3_ext_fix_en", "dummy", CCM_CSCDR1, 28); 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci /* ftm(n)_clk are FTM module operation clock */ 3658c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM0] = imx_clk_gate2("ftm0", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(8)); 3668c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM1] = imx_clk_gate2("ftm1", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(9)); 3678c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM2] = imx_clk_gate2("ftm2", "ipg_bus", CCM_CCGR7, CCM_CCGRx_CGn(8)); 3688c2ecf20Sopenharmony_ci clk[VF610_CLK_FTM3] = imx_clk_gate2("ftm3", "ipg_bus", CCM_CCGR7, CCM_CCGRx_CGn(9)); 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_ci clk[VF610_CLK_DCU0_SEL] = imx_clk_mux("dcu0_sel", CCM_CSCMR1, 28, 1, dcu_sels, 2); 3718c2ecf20Sopenharmony_ci clk[VF610_CLK_DCU0_EN] = imx_clk_gate("dcu0_en", "dcu0_sel", CCM_CSCDR3, 19); 3728c2ecf20Sopenharmony_ci clk[VF610_CLK_DCU0_DIV] = imx_clk_divider("dcu0_div", "dcu0_en", CCM_CSCDR3, 16, 3); 3738c2ecf20Sopenharmony_ci clk[VF610_CLK_DCU0] = imx_clk_gate2("dcu0", "ipg_bus", CCM_CCGR3, CCM_CCGRx_CGn(8)); 3748c2ecf20Sopenharmony_ci clk[VF610_CLK_DCU1_SEL] = imx_clk_mux("dcu1_sel", CCM_CSCMR1, 29, 1, dcu_sels, 2); 3758c2ecf20Sopenharmony_ci clk[VF610_CLK_DCU1_EN] = imx_clk_gate("dcu1_en", "dcu1_sel", CCM_CSCDR3, 23); 3768c2ecf20Sopenharmony_ci clk[VF610_CLK_DCU1_DIV] = imx_clk_divider("dcu1_div", "dcu1_en", CCM_CSCDR3, 20, 3); 3778c2ecf20Sopenharmony_ci clk[VF610_CLK_DCU1] = imx_clk_gate2("dcu1", "ipg_bus", CCM_CCGR9, CCM_CCGRx_CGn(8)); 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci clk[VF610_CLK_TCON0] = imx_clk_gate2("tcon0", "platform_bus", CCM_CCGR1, CCM_CCGRx_CGn(13)); 3808c2ecf20Sopenharmony_ci clk[VF610_CLK_TCON1] = imx_clk_gate2("tcon1", "platform_bus", CCM_CCGR7, CCM_CCGRx_CGn(13)); 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_ci clk[VF610_CLK_ESAI_SEL] = imx_clk_mux("esai_sel", CCM_CSCMR1, 20, 2, esai_sels, 4); 3838c2ecf20Sopenharmony_ci clk[VF610_CLK_ESAI_EN] = imx_clk_gate("esai_en", "esai_sel", CCM_CSCDR2, 30); 3848c2ecf20Sopenharmony_ci clk[VF610_CLK_ESAI_DIV] = imx_clk_divider("esai_div", "esai_en", CCM_CSCDR2, 24, 4); 3858c2ecf20Sopenharmony_ci clk[VF610_CLK_ESAI] = imx_clk_gate2("esai", "esai_div", CCM_CCGR4, CCM_CCGRx_CGn(2)); 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI0_SEL] = imx_clk_mux("sai0_sel", CCM_CSCMR1, 0, 2, sai_sels, 4); 3888c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI0_EN] = imx_clk_gate("sai0_en", "sai0_sel", CCM_CSCDR1, 16); 3898c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI0_DIV] = imx_clk_divider("sai0_div", "sai0_en", CCM_CSCDR1, 0, 4); 3908c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI0] = imx_clk_gate2("sai0", "ipg_bus", CCM_CCGR0, CCM_CCGRx_CGn(15)); 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI1_SEL] = imx_clk_mux("sai1_sel", CCM_CSCMR1, 2, 2, sai_sels, 4); 3938c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI1_EN] = imx_clk_gate("sai1_en", "sai1_sel", CCM_CSCDR1, 17); 3948c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI1_DIV] = imx_clk_divider("sai1_div", "sai1_en", CCM_CSCDR1, 4, 4); 3958c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI1] = imx_clk_gate2("sai1", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(0)); 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI2_SEL] = imx_clk_mux("sai2_sel", CCM_CSCMR1, 4, 2, sai_sels, 4); 3988c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI2_EN] = imx_clk_gate("sai2_en", "sai2_sel", CCM_CSCDR1, 18); 3998c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI2_DIV] = imx_clk_divider("sai2_div", "sai2_en", CCM_CSCDR1, 8, 4); 4008c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI2] = imx_clk_gate2("sai2", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(1)); 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI3_SEL] = imx_clk_mux("sai3_sel", CCM_CSCMR1, 6, 2, sai_sels, 4); 4038c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI3_EN] = imx_clk_gate("sai3_en", "sai3_sel", CCM_CSCDR1, 19); 4048c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI3_DIV] = imx_clk_divider("sai3_div", "sai3_en", CCM_CSCDR1, 12, 4); 4058c2ecf20Sopenharmony_ci clk[VF610_CLK_SAI3] = imx_clk_gate2("sai3", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(2)); 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_ci clk[VF610_CLK_NFC_SEL] = imx_clk_mux("nfc_sel", CCM_CSCMR1, 12, 2, nfc_sels, 4); 4088c2ecf20Sopenharmony_ci clk[VF610_CLK_NFC_EN] = imx_clk_gate("nfc_en", "nfc_sel", CCM_CSCDR2, 9); 4098c2ecf20Sopenharmony_ci clk[VF610_CLK_NFC_PRE_DIV] = imx_clk_divider("nfc_pre_div", "nfc_en", CCM_CSCDR3, 13, 3); 4108c2ecf20Sopenharmony_ci clk[VF610_CLK_NFC_FRAC_DIV] = imx_clk_divider("nfc_frac_div", "nfc_pre_div", CCM_CSCDR2, 4, 4); 4118c2ecf20Sopenharmony_ci clk[VF610_CLK_NFC] = imx_clk_gate2("nfc", "nfc_frac_div", CCM_CCGR10, CCM_CCGRx_CGn(0)); 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_ci clk[VF610_CLK_GPU_SEL] = imx_clk_mux("gpu_sel", CCM_CSCMR1, 14, 1, gpu_sels, 2); 4148c2ecf20Sopenharmony_ci clk[VF610_CLK_GPU_EN] = imx_clk_gate("gpu_en", "gpu_sel", CCM_CSCDR2, 10); 4158c2ecf20Sopenharmony_ci clk[VF610_CLK_GPU2D] = imx_clk_gate2("gpu", "gpu_en", CCM_CCGR8, CCM_CCGRx_CGn(15)); 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_ci clk[VF610_CLK_VADC_SEL] = imx_clk_mux("vadc_sel", CCM_CSCMR1, 8, 2, vadc_sels, 3); 4188c2ecf20Sopenharmony_ci clk[VF610_CLK_VADC_EN] = imx_clk_gate("vadc_en", "vadc_sel", CCM_CSCDR1, 22); 4198c2ecf20Sopenharmony_ci clk[VF610_CLK_VADC_DIV] = imx_clk_divider("vadc_div", "vadc_en", CCM_CSCDR1, 20, 2); 4208c2ecf20Sopenharmony_ci clk[VF610_CLK_VADC_DIV_HALF] = imx_clk_fixed_factor("vadc_div_half", "vadc_div", 1, 2); 4218c2ecf20Sopenharmony_ci clk[VF610_CLK_VADC] = imx_clk_gate2("vadc", "vadc_div", CCM_CCGR8, CCM_CCGRx_CGn(7)); 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ci clk[VF610_CLK_ADC0] = imx_clk_gate2("adc0", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(11)); 4248c2ecf20Sopenharmony_ci clk[VF610_CLK_ADC1] = imx_clk_gate2("adc1", "ipg_bus", CCM_CCGR7, CCM_CCGRx_CGn(11)); 4258c2ecf20Sopenharmony_ci clk[VF610_CLK_DAC0] = imx_clk_gate2("dac0", "ipg_bus", CCM_CCGR8, CCM_CCGRx_CGn(12)); 4268c2ecf20Sopenharmony_ci clk[VF610_CLK_DAC1] = imx_clk_gate2("dac1", "ipg_bus", CCM_CCGR8, CCM_CCGRx_CGn(13)); 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ci clk[VF610_CLK_ASRC] = imx_clk_gate2("asrc", "ipg_bus", CCM_CCGR4, CCM_CCGRx_CGn(1)); 4298c2ecf20Sopenharmony_ci 4308c2ecf20Sopenharmony_ci clk[VF610_CLK_FLEXCAN0_EN] = imx_clk_gate("flexcan0_en", "ipg_bus", CCM_CSCDR2, 11); 4318c2ecf20Sopenharmony_ci clk[VF610_CLK_FLEXCAN0] = imx_clk_gate2("flexcan0", "flexcan0_en", CCM_CCGR0, CCM_CCGRx_CGn(0)); 4328c2ecf20Sopenharmony_ci clk[VF610_CLK_FLEXCAN1_EN] = imx_clk_gate("flexcan1_en", "ipg_bus", CCM_CSCDR2, 12); 4338c2ecf20Sopenharmony_ci clk[VF610_CLK_FLEXCAN1] = imx_clk_gate2("flexcan1", "flexcan1_en", CCM_CCGR9, CCM_CCGRx_CGn(4)); 4348c2ecf20Sopenharmony_ci 4358c2ecf20Sopenharmony_ci clk[VF610_CLK_DMAMUX0] = imx_clk_gate2("dmamux0", "platform_bus", CCM_CCGR0, CCM_CCGRx_CGn(4)); 4368c2ecf20Sopenharmony_ci clk[VF610_CLK_DMAMUX1] = imx_clk_gate2("dmamux1", "platform_bus", CCM_CCGR0, CCM_CCGRx_CGn(5)); 4378c2ecf20Sopenharmony_ci clk[VF610_CLK_DMAMUX2] = imx_clk_gate2("dmamux2", "platform_bus", CCM_CCGR6, CCM_CCGRx_CGn(1)); 4388c2ecf20Sopenharmony_ci clk[VF610_CLK_DMAMUX3] = imx_clk_gate2("dmamux3", "platform_bus", CCM_CCGR6, CCM_CCGRx_CGn(2)); 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci clk[VF610_CLK_SNVS] = imx_clk_gate2("snvs-rtc", "ipg_bus", CCM_CCGR6, CCM_CCGRx_CGn(7)); 4418c2ecf20Sopenharmony_ci clk[VF610_CLK_DAP] = imx_clk_gate("dap", "platform_bus", CCM_CCSR, 24); 4428c2ecf20Sopenharmony_ci clk[VF610_CLK_OCOTP] = imx_clk_gate("ocotp", "ipg_bus", CCM_CCGR6, CCM_CCGRx_CGn(5)); 4438c2ecf20Sopenharmony_ci clk[VF610_CLK_CAAM] = imx_clk_gate2("caam", "ipg_bus", CCM_CCGR11, CCM_CCGRx_CGn(0)); 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_ci imx_check_clocks(clk, ARRAY_SIZE(clk)); 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci clk_set_parent(clk[VF610_CLK_QSPI0_SEL], clk[VF610_CLK_PLL1_PFD4]); 4488c2ecf20Sopenharmony_ci clk_set_rate(clk[VF610_CLK_QSPI0_X4_DIV], clk_get_rate(clk[VF610_CLK_QSPI0_SEL]) / 2); 4498c2ecf20Sopenharmony_ci clk_set_rate(clk[VF610_CLK_QSPI0_X2_DIV], clk_get_rate(clk[VF610_CLK_QSPI0_X4_DIV]) / 2); 4508c2ecf20Sopenharmony_ci clk_set_rate(clk[VF610_CLK_QSPI0_X1_DIV], clk_get_rate(clk[VF610_CLK_QSPI0_X2_DIV]) / 2); 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci clk_set_parent(clk[VF610_CLK_QSPI1_SEL], clk[VF610_CLK_PLL1_PFD4]); 4538c2ecf20Sopenharmony_ci clk_set_rate(clk[VF610_CLK_QSPI1_X4_DIV], clk_get_rate(clk[VF610_CLK_QSPI1_SEL]) / 2); 4548c2ecf20Sopenharmony_ci clk_set_rate(clk[VF610_CLK_QSPI1_X2_DIV], clk_get_rate(clk[VF610_CLK_QSPI1_X4_DIV]) / 2); 4558c2ecf20Sopenharmony_ci clk_set_rate(clk[VF610_CLK_QSPI1_X1_DIV], clk_get_rate(clk[VF610_CLK_QSPI1_X2_DIV]) / 2); 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci clk_set_parent(clk[VF610_CLK_SAI0_SEL], clk[VF610_CLK_AUDIO_EXT]); 4588c2ecf20Sopenharmony_ci clk_set_parent(clk[VF610_CLK_SAI1_SEL], clk[VF610_CLK_AUDIO_EXT]); 4598c2ecf20Sopenharmony_ci clk_set_parent(clk[VF610_CLK_SAI2_SEL], clk[VF610_CLK_AUDIO_EXT]); 4608c2ecf20Sopenharmony_ci clk_set_parent(clk[VF610_CLK_SAI3_SEL], clk[VF610_CLK_AUDIO_EXT]); 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(clks_init_on); i++) 4638c2ecf20Sopenharmony_ci clk_prepare_enable(clk[clks_init_on[i]]); 4648c2ecf20Sopenharmony_ci 4658c2ecf20Sopenharmony_ci register_syscore_ops(&vf610_clk_syscore_ops); 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_ci /* Add the clocks to provider list */ 4688c2ecf20Sopenharmony_ci clk_data.clks = clk; 4698c2ecf20Sopenharmony_ci clk_data.clk_num = ARRAY_SIZE(clk); 4708c2ecf20Sopenharmony_ci of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); 4718c2ecf20Sopenharmony_ci} 4728c2ecf20Sopenharmony_ciCLK_OF_DECLARE(vf610, "fsl,vf610-ccm", vf610_clocks_init); 473