18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci//
38c2ecf20Sopenharmony_ci// Copyright (c) 2018 MediaTek Inc.
48c2ecf20Sopenharmony_ci// Author: Weiyi Lu <weiyi.lu@mediatek.com>
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <linux/delay.h>
78c2ecf20Sopenharmony_ci#include <linux/mfd/syscon.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#include <linux/slab.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include "clk-mtk.h"
158c2ecf20Sopenharmony_ci#include "clk-mux.h"
168c2ecf20Sopenharmony_ci#include "clk-gate.h"
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#include <dt-bindings/clock/mt8183-clk.h>
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/* Infra global controller reset set register */
218c2ecf20Sopenharmony_ci#define INFRA_RST0_SET_OFFSET		0x120
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(mt8183_clk_lock);
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_cistatic const struct mtk_fixed_clk top_fixed_clks[] = {
268c2ecf20Sopenharmony_ci	FIXED_CLK(CLK_TOP_CLK26M, "f_f26m_ck", "clk26m", 26000000),
278c2ecf20Sopenharmony_ci	FIXED_CLK(CLK_TOP_ULPOSC, "osc", NULL, 250000),
288c2ecf20Sopenharmony_ci	FIXED_CLK(CLK_TOP_UNIVP_192M, "univpll_192m", "univpll", 192000000),
298c2ecf20Sopenharmony_ci};
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistatic const struct mtk_fixed_factor top_early_divs[] = {
328c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_CLK13M, "clk13m", "clk26m", 1, 2),
338c2ecf20Sopenharmony_ci};
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistatic const struct mtk_fixed_factor top_divs[] = {
368c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_F26M_CK_D2, "csw_f26m_ck_d2", "clk26m", 1,
378c2ecf20Sopenharmony_ci		2),
388c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_CK, "syspll_ck", "mainpll", 1,
398c2ecf20Sopenharmony_ci		1),
408c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D2, "syspll_d2", "syspll_ck", 1,
418c2ecf20Sopenharmony_ci		2),
428c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D2_D2, "syspll_d2_d2", "syspll_d2", 1,
438c2ecf20Sopenharmony_ci		2),
448c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D2_D4, "syspll_d2_d4", "syspll_d2", 1,
458c2ecf20Sopenharmony_ci		4),
468c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D2_D8, "syspll_d2_d8", "syspll_d2", 1,
478c2ecf20Sopenharmony_ci		8),
488c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D2_D16, "syspll_d2_d16", "syspll_d2", 1,
498c2ecf20Sopenharmony_ci		16),
508c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D3, "syspll_d3", "mainpll", 1,
518c2ecf20Sopenharmony_ci		3),
528c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D3_D2, "syspll_d3_d2", "syspll_d3", 1,
538c2ecf20Sopenharmony_ci		2),
548c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D3_D4, "syspll_d3_d4", "syspll_d3", 1,
558c2ecf20Sopenharmony_ci		4),
568c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D3_D8, "syspll_d3_d8", "syspll_d3", 1,
578c2ecf20Sopenharmony_ci		8),
588c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D5, "syspll_d5", "mainpll", 1,
598c2ecf20Sopenharmony_ci		5),
608c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D5_D2, "syspll_d5_d2", "syspll_d5", 1,
618c2ecf20Sopenharmony_ci		2),
628c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D5_D4, "syspll_d5_d4", "syspll_d5", 1,
638c2ecf20Sopenharmony_ci		4),
648c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D7, "syspll_d7", "mainpll", 1,
658c2ecf20Sopenharmony_ci		7),
668c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D7_D2, "syspll_d7_d2", "syspll_d7", 1,
678c2ecf20Sopenharmony_ci		2),
688c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_SYSPLL_D7_D4, "syspll_d7_d4", "syspll_d7", 1,
698c2ecf20Sopenharmony_ci		4),
708c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_CK, "univpll_ck", "univpll", 1,
718c2ecf20Sopenharmony_ci		1),
728c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll_ck", 1,
738c2ecf20Sopenharmony_ci		2),
748c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D2_D2, "univpll_d2_d2", "univpll_d2", 1,
758c2ecf20Sopenharmony_ci		2),
768c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D2_D4, "univpll_d2_d4", "univpll_d2", 1,
778c2ecf20Sopenharmony_ci		4),
788c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D2_D8, "univpll_d2_d8", "univpll_d2", 1,
798c2ecf20Sopenharmony_ci		8),
808c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll", 1,
818c2ecf20Sopenharmony_ci		3),
828c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D3_D2, "univpll_d3_d2", "univpll_d3", 1,
838c2ecf20Sopenharmony_ci		2),
848c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D3_D4, "univpll_d3_d4", "univpll_d3", 1,
858c2ecf20Sopenharmony_ci		4),
868c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D3_D8, "univpll_d3_d8", "univpll_d3", 1,
878c2ecf20Sopenharmony_ci		8),
888c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll", 1,
898c2ecf20Sopenharmony_ci		5),
908c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D5_D2, "univpll_d5_d2", "univpll_d5", 1,
918c2ecf20Sopenharmony_ci		2),
928c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D5_D4, "univpll_d5_d4", "univpll_d5", 1,
938c2ecf20Sopenharmony_ci		4),
948c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D5_D8, "univpll_d5_d8", "univpll_d5", 1,
958c2ecf20Sopenharmony_ci		8),
968c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D7, "univpll_d7", "univpll", 1,
978c2ecf20Sopenharmony_ci		7),
988c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVP_192M_CK, "univ_192m_ck", "univpll_192m", 1,
998c2ecf20Sopenharmony_ci		1),
1008c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVP_192M_D2, "univ_192m_d2", "univ_192m_ck", 1,
1018c2ecf20Sopenharmony_ci		2),
1028c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVP_192M_D4, "univ_192m_d4", "univ_192m_ck", 1,
1038c2ecf20Sopenharmony_ci		4),
1048c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVP_192M_D8, "univ_192m_d8", "univ_192m_ck", 1,
1058c2ecf20Sopenharmony_ci		8),
1068c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVP_192M_D16, "univ_192m_d16", "univ_192m_ck", 1,
1078c2ecf20Sopenharmony_ci		16),
1088c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVP_192M_D32, "univ_192m_d32", "univ_192m_ck", 1,
1098c2ecf20Sopenharmony_ci		32),
1108c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_APLL1_CK, "apll1_ck", "apll1", 1,
1118c2ecf20Sopenharmony_ci		1),
1128c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_APLL1_D2, "apll1_d2", "apll1", 1,
1138c2ecf20Sopenharmony_ci		2),
1148c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_APLL1_D4, "apll1_d4", "apll1", 1,
1158c2ecf20Sopenharmony_ci		4),
1168c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_APLL1_D8, "apll1_d8", "apll1", 1,
1178c2ecf20Sopenharmony_ci		8),
1188c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_APLL2_CK, "apll2_ck", "apll2", 1,
1198c2ecf20Sopenharmony_ci		1),
1208c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_APLL2_D2, "apll2_d2", "apll2", 1,
1218c2ecf20Sopenharmony_ci		2),
1228c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "apll2", 1,
1238c2ecf20Sopenharmony_ci		4),
1248c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_APLL2_D8, "apll2_d8", "apll2", 1,
1258c2ecf20Sopenharmony_ci		8),
1268c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_TVDPLL_CK, "tvdpll_ck", "tvdpll", 1,
1278c2ecf20Sopenharmony_ci		1),
1288c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_TVDPLL_D2, "tvdpll_d2", "tvdpll_ck", 1,
1298c2ecf20Sopenharmony_ci		2),
1308c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_TVDPLL_D4, "tvdpll_d4", "tvdpll", 1,
1318c2ecf20Sopenharmony_ci		4),
1328c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_TVDPLL_D8, "tvdpll_d8", "tvdpll", 1,
1338c2ecf20Sopenharmony_ci		8),
1348c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_TVDPLL_D16, "tvdpll_d16", "tvdpll", 1,
1358c2ecf20Sopenharmony_ci		16),
1368c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_CK, "mmpll_ck", "mmpll", 1,
1378c2ecf20Sopenharmony_ci		1),
1388c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D4, "mmpll_d4", "mmpll", 1,
1398c2ecf20Sopenharmony_ci		4),
1408c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D4_D2, "mmpll_d4_d2", "mmpll_d4", 1,
1418c2ecf20Sopenharmony_ci		2),
1428c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D4_D4, "mmpll_d4_d4", "mmpll_d4", 1,
1438c2ecf20Sopenharmony_ci		4),
1448c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D5, "mmpll_d5", "mmpll", 1,
1458c2ecf20Sopenharmony_ci		5),
1468c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D5_D2, "mmpll_d5_d2", "mmpll_d5", 1,
1478c2ecf20Sopenharmony_ci		2),
1488c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D5_D4, "mmpll_d5_d4", "mmpll_d5", 1,
1498c2ecf20Sopenharmony_ci		4),
1508c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D6, "mmpll_d6", "mmpll", 1,
1518c2ecf20Sopenharmony_ci		6),
1528c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MMPLL_D7, "mmpll_d7", "mmpll", 1,
1538c2ecf20Sopenharmony_ci		7),
1548c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MFGPLL_CK, "mfgpll_ck", "mfgpll", 1,
1558c2ecf20Sopenharmony_ci		1),
1568c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MSDCPLL_CK, "msdcpll_ck", "msdcpll", 1,
1578c2ecf20Sopenharmony_ci		1),
1588c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll", 1,
1598c2ecf20Sopenharmony_ci		2),
1608c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MSDCPLL_D4, "msdcpll_d4", "msdcpll", 1,
1618c2ecf20Sopenharmony_ci		4),
1628c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MSDCPLL_D8, "msdcpll_d8", "msdcpll", 1,
1638c2ecf20Sopenharmony_ci		8),
1648c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_MSDCPLL_D16, "msdcpll_d16", "msdcpll", 1,
1658c2ecf20Sopenharmony_ci		16),
1668c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_AD_OSC_CK, "ad_osc_ck", "osc", 1,
1678c2ecf20Sopenharmony_ci		1),
1688c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_OSC_D2, "osc_d2", "osc", 1,
1698c2ecf20Sopenharmony_ci		2),
1708c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_OSC_D4, "osc_d4", "osc", 1,
1718c2ecf20Sopenharmony_ci		4),
1728c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_OSC_D8, "osc_d8", "osc", 1,
1738c2ecf20Sopenharmony_ci		8),
1748c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_OSC_D16, "osc_d16", "osc", 1,
1758c2ecf20Sopenharmony_ci		16),
1768c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL, "univpll", "univ2pll", 1,
1778c2ecf20Sopenharmony_ci		2),
1788c2ecf20Sopenharmony_ci	FACTOR(CLK_TOP_UNIVPLL_D3_D16, "univpll_d3_d16", "univpll_d3", 1,
1798c2ecf20Sopenharmony_ci		16),
1808c2ecf20Sopenharmony_ci};
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_cistatic const char * const axi_parents[] = {
1838c2ecf20Sopenharmony_ci	"clk26m",
1848c2ecf20Sopenharmony_ci	"syspll_d2_d4",
1858c2ecf20Sopenharmony_ci	"syspll_d7",
1868c2ecf20Sopenharmony_ci	"osc_d4"
1878c2ecf20Sopenharmony_ci};
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_cistatic const char * const mm_parents[] = {
1908c2ecf20Sopenharmony_ci	"clk26m",
1918c2ecf20Sopenharmony_ci	"mmpll_d7",
1928c2ecf20Sopenharmony_ci	"syspll_d3",
1938c2ecf20Sopenharmony_ci	"univpll_d2_d2",
1948c2ecf20Sopenharmony_ci	"syspll_d2_d2",
1958c2ecf20Sopenharmony_ci	"syspll_d3_d2"
1968c2ecf20Sopenharmony_ci};
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_cistatic const char * const img_parents[] = {
1998c2ecf20Sopenharmony_ci	"clk26m",
2008c2ecf20Sopenharmony_ci	"mmpll_d6",
2018c2ecf20Sopenharmony_ci	"univpll_d3",
2028c2ecf20Sopenharmony_ci	"syspll_d3",
2038c2ecf20Sopenharmony_ci	"univpll_d2_d2",
2048c2ecf20Sopenharmony_ci	"syspll_d2_d2",
2058c2ecf20Sopenharmony_ci	"univpll_d3_d2",
2068c2ecf20Sopenharmony_ci	"syspll_d3_d2"
2078c2ecf20Sopenharmony_ci};
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_cistatic const char * const cam_parents[] = {
2108c2ecf20Sopenharmony_ci	"clk26m",
2118c2ecf20Sopenharmony_ci	"syspll_d2",
2128c2ecf20Sopenharmony_ci	"mmpll_d6",
2138c2ecf20Sopenharmony_ci	"syspll_d3",
2148c2ecf20Sopenharmony_ci	"mmpll_d7",
2158c2ecf20Sopenharmony_ci	"univpll_d3",
2168c2ecf20Sopenharmony_ci	"univpll_d2_d2",
2178c2ecf20Sopenharmony_ci	"syspll_d2_d2",
2188c2ecf20Sopenharmony_ci	"syspll_d3_d2",
2198c2ecf20Sopenharmony_ci	"univpll_d3_d2"
2208c2ecf20Sopenharmony_ci};
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_cistatic const char * const dsp_parents[] = {
2238c2ecf20Sopenharmony_ci	"clk26m",
2248c2ecf20Sopenharmony_ci	"mmpll_d6",
2258c2ecf20Sopenharmony_ci	"mmpll_d7",
2268c2ecf20Sopenharmony_ci	"univpll_d3",
2278c2ecf20Sopenharmony_ci	"syspll_d3",
2288c2ecf20Sopenharmony_ci	"univpll_d2_d2",
2298c2ecf20Sopenharmony_ci	"syspll_d2_d2",
2308c2ecf20Sopenharmony_ci	"univpll_d3_d2",
2318c2ecf20Sopenharmony_ci	"syspll_d3_d2"
2328c2ecf20Sopenharmony_ci};
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_cistatic const char * const dsp1_parents[] = {
2358c2ecf20Sopenharmony_ci	"clk26m",
2368c2ecf20Sopenharmony_ci	"mmpll_d6",
2378c2ecf20Sopenharmony_ci	"mmpll_d7",
2388c2ecf20Sopenharmony_ci	"univpll_d3",
2398c2ecf20Sopenharmony_ci	"syspll_d3",
2408c2ecf20Sopenharmony_ci	"univpll_d2_d2",
2418c2ecf20Sopenharmony_ci	"syspll_d2_d2",
2428c2ecf20Sopenharmony_ci	"univpll_d3_d2",
2438c2ecf20Sopenharmony_ci	"syspll_d3_d2"
2448c2ecf20Sopenharmony_ci};
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_cistatic const char * const dsp2_parents[] = {
2478c2ecf20Sopenharmony_ci	"clk26m",
2488c2ecf20Sopenharmony_ci	"mmpll_d6",
2498c2ecf20Sopenharmony_ci	"mmpll_d7",
2508c2ecf20Sopenharmony_ci	"univpll_d3",
2518c2ecf20Sopenharmony_ci	"syspll_d3",
2528c2ecf20Sopenharmony_ci	"univpll_d2_d2",
2538c2ecf20Sopenharmony_ci	"syspll_d2_d2",
2548c2ecf20Sopenharmony_ci	"univpll_d3_d2",
2558c2ecf20Sopenharmony_ci	"syspll_d3_d2"
2568c2ecf20Sopenharmony_ci};
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_cistatic const char * const ipu_if_parents[] = {
2598c2ecf20Sopenharmony_ci	"clk26m",
2608c2ecf20Sopenharmony_ci	"mmpll_d6",
2618c2ecf20Sopenharmony_ci	"mmpll_d7",
2628c2ecf20Sopenharmony_ci	"univpll_d3",
2638c2ecf20Sopenharmony_ci	"syspll_d3",
2648c2ecf20Sopenharmony_ci	"univpll_d2_d2",
2658c2ecf20Sopenharmony_ci	"syspll_d2_d2",
2668c2ecf20Sopenharmony_ci	"univpll_d3_d2",
2678c2ecf20Sopenharmony_ci	"syspll_d3_d2"
2688c2ecf20Sopenharmony_ci};
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_cistatic const char * const mfg_parents[] = {
2718c2ecf20Sopenharmony_ci	"clk26m",
2728c2ecf20Sopenharmony_ci	"mfgpll_ck",
2738c2ecf20Sopenharmony_ci	"univpll_d3",
2748c2ecf20Sopenharmony_ci	"syspll_d3"
2758c2ecf20Sopenharmony_ci};
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_cistatic const char * const f52m_mfg_parents[] = {
2788c2ecf20Sopenharmony_ci	"clk26m",
2798c2ecf20Sopenharmony_ci	"univpll_d3_d2",
2808c2ecf20Sopenharmony_ci	"univpll_d3_d4",
2818c2ecf20Sopenharmony_ci	"univpll_d3_d8"
2828c2ecf20Sopenharmony_ci};
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_cistatic const char * const camtg_parents[] = {
2858c2ecf20Sopenharmony_ci	"clk26m",
2868c2ecf20Sopenharmony_ci	"univ_192m_d8",
2878c2ecf20Sopenharmony_ci	"univpll_d3_d8",
2888c2ecf20Sopenharmony_ci	"univ_192m_d4",
2898c2ecf20Sopenharmony_ci	"univpll_d3_d16",
2908c2ecf20Sopenharmony_ci	"csw_f26m_ck_d2",
2918c2ecf20Sopenharmony_ci	"univ_192m_d16",
2928c2ecf20Sopenharmony_ci	"univ_192m_d32"
2938c2ecf20Sopenharmony_ci};
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_cistatic const char * const camtg2_parents[] = {
2968c2ecf20Sopenharmony_ci	"clk26m",
2978c2ecf20Sopenharmony_ci	"univ_192m_d8",
2988c2ecf20Sopenharmony_ci	"univpll_d3_d8",
2998c2ecf20Sopenharmony_ci	"univ_192m_d4",
3008c2ecf20Sopenharmony_ci	"univpll_d3_d16",
3018c2ecf20Sopenharmony_ci	"csw_f26m_ck_d2",
3028c2ecf20Sopenharmony_ci	"univ_192m_d16",
3038c2ecf20Sopenharmony_ci	"univ_192m_d32"
3048c2ecf20Sopenharmony_ci};
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_cistatic const char * const camtg3_parents[] = {
3078c2ecf20Sopenharmony_ci	"clk26m",
3088c2ecf20Sopenharmony_ci	"univ_192m_d8",
3098c2ecf20Sopenharmony_ci	"univpll_d3_d8",
3108c2ecf20Sopenharmony_ci	"univ_192m_d4",
3118c2ecf20Sopenharmony_ci	"univpll_d3_d16",
3128c2ecf20Sopenharmony_ci	"csw_f26m_ck_d2",
3138c2ecf20Sopenharmony_ci	"univ_192m_d16",
3148c2ecf20Sopenharmony_ci	"univ_192m_d32"
3158c2ecf20Sopenharmony_ci};
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_cistatic const char * const camtg4_parents[] = {
3188c2ecf20Sopenharmony_ci	"clk26m",
3198c2ecf20Sopenharmony_ci	"univ_192m_d8",
3208c2ecf20Sopenharmony_ci	"univpll_d3_d8",
3218c2ecf20Sopenharmony_ci	"univ_192m_d4",
3228c2ecf20Sopenharmony_ci	"univpll_d3_d16",
3238c2ecf20Sopenharmony_ci	"csw_f26m_ck_d2",
3248c2ecf20Sopenharmony_ci	"univ_192m_d16",
3258c2ecf20Sopenharmony_ci	"univ_192m_d32"
3268c2ecf20Sopenharmony_ci};
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_cistatic const char * const uart_parents[] = {
3298c2ecf20Sopenharmony_ci	"clk26m",
3308c2ecf20Sopenharmony_ci	"univpll_d3_d8"
3318c2ecf20Sopenharmony_ci};
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_cistatic const char * const spi_parents[] = {
3348c2ecf20Sopenharmony_ci	"clk26m",
3358c2ecf20Sopenharmony_ci	"syspll_d5_d2",
3368c2ecf20Sopenharmony_ci	"syspll_d3_d4",
3378c2ecf20Sopenharmony_ci	"msdcpll_d4"
3388c2ecf20Sopenharmony_ci};
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_cistatic const char * const msdc50_hclk_parents[] = {
3418c2ecf20Sopenharmony_ci	"clk26m",
3428c2ecf20Sopenharmony_ci	"syspll_d2_d2",
3438c2ecf20Sopenharmony_ci	"syspll_d3_d2"
3448c2ecf20Sopenharmony_ci};
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_cistatic const char * const msdc50_0_parents[] = {
3478c2ecf20Sopenharmony_ci	"clk26m",
3488c2ecf20Sopenharmony_ci	"msdcpll_ck",
3498c2ecf20Sopenharmony_ci	"msdcpll_d2",
3508c2ecf20Sopenharmony_ci	"univpll_d2_d4",
3518c2ecf20Sopenharmony_ci	"syspll_d3_d2",
3528c2ecf20Sopenharmony_ci	"univpll_d2_d2"
3538c2ecf20Sopenharmony_ci};
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_cistatic const char * const msdc30_1_parents[] = {
3568c2ecf20Sopenharmony_ci	"clk26m",
3578c2ecf20Sopenharmony_ci	"univpll_d3_d2",
3588c2ecf20Sopenharmony_ci	"syspll_d3_d2",
3598c2ecf20Sopenharmony_ci	"syspll_d7",
3608c2ecf20Sopenharmony_ci	"msdcpll_d2"
3618c2ecf20Sopenharmony_ci};
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_cistatic const char * const msdc30_2_parents[] = {
3648c2ecf20Sopenharmony_ci	"clk26m",
3658c2ecf20Sopenharmony_ci	"univpll_d3_d2",
3668c2ecf20Sopenharmony_ci	"syspll_d3_d2",
3678c2ecf20Sopenharmony_ci	"syspll_d7",
3688c2ecf20Sopenharmony_ci	"msdcpll_d2"
3698c2ecf20Sopenharmony_ci};
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_cistatic const char * const audio_parents[] = {
3728c2ecf20Sopenharmony_ci	"clk26m",
3738c2ecf20Sopenharmony_ci	"syspll_d5_d4",
3748c2ecf20Sopenharmony_ci	"syspll_d7_d4",
3758c2ecf20Sopenharmony_ci	"syspll_d2_d16"
3768c2ecf20Sopenharmony_ci};
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_cistatic const char * const aud_intbus_parents[] = {
3798c2ecf20Sopenharmony_ci	"clk26m",
3808c2ecf20Sopenharmony_ci	"syspll_d2_d4",
3818c2ecf20Sopenharmony_ci	"syspll_d7_d2"
3828c2ecf20Sopenharmony_ci};
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_cistatic const char * const pmicspi_parents[] = {
3858c2ecf20Sopenharmony_ci	"clk26m",
3868c2ecf20Sopenharmony_ci	"syspll_d2_d8",
3878c2ecf20Sopenharmony_ci	"osc_d8"
3888c2ecf20Sopenharmony_ci};
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_cistatic const char * const fpwrap_ulposc_parents[] = {
3918c2ecf20Sopenharmony_ci	"clk26m",
3928c2ecf20Sopenharmony_ci	"osc_d16",
3938c2ecf20Sopenharmony_ci	"osc_d4",
3948c2ecf20Sopenharmony_ci	"osc_d8"
3958c2ecf20Sopenharmony_ci};
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_cistatic const char * const atb_parents[] = {
3988c2ecf20Sopenharmony_ci	"clk26m",
3998c2ecf20Sopenharmony_ci	"syspll_d2_d2",
4008c2ecf20Sopenharmony_ci	"syspll_d5"
4018c2ecf20Sopenharmony_ci};
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_cistatic const char * const dpi0_parents[] = {
4048c2ecf20Sopenharmony_ci	"clk26m",
4058c2ecf20Sopenharmony_ci	"tvdpll_d2",
4068c2ecf20Sopenharmony_ci	"tvdpll_d4",
4078c2ecf20Sopenharmony_ci	"tvdpll_d8",
4088c2ecf20Sopenharmony_ci	"tvdpll_d16",
4098c2ecf20Sopenharmony_ci	"univpll_d5_d2",
4108c2ecf20Sopenharmony_ci	"univpll_d3_d4",
4118c2ecf20Sopenharmony_ci	"syspll_d3_d4",
4128c2ecf20Sopenharmony_ci	"univpll_d3_d8"
4138c2ecf20Sopenharmony_ci};
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_cistatic const char * const scam_parents[] = {
4168c2ecf20Sopenharmony_ci	"clk26m",
4178c2ecf20Sopenharmony_ci	"syspll_d5_d2"
4188c2ecf20Sopenharmony_ci};
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_cistatic const char * const disppwm_parents[] = {
4218c2ecf20Sopenharmony_ci	"clk26m",
4228c2ecf20Sopenharmony_ci	"univpll_d3_d4",
4238c2ecf20Sopenharmony_ci	"osc_d2",
4248c2ecf20Sopenharmony_ci	"osc_d4",
4258c2ecf20Sopenharmony_ci	"osc_d16"
4268c2ecf20Sopenharmony_ci};
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_cistatic const char * const usb_top_parents[] = {
4298c2ecf20Sopenharmony_ci	"clk26m",
4308c2ecf20Sopenharmony_ci	"univpll_d5_d4",
4318c2ecf20Sopenharmony_ci	"univpll_d3_d4",
4328c2ecf20Sopenharmony_ci	"univpll_d5_d2"
4338c2ecf20Sopenharmony_ci};
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci
4368c2ecf20Sopenharmony_cistatic const char * const ssusb_top_xhci_parents[] = {
4378c2ecf20Sopenharmony_ci	"clk26m",
4388c2ecf20Sopenharmony_ci	"univpll_d5_d4",
4398c2ecf20Sopenharmony_ci	"univpll_d3_d4",
4408c2ecf20Sopenharmony_ci	"univpll_d5_d2"
4418c2ecf20Sopenharmony_ci};
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_cistatic const char * const spm_parents[] = {
4448c2ecf20Sopenharmony_ci	"clk26m",
4458c2ecf20Sopenharmony_ci	"syspll_d2_d8"
4468c2ecf20Sopenharmony_ci};
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_cistatic const char * const i2c_parents[] = {
4498c2ecf20Sopenharmony_ci	"clk26m",
4508c2ecf20Sopenharmony_ci	"syspll_d2_d8",
4518c2ecf20Sopenharmony_ci	"univpll_d5_d2"
4528c2ecf20Sopenharmony_ci};
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_cistatic const char * const scp_parents[] = {
4558c2ecf20Sopenharmony_ci	"clk26m",
4568c2ecf20Sopenharmony_ci	"univpll_d2_d8",
4578c2ecf20Sopenharmony_ci	"syspll_d5",
4588c2ecf20Sopenharmony_ci	"syspll_d2_d2",
4598c2ecf20Sopenharmony_ci	"univpll_d2_d2",
4608c2ecf20Sopenharmony_ci	"syspll_d3",
4618c2ecf20Sopenharmony_ci	"univpll_d3"
4628c2ecf20Sopenharmony_ci};
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_cistatic const char * const seninf_parents[] = {
4658c2ecf20Sopenharmony_ci	"clk26m",
4668c2ecf20Sopenharmony_ci	"univpll_d2_d2",
4678c2ecf20Sopenharmony_ci	"univpll_d3_d2",
4688c2ecf20Sopenharmony_ci	"univpll_d2_d4"
4698c2ecf20Sopenharmony_ci};
4708c2ecf20Sopenharmony_ci
4718c2ecf20Sopenharmony_cistatic const char * const dxcc_parents[] = {
4728c2ecf20Sopenharmony_ci	"clk26m",
4738c2ecf20Sopenharmony_ci	"syspll_d2_d2",
4748c2ecf20Sopenharmony_ci	"syspll_d2_d4",
4758c2ecf20Sopenharmony_ci	"syspll_d2_d8"
4768c2ecf20Sopenharmony_ci};
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_cistatic const char * const aud_engen1_parents[] = {
4798c2ecf20Sopenharmony_ci	"clk26m",
4808c2ecf20Sopenharmony_ci	"apll1_d2",
4818c2ecf20Sopenharmony_ci	"apll1_d4",
4828c2ecf20Sopenharmony_ci	"apll1_d8"
4838c2ecf20Sopenharmony_ci};
4848c2ecf20Sopenharmony_ci
4858c2ecf20Sopenharmony_cistatic const char * const aud_engen2_parents[] = {
4868c2ecf20Sopenharmony_ci	"clk26m",
4878c2ecf20Sopenharmony_ci	"apll2_d2",
4888c2ecf20Sopenharmony_ci	"apll2_d4",
4898c2ecf20Sopenharmony_ci	"apll2_d8"
4908c2ecf20Sopenharmony_ci};
4918c2ecf20Sopenharmony_ci
4928c2ecf20Sopenharmony_cistatic const char * const faes_ufsfde_parents[] = {
4938c2ecf20Sopenharmony_ci	"clk26m",
4948c2ecf20Sopenharmony_ci	"syspll_d2",
4958c2ecf20Sopenharmony_ci	"syspll_d2_d2",
4968c2ecf20Sopenharmony_ci	"syspll_d3",
4978c2ecf20Sopenharmony_ci	"syspll_d2_d4",
4988c2ecf20Sopenharmony_ci	"univpll_d3"
4998c2ecf20Sopenharmony_ci};
5008c2ecf20Sopenharmony_ci
5018c2ecf20Sopenharmony_cistatic const char * const fufs_parents[] = {
5028c2ecf20Sopenharmony_ci	"clk26m",
5038c2ecf20Sopenharmony_ci	"syspll_d2_d4",
5048c2ecf20Sopenharmony_ci	"syspll_d2_d8",
5058c2ecf20Sopenharmony_ci	"syspll_d2_d16"
5068c2ecf20Sopenharmony_ci};
5078c2ecf20Sopenharmony_ci
5088c2ecf20Sopenharmony_cistatic const char * const aud_1_parents[] = {
5098c2ecf20Sopenharmony_ci	"clk26m",
5108c2ecf20Sopenharmony_ci	"apll1_ck"
5118c2ecf20Sopenharmony_ci};
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_cistatic const char * const aud_2_parents[] = {
5148c2ecf20Sopenharmony_ci	"clk26m",
5158c2ecf20Sopenharmony_ci	"apll2_ck"
5168c2ecf20Sopenharmony_ci};
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_ci/*
5198c2ecf20Sopenharmony_ci * CRITICAL CLOCK:
5208c2ecf20Sopenharmony_ci * axi_sel is the main bus clock of whole SOC.
5218c2ecf20Sopenharmony_ci * spm_sel is the clock of the always-on co-processor.
5228c2ecf20Sopenharmony_ci */
5238c2ecf20Sopenharmony_cistatic const struct mtk_mux top_muxes[] = {
5248c2ecf20Sopenharmony_ci	/* CLK_CFG_0 */
5258c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_MUX_AXI, "axi_sel",
5268c2ecf20Sopenharmony_ci		axi_parents, 0x40,
5278c2ecf20Sopenharmony_ci		0x44, 0x48, 0, 2, 7, 0x004, 0, CLK_IS_CRITICAL),
5288c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MM, "mm_sel",
5298c2ecf20Sopenharmony_ci		mm_parents, 0x40,
5308c2ecf20Sopenharmony_ci		0x44, 0x48, 8, 3, 15, 0x004, 1),
5318c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_IMG, "img_sel",
5328c2ecf20Sopenharmony_ci		img_parents, 0x40,
5338c2ecf20Sopenharmony_ci		0x44, 0x48, 16, 3, 23, 0x004, 2),
5348c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAM, "cam_sel",
5358c2ecf20Sopenharmony_ci		cam_parents, 0x40,
5368c2ecf20Sopenharmony_ci		0x44, 0x48, 24, 4, 31, 0x004, 3),
5378c2ecf20Sopenharmony_ci	/* CLK_CFG_1 */
5388c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DSP, "dsp_sel",
5398c2ecf20Sopenharmony_ci		dsp_parents, 0x50,
5408c2ecf20Sopenharmony_ci		0x54, 0x58, 0, 4, 7, 0x004, 4),
5418c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DSP1, "dsp1_sel",
5428c2ecf20Sopenharmony_ci		dsp1_parents, 0x50,
5438c2ecf20Sopenharmony_ci		0x54, 0x58, 8, 4, 15, 0x004, 5),
5448c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DSP2, "dsp2_sel",
5458c2ecf20Sopenharmony_ci		dsp2_parents, 0x50,
5468c2ecf20Sopenharmony_ci		0x54, 0x58, 16, 4, 23, 0x004, 6),
5478c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_IPU_IF, "ipu_if_sel",
5488c2ecf20Sopenharmony_ci		ipu_if_parents, 0x50,
5498c2ecf20Sopenharmony_ci		0x54, 0x58, 24, 4, 31, 0x004, 7),
5508c2ecf20Sopenharmony_ci	/* CLK_CFG_2 */
5518c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MFG, "mfg_sel",
5528c2ecf20Sopenharmony_ci		mfg_parents, 0x60,
5538c2ecf20Sopenharmony_ci		0x64, 0x68, 0, 2, 7, 0x004, 8),
5548c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_F52M_MFG, "f52m_mfg_sel",
5558c2ecf20Sopenharmony_ci		f52m_mfg_parents, 0x60,
5568c2ecf20Sopenharmony_ci		0x64, 0x68, 8, 2, 15, 0x004, 9),
5578c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAMTG, "camtg_sel",
5588c2ecf20Sopenharmony_ci		camtg_parents, 0x60,
5598c2ecf20Sopenharmony_ci		0x64, 0x68, 16, 3, 23, 0x004, 10),
5608c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAMTG2, "camtg2_sel",
5618c2ecf20Sopenharmony_ci		camtg2_parents, 0x60,
5628c2ecf20Sopenharmony_ci		0x64, 0x68, 24, 3, 31, 0x004, 11),
5638c2ecf20Sopenharmony_ci	/* CLK_CFG_3 */
5648c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAMTG3, "camtg3_sel",
5658c2ecf20Sopenharmony_ci		camtg3_parents, 0x70,
5668c2ecf20Sopenharmony_ci		0x74, 0x78, 0, 3, 7, 0x004, 12),
5678c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAMTG4, "camtg4_sel",
5688c2ecf20Sopenharmony_ci		camtg4_parents, 0x70,
5698c2ecf20Sopenharmony_ci		0x74, 0x78, 8, 3, 15, 0x004, 13),
5708c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_UART, "uart_sel",
5718c2ecf20Sopenharmony_ci		uart_parents, 0x70,
5728c2ecf20Sopenharmony_ci		0x74, 0x78, 16, 1, 23, 0x004, 14),
5738c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SPI, "spi_sel",
5748c2ecf20Sopenharmony_ci		spi_parents, 0x70,
5758c2ecf20Sopenharmony_ci		0x74, 0x78, 24, 2, 31, 0x004, 15),
5768c2ecf20Sopenharmony_ci	/* CLK_CFG_4 */
5778c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MSDC50_0_HCLK, "msdc50_hclk_sel",
5788c2ecf20Sopenharmony_ci		msdc50_hclk_parents, 0x80,
5798c2ecf20Sopenharmony_ci		0x84, 0x88, 0, 2, 7, 0x004, 16),
5808c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MSDC50_0, "msdc50_0_sel",
5818c2ecf20Sopenharmony_ci		msdc50_0_parents, 0x80,
5828c2ecf20Sopenharmony_ci		0x84, 0x88, 8, 3, 15, 0x004, 17),
5838c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MSDC30_1, "msdc30_1_sel",
5848c2ecf20Sopenharmony_ci		msdc30_1_parents, 0x80,
5858c2ecf20Sopenharmony_ci		0x84, 0x88, 16, 3, 23, 0x004, 18),
5868c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MSDC30_2, "msdc30_2_sel",
5878c2ecf20Sopenharmony_ci		msdc30_2_parents, 0x80,
5888c2ecf20Sopenharmony_ci		0x84, 0x88, 24, 3, 31, 0x004, 19),
5898c2ecf20Sopenharmony_ci	/* CLK_CFG_5 */
5908c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUDIO, "audio_sel",
5918c2ecf20Sopenharmony_ci		audio_parents, 0x90,
5928c2ecf20Sopenharmony_ci		0x94, 0x98, 0, 2, 7, 0x004, 20),
5938c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_INTBUS, "aud_intbus_sel",
5948c2ecf20Sopenharmony_ci		aud_intbus_parents, 0x90,
5958c2ecf20Sopenharmony_ci		0x94, 0x98, 8, 2, 15, 0x004, 21),
5968c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_PMICSPI, "pmicspi_sel",
5978c2ecf20Sopenharmony_ci		pmicspi_parents, 0x90,
5988c2ecf20Sopenharmony_ci		0x94, 0x98, 16, 2, 23, 0x004, 22),
5998c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_FPWRAP_ULPOSC, "fpwrap_ulposc_sel",
6008c2ecf20Sopenharmony_ci		fpwrap_ulposc_parents, 0x90,
6018c2ecf20Sopenharmony_ci		0x94, 0x98, 24, 2, 31, 0x004, 23),
6028c2ecf20Sopenharmony_ci	/* CLK_CFG_6 */
6038c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_ATB, "atb_sel",
6048c2ecf20Sopenharmony_ci		atb_parents, 0xa0,
6058c2ecf20Sopenharmony_ci		0xa4, 0xa8, 0, 2, 7, 0x004, 24),
6068c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DPI0, "dpi0_sel",
6078c2ecf20Sopenharmony_ci		dpi0_parents, 0xa0,
6088c2ecf20Sopenharmony_ci		0xa4, 0xa8, 16, 4, 23, 0x004, 26),
6098c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SCAM, "scam_sel",
6108c2ecf20Sopenharmony_ci		scam_parents, 0xa0,
6118c2ecf20Sopenharmony_ci		0xa4, 0xa8, 24, 1, 31, 0x004, 27),
6128c2ecf20Sopenharmony_ci	/* CLK_CFG_7 */
6138c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DISP_PWM, "disppwm_sel",
6148c2ecf20Sopenharmony_ci		disppwm_parents, 0xb0,
6158c2ecf20Sopenharmony_ci		0xb4, 0xb8, 0, 3, 7, 0x004, 28),
6168c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_USB_TOP, "usb_top_sel",
6178c2ecf20Sopenharmony_ci		usb_top_parents, 0xb0,
6188c2ecf20Sopenharmony_ci		0xb4, 0xb8, 8, 2, 15, 0x004, 29),
6198c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SSUSB_TOP_XHCI, "ssusb_top_xhci_sel",
6208c2ecf20Sopenharmony_ci		ssusb_top_xhci_parents, 0xb0,
6218c2ecf20Sopenharmony_ci		0xb4, 0xb8, 16, 2, 23, 0x004, 30),
6228c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_MUX_SPM, "spm_sel",
6238c2ecf20Sopenharmony_ci		spm_parents, 0xb0,
6248c2ecf20Sopenharmony_ci		0xb4, 0xb8, 24, 1, 31, 0x008, 0, CLK_IS_CRITICAL),
6258c2ecf20Sopenharmony_ci	/* CLK_CFG_8 */
6268c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_I2C, "i2c_sel",
6278c2ecf20Sopenharmony_ci		i2c_parents, 0xc0,
6288c2ecf20Sopenharmony_ci		0xc4, 0xc8, 0, 2, 7, 0x008, 1),
6298c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SCP, "scp_sel",
6308c2ecf20Sopenharmony_ci		scp_parents, 0xc0,
6318c2ecf20Sopenharmony_ci		0xc4, 0xc8, 8, 3, 15, 0x008, 2),
6328c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SENINF, "seninf_sel",
6338c2ecf20Sopenharmony_ci		seninf_parents, 0xc0,
6348c2ecf20Sopenharmony_ci		0xc4, 0xc8, 16, 2, 23, 0x008, 3),
6358c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DXCC, "dxcc_sel",
6368c2ecf20Sopenharmony_ci		dxcc_parents, 0xc0,
6378c2ecf20Sopenharmony_ci		0xc4, 0xc8, 24, 2, 31, 0x008, 4),
6388c2ecf20Sopenharmony_ci	/* CLK_CFG_9 */
6398c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_ENG1, "aud_eng1_sel",
6408c2ecf20Sopenharmony_ci		aud_engen1_parents, 0xd0,
6418c2ecf20Sopenharmony_ci		0xd4, 0xd8, 0, 2, 7, 0x008, 5),
6428c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_ENG2, "aud_eng2_sel",
6438c2ecf20Sopenharmony_ci		aud_engen2_parents, 0xd0,
6448c2ecf20Sopenharmony_ci		0xd4, 0xd8, 8, 2, 15, 0x008, 6),
6458c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_FAES_UFSFDE, "faes_ufsfde_sel",
6468c2ecf20Sopenharmony_ci		faes_ufsfde_parents, 0xd0,
6478c2ecf20Sopenharmony_ci		0xd4, 0xd8, 16, 3, 23, 0x008, 7),
6488c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_FUFS, "fufs_sel",
6498c2ecf20Sopenharmony_ci		fufs_parents, 0xd0,
6508c2ecf20Sopenharmony_ci		0xd4, 0xd8, 24, 2, 31, 0x008, 8),
6518c2ecf20Sopenharmony_ci	/* CLK_CFG_10 */
6528c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_1, "aud_1_sel",
6538c2ecf20Sopenharmony_ci		aud_1_parents, 0xe0,
6548c2ecf20Sopenharmony_ci		0xe4, 0xe8, 0, 1, 7, 0x008, 9),
6558c2ecf20Sopenharmony_ci	MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_2, "aud_2_sel",
6568c2ecf20Sopenharmony_ci		aud_2_parents, 0xe0,
6578c2ecf20Sopenharmony_ci		0xe4, 0xe8, 8, 1, 15, 0x008, 10),
6588c2ecf20Sopenharmony_ci};
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_cistatic const char * const apll_i2s0_parents[] = {
6618c2ecf20Sopenharmony_ci	"aud_1_sel",
6628c2ecf20Sopenharmony_ci	"aud_2_sel"
6638c2ecf20Sopenharmony_ci};
6648c2ecf20Sopenharmony_ci
6658c2ecf20Sopenharmony_cistatic const char * const apll_i2s1_parents[] = {
6668c2ecf20Sopenharmony_ci	"aud_1_sel",
6678c2ecf20Sopenharmony_ci	"aud_2_sel"
6688c2ecf20Sopenharmony_ci};
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_cistatic const char * const apll_i2s2_parents[] = {
6718c2ecf20Sopenharmony_ci	"aud_1_sel",
6728c2ecf20Sopenharmony_ci	"aud_2_sel"
6738c2ecf20Sopenharmony_ci};
6748c2ecf20Sopenharmony_ci
6758c2ecf20Sopenharmony_cistatic const char * const apll_i2s3_parents[] = {
6768c2ecf20Sopenharmony_ci	"aud_1_sel",
6778c2ecf20Sopenharmony_ci	"aud_2_sel"
6788c2ecf20Sopenharmony_ci};
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_cistatic const char * const apll_i2s4_parents[] = {
6818c2ecf20Sopenharmony_ci	"aud_1_sel",
6828c2ecf20Sopenharmony_ci	"aud_2_sel"
6838c2ecf20Sopenharmony_ci};
6848c2ecf20Sopenharmony_ci
6858c2ecf20Sopenharmony_cistatic const char * const apll_i2s5_parents[] = {
6868c2ecf20Sopenharmony_ci	"aud_1_sel",
6878c2ecf20Sopenharmony_ci	"aud_2_sel"
6888c2ecf20Sopenharmony_ci};
6898c2ecf20Sopenharmony_ci
6908c2ecf20Sopenharmony_cistatic struct mtk_composite top_aud_muxes[] = {
6918c2ecf20Sopenharmony_ci	MUX(CLK_TOP_MUX_APLL_I2S0, "apll_i2s0_sel", apll_i2s0_parents,
6928c2ecf20Sopenharmony_ci		0x320, 8, 1),
6938c2ecf20Sopenharmony_ci	MUX(CLK_TOP_MUX_APLL_I2S1, "apll_i2s1_sel", apll_i2s1_parents,
6948c2ecf20Sopenharmony_ci		0x320, 9, 1),
6958c2ecf20Sopenharmony_ci	MUX(CLK_TOP_MUX_APLL_I2S2, "apll_i2s2_sel", apll_i2s2_parents,
6968c2ecf20Sopenharmony_ci		0x320, 10, 1),
6978c2ecf20Sopenharmony_ci	MUX(CLK_TOP_MUX_APLL_I2S3, "apll_i2s3_sel", apll_i2s3_parents,
6988c2ecf20Sopenharmony_ci		0x320, 11, 1),
6998c2ecf20Sopenharmony_ci	MUX(CLK_TOP_MUX_APLL_I2S4, "apll_i2s4_sel", apll_i2s4_parents,
7008c2ecf20Sopenharmony_ci		0x320, 12, 1),
7018c2ecf20Sopenharmony_ci	MUX(CLK_TOP_MUX_APLL_I2S5, "apll_i2s5_sel", apll_i2s5_parents,
7028c2ecf20Sopenharmony_ci		0x328, 20, 1),
7038c2ecf20Sopenharmony_ci};
7048c2ecf20Sopenharmony_ci
7058c2ecf20Sopenharmony_cistatic const char * const mcu_mp0_parents[] = {
7068c2ecf20Sopenharmony_ci	"clk26m",
7078c2ecf20Sopenharmony_ci	"armpll_ll",
7088c2ecf20Sopenharmony_ci	"armpll_div_pll1",
7098c2ecf20Sopenharmony_ci	"armpll_div_pll2"
7108c2ecf20Sopenharmony_ci};
7118c2ecf20Sopenharmony_ci
7128c2ecf20Sopenharmony_cistatic const char * const mcu_mp2_parents[] = {
7138c2ecf20Sopenharmony_ci	"clk26m",
7148c2ecf20Sopenharmony_ci	"armpll_l",
7158c2ecf20Sopenharmony_ci	"armpll_div_pll1",
7168c2ecf20Sopenharmony_ci	"armpll_div_pll2"
7178c2ecf20Sopenharmony_ci};
7188c2ecf20Sopenharmony_ci
7198c2ecf20Sopenharmony_cistatic const char * const mcu_bus_parents[] = {
7208c2ecf20Sopenharmony_ci	"clk26m",
7218c2ecf20Sopenharmony_ci	"ccipll",
7228c2ecf20Sopenharmony_ci	"armpll_div_pll1",
7238c2ecf20Sopenharmony_ci	"armpll_div_pll2"
7248c2ecf20Sopenharmony_ci};
7258c2ecf20Sopenharmony_ci
7268c2ecf20Sopenharmony_cistatic struct mtk_composite mcu_muxes[] = {
7278c2ecf20Sopenharmony_ci	/* mp0_pll_divider_cfg */
7288c2ecf20Sopenharmony_ci	MUX(CLK_MCU_MP0_SEL, "mcu_mp0_sel", mcu_mp0_parents, 0x7A0, 9, 2),
7298c2ecf20Sopenharmony_ci	/* mp2_pll_divider_cfg */
7308c2ecf20Sopenharmony_ci	MUX(CLK_MCU_MP2_SEL, "mcu_mp2_sel", mcu_mp2_parents, 0x7A8, 9, 2),
7318c2ecf20Sopenharmony_ci	/* bus_pll_divider_cfg */
7328c2ecf20Sopenharmony_ci	MUX(CLK_MCU_BUS_SEL, "mcu_bus_sel", mcu_bus_parents, 0x7C0, 9, 2),
7338c2ecf20Sopenharmony_ci};
7348c2ecf20Sopenharmony_ci
7358c2ecf20Sopenharmony_cistatic struct mtk_composite top_aud_divs[] = {
7368c2ecf20Sopenharmony_ci	DIV_GATE(CLK_TOP_APLL12_DIV0, "apll12_div0", "apll_i2s0_sel",
7378c2ecf20Sopenharmony_ci		0x320, 2, 0x324, 8, 0),
7388c2ecf20Sopenharmony_ci	DIV_GATE(CLK_TOP_APLL12_DIV1, "apll12_div1", "apll_i2s1_sel",
7398c2ecf20Sopenharmony_ci		0x320, 3, 0x324, 8, 8),
7408c2ecf20Sopenharmony_ci	DIV_GATE(CLK_TOP_APLL12_DIV2, "apll12_div2", "apll_i2s2_sel",
7418c2ecf20Sopenharmony_ci		0x320, 4, 0x324, 8, 16),
7428c2ecf20Sopenharmony_ci	DIV_GATE(CLK_TOP_APLL12_DIV3, "apll12_div3", "apll_i2s3_sel",
7438c2ecf20Sopenharmony_ci		0x320, 5, 0x324, 8, 24),
7448c2ecf20Sopenharmony_ci	DIV_GATE(CLK_TOP_APLL12_DIV4, "apll12_div4", "apll_i2s4_sel",
7458c2ecf20Sopenharmony_ci		0x320, 6, 0x328, 8, 0),
7468c2ecf20Sopenharmony_ci	DIV_GATE(CLK_TOP_APLL12_DIVB, "apll12_divb", "apll12_div4",
7478c2ecf20Sopenharmony_ci		0x320, 7, 0x328, 8, 8),
7488c2ecf20Sopenharmony_ci};
7498c2ecf20Sopenharmony_ci
7508c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs top_cg_regs = {
7518c2ecf20Sopenharmony_ci	.set_ofs = 0x104,
7528c2ecf20Sopenharmony_ci	.clr_ofs = 0x104,
7538c2ecf20Sopenharmony_ci	.sta_ofs = 0x104,
7548c2ecf20Sopenharmony_ci};
7558c2ecf20Sopenharmony_ci
7568c2ecf20Sopenharmony_ci#define GATE_TOP(_id, _name, _parent, _shift)			\
7578c2ecf20Sopenharmony_ci	GATE_MTK(_id, _name, _parent, &top_cg_regs, _shift,	\
7588c2ecf20Sopenharmony_ci		&mtk_clk_gate_ops_no_setclr_inv)
7598c2ecf20Sopenharmony_ci
7608c2ecf20Sopenharmony_cistatic const struct mtk_gate top_clks[] = {
7618c2ecf20Sopenharmony_ci	/* TOP */
7628c2ecf20Sopenharmony_ci	GATE_TOP(CLK_TOP_ARMPLL_DIV_PLL1, "armpll_div_pll1", "mainpll", 4),
7638c2ecf20Sopenharmony_ci	GATE_TOP(CLK_TOP_ARMPLL_DIV_PLL2, "armpll_div_pll2", "univpll", 5),
7648c2ecf20Sopenharmony_ci};
7658c2ecf20Sopenharmony_ci
7668c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs infra0_cg_regs = {
7678c2ecf20Sopenharmony_ci	.set_ofs = 0x80,
7688c2ecf20Sopenharmony_ci	.clr_ofs = 0x84,
7698c2ecf20Sopenharmony_ci	.sta_ofs = 0x90,
7708c2ecf20Sopenharmony_ci};
7718c2ecf20Sopenharmony_ci
7728c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs infra1_cg_regs = {
7738c2ecf20Sopenharmony_ci	.set_ofs = 0x88,
7748c2ecf20Sopenharmony_ci	.clr_ofs = 0x8c,
7758c2ecf20Sopenharmony_ci	.sta_ofs = 0x94,
7768c2ecf20Sopenharmony_ci};
7778c2ecf20Sopenharmony_ci
7788c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs infra2_cg_regs = {
7798c2ecf20Sopenharmony_ci	.set_ofs = 0xa4,
7808c2ecf20Sopenharmony_ci	.clr_ofs = 0xa8,
7818c2ecf20Sopenharmony_ci	.sta_ofs = 0xac,
7828c2ecf20Sopenharmony_ci};
7838c2ecf20Sopenharmony_ci
7848c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs infra3_cg_regs = {
7858c2ecf20Sopenharmony_ci	.set_ofs = 0xc0,
7868c2ecf20Sopenharmony_ci	.clr_ofs = 0xc4,
7878c2ecf20Sopenharmony_ci	.sta_ofs = 0xc8,
7888c2ecf20Sopenharmony_ci};
7898c2ecf20Sopenharmony_ci
7908c2ecf20Sopenharmony_ci#define GATE_INFRA0(_id, _name, _parent, _shift)		\
7918c2ecf20Sopenharmony_ci	GATE_MTK(_id, _name, _parent, &infra0_cg_regs, _shift,	\
7928c2ecf20Sopenharmony_ci		&mtk_clk_gate_ops_setclr)
7938c2ecf20Sopenharmony_ci
7948c2ecf20Sopenharmony_ci#define GATE_INFRA1(_id, _name, _parent, _shift)		\
7958c2ecf20Sopenharmony_ci	GATE_MTK(_id, _name, _parent, &infra1_cg_regs, _shift,	\
7968c2ecf20Sopenharmony_ci		&mtk_clk_gate_ops_setclr)
7978c2ecf20Sopenharmony_ci
7988c2ecf20Sopenharmony_ci#define GATE_INFRA2(_id, _name, _parent, _shift)		\
7998c2ecf20Sopenharmony_ci	GATE_MTK(_id, _name, _parent, &infra2_cg_regs, _shift,	\
8008c2ecf20Sopenharmony_ci		&mtk_clk_gate_ops_setclr)
8018c2ecf20Sopenharmony_ci
8028c2ecf20Sopenharmony_ci#define GATE_INFRA3(_id, _name, _parent, _shift)		\
8038c2ecf20Sopenharmony_ci	GATE_MTK(_id, _name, _parent, &infra3_cg_regs, _shift,	\
8048c2ecf20Sopenharmony_ci		&mtk_clk_gate_ops_setclr)
8058c2ecf20Sopenharmony_ci
8068c2ecf20Sopenharmony_cistatic const struct mtk_gate infra_clks[] = {
8078c2ecf20Sopenharmony_ci	/* INFRA0 */
8088c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_PMIC_TMR, "infra_pmic_tmr",
8098c2ecf20Sopenharmony_ci		"axi_sel", 0),
8108c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_PMIC_AP, "infra_pmic_ap",
8118c2ecf20Sopenharmony_ci		"axi_sel", 1),
8128c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_PMIC_MD, "infra_pmic_md",
8138c2ecf20Sopenharmony_ci		"axi_sel", 2),
8148c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_PMIC_CONN, "infra_pmic_conn",
8158c2ecf20Sopenharmony_ci		"axi_sel", 3),
8168c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_SCPSYS, "infra_scp",
8178c2ecf20Sopenharmony_ci		"scp_sel", 4),
8188c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_SEJ, "infra_sej",
8198c2ecf20Sopenharmony_ci		"f_f26m_ck", 5),
8208c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_APXGPT, "infra_apxgpt",
8218c2ecf20Sopenharmony_ci		"axi_sel", 6),
8228c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_ICUSB, "infra_icusb",
8238c2ecf20Sopenharmony_ci		"axi_sel", 8),
8248c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_GCE, "infra_gce",
8258c2ecf20Sopenharmony_ci		"axi_sel", 9),
8268c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_THERM, "infra_therm",
8278c2ecf20Sopenharmony_ci		"axi_sel", 10),
8288c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_I2C0, "infra_i2c0",
8298c2ecf20Sopenharmony_ci		"i2c_sel", 11),
8308c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_I2C1, "infra_i2c1",
8318c2ecf20Sopenharmony_ci		"i2c_sel", 12),
8328c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_I2C2, "infra_i2c2",
8338c2ecf20Sopenharmony_ci		"i2c_sel", 13),
8348c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_I2C3, "infra_i2c3",
8358c2ecf20Sopenharmony_ci		"i2c_sel", 14),
8368c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_PWM_HCLK, "infra_pwm_hclk",
8378c2ecf20Sopenharmony_ci		"axi_sel", 15),
8388c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_PWM1, "infra_pwm1",
8398c2ecf20Sopenharmony_ci		"i2c_sel", 16),
8408c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_PWM2, "infra_pwm2",
8418c2ecf20Sopenharmony_ci		"i2c_sel", 17),
8428c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_PWM3, "infra_pwm3",
8438c2ecf20Sopenharmony_ci		"i2c_sel", 18),
8448c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_PWM4, "infra_pwm4",
8458c2ecf20Sopenharmony_ci		"i2c_sel", 19),
8468c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_PWM, "infra_pwm",
8478c2ecf20Sopenharmony_ci		"i2c_sel", 21),
8488c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_UART0, "infra_uart0",
8498c2ecf20Sopenharmony_ci		"uart_sel", 22),
8508c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_UART1, "infra_uart1",
8518c2ecf20Sopenharmony_ci		"uart_sel", 23),
8528c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_UART2, "infra_uart2",
8538c2ecf20Sopenharmony_ci		"uart_sel", 24),
8548c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_UART3, "infra_uart3",
8558c2ecf20Sopenharmony_ci		"uart_sel", 25),
8568c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_GCE_26M, "infra_gce_26m",
8578c2ecf20Sopenharmony_ci		"axi_sel", 27),
8588c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_CQ_DMA_FPC, "infra_cqdma_fpc",
8598c2ecf20Sopenharmony_ci		"axi_sel", 28),
8608c2ecf20Sopenharmony_ci	GATE_INFRA0(CLK_INFRA_BTIF, "infra_btif",
8618c2ecf20Sopenharmony_ci		"axi_sel", 31),
8628c2ecf20Sopenharmony_ci	/* INFRA1 */
8638c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_SPI0, "infra_spi0",
8648c2ecf20Sopenharmony_ci		"spi_sel", 1),
8658c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_MSDC0, "infra_msdc0",
8668c2ecf20Sopenharmony_ci		"msdc50_hclk_sel", 2),
8678c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_MSDC1, "infra_msdc1",
8688c2ecf20Sopenharmony_ci		"axi_sel", 4),
8698c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_MSDC2, "infra_msdc2",
8708c2ecf20Sopenharmony_ci		"axi_sel", 5),
8718c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_MSDC0_SCK, "infra_msdc0_sck",
8728c2ecf20Sopenharmony_ci		"msdc50_0_sel", 6),
8738c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_DVFSRC, "infra_dvfsrc",
8748c2ecf20Sopenharmony_ci		"f_f26m_ck", 7),
8758c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_GCPU, "infra_gcpu",
8768c2ecf20Sopenharmony_ci		"axi_sel", 8),
8778c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_TRNG, "infra_trng",
8788c2ecf20Sopenharmony_ci		"axi_sel", 9),
8798c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_AUXADC, "infra_auxadc",
8808c2ecf20Sopenharmony_ci		"f_f26m_ck", 10),
8818c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_CPUM, "infra_cpum",
8828c2ecf20Sopenharmony_ci		"axi_sel", 11),
8838c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_CCIF1_AP, "infra_ccif1_ap",
8848c2ecf20Sopenharmony_ci		"axi_sel", 12),
8858c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_CCIF1_MD, "infra_ccif1_md",
8868c2ecf20Sopenharmony_ci		"axi_sel", 13),
8878c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_AUXADC_MD, "infra_auxadc_md",
8888c2ecf20Sopenharmony_ci		"f_f26m_ck", 14),
8898c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_MSDC1_SCK, "infra_msdc1_sck",
8908c2ecf20Sopenharmony_ci		"msdc30_1_sel", 16),
8918c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_MSDC2_SCK, "infra_msdc2_sck",
8928c2ecf20Sopenharmony_ci		"msdc30_2_sel", 17),
8938c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_AP_DMA, "infra_apdma",
8948c2ecf20Sopenharmony_ci		"axi_sel", 18),
8958c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_XIU, "infra_xiu",
8968c2ecf20Sopenharmony_ci		"axi_sel", 19),
8978c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_DEVICE_APC, "infra_device_apc",
8988c2ecf20Sopenharmony_ci		"axi_sel", 20),
8998c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_CCIF_AP, "infra_ccif_ap",
9008c2ecf20Sopenharmony_ci		"axi_sel", 23),
9018c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_DEBUGSYS, "infra_debugsys",
9028c2ecf20Sopenharmony_ci		"axi_sel", 24),
9038c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_AUDIO, "infra_audio",
9048c2ecf20Sopenharmony_ci		"axi_sel", 25),
9058c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_CCIF_MD, "infra_ccif_md",
9068c2ecf20Sopenharmony_ci		"axi_sel", 26),
9078c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_DXCC_SEC_CORE, "infra_dxcc_sec_core",
9088c2ecf20Sopenharmony_ci		"dxcc_sel", 27),
9098c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_DXCC_AO, "infra_dxcc_ao",
9108c2ecf20Sopenharmony_ci		"dxcc_sel", 28),
9118c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_DEVMPU_BCLK, "infra_devmpu_bclk",
9128c2ecf20Sopenharmony_ci		"axi_sel", 30),
9138c2ecf20Sopenharmony_ci	GATE_INFRA1(CLK_INFRA_DRAMC_F26M, "infra_dramc_f26m",
9148c2ecf20Sopenharmony_ci		"f_f26m_ck", 31),
9158c2ecf20Sopenharmony_ci	/* INFRA2 */
9168c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_IRTX, "infra_irtx",
9178c2ecf20Sopenharmony_ci		"f_f26m_ck", 0),
9188c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_USB, "infra_usb",
9198c2ecf20Sopenharmony_ci		"usb_top_sel", 1),
9208c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_DISP_PWM, "infra_disppwm",
9218c2ecf20Sopenharmony_ci		"axi_sel", 2),
9228c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_CLDMA_BCLK, "infra_cldma_bclk",
9238c2ecf20Sopenharmony_ci		"axi_sel", 3),
9248c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_AUDIO_26M_BCLK, "infra_audio_26m_bclk",
9258c2ecf20Sopenharmony_ci		"f_f26m_ck", 4),
9268c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_SPI1, "infra_spi1",
9278c2ecf20Sopenharmony_ci		"spi_sel", 6),
9288c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_I2C4, "infra_i2c4",
9298c2ecf20Sopenharmony_ci		"i2c_sel", 7),
9308c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_MODEM_TEMP_SHARE, "infra_md_tmp_share",
9318c2ecf20Sopenharmony_ci		"f_f26m_ck", 8),
9328c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_SPI2, "infra_spi2",
9338c2ecf20Sopenharmony_ci		"spi_sel", 9),
9348c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_SPI3, "infra_spi3",
9358c2ecf20Sopenharmony_ci		"spi_sel", 10),
9368c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_UNIPRO_SCK, "infra_unipro_sck",
9378c2ecf20Sopenharmony_ci		"ssusb_top_xhci_sel", 11),
9388c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_UNIPRO_TICK, "infra_unipro_tick",
9398c2ecf20Sopenharmony_ci		"fufs_sel", 12),
9408c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_UFS_MP_SAP_BCLK, "infra_ufs_mp_sap_bck",
9418c2ecf20Sopenharmony_ci		"fufs_sel", 13),
9428c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_MD32_BCLK, "infra_md32_bclk",
9438c2ecf20Sopenharmony_ci		"axi_sel", 14),
9448c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_UNIPRO_MBIST, "infra_unipro_mbist",
9458c2ecf20Sopenharmony_ci		"axi_sel", 16),
9468c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_I2C5, "infra_i2c5",
9478c2ecf20Sopenharmony_ci		"i2c_sel", 18),
9488c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_I2C5_ARBITER, "infra_i2c5_arbiter",
9498c2ecf20Sopenharmony_ci		"i2c_sel", 19),
9508c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_I2C5_IMM, "infra_i2c5_imm",
9518c2ecf20Sopenharmony_ci		"i2c_sel", 20),
9528c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_I2C1_ARBITER, "infra_i2c1_arbiter",
9538c2ecf20Sopenharmony_ci		"i2c_sel", 21),
9548c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_I2C1_IMM, "infra_i2c1_imm",
9558c2ecf20Sopenharmony_ci		"i2c_sel", 22),
9568c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_I2C2_ARBITER, "infra_i2c2_arbiter",
9578c2ecf20Sopenharmony_ci		"i2c_sel", 23),
9588c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_I2C2_IMM, "infra_i2c2_imm",
9598c2ecf20Sopenharmony_ci		"i2c_sel", 24),
9608c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_SPI4, "infra_spi4",
9618c2ecf20Sopenharmony_ci		"spi_sel", 25),
9628c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_SPI5, "infra_spi5",
9638c2ecf20Sopenharmony_ci		"spi_sel", 26),
9648c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_CQ_DMA, "infra_cqdma",
9658c2ecf20Sopenharmony_ci		"axi_sel", 27),
9668c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_UFS, "infra_ufs",
9678c2ecf20Sopenharmony_ci		"fufs_sel", 28),
9688c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_AES_UFSFDE, "infra_aes_ufsfde",
9698c2ecf20Sopenharmony_ci		"faes_ufsfde_sel", 29),
9708c2ecf20Sopenharmony_ci	GATE_INFRA2(CLK_INFRA_UFS_TICK, "infra_ufs_tick",
9718c2ecf20Sopenharmony_ci		"fufs_sel", 30),
9728c2ecf20Sopenharmony_ci	/* INFRA3 */
9738c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_MSDC0_SELF, "infra_msdc0_self",
9748c2ecf20Sopenharmony_ci		"msdc50_0_sel", 0),
9758c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_MSDC1_SELF, "infra_msdc1_self",
9768c2ecf20Sopenharmony_ci		"msdc50_0_sel", 1),
9778c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_MSDC2_SELF, "infra_msdc2_self",
9788c2ecf20Sopenharmony_ci		"msdc50_0_sel", 2),
9798c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_UFS_AXI, "infra_ufs_axi",
9808c2ecf20Sopenharmony_ci		"axi_sel", 5),
9818c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_I2C6, "infra_i2c6",
9828c2ecf20Sopenharmony_ci		"i2c_sel", 6),
9838c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_AP_MSDC0, "infra_ap_msdc0",
9848c2ecf20Sopenharmony_ci		"msdc50_hclk_sel", 7),
9858c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_MD_MSDC0, "infra_md_msdc0",
9868c2ecf20Sopenharmony_ci		"msdc50_hclk_sel", 8),
9878c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_CCIF2_AP, "infra_ccif2_ap",
9888c2ecf20Sopenharmony_ci		"axi_sel", 16),
9898c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_CCIF2_MD, "infra_ccif2_md",
9908c2ecf20Sopenharmony_ci		"axi_sel", 17),
9918c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_CCIF3_AP, "infra_ccif3_ap",
9928c2ecf20Sopenharmony_ci		"axi_sel", 18),
9938c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_CCIF3_MD, "infra_ccif3_md",
9948c2ecf20Sopenharmony_ci		"axi_sel", 19),
9958c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_SEJ_F13M, "infra_sej_f13m",
9968c2ecf20Sopenharmony_ci		"f_f26m_ck", 20),
9978c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_AES_BCLK, "infra_aes_bclk",
9988c2ecf20Sopenharmony_ci		"axi_sel", 21),
9998c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_I2C7, "infra_i2c7",
10008c2ecf20Sopenharmony_ci		"i2c_sel", 22),
10018c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_I2C8, "infra_i2c8",
10028c2ecf20Sopenharmony_ci		"i2c_sel", 23),
10038c2ecf20Sopenharmony_ci	GATE_INFRA3(CLK_INFRA_FBIST2FPC, "infra_fbist2fpc",
10048c2ecf20Sopenharmony_ci		"msdc50_0_sel", 24),
10058c2ecf20Sopenharmony_ci};
10068c2ecf20Sopenharmony_ci
10078c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs peri_cg_regs = {
10088c2ecf20Sopenharmony_ci	.set_ofs = 0x20c,
10098c2ecf20Sopenharmony_ci	.clr_ofs = 0x20c,
10108c2ecf20Sopenharmony_ci	.sta_ofs = 0x20c,
10118c2ecf20Sopenharmony_ci};
10128c2ecf20Sopenharmony_ci
10138c2ecf20Sopenharmony_ci#define GATE_PERI(_id, _name, _parent, _shift)			\
10148c2ecf20Sopenharmony_ci	GATE_MTK(_id, _name, _parent, &peri_cg_regs, _shift,	\
10158c2ecf20Sopenharmony_ci		&mtk_clk_gate_ops_no_setclr_inv)
10168c2ecf20Sopenharmony_ci
10178c2ecf20Sopenharmony_cistatic const struct mtk_gate peri_clks[] = {
10188c2ecf20Sopenharmony_ci	GATE_PERI(CLK_PERI_AXI, "peri_axi", "axi_sel", 31),
10198c2ecf20Sopenharmony_ci};
10208c2ecf20Sopenharmony_ci
10218c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs apmixed_cg_regs = {
10228c2ecf20Sopenharmony_ci	.set_ofs = 0x20,
10238c2ecf20Sopenharmony_ci	.clr_ofs = 0x20,
10248c2ecf20Sopenharmony_ci	.sta_ofs = 0x20,
10258c2ecf20Sopenharmony_ci};
10268c2ecf20Sopenharmony_ci
10278c2ecf20Sopenharmony_ci#define GATE_APMIXED_FLAGS(_id, _name, _parent, _shift, _flags)	\
10288c2ecf20Sopenharmony_ci	GATE_MTK_FLAGS(_id, _name, _parent, &apmixed_cg_regs,		\
10298c2ecf20Sopenharmony_ci		_shift, &mtk_clk_gate_ops_no_setclr_inv, _flags)
10308c2ecf20Sopenharmony_ci
10318c2ecf20Sopenharmony_ci#define GATE_APMIXED(_id, _name, _parent, _shift)	\
10328c2ecf20Sopenharmony_ci	GATE_APMIXED_FLAGS(_id, _name, _parent, _shift,	0)
10338c2ecf20Sopenharmony_ci
10348c2ecf20Sopenharmony_ci/*
10358c2ecf20Sopenharmony_ci * CRITICAL CLOCK:
10368c2ecf20Sopenharmony_ci * apmixed_appll26m is the toppest clock gate of all PLLs.
10378c2ecf20Sopenharmony_ci */
10388c2ecf20Sopenharmony_cistatic const struct mtk_gate apmixed_clks[] = {
10398c2ecf20Sopenharmony_ci	/* AUDIO0 */
10408c2ecf20Sopenharmony_ci	GATE_APMIXED(CLK_APMIXED_SSUSB_26M, "apmixed_ssusb26m",
10418c2ecf20Sopenharmony_ci		"f_f26m_ck", 4),
10428c2ecf20Sopenharmony_ci	GATE_APMIXED_FLAGS(CLK_APMIXED_APPLL_26M, "apmixed_appll26m",
10438c2ecf20Sopenharmony_ci		"f_f26m_ck", 5, CLK_IS_CRITICAL),
10448c2ecf20Sopenharmony_ci	GATE_APMIXED(CLK_APMIXED_MIPIC0_26M, "apmixed_mipic026m",
10458c2ecf20Sopenharmony_ci		"f_f26m_ck", 6),
10468c2ecf20Sopenharmony_ci	GATE_APMIXED(CLK_APMIXED_MDPLLGP_26M, "apmixed_mdpll26m",
10478c2ecf20Sopenharmony_ci		"f_f26m_ck", 7),
10488c2ecf20Sopenharmony_ci	GATE_APMIXED(CLK_APMIXED_MMSYS_26M, "apmixed_mmsys26m",
10498c2ecf20Sopenharmony_ci		"f_f26m_ck", 8),
10508c2ecf20Sopenharmony_ci	GATE_APMIXED(CLK_APMIXED_UFS_26M, "apmixed_ufs26m",
10518c2ecf20Sopenharmony_ci		"f_f26m_ck", 9),
10528c2ecf20Sopenharmony_ci	GATE_APMIXED(CLK_APMIXED_MIPIC1_26M, "apmixed_mipic126m",
10538c2ecf20Sopenharmony_ci		"f_f26m_ck", 11),
10548c2ecf20Sopenharmony_ci	GATE_APMIXED(CLK_APMIXED_MEMPLL_26M, "apmixed_mempll26m",
10558c2ecf20Sopenharmony_ci		"f_f26m_ck", 13),
10568c2ecf20Sopenharmony_ci	GATE_APMIXED(CLK_APMIXED_CLKSQ_LVPLL_26M, "apmixed_lvpll26m",
10578c2ecf20Sopenharmony_ci		"f_f26m_ck", 14),
10588c2ecf20Sopenharmony_ci	GATE_APMIXED(CLK_APMIXED_MIPID0_26M, "apmixed_mipid026m",
10598c2ecf20Sopenharmony_ci		"f_f26m_ck", 16),
10608c2ecf20Sopenharmony_ci	GATE_APMIXED(CLK_APMIXED_MIPID1_26M, "apmixed_mipid126m",
10618c2ecf20Sopenharmony_ci		"f_f26m_ck", 17),
10628c2ecf20Sopenharmony_ci};
10638c2ecf20Sopenharmony_ci
10648c2ecf20Sopenharmony_ci#define MT8183_PLL_FMAX		(3800UL * MHZ)
10658c2ecf20Sopenharmony_ci#define MT8183_PLL_FMIN		(1500UL * MHZ)
10668c2ecf20Sopenharmony_ci
10678c2ecf20Sopenharmony_ci#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags,		\
10688c2ecf20Sopenharmony_ci			_rst_bar_mask, _pcwbits, _pcwibits, _pd_reg,	\
10698c2ecf20Sopenharmony_ci			_pd_shift, _tuner_reg,  _tuner_en_reg,		\
10708c2ecf20Sopenharmony_ci			_tuner_en_bit, _pcw_reg, _pcw_shift,		\
10718c2ecf20Sopenharmony_ci			_pcw_chg_reg, _div_table) {			\
10728c2ecf20Sopenharmony_ci		.id = _id,						\
10738c2ecf20Sopenharmony_ci		.name = _name,						\
10748c2ecf20Sopenharmony_ci		.reg = _reg,						\
10758c2ecf20Sopenharmony_ci		.pwr_reg = _pwr_reg,					\
10768c2ecf20Sopenharmony_ci		.en_mask = _en_mask,					\
10778c2ecf20Sopenharmony_ci		.flags = _flags,					\
10788c2ecf20Sopenharmony_ci		.rst_bar_mask = _rst_bar_mask,				\
10798c2ecf20Sopenharmony_ci		.fmax = MT8183_PLL_FMAX,				\
10808c2ecf20Sopenharmony_ci		.fmin = MT8183_PLL_FMIN,				\
10818c2ecf20Sopenharmony_ci		.pcwbits = _pcwbits,					\
10828c2ecf20Sopenharmony_ci		.pcwibits = _pcwibits,					\
10838c2ecf20Sopenharmony_ci		.pd_reg = _pd_reg,					\
10848c2ecf20Sopenharmony_ci		.pd_shift = _pd_shift,					\
10858c2ecf20Sopenharmony_ci		.tuner_reg = _tuner_reg,				\
10868c2ecf20Sopenharmony_ci		.tuner_en_reg = _tuner_en_reg,				\
10878c2ecf20Sopenharmony_ci		.tuner_en_bit = _tuner_en_bit,				\
10888c2ecf20Sopenharmony_ci		.pcw_reg = _pcw_reg,					\
10898c2ecf20Sopenharmony_ci		.pcw_shift = _pcw_shift,				\
10908c2ecf20Sopenharmony_ci		.pcw_chg_reg = _pcw_chg_reg,				\
10918c2ecf20Sopenharmony_ci		.div_table = _div_table,				\
10928c2ecf20Sopenharmony_ci	}
10938c2ecf20Sopenharmony_ci
10948c2ecf20Sopenharmony_ci#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags,		\
10958c2ecf20Sopenharmony_ci			_rst_bar_mask, _pcwbits, _pcwibits, _pd_reg,	\
10968c2ecf20Sopenharmony_ci			_pd_shift, _tuner_reg, _tuner_en_reg,		\
10978c2ecf20Sopenharmony_ci			_tuner_en_bit, _pcw_reg, _pcw_shift,		\
10988c2ecf20Sopenharmony_ci			_pcw_chg_reg)					\
10998c2ecf20Sopenharmony_ci		PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags,	\
11008c2ecf20Sopenharmony_ci			_rst_bar_mask, _pcwbits, _pcwibits, _pd_reg,	\
11018c2ecf20Sopenharmony_ci			_pd_shift, _tuner_reg, _tuner_en_reg,		\
11028c2ecf20Sopenharmony_ci			_tuner_en_bit, _pcw_reg, _pcw_shift,		\
11038c2ecf20Sopenharmony_ci			_pcw_chg_reg, NULL)
11048c2ecf20Sopenharmony_ci
11058c2ecf20Sopenharmony_cistatic const struct mtk_pll_div_table armpll_div_table[] = {
11068c2ecf20Sopenharmony_ci	{ .div = 0, .freq = MT8183_PLL_FMAX },
11078c2ecf20Sopenharmony_ci	{ .div = 1, .freq = 1500 * MHZ },
11088c2ecf20Sopenharmony_ci	{ .div = 2, .freq = 750 * MHZ },
11098c2ecf20Sopenharmony_ci	{ .div = 3, .freq = 375 * MHZ },
11108c2ecf20Sopenharmony_ci	{ .div = 4, .freq = 187500000 },
11118c2ecf20Sopenharmony_ci	{ } /* sentinel */
11128c2ecf20Sopenharmony_ci};
11138c2ecf20Sopenharmony_ci
11148c2ecf20Sopenharmony_cistatic const struct mtk_pll_div_table mfgpll_div_table[] = {
11158c2ecf20Sopenharmony_ci	{ .div = 0, .freq = MT8183_PLL_FMAX },
11168c2ecf20Sopenharmony_ci	{ .div = 1, .freq = 1600 * MHZ },
11178c2ecf20Sopenharmony_ci	{ .div = 2, .freq = 800 * MHZ },
11188c2ecf20Sopenharmony_ci	{ .div = 3, .freq = 400 * MHZ },
11198c2ecf20Sopenharmony_ci	{ .div = 4, .freq = 200 * MHZ },
11208c2ecf20Sopenharmony_ci	{ } /* sentinel */
11218c2ecf20Sopenharmony_ci};
11228c2ecf20Sopenharmony_ci
11238c2ecf20Sopenharmony_cistatic const struct mtk_pll_data plls[] = {
11248c2ecf20Sopenharmony_ci	PLL_B(CLK_APMIXED_ARMPLL_LL, "armpll_ll", 0x0200, 0x020C, 0x00000001,
11258c2ecf20Sopenharmony_ci		HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0204, 24, 0x0, 0x0, 0,
11268c2ecf20Sopenharmony_ci		0x0204, 0, 0, armpll_div_table),
11278c2ecf20Sopenharmony_ci	PLL_B(CLK_APMIXED_ARMPLL_L, "armpll_l", 0x0210, 0x021C, 0x00000001,
11288c2ecf20Sopenharmony_ci		HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0214, 24, 0x0, 0x0, 0,
11298c2ecf20Sopenharmony_ci		0x0214, 0, 0, armpll_div_table),
11308c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x0290, 0x029C, 0x00000001,
11318c2ecf20Sopenharmony_ci		HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0294, 24, 0x0, 0x0, 0,
11328c2ecf20Sopenharmony_ci		0x0294, 0, 0),
11338c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0220, 0x022C, 0x00000001,
11348c2ecf20Sopenharmony_ci		HAVE_RST_BAR, BIT(24), 22, 8, 0x0224, 24, 0x0, 0x0, 0,
11358c2ecf20Sopenharmony_ci		0x0224, 0, 0),
11368c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0230, 0x023C, 0x00000001,
11378c2ecf20Sopenharmony_ci		HAVE_RST_BAR, BIT(24), 22, 8, 0x0234, 24, 0x0, 0x0, 0,
11388c2ecf20Sopenharmony_ci		0x0234, 0, 0),
11398c2ecf20Sopenharmony_ci	PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0240, 0x024C, 0x00000001,
11408c2ecf20Sopenharmony_ci		0, 0, 22, 8, 0x0244, 24, 0x0, 0x0, 0, 0x0244, 0, 0,
11418c2ecf20Sopenharmony_ci		mfgpll_div_table),
11428c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0250, 0x025C, 0x00000001,
11438c2ecf20Sopenharmony_ci		0, 0, 22, 8, 0x0254, 24, 0x0, 0x0, 0, 0x0254, 0, 0),
11448c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0260, 0x026C, 0x00000001,
11458c2ecf20Sopenharmony_ci		0, 0, 22, 8, 0x0264, 24, 0x0, 0x0, 0, 0x0264, 0, 0),
11468c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0270, 0x027C, 0x00000001,
11478c2ecf20Sopenharmony_ci		HAVE_RST_BAR, BIT(23), 22, 8, 0x0274, 24, 0x0, 0x0, 0,
11488c2ecf20Sopenharmony_ci		0x0274, 0, 0),
11498c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_APLL1, "apll1", 0x02A0, 0x02B0, 0x00000001,
11508c2ecf20Sopenharmony_ci		0, 0, 32, 8, 0x02A0, 1, 0x02A8, 0x0014, 0, 0x02A4, 0, 0x02A0),
11518c2ecf20Sopenharmony_ci	PLL(CLK_APMIXED_APLL2, "apll2", 0x02b4, 0x02c4, 0x00000001,
11528c2ecf20Sopenharmony_ci		0, 0, 32, 8, 0x02B4, 1, 0x02BC, 0x0014, 1, 0x02B8, 0, 0x02B4),
11538c2ecf20Sopenharmony_ci};
11548c2ecf20Sopenharmony_ci
11558c2ecf20Sopenharmony_cistatic int clk_mt8183_apmixed_probe(struct platform_device *pdev)
11568c2ecf20Sopenharmony_ci{
11578c2ecf20Sopenharmony_ci	struct clk_onecell_data *clk_data;
11588c2ecf20Sopenharmony_ci	struct device_node *node = pdev->dev.of_node;
11598c2ecf20Sopenharmony_ci
11608c2ecf20Sopenharmony_ci	clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
11618c2ecf20Sopenharmony_ci
11628c2ecf20Sopenharmony_ci	mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
11638c2ecf20Sopenharmony_ci
11648c2ecf20Sopenharmony_ci	mtk_clk_register_gates(node, apmixed_clks, ARRAY_SIZE(apmixed_clks),
11658c2ecf20Sopenharmony_ci		clk_data);
11668c2ecf20Sopenharmony_ci
11678c2ecf20Sopenharmony_ci	return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
11688c2ecf20Sopenharmony_ci}
11698c2ecf20Sopenharmony_ci
11708c2ecf20Sopenharmony_cistatic struct clk_onecell_data *top_clk_data;
11718c2ecf20Sopenharmony_ci
11728c2ecf20Sopenharmony_cistatic void clk_mt8183_top_init_early(struct device_node *node)
11738c2ecf20Sopenharmony_ci{
11748c2ecf20Sopenharmony_ci	int i;
11758c2ecf20Sopenharmony_ci
11768c2ecf20Sopenharmony_ci	top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
11778c2ecf20Sopenharmony_ci
11788c2ecf20Sopenharmony_ci	for (i = 0; i < CLK_TOP_NR_CLK; i++)
11798c2ecf20Sopenharmony_ci		top_clk_data->clks[i] = ERR_PTR(-EPROBE_DEFER);
11808c2ecf20Sopenharmony_ci
11818c2ecf20Sopenharmony_ci	mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs),
11828c2ecf20Sopenharmony_ci			top_clk_data);
11838c2ecf20Sopenharmony_ci
11848c2ecf20Sopenharmony_ci	of_clk_add_provider(node, of_clk_src_onecell_get, top_clk_data);
11858c2ecf20Sopenharmony_ci}
11868c2ecf20Sopenharmony_ci
11878c2ecf20Sopenharmony_ciCLK_OF_DECLARE_DRIVER(mt8183_topckgen, "mediatek,mt8183-topckgen",
11888c2ecf20Sopenharmony_ci			clk_mt8183_top_init_early);
11898c2ecf20Sopenharmony_ci
11908c2ecf20Sopenharmony_cistatic int clk_mt8183_top_probe(struct platform_device *pdev)
11918c2ecf20Sopenharmony_ci{
11928c2ecf20Sopenharmony_ci	void __iomem *base;
11938c2ecf20Sopenharmony_ci	struct device_node *node = pdev->dev.of_node;
11948c2ecf20Sopenharmony_ci
11958c2ecf20Sopenharmony_ci	base = devm_platform_ioremap_resource(pdev, 0);
11968c2ecf20Sopenharmony_ci	if (IS_ERR(base))
11978c2ecf20Sopenharmony_ci		return PTR_ERR(base);
11988c2ecf20Sopenharmony_ci
11998c2ecf20Sopenharmony_ci	mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
12008c2ecf20Sopenharmony_ci		top_clk_data);
12018c2ecf20Sopenharmony_ci
12028c2ecf20Sopenharmony_ci	mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs),
12038c2ecf20Sopenharmony_ci		top_clk_data);
12048c2ecf20Sopenharmony_ci
12058c2ecf20Sopenharmony_ci	mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);
12068c2ecf20Sopenharmony_ci
12078c2ecf20Sopenharmony_ci	mtk_clk_register_muxes(top_muxes, ARRAY_SIZE(top_muxes),
12088c2ecf20Sopenharmony_ci		node, &mt8183_clk_lock, top_clk_data);
12098c2ecf20Sopenharmony_ci
12108c2ecf20Sopenharmony_ci	mtk_clk_register_composites(top_aud_muxes, ARRAY_SIZE(top_aud_muxes),
12118c2ecf20Sopenharmony_ci		base, &mt8183_clk_lock, top_clk_data);
12128c2ecf20Sopenharmony_ci
12138c2ecf20Sopenharmony_ci	mtk_clk_register_composites(top_aud_divs, ARRAY_SIZE(top_aud_divs),
12148c2ecf20Sopenharmony_ci		base, &mt8183_clk_lock, top_clk_data);
12158c2ecf20Sopenharmony_ci
12168c2ecf20Sopenharmony_ci	mtk_clk_register_gates(node, top_clks, ARRAY_SIZE(top_clks),
12178c2ecf20Sopenharmony_ci		top_clk_data);
12188c2ecf20Sopenharmony_ci
12198c2ecf20Sopenharmony_ci	return of_clk_add_provider(node, of_clk_src_onecell_get, top_clk_data);
12208c2ecf20Sopenharmony_ci}
12218c2ecf20Sopenharmony_ci
12228c2ecf20Sopenharmony_cistatic int clk_mt8183_infra_probe(struct platform_device *pdev)
12238c2ecf20Sopenharmony_ci{
12248c2ecf20Sopenharmony_ci	struct clk_onecell_data *clk_data;
12258c2ecf20Sopenharmony_ci	struct device_node *node = pdev->dev.of_node;
12268c2ecf20Sopenharmony_ci	int r;
12278c2ecf20Sopenharmony_ci
12288c2ecf20Sopenharmony_ci	clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
12298c2ecf20Sopenharmony_ci
12308c2ecf20Sopenharmony_ci	mtk_clk_register_gates(node, infra_clks, ARRAY_SIZE(infra_clks),
12318c2ecf20Sopenharmony_ci		clk_data);
12328c2ecf20Sopenharmony_ci
12338c2ecf20Sopenharmony_ci	r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
12348c2ecf20Sopenharmony_ci	if (r) {
12358c2ecf20Sopenharmony_ci		dev_err(&pdev->dev,
12368c2ecf20Sopenharmony_ci			"%s(): could not register clock provider: %d\n",
12378c2ecf20Sopenharmony_ci			__func__, r);
12388c2ecf20Sopenharmony_ci		return r;
12398c2ecf20Sopenharmony_ci	}
12408c2ecf20Sopenharmony_ci
12418c2ecf20Sopenharmony_ci	mtk_register_reset_controller_set_clr(node, 4, INFRA_RST0_SET_OFFSET);
12428c2ecf20Sopenharmony_ci
12438c2ecf20Sopenharmony_ci	return r;
12448c2ecf20Sopenharmony_ci}
12458c2ecf20Sopenharmony_ci
12468c2ecf20Sopenharmony_cistatic int clk_mt8183_peri_probe(struct platform_device *pdev)
12478c2ecf20Sopenharmony_ci{
12488c2ecf20Sopenharmony_ci	struct clk_onecell_data *clk_data;
12498c2ecf20Sopenharmony_ci	struct device_node *node = pdev->dev.of_node;
12508c2ecf20Sopenharmony_ci
12518c2ecf20Sopenharmony_ci	clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK);
12528c2ecf20Sopenharmony_ci
12538c2ecf20Sopenharmony_ci	mtk_clk_register_gates(node, peri_clks, ARRAY_SIZE(peri_clks),
12548c2ecf20Sopenharmony_ci			       clk_data);
12558c2ecf20Sopenharmony_ci
12568c2ecf20Sopenharmony_ci	return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
12578c2ecf20Sopenharmony_ci}
12588c2ecf20Sopenharmony_ci
12598c2ecf20Sopenharmony_cistatic int clk_mt8183_mcu_probe(struct platform_device *pdev)
12608c2ecf20Sopenharmony_ci{
12618c2ecf20Sopenharmony_ci	struct clk_onecell_data *clk_data;
12628c2ecf20Sopenharmony_ci	struct device_node *node = pdev->dev.of_node;
12638c2ecf20Sopenharmony_ci	void __iomem *base;
12648c2ecf20Sopenharmony_ci
12658c2ecf20Sopenharmony_ci	base = devm_platform_ioremap_resource(pdev, 0);
12668c2ecf20Sopenharmony_ci	if (IS_ERR(base))
12678c2ecf20Sopenharmony_ci		return PTR_ERR(base);
12688c2ecf20Sopenharmony_ci
12698c2ecf20Sopenharmony_ci	clk_data = mtk_alloc_clk_data(CLK_MCU_NR_CLK);
12708c2ecf20Sopenharmony_ci
12718c2ecf20Sopenharmony_ci	mtk_clk_register_composites(mcu_muxes, ARRAY_SIZE(mcu_muxes), base,
12728c2ecf20Sopenharmony_ci			&mt8183_clk_lock, clk_data);
12738c2ecf20Sopenharmony_ci
12748c2ecf20Sopenharmony_ci	return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
12758c2ecf20Sopenharmony_ci}
12768c2ecf20Sopenharmony_ci
12778c2ecf20Sopenharmony_cistatic const struct of_device_id of_match_clk_mt8183[] = {
12788c2ecf20Sopenharmony_ci	{
12798c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt8183-apmixedsys",
12808c2ecf20Sopenharmony_ci		.data = clk_mt8183_apmixed_probe,
12818c2ecf20Sopenharmony_ci	}, {
12828c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt8183-topckgen",
12838c2ecf20Sopenharmony_ci		.data = clk_mt8183_top_probe,
12848c2ecf20Sopenharmony_ci	}, {
12858c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt8183-infracfg",
12868c2ecf20Sopenharmony_ci		.data = clk_mt8183_infra_probe,
12878c2ecf20Sopenharmony_ci	}, {
12888c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt8183-pericfg",
12898c2ecf20Sopenharmony_ci		.data = clk_mt8183_peri_probe,
12908c2ecf20Sopenharmony_ci	}, {
12918c2ecf20Sopenharmony_ci		.compatible = "mediatek,mt8183-mcucfg",
12928c2ecf20Sopenharmony_ci		.data = clk_mt8183_mcu_probe,
12938c2ecf20Sopenharmony_ci	}, {
12948c2ecf20Sopenharmony_ci		/* sentinel */
12958c2ecf20Sopenharmony_ci	}
12968c2ecf20Sopenharmony_ci};
12978c2ecf20Sopenharmony_ci
12988c2ecf20Sopenharmony_cistatic int clk_mt8183_probe(struct platform_device *pdev)
12998c2ecf20Sopenharmony_ci{
13008c2ecf20Sopenharmony_ci	int (*clk_probe)(struct platform_device *pdev);
13018c2ecf20Sopenharmony_ci	int r;
13028c2ecf20Sopenharmony_ci
13038c2ecf20Sopenharmony_ci	clk_probe = of_device_get_match_data(&pdev->dev);
13048c2ecf20Sopenharmony_ci	if (!clk_probe)
13058c2ecf20Sopenharmony_ci		return -EINVAL;
13068c2ecf20Sopenharmony_ci
13078c2ecf20Sopenharmony_ci	r = clk_probe(pdev);
13088c2ecf20Sopenharmony_ci	if (r)
13098c2ecf20Sopenharmony_ci		dev_err(&pdev->dev,
13108c2ecf20Sopenharmony_ci			"could not register clock provider: %s: %d\n",
13118c2ecf20Sopenharmony_ci			pdev->name, r);
13128c2ecf20Sopenharmony_ci
13138c2ecf20Sopenharmony_ci	return r;
13148c2ecf20Sopenharmony_ci}
13158c2ecf20Sopenharmony_ci
13168c2ecf20Sopenharmony_cistatic struct platform_driver clk_mt8183_drv = {
13178c2ecf20Sopenharmony_ci	.probe = clk_mt8183_probe,
13188c2ecf20Sopenharmony_ci	.driver = {
13198c2ecf20Sopenharmony_ci		.name = "clk-mt8183",
13208c2ecf20Sopenharmony_ci		.of_match_table = of_match_clk_mt8183,
13218c2ecf20Sopenharmony_ci	},
13228c2ecf20Sopenharmony_ci};
13238c2ecf20Sopenharmony_ci
13248c2ecf20Sopenharmony_cistatic int __init clk_mt8183_init(void)
13258c2ecf20Sopenharmony_ci{
13268c2ecf20Sopenharmony_ci	return platform_driver_register(&clk_mt8183_drv);
13278c2ecf20Sopenharmony_ci}
13288c2ecf20Sopenharmony_ci
13298c2ecf20Sopenharmony_ciarch_initcall(clk_mt8183_init);
1330