18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2014 MediaTek Inc.
48c2ecf20Sopenharmony_ci * Author: James Liao <jamesjj.liao@mediatek.com>
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <linux/clk.h>
88c2ecf20Sopenharmony_ci#include <linux/of.h>
98c2ecf20Sopenharmony_ci#include <linux/of_address.h>
108c2ecf20Sopenharmony_ci#include <linux/slab.h>
118c2ecf20Sopenharmony_ci#include <linux/mfd/syscon.h>
128c2ecf20Sopenharmony_ci#include <dt-bindings/clock/mt8135-clk.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include "clk-mtk.h"
158c2ecf20Sopenharmony_ci#include "clk-gate.h"
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(mt8135_clk_lock);
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_cistatic const struct mtk_fixed_factor root_clk_alias[] __initconst = {
208c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_DSI0_LNTC_DSICLK, "dsi0_lntc_dsiclk", "clk_null", 1, 1),
218c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_HDMITX_CLKDIG_CTS, "hdmitx_clkdig_cts", "clk_null", 1, 1),
228c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_CLKPH_MCK, "clkph_mck", "clk_null", 1, 1),
238c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_CPUM_TCK_IN, "cpum_tck_in", "clk_null", 1, 1),
248c2ecf20Sopenharmony_ci};
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistatic const struct mtk_fixed_factor top_divs[] __initconst = {
278c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MAINPLL_806M, "mainpll_806m", "mainpll", 1, 2),
288c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MAINPLL_537P3M, "mainpll_537p3m", "mainpll", 1, 3),
298c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MAINPLL_322P4M, "mainpll_322p4m", "mainpll", 1, 5),
308c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MAINPLL_230P3M, "mainpll_230p3m", "mainpll", 1, 7),
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_624M, "univpll_624m", "univpll", 1, 2),
338c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_416M, "univpll_416m", "univpll", 1, 3),
348c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_249P6M, "univpll_249p6m", "univpll", 1, 5),
358c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_178P3M, "univpll_178p3m", "univpll", 1, 7),
368c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_48M, "univpll_48m", "univpll", 1, 26),
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D2, "mmpll_d2", "mmpll", 1, 2),
398c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D3, "mmpll_d3", "mmpll", 1, 3),
408c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D5, "mmpll_d5", "mmpll", 1, 5),
418c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D7, "mmpll_d7", "mmpll", 1, 7),
428c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D4, "mmpll_d4", "mmpll_d2", 1, 2),
438c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D6, "mmpll_d6", "mmpll_d3", 1, 2),
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D2, "syspll_d2", "mainpll_806m", 1, 1),
468c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D4, "syspll_d4", "mainpll_806m", 1, 2),
478c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D6, "syspll_d6", "mainpll_806m", 1, 3),
488c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D8, "syspll_d8", "mainpll_806m", 1, 4),
498c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D10, "syspll_d10", "mainpll_806m", 1, 5),
508c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D12, "syspll_d12", "mainpll_806m", 1, 6),
518c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D16, "syspll_d16", "mainpll_806m", 1, 8),
528c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D24, "syspll_d24", "mainpll_806m", 1, 12),
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D3, "syspll_d3", "mainpll_537p3m", 1, 1),
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D2P5, "syspll_d2p5", "mainpll_322p4m", 2, 1),
578c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D5, "syspll_d5", "mainpll_322p4m", 1, 1),
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D3P5, "syspll_d3p5", "mainpll_230p3m", 2, 1),
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL1_D2, "univpll1_d2", "univpll_624m", 1, 2),
628c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL1_D4, "univpll1_d4", "univpll_624m", 1, 4),
638c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL1_D6, "univpll1_d6", "univpll_624m", 1, 6),
648c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL1_D8, "univpll1_d8", "univpll_624m", 1, 8),
658c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL1_D10, "univpll1_d10", "univpll_624m", 1, 10),
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL2_D2, "univpll2_d2", "univpll_416m", 1, 2),
688c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL2_D4, "univpll2_d4", "univpll_416m", 1, 4),
698c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL2_D6, "univpll2_d6", "univpll_416m", 1, 6),
708c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL2_D8, "univpll2_d8", "univpll_416m", 1, 8),
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll_416m", 1, 1),
738c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll_249p6m", 1, 1),
748c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D7, "univpll_d7", "univpll_178p3m", 1, 1),
758c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D10, "univpll_d10", "univpll_249p6m", 1, 2),
768c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D26, "univpll_d26", "univpll_48m", 1, 1),
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_APLL, "apll_ck", "audpll", 1, 1),
798c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_APLL_D4, "apll_d4", "audpll", 1, 4),
808c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_APLL_D8, "apll_d8", "audpll", 1, 8),
818c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_APLL_D16, "apll_d16", "audpll", 1, 16),
828c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_APLL_D24, "apll_d24", "audpll", 1, 24),
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_LVDSPLL_D2, "lvdspll_d2", "lvdspll", 1, 2),
858c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_LVDSPLL_D4, "lvdspll_d4", "lvdspll", 1, 4),
868c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_LVDSPLL_D8, "lvdspll_d8", "lvdspll", 1, 8),
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_LVDSTX_CLKDIG_CT, "lvdstx_clkdig_cts", "lvdspll", 1, 1),
898c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_VPLL_DPIX, "vpll_dpix_ck", "lvdspll", 1, 1),
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_TVHDMI_H, "tvhdmi_h_ck", "tvdpll", 1, 1),
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_HDMITX_CLKDIG_D2, "hdmitx_clkdig_d2", "hdmitx_clkdig_cts", 1, 2),
948c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_HDMITX_CLKDIG_D3, "hdmitx_clkdig_d3", "hdmitx_clkdig_cts", 1, 3),
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_TVHDMI_D2, "tvhdmi_d2", "tvhdmi_h_ck", 1, 2),
978c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_TVHDMI_D4, "tvhdmi_d4", "tvhdmi_h_ck", 1, 4),
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MEMPLL_MCK_D4, "mempll_mck_d4", "clkph_mck", 1, 4),
1008c2ecf20Sopenharmony_ci};
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_cistatic const char * const axi_parents[] __initconst = {
1038c2ecf20Sopenharmony_ci	"clk26m",
1048c2ecf20Sopenharmony_ci	"syspll_d3",
1058c2ecf20Sopenharmony_ci	"syspll_d4",
1068c2ecf20Sopenharmony_ci	"syspll_d6",
1078c2ecf20Sopenharmony_ci	"univpll_d5",
1088c2ecf20Sopenharmony_ci	"univpll2_d2",
1098c2ecf20Sopenharmony_ci	"syspll_d3p5"
1108c2ecf20Sopenharmony_ci};
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_cistatic const char * const smi_parents[] __initconst = {
1138c2ecf20Sopenharmony_ci	"clk26m",
1148c2ecf20Sopenharmony_ci	"clkph_mck",
1158c2ecf20Sopenharmony_ci	"syspll_d2p5",
1168c2ecf20Sopenharmony_ci	"syspll_d3",
1178c2ecf20Sopenharmony_ci	"syspll_d8",
1188c2ecf20Sopenharmony_ci	"univpll_d5",
1198c2ecf20Sopenharmony_ci	"univpll1_d2",
1208c2ecf20Sopenharmony_ci	"univpll1_d6",
1218c2ecf20Sopenharmony_ci	"mmpll_d3",
1228c2ecf20Sopenharmony_ci	"mmpll_d4",
1238c2ecf20Sopenharmony_ci	"mmpll_d5",
1248c2ecf20Sopenharmony_ci	"mmpll_d6",
1258c2ecf20Sopenharmony_ci	"mmpll_d7",
1268c2ecf20Sopenharmony_ci	"vdecpll",
1278c2ecf20Sopenharmony_ci	"lvdspll"
1288c2ecf20Sopenharmony_ci};
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_cistatic const char * const mfg_parents[] __initconst = {
1318c2ecf20Sopenharmony_ci	"clk26m",
1328c2ecf20Sopenharmony_ci	"univpll1_d4",
1338c2ecf20Sopenharmony_ci	"syspll_d2",
1348c2ecf20Sopenharmony_ci	"syspll_d2p5",
1358c2ecf20Sopenharmony_ci	"syspll_d3",
1368c2ecf20Sopenharmony_ci	"univpll_d5",
1378c2ecf20Sopenharmony_ci	"univpll1_d2",
1388c2ecf20Sopenharmony_ci	"mmpll_d2",
1398c2ecf20Sopenharmony_ci	"mmpll_d3",
1408c2ecf20Sopenharmony_ci	"mmpll_d4",
1418c2ecf20Sopenharmony_ci	"mmpll_d5",
1428c2ecf20Sopenharmony_ci	"mmpll_d6",
1438c2ecf20Sopenharmony_ci	"mmpll_d7"
1448c2ecf20Sopenharmony_ci};
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_cistatic const char * const irda_parents[] __initconst = {
1478c2ecf20Sopenharmony_ci	"clk26m",
1488c2ecf20Sopenharmony_ci	"univpll2_d8",
1498c2ecf20Sopenharmony_ci	"univpll1_d6"
1508c2ecf20Sopenharmony_ci};
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_cistatic const char * const cam_parents[] __initconst = {
1538c2ecf20Sopenharmony_ci	"clk26m",
1548c2ecf20Sopenharmony_ci	"syspll_d3",
1558c2ecf20Sopenharmony_ci	"syspll_d3p5",
1568c2ecf20Sopenharmony_ci	"syspll_d4",
1578c2ecf20Sopenharmony_ci	"univpll_d5",
1588c2ecf20Sopenharmony_ci	"univpll2_d2",
1598c2ecf20Sopenharmony_ci	"univpll_d7",
1608c2ecf20Sopenharmony_ci	"univpll1_d4"
1618c2ecf20Sopenharmony_ci};
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_cistatic const char * const aud_intbus_parents[] __initconst = {
1648c2ecf20Sopenharmony_ci	"clk26m",
1658c2ecf20Sopenharmony_ci	"syspll_d6",
1668c2ecf20Sopenharmony_ci	"univpll_d10"
1678c2ecf20Sopenharmony_ci};
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_cistatic const char * const jpg_parents[] __initconst = {
1708c2ecf20Sopenharmony_ci	"clk26m",
1718c2ecf20Sopenharmony_ci	"syspll_d5",
1728c2ecf20Sopenharmony_ci	"syspll_d4",
1738c2ecf20Sopenharmony_ci	"syspll_d3",
1748c2ecf20Sopenharmony_ci	"univpll_d7",
1758c2ecf20Sopenharmony_ci	"univpll2_d2",
1768c2ecf20Sopenharmony_ci	"univpll_d5"
1778c2ecf20Sopenharmony_ci};
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_cistatic const char * const disp_parents[] __initconst = {
1808c2ecf20Sopenharmony_ci	"clk26m",
1818c2ecf20Sopenharmony_ci	"syspll_d3p5",
1828c2ecf20Sopenharmony_ci	"syspll_d3",
1838c2ecf20Sopenharmony_ci	"univpll2_d2",
1848c2ecf20Sopenharmony_ci	"univpll_d5",
1858c2ecf20Sopenharmony_ci	"univpll1_d2",
1868c2ecf20Sopenharmony_ci	"lvdspll",
1878c2ecf20Sopenharmony_ci	"vdecpll"
1888c2ecf20Sopenharmony_ci};
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_cistatic const char * const msdc30_parents[] __initconst = {
1918c2ecf20Sopenharmony_ci	"clk26m",
1928c2ecf20Sopenharmony_ci	"syspll_d6",
1938c2ecf20Sopenharmony_ci	"syspll_d5",
1948c2ecf20Sopenharmony_ci	"univpll1_d4",
1958c2ecf20Sopenharmony_ci	"univpll2_d4",
1968c2ecf20Sopenharmony_ci	"msdcpll"
1978c2ecf20Sopenharmony_ci};
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_cistatic const char * const usb20_parents[] __initconst = {
2008c2ecf20Sopenharmony_ci	"clk26m",
2018c2ecf20Sopenharmony_ci	"univpll2_d6",
2028c2ecf20Sopenharmony_ci	"univpll1_d10"
2038c2ecf20Sopenharmony_ci};
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_cistatic const char * const venc_parents[] __initconst = {
2068c2ecf20Sopenharmony_ci	"clk26m",
2078c2ecf20Sopenharmony_ci	"syspll_d3",
2088c2ecf20Sopenharmony_ci	"syspll_d8",
2098c2ecf20Sopenharmony_ci	"univpll_d5",
2108c2ecf20Sopenharmony_ci	"univpll1_d6",
2118c2ecf20Sopenharmony_ci	"mmpll_d4",
2128c2ecf20Sopenharmony_ci	"mmpll_d5",
2138c2ecf20Sopenharmony_ci	"mmpll_d6"
2148c2ecf20Sopenharmony_ci};
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_cistatic const char * const spi_parents[] __initconst = {
2178c2ecf20Sopenharmony_ci	"clk26m",
2188c2ecf20Sopenharmony_ci	"syspll_d6",
2198c2ecf20Sopenharmony_ci	"syspll_d8",
2208c2ecf20Sopenharmony_ci	"syspll_d10",
2218c2ecf20Sopenharmony_ci	"univpll1_d6",
2228c2ecf20Sopenharmony_ci	"univpll1_d8"
2238c2ecf20Sopenharmony_ci};
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_cistatic const char * const uart_parents[] __initconst = {
2268c2ecf20Sopenharmony_ci	"clk26m",
2278c2ecf20Sopenharmony_ci	"univpll2_d8"
2288c2ecf20Sopenharmony_ci};
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_cistatic const char * const mem_parents[] __initconst = {
2318c2ecf20Sopenharmony_ci	"clk26m",
2328c2ecf20Sopenharmony_ci	"clkph_mck"
2338c2ecf20Sopenharmony_ci};
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_cistatic const char * const camtg_parents[] __initconst = {
2368c2ecf20Sopenharmony_ci	"clk26m",
2378c2ecf20Sopenharmony_ci	"univpll_d26",
2388c2ecf20Sopenharmony_ci	"univpll1_d6",
2398c2ecf20Sopenharmony_ci	"syspll_d16",
2408c2ecf20Sopenharmony_ci	"syspll_d8"
2418c2ecf20Sopenharmony_ci};
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_cistatic const char * const audio_parents[] __initconst = {
2448c2ecf20Sopenharmony_ci	"clk26m",
2458c2ecf20Sopenharmony_ci	"syspll_d24"
2468c2ecf20Sopenharmony_ci};
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_cistatic const char * const fix_parents[] __initconst = {
2498c2ecf20Sopenharmony_ci	"rtc32k",
2508c2ecf20Sopenharmony_ci	"clk26m",
2518c2ecf20Sopenharmony_ci	"univpll_d5",
2528c2ecf20Sopenharmony_ci	"univpll_d7",
2538c2ecf20Sopenharmony_ci	"univpll1_d2",
2548c2ecf20Sopenharmony_ci	"univpll1_d4",
2558c2ecf20Sopenharmony_ci	"univpll1_d6",
2568c2ecf20Sopenharmony_ci	"univpll1_d8"
2578c2ecf20Sopenharmony_ci};
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_cistatic const char * const vdec_parents[] __initconst = {
2608c2ecf20Sopenharmony_ci	"clk26m",
2618c2ecf20Sopenharmony_ci	"vdecpll",
2628c2ecf20Sopenharmony_ci	"clkph_mck",
2638c2ecf20Sopenharmony_ci	"syspll_d2p5",
2648c2ecf20Sopenharmony_ci	"syspll_d3",
2658c2ecf20Sopenharmony_ci	"syspll_d3p5",
2668c2ecf20Sopenharmony_ci	"syspll_d4",
2678c2ecf20Sopenharmony_ci	"syspll_d5",
2688c2ecf20Sopenharmony_ci	"syspll_d6",
2698c2ecf20Sopenharmony_ci	"syspll_d8",
2708c2ecf20Sopenharmony_ci	"univpll1_d2",
2718c2ecf20Sopenharmony_ci	"univpll2_d2",
2728c2ecf20Sopenharmony_ci	"univpll_d7",
2738c2ecf20Sopenharmony_ci	"univpll_d10",
2748c2ecf20Sopenharmony_ci	"univpll2_d4",
2758c2ecf20Sopenharmony_ci	"lvdspll"
2768c2ecf20Sopenharmony_ci};
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_cistatic const char * const ddrphycfg_parents[] __initconst = {
2798c2ecf20Sopenharmony_ci	"clk26m",
2808c2ecf20Sopenharmony_ci	"axi_sel",
2818c2ecf20Sopenharmony_ci	"syspll_d12"
2828c2ecf20Sopenharmony_ci};
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_cistatic const char * const dpilvds_parents[] __initconst = {
2858c2ecf20Sopenharmony_ci	"clk26m",
2868c2ecf20Sopenharmony_ci	"lvdspll",
2878c2ecf20Sopenharmony_ci	"lvdspll_d2",
2888c2ecf20Sopenharmony_ci	"lvdspll_d4",
2898c2ecf20Sopenharmony_ci	"lvdspll_d8"
2908c2ecf20Sopenharmony_ci};
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_cistatic const char * const pmicspi_parents[] __initconst = {
2938c2ecf20Sopenharmony_ci	"clk26m",
2948c2ecf20Sopenharmony_ci	"univpll2_d6",
2958c2ecf20Sopenharmony_ci	"syspll_d8",
2968c2ecf20Sopenharmony_ci	"syspll_d10",
2978c2ecf20Sopenharmony_ci	"univpll1_d10",
2988c2ecf20Sopenharmony_ci	"mempll_mck_d4",
2998c2ecf20Sopenharmony_ci	"univpll_d26",
3008c2ecf20Sopenharmony_ci	"syspll_d24"
3018c2ecf20Sopenharmony_ci};
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_cistatic const char * const smi_mfg_as_parents[] __initconst = {
3048c2ecf20Sopenharmony_ci	"clk26m",
3058c2ecf20Sopenharmony_ci	"smi_sel",
3068c2ecf20Sopenharmony_ci	"mfg_sel",
3078c2ecf20Sopenharmony_ci	"mem_sel"
3088c2ecf20Sopenharmony_ci};
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_cistatic const char * const gcpu_parents[] __initconst = {
3118c2ecf20Sopenharmony_ci	"clk26m",
3128c2ecf20Sopenharmony_ci	"syspll_d4",
3138c2ecf20Sopenharmony_ci	"univpll_d7",
3148c2ecf20Sopenharmony_ci	"syspll_d5",
3158c2ecf20Sopenharmony_ci	"syspll_d6"
3168c2ecf20Sopenharmony_ci};
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_cistatic const char * const dpi1_parents[] __initconst = {
3198c2ecf20Sopenharmony_ci	"clk26m",
3208c2ecf20Sopenharmony_ci	"tvhdmi_h_ck",
3218c2ecf20Sopenharmony_ci	"tvhdmi_d2",
3228c2ecf20Sopenharmony_ci	"tvhdmi_d4"
3238c2ecf20Sopenharmony_ci};
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_cistatic const char * const cci_parents[] __initconst = {
3268c2ecf20Sopenharmony_ci	"clk26m",
3278c2ecf20Sopenharmony_ci	"mainpll_537p3m",
3288c2ecf20Sopenharmony_ci	"univpll_d3",
3298c2ecf20Sopenharmony_ci	"syspll_d2p5",
3308c2ecf20Sopenharmony_ci	"syspll_d3",
3318c2ecf20Sopenharmony_ci	"syspll_d5"
3328c2ecf20Sopenharmony_ci};
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_cistatic const char * const apll_parents[] __initconst = {
3358c2ecf20Sopenharmony_ci	"clk26m",
3368c2ecf20Sopenharmony_ci	"apll_ck",
3378c2ecf20Sopenharmony_ci	"apll_d4",
3388c2ecf20Sopenharmony_ci	"apll_d8",
3398c2ecf20Sopenharmony_ci	"apll_d16",
3408c2ecf20Sopenharmony_ci	"apll_d24"
3418c2ecf20Sopenharmony_ci};
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_cistatic const char * const hdmipll_parents[] __initconst = {
3448c2ecf20Sopenharmony_ci	"clk26m",
3458c2ecf20Sopenharmony_ci	"hdmitx_clkdig_cts",
3468c2ecf20Sopenharmony_ci	"hdmitx_clkdig_d2",
3478c2ecf20Sopenharmony_ci	"hdmitx_clkdig_d3"
3488c2ecf20Sopenharmony_ci};
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_cistatic const struct mtk_composite top_muxes[] __initconst = {
3518c2ecf20Sopenharmony_ci	/* CLK_CFG_0 */
3528c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_AXI_SEL, "axi_sel", axi_parents,
3538c2ecf20Sopenharmony_ci		0x0140, 0, 3, INVALID_MUX_GATE_BIT),
3548c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_SMI_SEL, "smi_sel", smi_parents, 0x0140, 8, 4, 15),
3558c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_MFG_SEL, "mfg_sel", mfg_parents, 0x0140, 16, 4, 23),
3568c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_IRDA_SEL, "irda_sel", irda_parents, 0x0140, 24, 2, 31),
3578c2ecf20Sopenharmony_ci	/* CLK_CFG_1 */
3588c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_CAM_SEL, "cam_sel", cam_parents, 0x0144, 0, 3, 7),
3598c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_AUD_INTBUS_SEL, "aud_intbus_sel", aud_intbus_parents,
3608c2ecf20Sopenharmony_ci		0x0144, 8, 2, 15),
3618c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_JPG_SEL, "jpg_sel", jpg_parents, 0x0144, 16, 3, 23),
3628c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_DISP_SEL, "disp_sel", disp_parents, 0x0144, 24, 3, 31),
3638c2ecf20Sopenharmony_ci	/* CLK_CFG_2 */
3648c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_MSDC30_1_SEL, "msdc30_1_sel", msdc30_parents, 0x0148, 0, 3, 7),
3658c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_MSDC30_2_SEL, "msdc30_2_sel", msdc30_parents, 0x0148, 8, 3, 15),
3668c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_MSDC30_3_SEL, "msdc30_3_sel", msdc30_parents, 0x0148, 16, 3, 23),
3678c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_MSDC30_4_SEL, "msdc30_4_sel", msdc30_parents, 0x0148, 24, 3, 31),
3688c2ecf20Sopenharmony_ci	/* CLK_CFG_3 */
3698c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_USB20_SEL, "usb20_sel", usb20_parents, 0x014c, 0, 2, 7),
3708c2ecf20Sopenharmony_ci	/* CLK_CFG_4 */
3718c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_VENC_SEL, "venc_sel", venc_parents, 0x0150, 8, 3, 15),
3728c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_SPI_SEL, "spi_sel", spi_parents, 0x0150, 16, 3, 23),
3738c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_UART_SEL, "uart_sel", uart_parents, 0x0150, 24, 2, 31),
3748c2ecf20Sopenharmony_ci	/* CLK_CFG_6 */
3758c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_MEM_SEL, "mem_sel", mem_parents, 0x0158, 0, 2, 7),
3768c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_CAMTG_SEL, "camtg_sel", camtg_parents, 0x0158, 8, 3, 15),
3778c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_AUDIO_SEL, "audio_sel", audio_parents, 0x0158, 24, 2, 31),
3788c2ecf20Sopenharmony_ci	/* CLK_CFG_7 */
3798c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_FIX_SEL, "fix_sel", fix_parents, 0x015c, 0, 3, 7),
3808c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_VDEC_SEL, "vdec_sel", vdec_parents, 0x015c, 8, 4, 15),
3818c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_DDRPHYCFG_SEL, "ddrphycfg_sel", ddrphycfg_parents,
3828c2ecf20Sopenharmony_ci		0x015c, 16, 2, 23),
3838c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_DPILVDS_SEL, "dpilvds_sel", dpilvds_parents, 0x015c, 24, 3, 31),
3848c2ecf20Sopenharmony_ci	/* CLK_CFG_8 */
3858c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_PMICSPI_SEL, "pmicspi_sel", pmicspi_parents, 0x0164, 0, 3, 7),
3868c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_MSDC30_0_SEL, "msdc30_0_sel", msdc30_parents, 0x0164, 8, 3, 15),
3878c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_SMI_MFG_AS_SEL, "smi_mfg_as_sel", smi_mfg_as_parents,
3888c2ecf20Sopenharmony_ci		0x0164, 16, 2, 23),
3898c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_GCPU_SEL, "gcpu_sel", gcpu_parents, 0x0164, 24, 3, 31),
3908c2ecf20Sopenharmony_ci	/* CLK_CFG_9 */
3918c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_DPI1_SEL, "dpi1_sel", dpi1_parents, 0x0168, 0, 2, 7),
3928c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_CCI_SEL, "cci_sel", cci_parents, 0x0168, 8, 3, 15),
3938c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_APLL_SEL, "apll_sel", apll_parents, 0x0168, 16, 3, 23),
3948c2ecf20Sopenharmony_ci	MUX_GATE(CLK_TOP_HDMIPLL_SEL, "hdmipll_sel", hdmipll_parents, 0x0168, 24, 2, 31),
3958c2ecf20Sopenharmony_ci};
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs infra_cg_regs = {
3988c2ecf20Sopenharmony_ci	.set_ofs = 0x0040,
3998c2ecf20Sopenharmony_ci	.clr_ofs = 0x0044,
4008c2ecf20Sopenharmony_ci	.sta_ofs = 0x0048,
4018c2ecf20Sopenharmony_ci};
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_ci#define GATE_ICG(_id, _name, _parent, _shift) {	\
4048c2ecf20Sopenharmony_ci		.id = _id,					\
4058c2ecf20Sopenharmony_ci		.name = _name,					\
4068c2ecf20Sopenharmony_ci		.parent_name = _parent,				\
4078c2ecf20Sopenharmony_ci		.regs = &infra_cg_regs,				\
4088c2ecf20Sopenharmony_ci		.shift = _shift,				\
4098c2ecf20Sopenharmony_ci		.ops = &mtk_clk_gate_ops_setclr,		\
4108c2ecf20Sopenharmony_ci	}
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_cistatic const struct mtk_gate infra_clks[] __initconst = {
4138c2ecf20Sopenharmony_ci	GATE_ICG(CLK_INFRA_PMIC_WRAP, "pmic_wrap_ck", "axi_sel", 23),
4148c2ecf20Sopenharmony_ci	GATE_ICG(CLK_INFRA_PMICSPI, "pmicspi_ck", "pmicspi_sel", 22),
4158c2ecf20Sopenharmony_ci	GATE_ICG(CLK_INFRA_CCIF1_AP_CTRL, "ccif1_ap_ctrl", "axi_sel", 21),
4168c2ecf20Sopenharmony_ci	GATE_ICG(CLK_INFRA_CCIF0_AP_CTRL, "ccif0_ap_ctrl", "axi_sel", 20),
4178c2ecf20Sopenharmony_ci	GATE_ICG(CLK_INFRA_KP, "kp_ck", "axi_sel", 16),
4188c2ecf20Sopenharmony_ci	GATE_ICG(CLK_INFRA_CPUM, "cpum_ck", "cpum_tck_in", 15),
4198c2ecf20Sopenharmony_ci	GATE_ICG(CLK_INFRA_M4U, "m4u_ck", "mem_sel", 8),
4208c2ecf20Sopenharmony_ci	GATE_ICG(CLK_INFRA_MFGAXI, "mfgaxi_ck", "axi_sel", 7),
4218c2ecf20Sopenharmony_ci	GATE_ICG(CLK_INFRA_DEVAPC, "devapc_ck", "axi_sel", 6),
4228c2ecf20Sopenharmony_ci	GATE_ICG(CLK_INFRA_AUDIO, "audio_ck", "aud_intbus_sel", 5),
4238c2ecf20Sopenharmony_ci	GATE_ICG(CLK_INFRA_MFG_BUS, "mfg_bus_ck", "axi_sel", 2),
4248c2ecf20Sopenharmony_ci	GATE_ICG(CLK_INFRA_SMI, "smi_ck", "smi_sel", 1),
4258c2ecf20Sopenharmony_ci	GATE_ICG(CLK_INFRA_DBGCLK, "dbgclk_ck", "axi_sel", 0),
4268c2ecf20Sopenharmony_ci};
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs peri0_cg_regs = {
4298c2ecf20Sopenharmony_ci	.set_ofs = 0x0008,
4308c2ecf20Sopenharmony_ci	.clr_ofs = 0x0010,
4318c2ecf20Sopenharmony_ci	.sta_ofs = 0x0018,
4328c2ecf20Sopenharmony_ci};
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs peri1_cg_regs = {
4358c2ecf20Sopenharmony_ci	.set_ofs = 0x000c,
4368c2ecf20Sopenharmony_ci	.clr_ofs = 0x0014,
4378c2ecf20Sopenharmony_ci	.sta_ofs = 0x001c,
4388c2ecf20Sopenharmony_ci};
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci#define GATE_PERI0(_id, _name, _parent, _shift) {	\
4418c2ecf20Sopenharmony_ci		.id = _id,					\
4428c2ecf20Sopenharmony_ci		.name = _name,					\
4438c2ecf20Sopenharmony_ci		.parent_name = _parent,				\
4448c2ecf20Sopenharmony_ci		.regs = &peri0_cg_regs,				\
4458c2ecf20Sopenharmony_ci		.shift = _shift,				\
4468c2ecf20Sopenharmony_ci		.ops = &mtk_clk_gate_ops_setclr,		\
4478c2ecf20Sopenharmony_ci	}
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci#define GATE_PERI1(_id, _name, _parent, _shift) {	\
4508c2ecf20Sopenharmony_ci		.id = _id,					\
4518c2ecf20Sopenharmony_ci		.name = _name,					\
4528c2ecf20Sopenharmony_ci		.parent_name = _parent,				\
4538c2ecf20Sopenharmony_ci		.regs = &peri1_cg_regs,				\
4548c2ecf20Sopenharmony_ci		.shift = _shift,				\
4558c2ecf20Sopenharmony_ci		.ops = &mtk_clk_gate_ops_setclr,		\
4568c2ecf20Sopenharmony_ci	}
4578c2ecf20Sopenharmony_ci
4588c2ecf20Sopenharmony_cistatic const struct mtk_gate peri_gates[] __initconst = {
4598c2ecf20Sopenharmony_ci	/* PERI0 */
4608c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_I2C5, "i2c5_ck", "axi_sel", 31),
4618c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_I2C4, "i2c4_ck", "axi_sel", 30),
4628c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_I2C3, "i2c3_ck", "axi_sel", 29),
4638c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_I2C2, "i2c2_ck", "axi_sel", 28),
4648c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_I2C1, "i2c1_ck", "axi_sel", 27),
4658c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_I2C0, "i2c0_ck", "axi_sel", 26),
4668c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_UART3, "uart3_ck", "axi_sel", 25),
4678c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_UART2, "uart2_ck", "axi_sel", 24),
4688c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_UART1, "uart1_ck", "axi_sel", 23),
4698c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_UART0, "uart0_ck", "axi_sel", 22),
4708c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_IRDA, "irda_ck", "irda_sel", 21),
4718c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_NLI, "nli_ck", "axi_sel", 20),
4728c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_MD_HIF, "md_hif_ck", "axi_sel", 19),
4738c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_AP_HIF, "ap_hif_ck", "axi_sel", 18),
4748c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_MSDC30_3, "msdc30_3_ck", "msdc30_4_sel", 17),
4758c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_MSDC30_2, "msdc30_2_ck", "msdc30_3_sel", 16),
4768c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_MSDC30_1, "msdc30_1_ck", "msdc30_2_sel", 15),
4778c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_MSDC20_2, "msdc20_2_ck", "msdc30_1_sel", 14),
4788c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_MSDC20_1, "msdc20_1_ck", "msdc30_0_sel", 13),
4798c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_AP_DMA, "ap_dma_ck", "axi_sel", 12),
4808c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_USB1, "usb1_ck", "usb20_sel", 11),
4818c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_USB0, "usb0_ck", "usb20_sel", 10),
4828c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_PWM, "pwm_ck", "axi_sel", 9),
4838c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_PWM7, "pwm7_ck", "axi_sel", 8),
4848c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_PWM6, "pwm6_ck", "axi_sel", 7),
4858c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_PWM5, "pwm5_ck", "axi_sel", 6),
4868c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_PWM4, "pwm4_ck", "axi_sel", 5),
4878c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_PWM3, "pwm3_ck", "axi_sel", 4),
4888c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_PWM2, "pwm2_ck", "axi_sel", 3),
4898c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_PWM1, "pwm1_ck", "axi_sel", 2),
4908c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_THERM, "therm_ck", "axi_sel", 1),
4918c2ecf20Sopenharmony_ci	GATE_PERI0(CLK_PERI_NFI, "nfi_ck", "axi_sel", 0),
4928c2ecf20Sopenharmony_ci	/* PERI1 */
4938c2ecf20Sopenharmony_ci	GATE_PERI1(CLK_PERI_USBSLV, "usbslv_ck", "axi_sel", 8),
4948c2ecf20Sopenharmony_ci	GATE_PERI1(CLK_PERI_USB1_MCU, "usb1_mcu_ck", "axi_sel", 7),
4958c2ecf20Sopenharmony_ci	GATE_PERI1(CLK_PERI_USB0_MCU, "usb0_mcu_ck", "axi_sel", 6),
4968c2ecf20Sopenharmony_ci	GATE_PERI1(CLK_PERI_GCPU, "gcpu_ck", "gcpu_sel", 5),
4978c2ecf20Sopenharmony_ci	GATE_PERI1(CLK_PERI_FHCTL, "fhctl_ck", "clk26m", 4),
4988c2ecf20Sopenharmony_ci	GATE_PERI1(CLK_PERI_SPI1, "spi1_ck", "spi_sel", 3),
4998c2ecf20Sopenharmony_ci	GATE_PERI1(CLK_PERI_AUXADC, "auxadc_ck", "clk26m", 2),
5008c2ecf20Sopenharmony_ci	GATE_PERI1(CLK_PERI_PERI_PWRAP, "peri_pwrap_ck", "axi_sel", 1),
5018c2ecf20Sopenharmony_ci	GATE_PERI1(CLK_PERI_I2C6, "i2c6_ck", "axi_sel", 0),
5028c2ecf20Sopenharmony_ci};
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_cistatic const char * const uart_ck_sel_parents[] __initconst = {
5058c2ecf20Sopenharmony_ci	"clk26m",
5068c2ecf20Sopenharmony_ci	"uart_sel",
5078c2ecf20Sopenharmony_ci};
5088c2ecf20Sopenharmony_ci
5098c2ecf20Sopenharmony_cistatic const struct mtk_composite peri_clks[] __initconst = {
5108c2ecf20Sopenharmony_ci	MUX(CLK_PERI_UART0_SEL, "uart0_ck_sel", uart_ck_sel_parents, 0x40c, 0, 1),
5118c2ecf20Sopenharmony_ci	MUX(CLK_PERI_UART1_SEL, "uart1_ck_sel", uart_ck_sel_parents, 0x40c, 1, 1),
5128c2ecf20Sopenharmony_ci	MUX(CLK_PERI_UART2_SEL, "uart2_ck_sel", uart_ck_sel_parents, 0x40c, 2, 1),
5138c2ecf20Sopenharmony_ci	MUX(CLK_PERI_UART3_SEL, "uart3_ck_sel", uart_ck_sel_parents, 0x40c, 3, 1),
5148c2ecf20Sopenharmony_ci};
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_cistatic void __init mtk_topckgen_init(struct device_node *node)
5178c2ecf20Sopenharmony_ci{
5188c2ecf20Sopenharmony_ci	struct clk_onecell_data *clk_data;
5198c2ecf20Sopenharmony_ci	void __iomem *base;
5208c2ecf20Sopenharmony_ci	int r;
5218c2ecf20Sopenharmony_ci
5228c2ecf20Sopenharmony_ci	base = of_iomap(node, 0);
5238c2ecf20Sopenharmony_ci	if (!base) {
5248c2ecf20Sopenharmony_ci		pr_err("%s(): ioremap failed\n", __func__);
5258c2ecf20Sopenharmony_ci		return;
5268c2ecf20Sopenharmony_ci	}
5278c2ecf20Sopenharmony_ci
5288c2ecf20Sopenharmony_ci	clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_ci	mtk_clk_register_factors(root_clk_alias, ARRAY_SIZE(root_clk_alias), clk_data);
5318c2ecf20Sopenharmony_ci	mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
5328c2ecf20Sopenharmony_ci	mtk_clk_register_composites(top_muxes, ARRAY_SIZE(top_muxes), base,
5338c2ecf20Sopenharmony_ci			&mt8135_clk_lock, clk_data);
5348c2ecf20Sopenharmony_ci
5358c2ecf20Sopenharmony_ci	clk_prepare_enable(clk_data->clks[CLK_TOP_CCI_SEL]);
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_ci	r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
5388c2ecf20Sopenharmony_ci	if (r)
5398c2ecf20Sopenharmony_ci		pr_err("%s(): could not register clock provider: %d\n",
5408c2ecf20Sopenharmony_ci			__func__, r);
5418c2ecf20Sopenharmony_ci}
5428c2ecf20Sopenharmony_ciCLK_OF_DECLARE(mtk_topckgen, "mediatek,mt8135-topckgen", mtk_topckgen_init);
5438c2ecf20Sopenharmony_ci
5448c2ecf20Sopenharmony_cistatic void __init mtk_infrasys_init(struct device_node *node)
5458c2ecf20Sopenharmony_ci{
5468c2ecf20Sopenharmony_ci	struct clk_onecell_data *clk_data;
5478c2ecf20Sopenharmony_ci	int r;
5488c2ecf20Sopenharmony_ci
5498c2ecf20Sopenharmony_ci	clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
5508c2ecf20Sopenharmony_ci
5518c2ecf20Sopenharmony_ci	mtk_clk_register_gates(node, infra_clks, ARRAY_SIZE(infra_clks),
5528c2ecf20Sopenharmony_ci						clk_data);
5538c2ecf20Sopenharmony_ci
5548c2ecf20Sopenharmony_ci	clk_prepare_enable(clk_data->clks[CLK_INFRA_M4U]);
5558c2ecf20Sopenharmony_ci
5568c2ecf20Sopenharmony_ci	r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
5578c2ecf20Sopenharmony_ci	if (r)
5588c2ecf20Sopenharmony_ci		pr_err("%s(): could not register clock provider: %d\n",
5598c2ecf20Sopenharmony_ci			__func__, r);
5608c2ecf20Sopenharmony_ci
5618c2ecf20Sopenharmony_ci	mtk_register_reset_controller(node, 2, 0x30);
5628c2ecf20Sopenharmony_ci}
5638c2ecf20Sopenharmony_ciCLK_OF_DECLARE(mtk_infrasys, "mediatek,mt8135-infracfg", mtk_infrasys_init);
5648c2ecf20Sopenharmony_ci
5658c2ecf20Sopenharmony_cistatic void __init mtk_pericfg_init(struct device_node *node)
5668c2ecf20Sopenharmony_ci{
5678c2ecf20Sopenharmony_ci	struct clk_onecell_data *clk_data;
5688c2ecf20Sopenharmony_ci	int r;
5698c2ecf20Sopenharmony_ci	void __iomem *base;
5708c2ecf20Sopenharmony_ci
5718c2ecf20Sopenharmony_ci	base = of_iomap(node, 0);
5728c2ecf20Sopenharmony_ci	if (!base) {
5738c2ecf20Sopenharmony_ci		pr_err("%s(): ioremap failed\n", __func__);
5748c2ecf20Sopenharmony_ci		return;
5758c2ecf20Sopenharmony_ci	}
5768c2ecf20Sopenharmony_ci
5778c2ecf20Sopenharmony_ci	clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK);
5788c2ecf20Sopenharmony_ci
5798c2ecf20Sopenharmony_ci	mtk_clk_register_gates(node, peri_gates, ARRAY_SIZE(peri_gates),
5808c2ecf20Sopenharmony_ci						clk_data);
5818c2ecf20Sopenharmony_ci	mtk_clk_register_composites(peri_clks, ARRAY_SIZE(peri_clks), base,
5828c2ecf20Sopenharmony_ci			&mt8135_clk_lock, clk_data);
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_ci	r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
5858c2ecf20Sopenharmony_ci	if (r)
5868c2ecf20Sopenharmony_ci		pr_err("%s(): could not register clock provider: %d\n",
5878c2ecf20Sopenharmony_ci			__func__, r);
5888c2ecf20Sopenharmony_ci
5898c2ecf20Sopenharmony_ci	mtk_register_reset_controller(node, 2, 0);
5908c2ecf20Sopenharmony_ci}
5918c2ecf20Sopenharmony_ciCLK_OF_DECLARE(mtk_pericfg, "mediatek,mt8135-pericfg", mtk_pericfg_init);
5928c2ecf20Sopenharmony_ci
5938c2ecf20Sopenharmony_ci#define MT8135_PLL_FMAX		(2000 * MHZ)
5948c2ecf20Sopenharmony_ci#define CON0_MT8135_RST_BAR	BIT(27)
5958c2ecf20Sopenharmony_ci
5968c2ecf20Sopenharmony_ci#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift) { \
5978c2ecf20Sopenharmony_ci		.id = _id,						\
5988c2ecf20Sopenharmony_ci		.name = _name,						\
5998c2ecf20Sopenharmony_ci		.reg = _reg,						\
6008c2ecf20Sopenharmony_ci		.pwr_reg = _pwr_reg,					\
6018c2ecf20Sopenharmony_ci		.en_mask = _en_mask,					\
6028c2ecf20Sopenharmony_ci		.flags = _flags,					\
6038c2ecf20Sopenharmony_ci		.rst_bar_mask = CON0_MT8135_RST_BAR,			\
6048c2ecf20Sopenharmony_ci		.fmax = MT8135_PLL_FMAX,				\
6058c2ecf20Sopenharmony_ci		.pcwbits = _pcwbits,					\
6068c2ecf20Sopenharmony_ci		.pd_reg = _pd_reg,					\
6078c2ecf20Sopenharmony_ci		.pd_shift = _pd_shift,					\
6088c2ecf20Sopenharmony_ci		.tuner_reg = _tuner_reg,				\
6098c2ecf20Sopenharmony_ci		.pcw_reg = _pcw_reg,					\
6108c2ecf20Sopenharmony_ci		.pcw_shift = _pcw_shift,				\
6118c2ecf20Sopenharmony_ci	}
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_cistatic const struct mtk_pll_data plls[] = {
6148c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_ARMPLL1, "armpll1", 0x200, 0x218, 0x80000001, 0, 21, 0x204, 24, 0x0, 0x204, 0),
6158c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_ARMPLL2, "armpll2", 0x2cc, 0x2e4, 0x80000001, 0, 21, 0x2d0, 24, 0x0, 0x2d0, 0),
6168c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x21c, 0x234, 0xf0000001, HAVE_RST_BAR, 21, 0x21c, 6, 0x0, 0x220, 0),
6178c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x238, 0x250, 0xf3000001, HAVE_RST_BAR, 7, 0x238, 6, 0x0, 0x238, 9),
6188c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_MMPLL, "mmpll", 0x254, 0x26c, 0xf0000001, HAVE_RST_BAR, 21, 0x254, 6, 0x0, 0x258, 0),
6198c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x278, 0x290, 0x80000001, 0, 21, 0x278, 6, 0x0, 0x27c, 0),
6208c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x294, 0x2ac, 0x80000001, 0, 31, 0x294, 6, 0x0, 0x298, 0),
6218c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x2b0, 0x2c8,	0x80000001, 0, 21, 0x2b0, 6, 0x0, 0x2b4, 0),
6228c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_AUDPLL, "audpll", 0x2e8, 0x300, 0x80000001, 0, 31, 0x2e8, 6, 0x2f8, 0x2ec, 0),
6238c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x304, 0x31c,	0x80000001, 0, 21, 0x2b0, 6, 0x0, 0x308, 0),
6248c2ecf20Sopenharmony_ci};
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_cistatic void __init mtk_apmixedsys_init(struct device_node *node)
6278c2ecf20Sopenharmony_ci{
6288c2ecf20Sopenharmony_ci	struct clk_onecell_data *clk_data;
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ci	clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
6318c2ecf20Sopenharmony_ci	if (!clk_data)
6328c2ecf20Sopenharmony_ci		return;
6338c2ecf20Sopenharmony_ci
6348c2ecf20Sopenharmony_ci	mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
6358c2ecf20Sopenharmony_ci}
6368c2ecf20Sopenharmony_ciCLK_OF_DECLARE(mtk_apmixedsys, "mediatek,mt8135-apmixedsys",
6378c2ecf20Sopenharmony_ci		mtk_apmixedsys_init);
638