18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2014 MediaTek Inc. 48c2ecf20Sopenharmony_ci * Author: Shunli Wang <shunli.wang@mediatek.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 88c2ecf20Sopenharmony_ci#include <linux/of.h> 98c2ecf20Sopenharmony_ci#include <linux/of_address.h> 108c2ecf20Sopenharmony_ci#include <linux/of_device.h> 118c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include "clk-mtk.h" 148c2ecf20Sopenharmony_ci#include "clk-gate.h" 158c2ecf20Sopenharmony_ci#include "clk-cpumux.h" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <dt-bindings/clock/mt2701-clk.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* 208c2ecf20Sopenharmony_ci * For some clocks, we don't care what their actual rates are. And these 218c2ecf20Sopenharmony_ci * clocks may change their rate on different products or different scenarios. 228c2ecf20Sopenharmony_ci * So we model these clocks' rate as 0, to denote it's not an actual rate. 238c2ecf20Sopenharmony_ci */ 248c2ecf20Sopenharmony_ci#define DUMMY_RATE 0 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(mt2701_clk_lock); 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cistatic const struct mtk_fixed_clk top_fixed_clks[] = { 298c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_DPI, "dpi_ck", "clk26m", 308c2ecf20Sopenharmony_ci 108 * MHZ), 318c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_DMPLL, "dmpll_ck", "clk26m", 328c2ecf20Sopenharmony_ci 400 * MHZ), 338c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_VENCPLL, "vencpll_ck", "clk26m", 348c2ecf20Sopenharmony_ci 295750000), 358c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_HDMI_0_PIX340M, "hdmi_0_pix340m", "clk26m", 368c2ecf20Sopenharmony_ci 340 * MHZ), 378c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_HDMI_0_DEEP340M, "hdmi_0_deep340m", "clk26m", 388c2ecf20Sopenharmony_ci 340 * MHZ), 398c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_HDMI_0_PLL340M, "hdmi_0_pll340m", "clk26m", 408c2ecf20Sopenharmony_ci 340 * MHZ), 418c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_HADDS2_FB, "hadds2_fbclk", "clk26m", 428c2ecf20Sopenharmony_ci 27 * MHZ), 438c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_WBG_DIG_416M, "wbg_dig_ck_416m", "clk26m", 448c2ecf20Sopenharmony_ci 416 * MHZ), 458c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_DSI0_LNTC_DSI, "dsi0_lntc_dsi", "clk26m", 468c2ecf20Sopenharmony_ci 143 * MHZ), 478c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_HDMI_SCL_RX, "hdmi_scl_rx", "clk26m", 488c2ecf20Sopenharmony_ci 27 * MHZ), 498c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_AUD_EXT1, "aud_ext1", "clk26m", 508c2ecf20Sopenharmony_ci DUMMY_RATE), 518c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_AUD_EXT2, "aud_ext2", "clk26m", 528c2ecf20Sopenharmony_ci DUMMY_RATE), 538c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_NFI1X_PAD, "nfi1x_pad", "clk26m", 548c2ecf20Sopenharmony_ci DUMMY_RATE), 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_cistatic const struct mtk_fixed_factor top_fixed_divs[] = { 588c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL, "syspll_ck", "mainpll", 1, 1), 598c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL_D2, "syspll_d2", "mainpll", 1, 2), 608c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL_D3, "syspll_d3", "mainpll", 1, 3), 618c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL_D5, "syspll_d5", "mainpll", 1, 5), 628c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL_D7, "syspll_d7", "mainpll", 1, 7), 638c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL1_D2, "syspll1_d2", "syspll_d2", 1, 2), 648c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL1_D4, "syspll1_d4", "syspll_d2", 1, 4), 658c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL1_D8, "syspll1_d8", "syspll_d2", 1, 8), 668c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL1_D16, "syspll1_d16", "syspll_d2", 1, 16), 678c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL2_D2, "syspll2_d2", "syspll_d3", 1, 2), 688c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL2_D4, "syspll2_d4", "syspll_d3", 1, 4), 698c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL2_D8, "syspll2_d8", "syspll_d3", 1, 8), 708c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL3_D2, "syspll3_d2", "syspll_d5", 1, 2), 718c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL3_D4, "syspll3_d4", "syspll_d5", 1, 4), 728c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL4_D2, "syspll4_d2", "syspll_d7", 1, 2), 738c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_SYSPLL4_D4, "syspll4_d4", "syspll_d7", 1, 4), 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL, "univpll_ck", "univpll", 1, 1), 768c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll", 1, 2), 778c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll", 1, 3), 788c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll", 1, 5), 798c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D7, "univpll_d7", "univpll", 1, 7), 808c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D26, "univpll_d26", "univpll", 1, 26), 818c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D52, "univpll_d52", "univpll", 1, 52), 828c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D108, "univpll_d108", "univpll", 1, 108), 838c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_USB_PHY48M, "usb_phy48m_ck", "univpll", 1, 26), 848c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL1_D2, "univpll1_d2", "univpll_d2", 1, 2), 858c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL1_D4, "univpll1_d4", "univpll_d2", 1, 4), 868c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL1_D8, "univpll1_d8", "univpll_d2", 1, 8), 878c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_8BDAC, "8bdac_ck", "univpll_d2", 1, 1), 888c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL2_D2, "univpll2_d2", "univpll_d3", 1, 2), 898c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL2_D4, "univpll2_d4", "univpll_d3", 1, 4), 908c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL2_D8, "univpll2_d8", "univpll_d3", 1, 8), 918c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL2_D16, "univpll2_d16", "univpll_d3", 1, 16), 928c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL2_D32, "univpll2_d32", "univpll_d3", 1, 32), 938c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL3_D2, "univpll3_d2", "univpll_d5", 1, 2), 948c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL3_D4, "univpll3_d4", "univpll_d5", 1, 4), 958c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL3_D8, "univpll3_d8", "univpll_d5", 1, 8), 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MSDCPLL, "msdcpll_ck", "msdcpll", 1, 1), 988c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll", 1, 2), 998c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MSDCPLL_D4, "msdcpll_d4", "msdcpll", 1, 4), 1008c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MSDCPLL_D8, "msdcpll_d8", "msdcpll", 1, 8), 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MMPLL, "mmpll_ck", "mmpll", 1, 1), 1038c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MMPLL_D2, "mmpll_d2", "mmpll", 1, 2), 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_DMPLL_D2, "dmpll_d2", "dmpll_ck", 1, 2), 1068c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_DMPLL_D4, "dmpll_d4", "dmpll_ck", 1, 4), 1078c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_DMPLL_X2, "dmpll_x2", "dmpll_ck", 1, 1), 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_TVDPLL, "tvdpll_ck", "tvdpll", 1, 1), 1108c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_TVDPLL_D2, "tvdpll_d2", "tvdpll", 1, 2), 1118c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_TVDPLL_D4, "tvdpll_d4", "tvdpll", 1, 4), 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_VDECPLL, "vdecpll_ck", "vdecpll", 1, 1), 1148c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_TVD2PLL, "tvd2pll_ck", "tvd2pll", 1, 1), 1158c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_TVD2PLL_D2, "tvd2pll_d2", "tvd2pll", 1, 2), 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MIPIPLL, "mipipll", "dpi_ck", 1, 1), 1188c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MIPIPLL_D2, "mipipll_d2", "dpi_ck", 1, 2), 1198c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MIPIPLL_D4, "mipipll_d4", "dpi_ck", 1, 4), 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_HDMIPLL, "hdmipll_ck", "hdmitx_dig_cts", 1, 1), 1228c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_HDMIPLL_D2, "hdmipll_d2", "hdmitx_dig_cts", 1, 2), 1238c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_HDMIPLL_D3, "hdmipll_d3", "hdmitx_dig_cts", 1, 3), 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_ARMPLL_1P3G, "armpll_1p3g_ck", "armpll", 1, 1), 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_AUDPLL, "audpll", "audpll_sel", 1, 1), 1288c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_AUDPLL_D4, "audpll_d4", "audpll_sel", 1, 4), 1298c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_AUDPLL_D8, "audpll_d8", "audpll_sel", 1, 8), 1308c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_AUDPLL_D16, "audpll_d16", "audpll_sel", 1, 16), 1318c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_AUDPLL_D24, "audpll_d24", "audpll_sel", 1, 24), 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_AUD1PLL_98M, "aud1pll_98m_ck", "aud1pll", 1, 3), 1348c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_AUD2PLL_90M, "aud2pll_90m_ck", "aud2pll", 1, 3), 1358c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_HADDS2PLL_98M, "hadds2pll_98m", "hadds2pll", 1, 3), 1368c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_HADDS2PLL_294M, "hadds2pll_294m", "hadds2pll", 1, 1), 1378c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_ETHPLL_500M, "ethpll_500m_ck", "ethpll", 1, 1), 1388c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_CLK26M_D8, "clk26m_d8", "clk26m", 1, 8), 1398c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_32K_INTERNAL, "32k_internal", "clk26m", 1, 793), 1408c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_32K_EXTERNAL, "32k_external", "rtc32k", 1, 1), 1418c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_AXISEL_D4, "axisel_d4", "axi_sel", 1, 4), 1428c2ecf20Sopenharmony_ci}; 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_cistatic const char * const axi_parents[] = { 1458c2ecf20Sopenharmony_ci "clk26m", 1468c2ecf20Sopenharmony_ci "syspll1_d2", 1478c2ecf20Sopenharmony_ci "syspll_d5", 1488c2ecf20Sopenharmony_ci "syspll1_d4", 1498c2ecf20Sopenharmony_ci "univpll_d5", 1508c2ecf20Sopenharmony_ci "univpll2_d2", 1518c2ecf20Sopenharmony_ci "mmpll_d2", 1528c2ecf20Sopenharmony_ci "dmpll_d2" 1538c2ecf20Sopenharmony_ci}; 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_cistatic const char * const mem_parents[] = { 1568c2ecf20Sopenharmony_ci "clk26m", 1578c2ecf20Sopenharmony_ci "dmpll_ck" 1588c2ecf20Sopenharmony_ci}; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_cistatic const char * const ddrphycfg_parents[] = { 1618c2ecf20Sopenharmony_ci "clk26m", 1628c2ecf20Sopenharmony_ci "syspll1_d8" 1638c2ecf20Sopenharmony_ci}; 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_cistatic const char * const mm_parents[] = { 1668c2ecf20Sopenharmony_ci "clk26m", 1678c2ecf20Sopenharmony_ci "vencpll_ck", 1688c2ecf20Sopenharmony_ci "syspll1_d2", 1698c2ecf20Sopenharmony_ci "syspll1_d4", 1708c2ecf20Sopenharmony_ci "univpll_d5", 1718c2ecf20Sopenharmony_ci "univpll1_d2", 1728c2ecf20Sopenharmony_ci "univpll2_d2", 1738c2ecf20Sopenharmony_ci "dmpll_ck" 1748c2ecf20Sopenharmony_ci}; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_cistatic const char * const pwm_parents[] = { 1778c2ecf20Sopenharmony_ci "clk26m", 1788c2ecf20Sopenharmony_ci "univpll2_d4", 1798c2ecf20Sopenharmony_ci "univpll3_d2", 1808c2ecf20Sopenharmony_ci "univpll1_d4", 1818c2ecf20Sopenharmony_ci}; 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_cistatic const char * const vdec_parents[] = { 1848c2ecf20Sopenharmony_ci "clk26m", 1858c2ecf20Sopenharmony_ci "vdecpll_ck", 1868c2ecf20Sopenharmony_ci "syspll_d5", 1878c2ecf20Sopenharmony_ci "syspll1_d4", 1888c2ecf20Sopenharmony_ci "univpll_d5", 1898c2ecf20Sopenharmony_ci "univpll2_d2", 1908c2ecf20Sopenharmony_ci "vencpll_ck", 1918c2ecf20Sopenharmony_ci "msdcpll_d2", 1928c2ecf20Sopenharmony_ci "mmpll_d2" 1938c2ecf20Sopenharmony_ci}; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_cistatic const char * const mfg_parents[] = { 1968c2ecf20Sopenharmony_ci "clk26m", 1978c2ecf20Sopenharmony_ci "mmpll_ck", 1988c2ecf20Sopenharmony_ci "dmpll_x2_ck", 1998c2ecf20Sopenharmony_ci "msdcpll_ck", 2008c2ecf20Sopenharmony_ci "clk26m", 2018c2ecf20Sopenharmony_ci "syspll_d3", 2028c2ecf20Sopenharmony_ci "univpll_d3", 2038c2ecf20Sopenharmony_ci "univpll1_d2" 2048c2ecf20Sopenharmony_ci}; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_cistatic const char * const camtg_parents[] = { 2078c2ecf20Sopenharmony_ci "clk26m", 2088c2ecf20Sopenharmony_ci "univpll_d26", 2098c2ecf20Sopenharmony_ci "univpll2_d2", 2108c2ecf20Sopenharmony_ci "syspll3_d2", 2118c2ecf20Sopenharmony_ci "syspll3_d4", 2128c2ecf20Sopenharmony_ci "msdcpll_d2", 2138c2ecf20Sopenharmony_ci "mmpll_d2" 2148c2ecf20Sopenharmony_ci}; 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_cistatic const char * const uart_parents[] = { 2178c2ecf20Sopenharmony_ci "clk26m", 2188c2ecf20Sopenharmony_ci "univpll2_d8" 2198c2ecf20Sopenharmony_ci}; 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_cistatic const char * const spi_parents[] = { 2228c2ecf20Sopenharmony_ci "clk26m", 2238c2ecf20Sopenharmony_ci "syspll3_d2", 2248c2ecf20Sopenharmony_ci "syspll4_d2", 2258c2ecf20Sopenharmony_ci "univpll2_d4", 2268c2ecf20Sopenharmony_ci "univpll1_d8" 2278c2ecf20Sopenharmony_ci}; 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_cistatic const char * const usb20_parents[] = { 2308c2ecf20Sopenharmony_ci "clk26m", 2318c2ecf20Sopenharmony_ci "univpll1_d8", 2328c2ecf20Sopenharmony_ci "univpll3_d4" 2338c2ecf20Sopenharmony_ci}; 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_cistatic const char * const msdc30_parents[] = { 2368c2ecf20Sopenharmony_ci "clk26m", 2378c2ecf20Sopenharmony_ci "msdcpll_d2", 2388c2ecf20Sopenharmony_ci "syspll2_d2", 2398c2ecf20Sopenharmony_ci "syspll1_d4", 2408c2ecf20Sopenharmony_ci "univpll1_d4", 2418c2ecf20Sopenharmony_ci "univpll2_d4" 2428c2ecf20Sopenharmony_ci}; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_cistatic const char * const aud_intbus_parents[] = { 2458c2ecf20Sopenharmony_ci "clk26m", 2468c2ecf20Sopenharmony_ci "syspll1_d4", 2478c2ecf20Sopenharmony_ci "syspll3_d2", 2488c2ecf20Sopenharmony_ci "syspll4_d2", 2498c2ecf20Sopenharmony_ci "univpll3_d2", 2508c2ecf20Sopenharmony_ci "univpll2_d4" 2518c2ecf20Sopenharmony_ci}; 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_cistatic const char * const pmicspi_parents[] = { 2548c2ecf20Sopenharmony_ci "clk26m", 2558c2ecf20Sopenharmony_ci "syspll1_d8", 2568c2ecf20Sopenharmony_ci "syspll2_d4", 2578c2ecf20Sopenharmony_ci "syspll4_d2", 2588c2ecf20Sopenharmony_ci "syspll3_d4", 2598c2ecf20Sopenharmony_ci "syspll2_d8", 2608c2ecf20Sopenharmony_ci "syspll1_d16", 2618c2ecf20Sopenharmony_ci "univpll3_d4", 2628c2ecf20Sopenharmony_ci "univpll_d26", 2638c2ecf20Sopenharmony_ci "dmpll_d2", 2648c2ecf20Sopenharmony_ci "dmpll_d4" 2658c2ecf20Sopenharmony_ci}; 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_cistatic const char * const scp_parents[] = { 2688c2ecf20Sopenharmony_ci "clk26m", 2698c2ecf20Sopenharmony_ci "syspll1_d8", 2708c2ecf20Sopenharmony_ci "dmpll_d2", 2718c2ecf20Sopenharmony_ci "dmpll_d4" 2728c2ecf20Sopenharmony_ci}; 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_cistatic const char * const dpi0_parents[] = { 2758c2ecf20Sopenharmony_ci "clk26m", 2768c2ecf20Sopenharmony_ci "mipipll", 2778c2ecf20Sopenharmony_ci "mipipll_d2", 2788c2ecf20Sopenharmony_ci "mipipll_d4", 2798c2ecf20Sopenharmony_ci "clk26m", 2808c2ecf20Sopenharmony_ci "tvdpll_ck", 2818c2ecf20Sopenharmony_ci "tvdpll_d2", 2828c2ecf20Sopenharmony_ci "tvdpll_d4" 2838c2ecf20Sopenharmony_ci}; 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_cistatic const char * const dpi1_parents[] = { 2868c2ecf20Sopenharmony_ci "clk26m", 2878c2ecf20Sopenharmony_ci "tvdpll_ck", 2888c2ecf20Sopenharmony_ci "tvdpll_d2", 2898c2ecf20Sopenharmony_ci "tvdpll_d4" 2908c2ecf20Sopenharmony_ci}; 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_cistatic const char * const tve_parents[] = { 2938c2ecf20Sopenharmony_ci "clk26m", 2948c2ecf20Sopenharmony_ci "mipipll", 2958c2ecf20Sopenharmony_ci "mipipll_d2", 2968c2ecf20Sopenharmony_ci "mipipll_d4", 2978c2ecf20Sopenharmony_ci "clk26m", 2988c2ecf20Sopenharmony_ci "tvdpll_ck", 2998c2ecf20Sopenharmony_ci "tvdpll_d2", 3008c2ecf20Sopenharmony_ci "tvdpll_d4" 3018c2ecf20Sopenharmony_ci}; 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_cistatic const char * const hdmi_parents[] = { 3048c2ecf20Sopenharmony_ci "clk26m", 3058c2ecf20Sopenharmony_ci "hdmipll_ck", 3068c2ecf20Sopenharmony_ci "hdmipll_d2", 3078c2ecf20Sopenharmony_ci "hdmipll_d3" 3088c2ecf20Sopenharmony_ci}; 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_cistatic const char * const apll_parents[] = { 3118c2ecf20Sopenharmony_ci "clk26m", 3128c2ecf20Sopenharmony_ci "audpll", 3138c2ecf20Sopenharmony_ci "audpll_d4", 3148c2ecf20Sopenharmony_ci "audpll_d8", 3158c2ecf20Sopenharmony_ci "audpll_d16", 3168c2ecf20Sopenharmony_ci "audpll_d24", 3178c2ecf20Sopenharmony_ci "clk26m", 3188c2ecf20Sopenharmony_ci "clk26m" 3198c2ecf20Sopenharmony_ci}; 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_cistatic const char * const rtc_parents[] = { 3228c2ecf20Sopenharmony_ci "32k_internal", 3238c2ecf20Sopenharmony_ci "32k_external", 3248c2ecf20Sopenharmony_ci "clk26m", 3258c2ecf20Sopenharmony_ci "univpll3_d8" 3268c2ecf20Sopenharmony_ci}; 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_cistatic const char * const nfi2x_parents[] = { 3298c2ecf20Sopenharmony_ci "clk26m", 3308c2ecf20Sopenharmony_ci "syspll2_d2", 3318c2ecf20Sopenharmony_ci "syspll_d7", 3328c2ecf20Sopenharmony_ci "univpll3_d2", 3338c2ecf20Sopenharmony_ci "syspll2_d4", 3348c2ecf20Sopenharmony_ci "univpll3_d4", 3358c2ecf20Sopenharmony_ci "syspll4_d4", 3368c2ecf20Sopenharmony_ci "clk26m" 3378c2ecf20Sopenharmony_ci}; 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_cistatic const char * const emmc_hclk_parents[] = { 3408c2ecf20Sopenharmony_ci "clk26m", 3418c2ecf20Sopenharmony_ci "syspll1_d2", 3428c2ecf20Sopenharmony_ci "syspll1_d4", 3438c2ecf20Sopenharmony_ci "syspll2_d2" 3448c2ecf20Sopenharmony_ci}; 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_cistatic const char * const flash_parents[] = { 3478c2ecf20Sopenharmony_ci "clk26m_d8", 3488c2ecf20Sopenharmony_ci "clk26m", 3498c2ecf20Sopenharmony_ci "syspll2_d8", 3508c2ecf20Sopenharmony_ci "syspll3_d4", 3518c2ecf20Sopenharmony_ci "univpll3_d4", 3528c2ecf20Sopenharmony_ci "syspll4_d2", 3538c2ecf20Sopenharmony_ci "syspll2_d4", 3548c2ecf20Sopenharmony_ci "univpll2_d4" 3558c2ecf20Sopenharmony_ci}; 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_cistatic const char * const di_parents[] = { 3588c2ecf20Sopenharmony_ci "clk26m", 3598c2ecf20Sopenharmony_ci "tvd2pll_ck", 3608c2ecf20Sopenharmony_ci "tvd2pll_d2", 3618c2ecf20Sopenharmony_ci "clk26m" 3628c2ecf20Sopenharmony_ci}; 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_cistatic const char * const nr_osd_parents[] = { 3658c2ecf20Sopenharmony_ci "clk26m", 3668c2ecf20Sopenharmony_ci "vencpll_ck", 3678c2ecf20Sopenharmony_ci "syspll1_d2", 3688c2ecf20Sopenharmony_ci "syspll1_d4", 3698c2ecf20Sopenharmony_ci "univpll_d5", 3708c2ecf20Sopenharmony_ci "univpll1_d2", 3718c2ecf20Sopenharmony_ci "univpll2_d2", 3728c2ecf20Sopenharmony_ci "dmpll_ck" 3738c2ecf20Sopenharmony_ci}; 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_cistatic const char * const hdmirx_bist_parents[] = { 3768c2ecf20Sopenharmony_ci "clk26m", 3778c2ecf20Sopenharmony_ci "syspll_d3", 3788c2ecf20Sopenharmony_ci "clk26m", 3798c2ecf20Sopenharmony_ci "syspll1_d16", 3808c2ecf20Sopenharmony_ci "syspll4_d2", 3818c2ecf20Sopenharmony_ci "syspll1_d4", 3828c2ecf20Sopenharmony_ci "vencpll_ck", 3838c2ecf20Sopenharmony_ci "clk26m" 3848c2ecf20Sopenharmony_ci}; 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_cistatic const char * const intdir_parents[] = { 3878c2ecf20Sopenharmony_ci "clk26m", 3888c2ecf20Sopenharmony_ci "mmpll_ck", 3898c2ecf20Sopenharmony_ci "syspll_d2", 3908c2ecf20Sopenharmony_ci "univpll_d2" 3918c2ecf20Sopenharmony_ci}; 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_cistatic const char * const asm_parents[] = { 3948c2ecf20Sopenharmony_ci "clk26m", 3958c2ecf20Sopenharmony_ci "univpll2_d4", 3968c2ecf20Sopenharmony_ci "univpll2_d2", 3978c2ecf20Sopenharmony_ci "syspll_d5" 3988c2ecf20Sopenharmony_ci}; 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_cistatic const char * const ms_card_parents[] = { 4018c2ecf20Sopenharmony_ci "clk26m", 4028c2ecf20Sopenharmony_ci "univpll3_d8", 4038c2ecf20Sopenharmony_ci "syspll4_d4" 4048c2ecf20Sopenharmony_ci}; 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_cistatic const char * const ethif_parents[] = { 4078c2ecf20Sopenharmony_ci "clk26m", 4088c2ecf20Sopenharmony_ci "syspll1_d2", 4098c2ecf20Sopenharmony_ci "syspll_d5", 4108c2ecf20Sopenharmony_ci "syspll1_d4", 4118c2ecf20Sopenharmony_ci "univpll_d5", 4128c2ecf20Sopenharmony_ci "univpll1_d2", 4138c2ecf20Sopenharmony_ci "dmpll_ck", 4148c2ecf20Sopenharmony_ci "dmpll_d2" 4158c2ecf20Sopenharmony_ci}; 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_cistatic const char * const hdmirx_parents[] = { 4188c2ecf20Sopenharmony_ci "clk26m", 4198c2ecf20Sopenharmony_ci "univpll_d52" 4208c2ecf20Sopenharmony_ci}; 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_cistatic const char * const cmsys_parents[] = { 4238c2ecf20Sopenharmony_ci "clk26m", 4248c2ecf20Sopenharmony_ci "syspll1_d2", 4258c2ecf20Sopenharmony_ci "univpll1_d2", 4268c2ecf20Sopenharmony_ci "univpll_d5", 4278c2ecf20Sopenharmony_ci "syspll_d5", 4288c2ecf20Sopenharmony_ci "syspll2_d2", 4298c2ecf20Sopenharmony_ci "syspll1_d4", 4308c2ecf20Sopenharmony_ci "syspll3_d2", 4318c2ecf20Sopenharmony_ci "syspll2_d4", 4328c2ecf20Sopenharmony_ci "syspll1_d8", 4338c2ecf20Sopenharmony_ci "clk26m", 4348c2ecf20Sopenharmony_ci "clk26m", 4358c2ecf20Sopenharmony_ci "clk26m", 4368c2ecf20Sopenharmony_ci "clk26m", 4378c2ecf20Sopenharmony_ci "clk26m" 4388c2ecf20Sopenharmony_ci}; 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_cistatic const char * const clk_8bdac_parents[] = { 4418c2ecf20Sopenharmony_ci "32k_internal", 4428c2ecf20Sopenharmony_ci "8bdac_ck", 4438c2ecf20Sopenharmony_ci "clk26m", 4448c2ecf20Sopenharmony_ci "clk26m" 4458c2ecf20Sopenharmony_ci}; 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_cistatic const char * const aud2dvd_parents[] = { 4488c2ecf20Sopenharmony_ci "a1sys_hp_ck", 4498c2ecf20Sopenharmony_ci "a2sys_hp_ck" 4508c2ecf20Sopenharmony_ci}; 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_cistatic const char * const padmclk_parents[] = { 4538c2ecf20Sopenharmony_ci "clk26m", 4548c2ecf20Sopenharmony_ci "univpll_d26", 4558c2ecf20Sopenharmony_ci "univpll_d52", 4568c2ecf20Sopenharmony_ci "univpll_d108", 4578c2ecf20Sopenharmony_ci "univpll2_d8", 4588c2ecf20Sopenharmony_ci "univpll2_d16", 4598c2ecf20Sopenharmony_ci "univpll2_d32" 4608c2ecf20Sopenharmony_ci}; 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_cistatic const char * const aud_mux_parents[] = { 4638c2ecf20Sopenharmony_ci "clk26m", 4648c2ecf20Sopenharmony_ci "aud1pll_98m_ck", 4658c2ecf20Sopenharmony_ci "aud2pll_90m_ck", 4668c2ecf20Sopenharmony_ci "hadds2pll_98m", 4678c2ecf20Sopenharmony_ci "audio_ext1_ck", 4688c2ecf20Sopenharmony_ci "audio_ext2_ck" 4698c2ecf20Sopenharmony_ci}; 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_cistatic const char * const aud_src_parents[] = { 4728c2ecf20Sopenharmony_ci "aud_mux1_sel", 4738c2ecf20Sopenharmony_ci "aud_mux2_sel" 4748c2ecf20Sopenharmony_ci}; 4758c2ecf20Sopenharmony_ci 4768c2ecf20Sopenharmony_cistatic const char * const cpu_parents[] = { 4778c2ecf20Sopenharmony_ci "clk26m", 4788c2ecf20Sopenharmony_ci "armpll", 4798c2ecf20Sopenharmony_ci "mainpll", 4808c2ecf20Sopenharmony_ci "mmpll" 4818c2ecf20Sopenharmony_ci}; 4828c2ecf20Sopenharmony_ci 4838c2ecf20Sopenharmony_cistatic const struct mtk_composite cpu_muxes[] __initconst = { 4848c2ecf20Sopenharmony_ci MUX(CLK_INFRA_CPUSEL, "infra_cpu_sel", cpu_parents, 0x0000, 2, 2), 4858c2ecf20Sopenharmony_ci}; 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_cistatic const struct mtk_composite top_muxes[] = { 4888c2ecf20Sopenharmony_ci MUX_GATE_FLAGS(CLK_TOP_AXI_SEL, "axi_sel", axi_parents, 4898c2ecf20Sopenharmony_ci 0x0040, 0, 3, 7, CLK_IS_CRITICAL), 4908c2ecf20Sopenharmony_ci MUX_GATE_FLAGS(CLK_TOP_MEM_SEL, "mem_sel", mem_parents, 4918c2ecf20Sopenharmony_ci 0x0040, 8, 1, 15, CLK_IS_CRITICAL), 4928c2ecf20Sopenharmony_ci MUX_GATE_FLAGS(CLK_TOP_DDRPHYCFG_SEL, "ddrphycfg_sel", 4938c2ecf20Sopenharmony_ci ddrphycfg_parents, 0x0040, 16, 1, 23, CLK_IS_CRITICAL), 4948c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_MM_SEL, "mm_sel", mm_parents, 4958c2ecf20Sopenharmony_ci 0x0040, 24, 3, 31), 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_PWM_SEL, "pwm_sel", pwm_parents, 4988c2ecf20Sopenharmony_ci 0x0050, 0, 2, 7), 4998c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_VDEC_SEL, "vdec_sel", vdec_parents, 5008c2ecf20Sopenharmony_ci 0x0050, 8, 4, 15), 5018c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_MFG_SEL, "mfg_sel", mfg_parents, 5028c2ecf20Sopenharmony_ci 0x0050, 16, 3, 23), 5038c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_CAMTG_SEL, "camtg_sel", camtg_parents, 5048c2ecf20Sopenharmony_ci 0x0050, 24, 3, 31), 5058c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_UART_SEL, "uart_sel", uart_parents, 5068c2ecf20Sopenharmony_ci 0x0060, 0, 1, 7), 5078c2ecf20Sopenharmony_ci 5088c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_SPI0_SEL, "spi0_sel", spi_parents, 5098c2ecf20Sopenharmony_ci 0x0060, 8, 3, 15), 5108c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_USB20_SEL, "usb20_sel", usb20_parents, 5118c2ecf20Sopenharmony_ci 0x0060, 16, 2, 23), 5128c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_MSDC30_0_SEL, "msdc30_0_sel", msdc30_parents, 5138c2ecf20Sopenharmony_ci 0x0060, 24, 3, 31), 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_MSDC30_1_SEL, "msdc30_1_sel", msdc30_parents, 5168c2ecf20Sopenharmony_ci 0x0070, 0, 3, 7), 5178c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_MSDC30_2_SEL, "msdc30_2_sel", msdc30_parents, 5188c2ecf20Sopenharmony_ci 0x0070, 8, 3, 15), 5198c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_AUDIO_SEL, "audio_sel", msdc30_parents, 5208c2ecf20Sopenharmony_ci 0x0070, 16, 1, 23), 5218c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_AUDINTBUS_SEL, "aud_intbus_sel", aud_intbus_parents, 5228c2ecf20Sopenharmony_ci 0x0070, 24, 3, 31), 5238c2ecf20Sopenharmony_ci 5248c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_PMICSPI_SEL, "pmicspi_sel", pmicspi_parents, 5258c2ecf20Sopenharmony_ci 0x0080, 0, 4, 7), 5268c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_SCP_SEL, "scp_sel", scp_parents, 5278c2ecf20Sopenharmony_ci 0x0080, 8, 2, 15), 5288c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_DPI0_SEL, "dpi0_sel", dpi0_parents, 5298c2ecf20Sopenharmony_ci 0x0080, 16, 3, 23), 5308c2ecf20Sopenharmony_ci MUX_GATE_FLAGS_2(CLK_TOP_DPI1_SEL, "dpi1_sel", dpi1_parents, 5318c2ecf20Sopenharmony_ci 0x0080, 24, 2, 31, 0, CLK_MUX_ROUND_CLOSEST), 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_TVE_SEL, "tve_sel", tve_parents, 5348c2ecf20Sopenharmony_ci 0x0090, 0, 3, 7), 5358c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_HDMI_SEL, "hdmi_sel", hdmi_parents, 5368c2ecf20Sopenharmony_ci 0x0090, 8, 2, 15), 5378c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_APLL_SEL, "apll_sel", apll_parents, 5388c2ecf20Sopenharmony_ci 0x0090, 16, 3, 23), 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_ci MUX_GATE_FLAGS(CLK_TOP_RTC_SEL, "rtc_sel", rtc_parents, 5418c2ecf20Sopenharmony_ci 0x00A0, 0, 2, 7, CLK_IS_CRITICAL), 5428c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_NFI2X_SEL, "nfi2x_sel", nfi2x_parents, 5438c2ecf20Sopenharmony_ci 0x00A0, 8, 3, 15), 5448c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_EMMC_HCLK_SEL, "emmc_hclk_sel", emmc_hclk_parents, 5458c2ecf20Sopenharmony_ci 0x00A0, 24, 2, 31), 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_FLASH_SEL, "flash_sel", flash_parents, 5488c2ecf20Sopenharmony_ci 0x00B0, 0, 3, 7), 5498c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_DI_SEL, "di_sel", di_parents, 5508c2ecf20Sopenharmony_ci 0x00B0, 8, 2, 15), 5518c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_NR_SEL, "nr_sel", nr_osd_parents, 5528c2ecf20Sopenharmony_ci 0x00B0, 16, 3, 23), 5538c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_OSD_SEL, "osd_sel", nr_osd_parents, 5548c2ecf20Sopenharmony_ci 0x00B0, 24, 3, 31), 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_HDMIRX_BIST_SEL, "hdmirx_bist_sel", 5578c2ecf20Sopenharmony_ci hdmirx_bist_parents, 0x00C0, 0, 3, 7), 5588c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_INTDIR_SEL, "intdir_sel", intdir_parents, 5598c2ecf20Sopenharmony_ci 0x00C0, 8, 2, 15), 5608c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_ASM_I_SEL, "asm_i_sel", asm_parents, 5618c2ecf20Sopenharmony_ci 0x00C0, 16, 2, 23), 5628c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_ASM_M_SEL, "asm_m_sel", asm_parents, 5638c2ecf20Sopenharmony_ci 0x00C0, 24, 3, 31), 5648c2ecf20Sopenharmony_ci 5658c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_ASM_H_SEL, "asm_h_sel", asm_parents, 5668c2ecf20Sopenharmony_ci 0x00D0, 0, 2, 7), 5678c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_MS_CARD_SEL, "ms_card_sel", ms_card_parents, 5688c2ecf20Sopenharmony_ci 0x00D0, 16, 2, 23), 5698c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_ETHIF_SEL, "ethif_sel", ethif_parents, 5708c2ecf20Sopenharmony_ci 0x00D0, 24, 3, 31), 5718c2ecf20Sopenharmony_ci 5728c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_HDMIRX26_24_SEL, "hdmirx26_24_sel", hdmirx_parents, 5738c2ecf20Sopenharmony_ci 0x00E0, 0, 1, 7), 5748c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_MSDC30_3_SEL, "msdc30_3_sel", msdc30_parents, 5758c2ecf20Sopenharmony_ci 0x00E0, 8, 3, 15), 5768c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_CMSYS_SEL, "cmsys_sel", cmsys_parents, 5778c2ecf20Sopenharmony_ci 0x00E0, 16, 4, 23), 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_SPI1_SEL, "spi2_sel", spi_parents, 5808c2ecf20Sopenharmony_ci 0x00E0, 24, 3, 31), 5818c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_SPI2_SEL, "spi1_sel", spi_parents, 5828c2ecf20Sopenharmony_ci 0x00F0, 0, 3, 7), 5838c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_8BDAC_SEL, "8bdac_sel", clk_8bdac_parents, 5848c2ecf20Sopenharmony_ci 0x00F0, 8, 2, 15), 5858c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_AUD2DVD_SEL, "aud2dvd_sel", aud2dvd_parents, 5868c2ecf20Sopenharmony_ci 0x00F0, 16, 1, 23), 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_ci MUX(CLK_TOP_PADMCLK_SEL, "padmclk_sel", padmclk_parents, 5898c2ecf20Sopenharmony_ci 0x0100, 0, 3), 5908c2ecf20Sopenharmony_ci 5918c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD_MUX1_SEL, "aud_mux1_sel", aud_mux_parents, 5928c2ecf20Sopenharmony_ci 0x012c, 0, 3), 5938c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD_MUX2_SEL, "aud_mux2_sel", aud_mux_parents, 5948c2ecf20Sopenharmony_ci 0x012c, 3, 3), 5958c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUDPLL_MUX_SEL, "audpll_sel", aud_mux_parents, 5968c2ecf20Sopenharmony_ci 0x012c, 6, 3), 5978c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_AUD_K1_SRC_SEL, "aud_k1_src_sel", aud_src_parents, 5988c2ecf20Sopenharmony_ci 0x012c, 15, 1, 23), 5998c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_AUD_K2_SRC_SEL, "aud_k2_src_sel", aud_src_parents, 6008c2ecf20Sopenharmony_ci 0x012c, 16, 1, 24), 6018c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_AUD_K3_SRC_SEL, "aud_k3_src_sel", aud_src_parents, 6028c2ecf20Sopenharmony_ci 0x012c, 17, 1, 25), 6038c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_AUD_K4_SRC_SEL, "aud_k4_src_sel", aud_src_parents, 6048c2ecf20Sopenharmony_ci 0x012c, 18, 1, 26), 6058c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_AUD_K5_SRC_SEL, "aud_k5_src_sel", aud_src_parents, 6068c2ecf20Sopenharmony_ci 0x012c, 19, 1, 27), 6078c2ecf20Sopenharmony_ci MUX_GATE(CLK_TOP_AUD_K6_SRC_SEL, "aud_k6_src_sel", aud_src_parents, 6088c2ecf20Sopenharmony_ci 0x012c, 20, 1, 28), 6098c2ecf20Sopenharmony_ci}; 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_cistatic const struct mtk_clk_divider top_adj_divs[] = { 6128c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_AUD_EXTCK1_DIV, "audio_ext1_ck", "aud_ext1", 6138c2ecf20Sopenharmony_ci 0x0120, 0, 8), 6148c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_AUD_EXTCK2_DIV, "audio_ext2_ck", "aud_ext2", 6158c2ecf20Sopenharmony_ci 0x0120, 8, 8), 6168c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_AUD_MUX1_DIV, "aud_mux1_div", "aud_mux1_sel", 6178c2ecf20Sopenharmony_ci 0x0120, 16, 8), 6188c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_AUD_MUX2_DIV, "aud_mux2_div", "aud_mux2_sel", 6198c2ecf20Sopenharmony_ci 0x0120, 24, 8), 6208c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_AUD_K1_SRC_DIV, "aud_k1_src_div", "aud_k1_src_sel", 6218c2ecf20Sopenharmony_ci 0x0124, 0, 8), 6228c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_AUD_K2_SRC_DIV, "aud_k2_src_div", "aud_k2_src_sel", 6238c2ecf20Sopenharmony_ci 0x0124, 8, 8), 6248c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_AUD_K3_SRC_DIV, "aud_k3_src_div", "aud_k3_src_sel", 6258c2ecf20Sopenharmony_ci 0x0124, 16, 8), 6268c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_AUD_K4_SRC_DIV, "aud_k4_src_div", "aud_k4_src_sel", 6278c2ecf20Sopenharmony_ci 0x0124, 24, 8), 6288c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_AUD_K5_SRC_DIV, "aud_k5_src_div", "aud_k5_src_sel", 6298c2ecf20Sopenharmony_ci 0x0128, 0, 8), 6308c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_AUD_K6_SRC_DIV, "aud_k6_src_div", "aud_k6_src_sel", 6318c2ecf20Sopenharmony_ci 0x0128, 8, 8), 6328c2ecf20Sopenharmony_ci}; 6338c2ecf20Sopenharmony_ci 6348c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs top_aud_cg_regs = { 6358c2ecf20Sopenharmony_ci .sta_ofs = 0x012C, 6368c2ecf20Sopenharmony_ci}; 6378c2ecf20Sopenharmony_ci 6388c2ecf20Sopenharmony_ci#define GATE_TOP_AUD(_id, _name, _parent, _shift) { \ 6398c2ecf20Sopenharmony_ci .id = _id, \ 6408c2ecf20Sopenharmony_ci .name = _name, \ 6418c2ecf20Sopenharmony_ci .parent_name = _parent, \ 6428c2ecf20Sopenharmony_ci .regs = &top_aud_cg_regs, \ 6438c2ecf20Sopenharmony_ci .shift = _shift, \ 6448c2ecf20Sopenharmony_ci .ops = &mtk_clk_gate_ops_no_setclr, \ 6458c2ecf20Sopenharmony_ci } 6468c2ecf20Sopenharmony_ci 6478c2ecf20Sopenharmony_cistatic const struct mtk_gate top_clks[] = { 6488c2ecf20Sopenharmony_ci GATE_TOP_AUD(CLK_TOP_AUD_48K_TIMING, "a1sys_hp_ck", "aud_mux1_div", 6498c2ecf20Sopenharmony_ci 21), 6508c2ecf20Sopenharmony_ci GATE_TOP_AUD(CLK_TOP_AUD_44K_TIMING, "a2sys_hp_ck", "aud_mux2_div", 6518c2ecf20Sopenharmony_ci 22), 6528c2ecf20Sopenharmony_ci GATE_TOP_AUD(CLK_TOP_AUD_I2S1_MCLK, "aud_i2s1_mclk", "aud_k1_src_div", 6538c2ecf20Sopenharmony_ci 23), 6548c2ecf20Sopenharmony_ci GATE_TOP_AUD(CLK_TOP_AUD_I2S2_MCLK, "aud_i2s2_mclk", "aud_k2_src_div", 6558c2ecf20Sopenharmony_ci 24), 6568c2ecf20Sopenharmony_ci GATE_TOP_AUD(CLK_TOP_AUD_I2S3_MCLK, "aud_i2s3_mclk", "aud_k3_src_div", 6578c2ecf20Sopenharmony_ci 25), 6588c2ecf20Sopenharmony_ci GATE_TOP_AUD(CLK_TOP_AUD_I2S4_MCLK, "aud_i2s4_mclk", "aud_k4_src_div", 6598c2ecf20Sopenharmony_ci 26), 6608c2ecf20Sopenharmony_ci GATE_TOP_AUD(CLK_TOP_AUD_I2S5_MCLK, "aud_i2s5_mclk", "aud_k5_src_div", 6618c2ecf20Sopenharmony_ci 27), 6628c2ecf20Sopenharmony_ci GATE_TOP_AUD(CLK_TOP_AUD_I2S6_MCLK, "aud_i2s6_mclk", "aud_k6_src_div", 6638c2ecf20Sopenharmony_ci 28), 6648c2ecf20Sopenharmony_ci}; 6658c2ecf20Sopenharmony_ci 6668c2ecf20Sopenharmony_cistatic int mtk_topckgen_init(struct platform_device *pdev) 6678c2ecf20Sopenharmony_ci{ 6688c2ecf20Sopenharmony_ci struct clk_onecell_data *clk_data; 6698c2ecf20Sopenharmony_ci void __iomem *base; 6708c2ecf20Sopenharmony_ci struct device_node *node = pdev->dev.of_node; 6718c2ecf20Sopenharmony_ci struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_ci base = devm_ioremap_resource(&pdev->dev, res); 6748c2ecf20Sopenharmony_ci if (IS_ERR(base)) 6758c2ecf20Sopenharmony_ci return PTR_ERR(base); 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_ci clk_data = mtk_alloc_clk_data(CLK_TOP_NR); 6788c2ecf20Sopenharmony_ci if (!clk_data) 6798c2ecf20Sopenharmony_ci return -ENOMEM; 6808c2ecf20Sopenharmony_ci 6818c2ecf20Sopenharmony_ci mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), 6828c2ecf20Sopenharmony_ci clk_data); 6838c2ecf20Sopenharmony_ci 6848c2ecf20Sopenharmony_ci mtk_clk_register_factors(top_fixed_divs, ARRAY_SIZE(top_fixed_divs), 6858c2ecf20Sopenharmony_ci clk_data); 6868c2ecf20Sopenharmony_ci 6878c2ecf20Sopenharmony_ci mtk_clk_register_composites(top_muxes, ARRAY_SIZE(top_muxes), 6888c2ecf20Sopenharmony_ci base, &mt2701_clk_lock, clk_data); 6898c2ecf20Sopenharmony_ci 6908c2ecf20Sopenharmony_ci mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs), 6918c2ecf20Sopenharmony_ci base, &mt2701_clk_lock, clk_data); 6928c2ecf20Sopenharmony_ci 6938c2ecf20Sopenharmony_ci mtk_clk_register_gates(node, top_clks, ARRAY_SIZE(top_clks), 6948c2ecf20Sopenharmony_ci clk_data); 6958c2ecf20Sopenharmony_ci 6968c2ecf20Sopenharmony_ci return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 6978c2ecf20Sopenharmony_ci} 6988c2ecf20Sopenharmony_ci 6998c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs infra_cg_regs = { 7008c2ecf20Sopenharmony_ci .set_ofs = 0x0040, 7018c2ecf20Sopenharmony_ci .clr_ofs = 0x0044, 7028c2ecf20Sopenharmony_ci .sta_ofs = 0x0048, 7038c2ecf20Sopenharmony_ci}; 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_ci#define GATE_ICG(_id, _name, _parent, _shift) { \ 7068c2ecf20Sopenharmony_ci .id = _id, \ 7078c2ecf20Sopenharmony_ci .name = _name, \ 7088c2ecf20Sopenharmony_ci .parent_name = _parent, \ 7098c2ecf20Sopenharmony_ci .regs = &infra_cg_regs, \ 7108c2ecf20Sopenharmony_ci .shift = _shift, \ 7118c2ecf20Sopenharmony_ci .ops = &mtk_clk_gate_ops_setclr, \ 7128c2ecf20Sopenharmony_ci } 7138c2ecf20Sopenharmony_ci 7148c2ecf20Sopenharmony_cistatic const struct mtk_gate infra_clks[] = { 7158c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_DBG, "dbgclk", "axi_sel", 0), 7168c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_SMI, "smi_ck", "mm_sel", 1), 7178c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_QAXI_CM4, "cm4_ck", "axi_sel", 2), 7188c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_AUD_SPLIN_B, "audio_splin_bck", "hadds2pll_294m", 4), 7198c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_AUDIO, "audio_ck", "clk26m", 5), 7208c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_EFUSE, "efuse_ck", "clk26m", 6), 7218c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_L2C_SRAM, "l2c_sram_ck", "mm_sel", 7), 7228c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_M4U, "m4u_ck", "mem_sel", 8), 7238c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_CONNMCU, "connsys_bus", "wbg_dig_ck_416m", 12), 7248c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_TRNG, "trng_ck", "axi_sel", 13), 7258c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_RAMBUFIF, "rambufif_ck", "mem_sel", 14), 7268c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_CPUM, "cpum_ck", "mem_sel", 15), 7278c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_KP, "kp_ck", "axi_sel", 16), 7288c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_CEC, "cec_ck", "rtc_sel", 18), 7298c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_IRRX, "irrx_ck", "axi_sel", 19), 7308c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_PMICSPI, "pmicspi_ck", "pmicspi_sel", 22), 7318c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_PMICWRAP, "pmicwrap_ck", "axi_sel", 23), 7328c2ecf20Sopenharmony_ci GATE_ICG(CLK_INFRA_DDCCI, "ddcci_ck", "axi_sel", 24), 7338c2ecf20Sopenharmony_ci}; 7348c2ecf20Sopenharmony_ci 7358c2ecf20Sopenharmony_cistatic const struct mtk_fixed_factor infra_fixed_divs[] = { 7368c2ecf20Sopenharmony_ci FACTOR(CLK_INFRA_CLK_13M, "clk13m", "clk26m", 1, 2), 7378c2ecf20Sopenharmony_ci}; 7388c2ecf20Sopenharmony_ci 7398c2ecf20Sopenharmony_cistatic struct clk_onecell_data *infra_clk_data; 7408c2ecf20Sopenharmony_ci 7418c2ecf20Sopenharmony_cistatic void __init mtk_infrasys_init_early(struct device_node *node) 7428c2ecf20Sopenharmony_ci{ 7438c2ecf20Sopenharmony_ci int r, i; 7448c2ecf20Sopenharmony_ci 7458c2ecf20Sopenharmony_ci if (!infra_clk_data) { 7468c2ecf20Sopenharmony_ci infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR); 7478c2ecf20Sopenharmony_ci if (!infra_clk_data) 7488c2ecf20Sopenharmony_ci return; 7498c2ecf20Sopenharmony_ci 7508c2ecf20Sopenharmony_ci for (i = 0; i < CLK_INFRA_NR; i++) 7518c2ecf20Sopenharmony_ci infra_clk_data->clks[i] = ERR_PTR(-EPROBE_DEFER); 7528c2ecf20Sopenharmony_ci } 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_ci mtk_clk_register_factors(infra_fixed_divs, ARRAY_SIZE(infra_fixed_divs), 7558c2ecf20Sopenharmony_ci infra_clk_data); 7568c2ecf20Sopenharmony_ci 7578c2ecf20Sopenharmony_ci mtk_clk_register_cpumuxes(node, cpu_muxes, ARRAY_SIZE(cpu_muxes), 7588c2ecf20Sopenharmony_ci infra_clk_data); 7598c2ecf20Sopenharmony_ci 7608c2ecf20Sopenharmony_ci r = of_clk_add_provider(node, of_clk_src_onecell_get, infra_clk_data); 7618c2ecf20Sopenharmony_ci if (r) 7628c2ecf20Sopenharmony_ci pr_err("%s(): could not register clock provider: %d\n", 7638c2ecf20Sopenharmony_ci __func__, r); 7648c2ecf20Sopenharmony_ci} 7658c2ecf20Sopenharmony_ciCLK_OF_DECLARE_DRIVER(mtk_infra, "mediatek,mt2701-infracfg", 7668c2ecf20Sopenharmony_ci mtk_infrasys_init_early); 7678c2ecf20Sopenharmony_ci 7688c2ecf20Sopenharmony_cistatic int mtk_infrasys_init(struct platform_device *pdev) 7698c2ecf20Sopenharmony_ci{ 7708c2ecf20Sopenharmony_ci int r, i; 7718c2ecf20Sopenharmony_ci struct device_node *node = pdev->dev.of_node; 7728c2ecf20Sopenharmony_ci 7738c2ecf20Sopenharmony_ci if (!infra_clk_data) { 7748c2ecf20Sopenharmony_ci infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR); 7758c2ecf20Sopenharmony_ci if (!infra_clk_data) 7768c2ecf20Sopenharmony_ci return -ENOMEM; 7778c2ecf20Sopenharmony_ci } else { 7788c2ecf20Sopenharmony_ci for (i = 0; i < CLK_INFRA_NR; i++) { 7798c2ecf20Sopenharmony_ci if (infra_clk_data->clks[i] == ERR_PTR(-EPROBE_DEFER)) 7808c2ecf20Sopenharmony_ci infra_clk_data->clks[i] = ERR_PTR(-ENOENT); 7818c2ecf20Sopenharmony_ci } 7828c2ecf20Sopenharmony_ci } 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_ci mtk_clk_register_gates(node, infra_clks, ARRAY_SIZE(infra_clks), 7858c2ecf20Sopenharmony_ci infra_clk_data); 7868c2ecf20Sopenharmony_ci mtk_clk_register_factors(infra_fixed_divs, ARRAY_SIZE(infra_fixed_divs), 7878c2ecf20Sopenharmony_ci infra_clk_data); 7888c2ecf20Sopenharmony_ci 7898c2ecf20Sopenharmony_ci r = of_clk_add_provider(node, of_clk_src_onecell_get, infra_clk_data); 7908c2ecf20Sopenharmony_ci if (r) 7918c2ecf20Sopenharmony_ci return r; 7928c2ecf20Sopenharmony_ci 7938c2ecf20Sopenharmony_ci mtk_register_reset_controller(node, 2, 0x30); 7948c2ecf20Sopenharmony_ci 7958c2ecf20Sopenharmony_ci return 0; 7968c2ecf20Sopenharmony_ci} 7978c2ecf20Sopenharmony_ci 7988c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs peri0_cg_regs = { 7998c2ecf20Sopenharmony_ci .set_ofs = 0x0008, 8008c2ecf20Sopenharmony_ci .clr_ofs = 0x0010, 8018c2ecf20Sopenharmony_ci .sta_ofs = 0x0018, 8028c2ecf20Sopenharmony_ci}; 8038c2ecf20Sopenharmony_ci 8048c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs peri1_cg_regs = { 8058c2ecf20Sopenharmony_ci .set_ofs = 0x000c, 8068c2ecf20Sopenharmony_ci .clr_ofs = 0x0014, 8078c2ecf20Sopenharmony_ci .sta_ofs = 0x001c, 8088c2ecf20Sopenharmony_ci}; 8098c2ecf20Sopenharmony_ci 8108c2ecf20Sopenharmony_ci#define GATE_PERI0(_id, _name, _parent, _shift) { \ 8118c2ecf20Sopenharmony_ci .id = _id, \ 8128c2ecf20Sopenharmony_ci .name = _name, \ 8138c2ecf20Sopenharmony_ci .parent_name = _parent, \ 8148c2ecf20Sopenharmony_ci .regs = &peri0_cg_regs, \ 8158c2ecf20Sopenharmony_ci .shift = _shift, \ 8168c2ecf20Sopenharmony_ci .ops = &mtk_clk_gate_ops_setclr, \ 8178c2ecf20Sopenharmony_ci } 8188c2ecf20Sopenharmony_ci 8198c2ecf20Sopenharmony_ci#define GATE_PERI1(_id, _name, _parent, _shift) { \ 8208c2ecf20Sopenharmony_ci .id = _id, \ 8218c2ecf20Sopenharmony_ci .name = _name, \ 8228c2ecf20Sopenharmony_ci .parent_name = _parent, \ 8238c2ecf20Sopenharmony_ci .regs = &peri1_cg_regs, \ 8248c2ecf20Sopenharmony_ci .shift = _shift, \ 8258c2ecf20Sopenharmony_ci .ops = &mtk_clk_gate_ops_setclr, \ 8268c2ecf20Sopenharmony_ci } 8278c2ecf20Sopenharmony_ci 8288c2ecf20Sopenharmony_cistatic const struct mtk_gate peri_clks[] = { 8298c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_USB0_MCU, "usb0_mcu_ck", "axi_sel", 31), 8308c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_ETH, "eth_ck", "clk26m", 30), 8318c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_SPI0, "spi0_ck", "spi0_sel", 29), 8328c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_AUXADC, "auxadc_ck", "clk26m", 28), 8338c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_I2C3, "i2c3_ck", "clk26m", 27), 8348c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_I2C2, "i2c2_ck", "axi_sel", 26), 8358c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_I2C1, "i2c1_ck", "axi_sel", 25), 8368c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_I2C0, "i2c0_ck", "axi_sel", 24), 8378c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_BTIF, "bitif_ck", "axi_sel", 23), 8388c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_UART3, "uart3_ck", "axi_sel", 22), 8398c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_UART2, "uart2_ck", "axi_sel", 21), 8408c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_UART1, "uart1_ck", "axi_sel", 20), 8418c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_UART0, "uart0_ck", "axi_sel", 19), 8428c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_NLI, "nli_ck", "axi_sel", 18), 8438c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_MSDC50_3, "msdc50_3_ck", "emmc_hclk_sel", 17), 8448c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_MSDC30_3, "msdc30_3_ck", "msdc30_3_sel", 16), 8458c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_MSDC30_2, "msdc30_2_ck", "msdc30_2_sel", 15), 8468c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_MSDC30_1, "msdc30_1_ck", "msdc30_1_sel", 14), 8478c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_MSDC30_0, "msdc30_0_ck", "msdc30_0_sel", 13), 8488c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_AP_DMA, "ap_dma_ck", "axi_sel", 12), 8498c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_USB1, "usb1_ck", "usb20_sel", 11), 8508c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_USB0, "usb0_ck", "usb20_sel", 10), 8518c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_PWM, "pwm_ck", "axi_sel", 9), 8528c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_PWM7, "pwm7_ck", "axisel_d4", 8), 8538c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_PWM6, "pwm6_ck", "axisel_d4", 7), 8548c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_PWM5, "pwm5_ck", "axisel_d4", 6), 8558c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_PWM4, "pwm4_ck", "axisel_d4", 5), 8568c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_PWM3, "pwm3_ck", "axisel_d4", 4), 8578c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_PWM2, "pwm2_ck", "axisel_d4", 3), 8588c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_PWM1, "pwm1_ck", "axisel_d4", 2), 8598c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_THERM, "therm_ck", "axi_sel", 1), 8608c2ecf20Sopenharmony_ci GATE_PERI0(CLK_PERI_NFI, "nfi_ck", "nfi2x_sel", 0), 8618c2ecf20Sopenharmony_ci 8628c2ecf20Sopenharmony_ci GATE_PERI1(CLK_PERI_FCI, "fci_ck", "ms_card_sel", 11), 8638c2ecf20Sopenharmony_ci GATE_PERI1(CLK_PERI_SPI2, "spi2_ck", "spi2_sel", 10), 8648c2ecf20Sopenharmony_ci GATE_PERI1(CLK_PERI_SPI1, "spi1_ck", "spi1_sel", 9), 8658c2ecf20Sopenharmony_ci GATE_PERI1(CLK_PERI_HOST89_DVD, "host89_dvd_ck", "aud2dvd_sel", 8), 8668c2ecf20Sopenharmony_ci GATE_PERI1(CLK_PERI_HOST89_SPI, "host89_spi_ck", "spi0_sel", 7), 8678c2ecf20Sopenharmony_ci GATE_PERI1(CLK_PERI_HOST89_INT, "host89_int_ck", "axi_sel", 6), 8688c2ecf20Sopenharmony_ci GATE_PERI1(CLK_PERI_FLASH, "flash_ck", "nfi2x_sel", 5), 8698c2ecf20Sopenharmony_ci GATE_PERI1(CLK_PERI_NFI_PAD, "nfi_pad_ck", "nfi1x_pad", 4), 8708c2ecf20Sopenharmony_ci GATE_PERI1(CLK_PERI_NFI_ECC, "nfi_ecc_ck", "nfi1x_pad", 3), 8718c2ecf20Sopenharmony_ci GATE_PERI1(CLK_PERI_GCPU, "gcpu_ck", "axi_sel", 2), 8728c2ecf20Sopenharmony_ci GATE_PERI1(CLK_PERI_USB_SLV, "usbslv_ck", "axi_sel", 1), 8738c2ecf20Sopenharmony_ci GATE_PERI1(CLK_PERI_USB1_MCU, "usb1_mcu_ck", "axi_sel", 0), 8748c2ecf20Sopenharmony_ci}; 8758c2ecf20Sopenharmony_ci 8768c2ecf20Sopenharmony_cistatic const char * const uart_ck_sel_parents[] = { 8778c2ecf20Sopenharmony_ci "clk26m", 8788c2ecf20Sopenharmony_ci "uart_sel", 8798c2ecf20Sopenharmony_ci}; 8808c2ecf20Sopenharmony_ci 8818c2ecf20Sopenharmony_cistatic const struct mtk_composite peri_muxs[] = { 8828c2ecf20Sopenharmony_ci MUX(CLK_PERI_UART0_SEL, "uart0_ck_sel", uart_ck_sel_parents, 8838c2ecf20Sopenharmony_ci 0x40c, 0, 1), 8848c2ecf20Sopenharmony_ci MUX(CLK_PERI_UART1_SEL, "uart1_ck_sel", uart_ck_sel_parents, 8858c2ecf20Sopenharmony_ci 0x40c, 1, 1), 8868c2ecf20Sopenharmony_ci MUX(CLK_PERI_UART2_SEL, "uart2_ck_sel", uart_ck_sel_parents, 8878c2ecf20Sopenharmony_ci 0x40c, 2, 1), 8888c2ecf20Sopenharmony_ci MUX(CLK_PERI_UART3_SEL, "uart3_ck_sel", uart_ck_sel_parents, 8898c2ecf20Sopenharmony_ci 0x40c, 3, 1), 8908c2ecf20Sopenharmony_ci}; 8918c2ecf20Sopenharmony_ci 8928c2ecf20Sopenharmony_cistatic int mtk_pericfg_init(struct platform_device *pdev) 8938c2ecf20Sopenharmony_ci{ 8948c2ecf20Sopenharmony_ci struct clk_onecell_data *clk_data; 8958c2ecf20Sopenharmony_ci void __iomem *base; 8968c2ecf20Sopenharmony_ci int r; 8978c2ecf20Sopenharmony_ci struct device_node *node = pdev->dev.of_node; 8988c2ecf20Sopenharmony_ci struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 8998c2ecf20Sopenharmony_ci 9008c2ecf20Sopenharmony_ci base = devm_ioremap_resource(&pdev->dev, res); 9018c2ecf20Sopenharmony_ci if (IS_ERR(base)) 9028c2ecf20Sopenharmony_ci return PTR_ERR(base); 9038c2ecf20Sopenharmony_ci 9048c2ecf20Sopenharmony_ci clk_data = mtk_alloc_clk_data(CLK_PERI_NR); 9058c2ecf20Sopenharmony_ci if (!clk_data) 9068c2ecf20Sopenharmony_ci return -ENOMEM; 9078c2ecf20Sopenharmony_ci 9088c2ecf20Sopenharmony_ci mtk_clk_register_gates(node, peri_clks, ARRAY_SIZE(peri_clks), 9098c2ecf20Sopenharmony_ci clk_data); 9108c2ecf20Sopenharmony_ci 9118c2ecf20Sopenharmony_ci mtk_clk_register_composites(peri_muxs, ARRAY_SIZE(peri_muxs), base, 9128c2ecf20Sopenharmony_ci &mt2701_clk_lock, clk_data); 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_ci r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 9158c2ecf20Sopenharmony_ci if (r) 9168c2ecf20Sopenharmony_ci return r; 9178c2ecf20Sopenharmony_ci 9188c2ecf20Sopenharmony_ci mtk_register_reset_controller(node, 2, 0x0); 9198c2ecf20Sopenharmony_ci 9208c2ecf20Sopenharmony_ci return 0; 9218c2ecf20Sopenharmony_ci} 9228c2ecf20Sopenharmony_ci 9238c2ecf20Sopenharmony_ci#define MT8590_PLL_FMAX (2000 * MHZ) 9248c2ecf20Sopenharmony_ci#define CON0_MT8590_RST_BAR BIT(27) 9258c2ecf20Sopenharmony_ci 9268c2ecf20Sopenharmony_ci#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, _pd_reg, \ 9278c2ecf20Sopenharmony_ci _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift) { \ 9288c2ecf20Sopenharmony_ci .id = _id, \ 9298c2ecf20Sopenharmony_ci .name = _name, \ 9308c2ecf20Sopenharmony_ci .reg = _reg, \ 9318c2ecf20Sopenharmony_ci .pwr_reg = _pwr_reg, \ 9328c2ecf20Sopenharmony_ci .en_mask = _en_mask, \ 9338c2ecf20Sopenharmony_ci .flags = _flags, \ 9348c2ecf20Sopenharmony_ci .rst_bar_mask = CON0_MT8590_RST_BAR, \ 9358c2ecf20Sopenharmony_ci .fmax = MT8590_PLL_FMAX, \ 9368c2ecf20Sopenharmony_ci .pcwbits = _pcwbits, \ 9378c2ecf20Sopenharmony_ci .pd_reg = _pd_reg, \ 9388c2ecf20Sopenharmony_ci .pd_shift = _pd_shift, \ 9398c2ecf20Sopenharmony_ci .tuner_reg = _tuner_reg, \ 9408c2ecf20Sopenharmony_ci .pcw_reg = _pcw_reg, \ 9418c2ecf20Sopenharmony_ci .pcw_shift = _pcw_shift, \ 9428c2ecf20Sopenharmony_ci } 9438c2ecf20Sopenharmony_ci 9448c2ecf20Sopenharmony_cistatic const struct mtk_pll_data apmixed_plls[] = { 9458c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_ARMPLL, "armpll", 0x200, 0x20c, 0x80000001, 9468c2ecf20Sopenharmony_ci PLL_AO, 21, 0x204, 24, 0x0, 0x204, 0), 9478c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x210, 0x21c, 0xf0000001, 9488c2ecf20Sopenharmony_ci HAVE_RST_BAR, 21, 0x210, 4, 0x0, 0x214, 0), 9498c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x220, 0x22c, 0xf3000001, 9508c2ecf20Sopenharmony_ci HAVE_RST_BAR, 7, 0x220, 4, 0x0, 0x224, 14), 9518c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_MMPLL, "mmpll", 0x230, 0x23c, 0x00000001, 0, 9528c2ecf20Sopenharmony_ci 21, 0x230, 4, 0x0, 0x234, 0), 9538c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x240, 0x24c, 0x00000001, 0, 9548c2ecf20Sopenharmony_ci 21, 0x240, 4, 0x0, 0x244, 0), 9558c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x250, 0x25c, 0x00000001, 0, 9568c2ecf20Sopenharmony_ci 21, 0x250, 4, 0x0, 0x254, 0), 9578c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_AUD1PLL, "aud1pll", 0x270, 0x27c, 0x00000001, 0, 9588c2ecf20Sopenharmony_ci 31, 0x270, 4, 0x0, 0x274, 0), 9598c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_TRGPLL, "trgpll", 0x280, 0x28c, 0x00000001, 0, 9608c2ecf20Sopenharmony_ci 31, 0x280, 4, 0x0, 0x284, 0), 9618c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_ETHPLL, "ethpll", 0x290, 0x29c, 0x00000001, 0, 9628c2ecf20Sopenharmony_ci 31, 0x290, 4, 0x0, 0x294, 0), 9638c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x2a0, 0x2ac, 0x00000001, 0, 9648c2ecf20Sopenharmony_ci 31, 0x2a0, 4, 0x0, 0x2a4, 0), 9658c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_HADDS2PLL, "hadds2pll", 0x2b0, 0x2bc, 0x00000001, 0, 9668c2ecf20Sopenharmony_ci 31, 0x2b0, 4, 0x0, 0x2b4, 0), 9678c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_AUD2PLL, "aud2pll", 0x2c0, 0x2cc, 0x00000001, 0, 9688c2ecf20Sopenharmony_ci 31, 0x2c0, 4, 0x0, 0x2c4, 0), 9698c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_TVD2PLL, "tvd2pll", 0x2d0, 0x2dc, 0x00000001, 0, 9708c2ecf20Sopenharmony_ci 21, 0x2d0, 4, 0x0, 0x2d4, 0), 9718c2ecf20Sopenharmony_ci}; 9728c2ecf20Sopenharmony_ci 9738c2ecf20Sopenharmony_cistatic const struct mtk_fixed_factor apmixed_fixed_divs[] = { 9748c2ecf20Sopenharmony_ci FACTOR(CLK_APMIXED_HDMI_REF, "hdmi_ref", "tvdpll", 1, 1), 9758c2ecf20Sopenharmony_ci}; 9768c2ecf20Sopenharmony_ci 9778c2ecf20Sopenharmony_cistatic int mtk_apmixedsys_init(struct platform_device *pdev) 9788c2ecf20Sopenharmony_ci{ 9798c2ecf20Sopenharmony_ci struct clk_onecell_data *clk_data; 9808c2ecf20Sopenharmony_ci struct device_node *node = pdev->dev.of_node; 9818c2ecf20Sopenharmony_ci 9828c2ecf20Sopenharmony_ci clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR); 9838c2ecf20Sopenharmony_ci if (!clk_data) 9848c2ecf20Sopenharmony_ci return -ENOMEM; 9858c2ecf20Sopenharmony_ci 9868c2ecf20Sopenharmony_ci mtk_clk_register_plls(node, apmixed_plls, ARRAY_SIZE(apmixed_plls), 9878c2ecf20Sopenharmony_ci clk_data); 9888c2ecf20Sopenharmony_ci mtk_clk_register_factors(apmixed_fixed_divs, ARRAY_SIZE(apmixed_fixed_divs), 9898c2ecf20Sopenharmony_ci clk_data); 9908c2ecf20Sopenharmony_ci 9918c2ecf20Sopenharmony_ci return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 9928c2ecf20Sopenharmony_ci} 9938c2ecf20Sopenharmony_ci 9948c2ecf20Sopenharmony_cistatic const struct of_device_id of_match_clk_mt2701[] = { 9958c2ecf20Sopenharmony_ci { 9968c2ecf20Sopenharmony_ci .compatible = "mediatek,mt2701-topckgen", 9978c2ecf20Sopenharmony_ci .data = mtk_topckgen_init, 9988c2ecf20Sopenharmony_ci }, { 9998c2ecf20Sopenharmony_ci .compatible = "mediatek,mt2701-infracfg", 10008c2ecf20Sopenharmony_ci .data = mtk_infrasys_init, 10018c2ecf20Sopenharmony_ci }, { 10028c2ecf20Sopenharmony_ci .compatible = "mediatek,mt2701-pericfg", 10038c2ecf20Sopenharmony_ci .data = mtk_pericfg_init, 10048c2ecf20Sopenharmony_ci }, { 10058c2ecf20Sopenharmony_ci .compatible = "mediatek,mt2701-apmixedsys", 10068c2ecf20Sopenharmony_ci .data = mtk_apmixedsys_init, 10078c2ecf20Sopenharmony_ci }, { 10088c2ecf20Sopenharmony_ci /* sentinel */ 10098c2ecf20Sopenharmony_ci } 10108c2ecf20Sopenharmony_ci}; 10118c2ecf20Sopenharmony_ci 10128c2ecf20Sopenharmony_cistatic int clk_mt2701_probe(struct platform_device *pdev) 10138c2ecf20Sopenharmony_ci{ 10148c2ecf20Sopenharmony_ci int (*clk_init)(struct platform_device *); 10158c2ecf20Sopenharmony_ci int r; 10168c2ecf20Sopenharmony_ci 10178c2ecf20Sopenharmony_ci clk_init = of_device_get_match_data(&pdev->dev); 10188c2ecf20Sopenharmony_ci if (!clk_init) 10198c2ecf20Sopenharmony_ci return -EINVAL; 10208c2ecf20Sopenharmony_ci 10218c2ecf20Sopenharmony_ci r = clk_init(pdev); 10228c2ecf20Sopenharmony_ci if (r) 10238c2ecf20Sopenharmony_ci dev_err(&pdev->dev, 10248c2ecf20Sopenharmony_ci "could not register clock provider: %s: %d\n", 10258c2ecf20Sopenharmony_ci pdev->name, r); 10268c2ecf20Sopenharmony_ci 10278c2ecf20Sopenharmony_ci return r; 10288c2ecf20Sopenharmony_ci} 10298c2ecf20Sopenharmony_ci 10308c2ecf20Sopenharmony_cistatic struct platform_driver clk_mt2701_drv = { 10318c2ecf20Sopenharmony_ci .probe = clk_mt2701_probe, 10328c2ecf20Sopenharmony_ci .driver = { 10338c2ecf20Sopenharmony_ci .name = "clk-mt2701", 10348c2ecf20Sopenharmony_ci .of_match_table = of_match_clk_mt2701, 10358c2ecf20Sopenharmony_ci }, 10368c2ecf20Sopenharmony_ci}; 10378c2ecf20Sopenharmony_ci 10388c2ecf20Sopenharmony_cistatic int __init clk_mt2701_init(void) 10398c2ecf20Sopenharmony_ci{ 10408c2ecf20Sopenharmony_ci return platform_driver_register(&clk_mt2701_drv); 10418c2ecf20Sopenharmony_ci} 10428c2ecf20Sopenharmony_ci 10438c2ecf20Sopenharmony_ciarch_initcall(clk_mt2701_init); 1044