18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2019 MediaTek Inc. 48c2ecf20Sopenharmony_ci * Author: James Liao <jamesjj.liao@mediatek.com> 58c2ecf20Sopenharmony_ci * Fabien Parent <fparent@baylibre.com> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/delay.h> 98c2ecf20Sopenharmony_ci#include <linux/of.h> 108c2ecf20Sopenharmony_ci#include <linux/of_address.h> 118c2ecf20Sopenharmony_ci#include <linux/slab.h> 128c2ecf20Sopenharmony_ci#include <linux/mfd/syscon.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include "clk-mtk.h" 158c2ecf20Sopenharmony_ci#include "clk-gate.h" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <dt-bindings/clock/mt8516-clk.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(mt8516_clk_lock); 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistatic const struct mtk_fixed_clk fixed_clks[] __initconst = { 228c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_CLK_NULL, "clk_null", NULL, 0), 238c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_I2S_INFRA_BCK, "i2s_infra_bck", "clk_null", 26000000), 248c2ecf20Sopenharmony_ci FIXED_CLK(CLK_TOP_MEMPLL, "mempll", "clk26m", 800000000), 258c2ecf20Sopenharmony_ci}; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistatic const struct mtk_fixed_factor top_divs[] __initconst = { 288c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_DMPLL, "dmpll_ck", "mempll", 1, 1), 298c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D2, "mainpll_d2", "mainpll", 1, 2), 308c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D4, "mainpll_d4", "mainpll", 1, 4), 318c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D8, "mainpll_d8", "mainpll", 1, 8), 328c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D16, "mainpll_d16", "mainpll", 1, 16), 338c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D11, "mainpll_d11", "mainpll", 1, 11), 348c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D22, "mainpll_d22", "mainpll", 1, 22), 358c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D3, "mainpll_d3", "mainpll", 1, 3), 368c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D6, "mainpll_d6", "mainpll", 1, 6), 378c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D12, "mainpll_d12", "mainpll", 1, 12), 388c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D5, "mainpll_d5", "mainpll", 1, 5), 398c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D10, "mainpll_d10", "mainpll", 1, 10), 408c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D20, "mainpll_d20", "mainpll", 1, 20), 418c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D40, "mainpll_d40", "mainpll", 1, 40), 428c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D7, "mainpll_d7", "mainpll", 1, 7), 438c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MAINPLL_D14, "mainpll_d14", "mainpll", 1, 14), 448c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll", 1, 2), 458c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D4, "univpll_d4", "univpll", 1, 4), 468c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D8, "univpll_d8", "univpll", 1, 8), 478c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D16, "univpll_d16", "univpll", 1, 16), 488c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll", 1, 3), 498c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D6, "univpll_d6", "univpll", 1, 6), 508c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D12, "univpll_d12", "univpll", 1, 12), 518c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D24, "univpll_d24", "univpll", 1, 24), 528c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll", 1, 5), 538c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_UNIVPLL_D20, "univpll_d20", "univpll", 1, 20), 548c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MMPLL380M, "mmpll380m", "mmpll", 1, 1), 558c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MMPLL_D2, "mmpll_d2", "mmpll", 1, 2), 568c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_MMPLL_200M, "mmpll_200m", "mmpll", 1, 3), 578c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_USB_PHY48M, "usb_phy48m_ck", "univpll", 1, 26), 588c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_APLL1, "apll1_ck", "apll1", 1, 1), 598c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_APLL1_D2, "apll1_d2", "apll1_ck", 1, 2), 608c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_APLL1_D4, "apll1_d4", "rg_apll1_d2_en", 1, 2), 618c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_APLL1_D8, "apll1_d8", "rg_apll1_d4_en", 1, 2), 628c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_APLL2, "apll2_ck", "apll2", 1, 1), 638c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_APLL2_D2, "apll2_d2", "apll2_ck", 1, 2), 648c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "rg_apll2_d2_en", 1, 2), 658c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_APLL2_D8, "apll2_d8", "rg_apll2_d4_en", 1, 2), 668c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_CLK26M, "clk26m_ck", "clk26m", 1, 1), 678c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_CLK26M_D2, "clk26m_d2", "clk26m", 1, 2), 688c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_AHB_INFRA_D2, "ahb_infra_d2", "ahb_infra_sel", 1, 2), 698c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_NFI1X, "nfi1x_ck", "nfi2x_pad_sel", 1, 2), 708c2ecf20Sopenharmony_ci FACTOR(CLK_TOP_ETH_D2, "eth_d2_ck", "eth_sel", 1, 2), 718c2ecf20Sopenharmony_ci}; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_cistatic const char * const uart0_parents[] __initconst = { 748c2ecf20Sopenharmony_ci "clk26m_ck", 758c2ecf20Sopenharmony_ci "univpll_d24" 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistatic const char * const ahb_infra_parents[] __initconst = { 798c2ecf20Sopenharmony_ci "clk_null", 808c2ecf20Sopenharmony_ci "clk26m_ck", 818c2ecf20Sopenharmony_ci "mainpll_d11", 828c2ecf20Sopenharmony_ci "clk_null", 838c2ecf20Sopenharmony_ci "mainpll_d12", 848c2ecf20Sopenharmony_ci "clk_null", 858c2ecf20Sopenharmony_ci "clk_null", 868c2ecf20Sopenharmony_ci "clk_null", 878c2ecf20Sopenharmony_ci "clk_null", 888c2ecf20Sopenharmony_ci "clk_null", 898c2ecf20Sopenharmony_ci "clk_null", 908c2ecf20Sopenharmony_ci "clk_null", 918c2ecf20Sopenharmony_ci "mainpll_d10" 928c2ecf20Sopenharmony_ci}; 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cistatic const char * const msdc0_parents[] __initconst = { 958c2ecf20Sopenharmony_ci "clk26m_ck", 968c2ecf20Sopenharmony_ci "univpll_d6", 978c2ecf20Sopenharmony_ci "mainpll_d8", 988c2ecf20Sopenharmony_ci "univpll_d8", 998c2ecf20Sopenharmony_ci "mainpll_d16", 1008c2ecf20Sopenharmony_ci "mmpll_200m", 1018c2ecf20Sopenharmony_ci "mainpll_d12", 1028c2ecf20Sopenharmony_ci "mmpll_d2" 1038c2ecf20Sopenharmony_ci}; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistatic const char * const uart1_parents[] __initconst = { 1068c2ecf20Sopenharmony_ci "clk26m_ck", 1078c2ecf20Sopenharmony_ci "univpll_d24" 1088c2ecf20Sopenharmony_ci}; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_cistatic const char * const msdc1_parents[] __initconst = { 1118c2ecf20Sopenharmony_ci "clk26m_ck", 1128c2ecf20Sopenharmony_ci "univpll_d6", 1138c2ecf20Sopenharmony_ci "mainpll_d8", 1148c2ecf20Sopenharmony_ci "univpll_d8", 1158c2ecf20Sopenharmony_ci "mainpll_d16", 1168c2ecf20Sopenharmony_ci "mmpll_200m", 1178c2ecf20Sopenharmony_ci "mainpll_d12", 1188c2ecf20Sopenharmony_ci "mmpll_d2" 1198c2ecf20Sopenharmony_ci}; 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_cistatic const char * const pmicspi_parents[] __initconst = { 1228c2ecf20Sopenharmony_ci "univpll_d20", 1238c2ecf20Sopenharmony_ci "usb_phy48m_ck", 1248c2ecf20Sopenharmony_ci "univpll_d16", 1258c2ecf20Sopenharmony_ci "clk26m_ck" 1268c2ecf20Sopenharmony_ci}; 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_cistatic const char * const qaxi_aud26m_parents[] __initconst = { 1298c2ecf20Sopenharmony_ci "clk26m_ck", 1308c2ecf20Sopenharmony_ci "ahb_infra_sel" 1318c2ecf20Sopenharmony_ci}; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_cistatic const char * const aud_intbus_parents[] __initconst = { 1348c2ecf20Sopenharmony_ci "clk_null", 1358c2ecf20Sopenharmony_ci "clk26m_ck", 1368c2ecf20Sopenharmony_ci "mainpll_d22", 1378c2ecf20Sopenharmony_ci "clk_null", 1388c2ecf20Sopenharmony_ci "mainpll_d11" 1398c2ecf20Sopenharmony_ci}; 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_cistatic const char * const nfi2x_pad_parents[] __initconst = { 1428c2ecf20Sopenharmony_ci "clk_null", 1438c2ecf20Sopenharmony_ci "clk_null", 1448c2ecf20Sopenharmony_ci "clk_null", 1458c2ecf20Sopenharmony_ci "clk_null", 1468c2ecf20Sopenharmony_ci "clk_null", 1478c2ecf20Sopenharmony_ci "clk_null", 1488c2ecf20Sopenharmony_ci "clk_null", 1498c2ecf20Sopenharmony_ci "clk_null", 1508c2ecf20Sopenharmony_ci "clk26m_ck", 1518c2ecf20Sopenharmony_ci "clk_null", 1528c2ecf20Sopenharmony_ci "clk_null", 1538c2ecf20Sopenharmony_ci "clk_null", 1548c2ecf20Sopenharmony_ci "clk_null", 1558c2ecf20Sopenharmony_ci "clk_null", 1568c2ecf20Sopenharmony_ci "clk_null", 1578c2ecf20Sopenharmony_ci "clk_null", 1588c2ecf20Sopenharmony_ci "clk_null", 1598c2ecf20Sopenharmony_ci "mainpll_d12", 1608c2ecf20Sopenharmony_ci "mainpll_d8", 1618c2ecf20Sopenharmony_ci "clk_null", 1628c2ecf20Sopenharmony_ci "mainpll_d6", 1638c2ecf20Sopenharmony_ci "clk_null", 1648c2ecf20Sopenharmony_ci "clk_null", 1658c2ecf20Sopenharmony_ci "clk_null", 1668c2ecf20Sopenharmony_ci "clk_null", 1678c2ecf20Sopenharmony_ci "clk_null", 1688c2ecf20Sopenharmony_ci "clk_null", 1698c2ecf20Sopenharmony_ci "clk_null", 1708c2ecf20Sopenharmony_ci "clk_null", 1718c2ecf20Sopenharmony_ci "clk_null", 1728c2ecf20Sopenharmony_ci "clk_null", 1738c2ecf20Sopenharmony_ci "clk_null", 1748c2ecf20Sopenharmony_ci "mainpll_d4", 1758c2ecf20Sopenharmony_ci "clk_null", 1768c2ecf20Sopenharmony_ci "clk_null", 1778c2ecf20Sopenharmony_ci "clk_null", 1788c2ecf20Sopenharmony_ci "clk_null", 1798c2ecf20Sopenharmony_ci "clk_null", 1808c2ecf20Sopenharmony_ci "clk_null", 1818c2ecf20Sopenharmony_ci "clk_null", 1828c2ecf20Sopenharmony_ci "clk_null", 1838c2ecf20Sopenharmony_ci "clk_null", 1848c2ecf20Sopenharmony_ci "clk_null", 1858c2ecf20Sopenharmony_ci "clk_null", 1868c2ecf20Sopenharmony_ci "clk_null", 1878c2ecf20Sopenharmony_ci "clk_null", 1888c2ecf20Sopenharmony_ci "clk_null", 1898c2ecf20Sopenharmony_ci "clk_null", 1908c2ecf20Sopenharmony_ci "clk_null", 1918c2ecf20Sopenharmony_ci "clk_null", 1928c2ecf20Sopenharmony_ci "clk_null", 1938c2ecf20Sopenharmony_ci "clk_null", 1948c2ecf20Sopenharmony_ci "clk_null", 1958c2ecf20Sopenharmony_ci "clk_null", 1968c2ecf20Sopenharmony_ci "clk_null", 1978c2ecf20Sopenharmony_ci "clk_null", 1988c2ecf20Sopenharmony_ci "clk_null", 1998c2ecf20Sopenharmony_ci "clk_null", 2008c2ecf20Sopenharmony_ci "clk_null", 2018c2ecf20Sopenharmony_ci "clk_null", 2028c2ecf20Sopenharmony_ci "clk_null", 2038c2ecf20Sopenharmony_ci "clk_null", 2048c2ecf20Sopenharmony_ci "clk_null", 2058c2ecf20Sopenharmony_ci "clk_null", 2068c2ecf20Sopenharmony_ci "clk_null", 2078c2ecf20Sopenharmony_ci "clk_null", 2088c2ecf20Sopenharmony_ci "clk_null", 2098c2ecf20Sopenharmony_ci "clk_null", 2108c2ecf20Sopenharmony_ci "clk_null", 2118c2ecf20Sopenharmony_ci "clk_null", 2128c2ecf20Sopenharmony_ci "clk_null", 2138c2ecf20Sopenharmony_ci "clk_null", 2148c2ecf20Sopenharmony_ci "clk_null", 2158c2ecf20Sopenharmony_ci "clk_null", 2168c2ecf20Sopenharmony_ci "clk_null", 2178c2ecf20Sopenharmony_ci "clk_null", 2188c2ecf20Sopenharmony_ci "clk_null", 2198c2ecf20Sopenharmony_ci "clk_null", 2208c2ecf20Sopenharmony_ci "clk_null", 2218c2ecf20Sopenharmony_ci "clk_null", 2228c2ecf20Sopenharmony_ci "clk_null", 2238c2ecf20Sopenharmony_ci "mainpll_d10", 2248c2ecf20Sopenharmony_ci "mainpll_d7", 2258c2ecf20Sopenharmony_ci "clk_null", 2268c2ecf20Sopenharmony_ci "mainpll_d5" 2278c2ecf20Sopenharmony_ci}; 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_cistatic const char * const nfi1x_pad_parents[] __initconst = { 2308c2ecf20Sopenharmony_ci "ahb_infra_sel", 2318c2ecf20Sopenharmony_ci "nfi1x_ck" 2328c2ecf20Sopenharmony_ci}; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_cistatic const char * const usb_78m_parents[] __initconst = { 2358c2ecf20Sopenharmony_ci "clk_null", 2368c2ecf20Sopenharmony_ci "clk26m_ck", 2378c2ecf20Sopenharmony_ci "univpll_d16", 2388c2ecf20Sopenharmony_ci "clk_null", 2398c2ecf20Sopenharmony_ci "mainpll_d20" 2408c2ecf20Sopenharmony_ci}; 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_cistatic const char * const spinor_parents[] __initconst = { 2438c2ecf20Sopenharmony_ci "clk26m_d2", 2448c2ecf20Sopenharmony_ci "clk26m_ck", 2458c2ecf20Sopenharmony_ci "mainpll_d40", 2468c2ecf20Sopenharmony_ci "univpll_d24", 2478c2ecf20Sopenharmony_ci "univpll_d20", 2488c2ecf20Sopenharmony_ci "mainpll_d20", 2498c2ecf20Sopenharmony_ci "mainpll_d16", 2508c2ecf20Sopenharmony_ci "univpll_d12" 2518c2ecf20Sopenharmony_ci}; 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_cistatic const char * const msdc2_parents[] __initconst = { 2548c2ecf20Sopenharmony_ci "clk26m_ck", 2558c2ecf20Sopenharmony_ci "univpll_d6", 2568c2ecf20Sopenharmony_ci "mainpll_d8", 2578c2ecf20Sopenharmony_ci "univpll_d8", 2588c2ecf20Sopenharmony_ci "mainpll_d16", 2598c2ecf20Sopenharmony_ci "mmpll_200m", 2608c2ecf20Sopenharmony_ci "mainpll_d12", 2618c2ecf20Sopenharmony_ci "mmpll_d2" 2628c2ecf20Sopenharmony_ci}; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_cistatic const char * const eth_parents[] __initconst = { 2658c2ecf20Sopenharmony_ci "clk26m_ck", 2668c2ecf20Sopenharmony_ci "mainpll_d40", 2678c2ecf20Sopenharmony_ci "univpll_d24", 2688c2ecf20Sopenharmony_ci "univpll_d20", 2698c2ecf20Sopenharmony_ci "mainpll_d20" 2708c2ecf20Sopenharmony_ci}; 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_cistatic const char * const aud1_parents[] __initconst = { 2738c2ecf20Sopenharmony_ci "clk26m_ck", 2748c2ecf20Sopenharmony_ci "apll1_ck" 2758c2ecf20Sopenharmony_ci}; 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_cistatic const char * const aud2_parents[] __initconst = { 2788c2ecf20Sopenharmony_ci "clk26m_ck", 2798c2ecf20Sopenharmony_ci "apll2_ck" 2808c2ecf20Sopenharmony_ci}; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_cistatic const char * const aud_engen1_parents[] __initconst = { 2838c2ecf20Sopenharmony_ci "clk26m_ck", 2848c2ecf20Sopenharmony_ci "rg_apll1_d2_en", 2858c2ecf20Sopenharmony_ci "rg_apll1_d4_en", 2868c2ecf20Sopenharmony_ci "rg_apll1_d8_en" 2878c2ecf20Sopenharmony_ci}; 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_cistatic const char * const aud_engen2_parents[] __initconst = { 2908c2ecf20Sopenharmony_ci "clk26m_ck", 2918c2ecf20Sopenharmony_ci "rg_apll2_d2_en", 2928c2ecf20Sopenharmony_ci "rg_apll2_d4_en", 2938c2ecf20Sopenharmony_ci "rg_apll2_d8_en" 2948c2ecf20Sopenharmony_ci}; 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_cistatic const char * const i2c_parents[] __initconst = { 2978c2ecf20Sopenharmony_ci "clk26m_ck", 2988c2ecf20Sopenharmony_ci "univpll_d20", 2998c2ecf20Sopenharmony_ci "univpll_d16", 3008c2ecf20Sopenharmony_ci "univpll_d12" 3018c2ecf20Sopenharmony_ci}; 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_cistatic const char * const aud_i2s0_m_parents[] __initconst = { 3048c2ecf20Sopenharmony_ci "rg_aud1", 3058c2ecf20Sopenharmony_ci "rg_aud2" 3068c2ecf20Sopenharmony_ci}; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_cistatic const char * const pwm_parents[] __initconst = { 3098c2ecf20Sopenharmony_ci "clk26m_ck", 3108c2ecf20Sopenharmony_ci "univpll_d12" 3118c2ecf20Sopenharmony_ci}; 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_cistatic const char * const spi_parents[] __initconst = { 3148c2ecf20Sopenharmony_ci "clk26m_ck", 3158c2ecf20Sopenharmony_ci "univpll_d12", 3168c2ecf20Sopenharmony_ci "univpll_d8", 3178c2ecf20Sopenharmony_ci "univpll_d6" 3188c2ecf20Sopenharmony_ci}; 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_cistatic const char * const aud_spdifin_parents[] __initconst = { 3218c2ecf20Sopenharmony_ci "clk26m_ck", 3228c2ecf20Sopenharmony_ci "univpll_d2" 3238c2ecf20Sopenharmony_ci}; 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_cistatic const char * const uart2_parents[] __initconst = { 3268c2ecf20Sopenharmony_ci "clk26m_ck", 3278c2ecf20Sopenharmony_ci "univpll_d24" 3288c2ecf20Sopenharmony_ci}; 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_cistatic const char * const bsi_parents[] __initconst = { 3318c2ecf20Sopenharmony_ci "clk26m_ck", 3328c2ecf20Sopenharmony_ci "mainpll_d10", 3338c2ecf20Sopenharmony_ci "mainpll_d12", 3348c2ecf20Sopenharmony_ci "mainpll_d20" 3358c2ecf20Sopenharmony_ci}; 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_cistatic const char * const dbg_atclk_parents[] __initconst = { 3388c2ecf20Sopenharmony_ci "clk_null", 3398c2ecf20Sopenharmony_ci "clk26m_ck", 3408c2ecf20Sopenharmony_ci "mainpll_d5", 3418c2ecf20Sopenharmony_ci "clk_null", 3428c2ecf20Sopenharmony_ci "univpll_d5" 3438c2ecf20Sopenharmony_ci}; 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_cistatic const char * const csw_nfiecc_parents[] __initconst = { 3468c2ecf20Sopenharmony_ci "clk_null", 3478c2ecf20Sopenharmony_ci "mainpll_d7", 3488c2ecf20Sopenharmony_ci "mainpll_d6", 3498c2ecf20Sopenharmony_ci "clk_null", 3508c2ecf20Sopenharmony_ci "mainpll_d5" 3518c2ecf20Sopenharmony_ci}; 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_cistatic const char * const nfiecc_parents[] __initconst = { 3548c2ecf20Sopenharmony_ci "clk_null", 3558c2ecf20Sopenharmony_ci "nfi2x_pad_sel", 3568c2ecf20Sopenharmony_ci "mainpll_d4", 3578c2ecf20Sopenharmony_ci "clk_null", 3588c2ecf20Sopenharmony_ci "csw_nfiecc_sel" 3598c2ecf20Sopenharmony_ci}; 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_cistatic struct mtk_composite top_muxes[] __initdata = { 3628c2ecf20Sopenharmony_ci /* CLK_MUX_SEL0 */ 3638c2ecf20Sopenharmony_ci MUX(CLK_TOP_UART0_SEL, "uart0_sel", uart0_parents, 3648c2ecf20Sopenharmony_ci 0x000, 0, 1), 3658c2ecf20Sopenharmony_ci MUX(CLK_TOP_AHB_INFRA_SEL, "ahb_infra_sel", ahb_infra_parents, 3668c2ecf20Sopenharmony_ci 0x000, 4, 4), 3678c2ecf20Sopenharmony_ci MUX(CLK_TOP_MSDC0_SEL, "msdc0_sel", msdc0_parents, 3688c2ecf20Sopenharmony_ci 0x000, 11, 3), 3698c2ecf20Sopenharmony_ci MUX(CLK_TOP_UART1_SEL, "uart1_sel", uart1_parents, 3708c2ecf20Sopenharmony_ci 0x000, 19, 1), 3718c2ecf20Sopenharmony_ci MUX(CLK_TOP_MSDC1_SEL, "msdc1_sel", msdc1_parents, 3728c2ecf20Sopenharmony_ci 0x000, 20, 3), 3738c2ecf20Sopenharmony_ci MUX(CLK_TOP_PMICSPI_SEL, "pmicspi_sel", pmicspi_parents, 3748c2ecf20Sopenharmony_ci 0x000, 24, 2), 3758c2ecf20Sopenharmony_ci MUX(CLK_TOP_QAXI_AUD26M_SEL, "qaxi_aud26m_sel", qaxi_aud26m_parents, 3768c2ecf20Sopenharmony_ci 0x000, 26, 1), 3778c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD_INTBUS_SEL, "aud_intbus_sel", aud_intbus_parents, 3788c2ecf20Sopenharmony_ci 0x000, 27, 3), 3798c2ecf20Sopenharmony_ci /* CLK_MUX_SEL1 */ 3808c2ecf20Sopenharmony_ci MUX(CLK_TOP_NFI2X_PAD_SEL, "nfi2x_pad_sel", nfi2x_pad_parents, 3818c2ecf20Sopenharmony_ci 0x004, 0, 7), 3828c2ecf20Sopenharmony_ci MUX(CLK_TOP_NFI1X_PAD_SEL, "nfi1x_pad_sel", nfi1x_pad_parents, 3838c2ecf20Sopenharmony_ci 0x004, 7, 1), 3848c2ecf20Sopenharmony_ci MUX(CLK_TOP_USB_78M_SEL, "usb_78m_sel", usb_78m_parents, 3858c2ecf20Sopenharmony_ci 0x004, 20, 3), 3868c2ecf20Sopenharmony_ci /* CLK_MUX_SEL8 */ 3878c2ecf20Sopenharmony_ci MUX(CLK_TOP_SPINOR_SEL, "spinor_sel", spinor_parents, 3888c2ecf20Sopenharmony_ci 0x040, 0, 3), 3898c2ecf20Sopenharmony_ci MUX(CLK_TOP_MSDC2_SEL, "msdc2_sel", msdc2_parents, 3908c2ecf20Sopenharmony_ci 0x040, 3, 3), 3918c2ecf20Sopenharmony_ci MUX(CLK_TOP_ETH_SEL, "eth_sel", eth_parents, 3928c2ecf20Sopenharmony_ci 0x040, 6, 3), 3938c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD1_SEL, "aud1_sel", aud1_parents, 3948c2ecf20Sopenharmony_ci 0x040, 22, 1), 3958c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD2_SEL, "aud2_sel", aud2_parents, 3968c2ecf20Sopenharmony_ci 0x040, 23, 1), 3978c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD_ENGEN1_SEL, "aud_engen1_sel", aud_engen1_parents, 3988c2ecf20Sopenharmony_ci 0x040, 24, 2), 3998c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD_ENGEN2_SEL, "aud_engen2_sel", aud_engen2_parents, 4008c2ecf20Sopenharmony_ci 0x040, 26, 2), 4018c2ecf20Sopenharmony_ci MUX(CLK_TOP_I2C_SEL, "i2c_sel", i2c_parents, 4028c2ecf20Sopenharmony_ci 0x040, 28, 2), 4038c2ecf20Sopenharmony_ci /* CLK_SEL_9 */ 4048c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD_I2S0_M_SEL, "aud_i2s0_m_sel", aud_i2s0_m_parents, 4058c2ecf20Sopenharmony_ci 0x044, 12, 1), 4068c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD_I2S1_M_SEL, "aud_i2s1_m_sel", aud_i2s0_m_parents, 4078c2ecf20Sopenharmony_ci 0x044, 13, 1), 4088c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD_I2S2_M_SEL, "aud_i2s2_m_sel", aud_i2s0_m_parents, 4098c2ecf20Sopenharmony_ci 0x044, 14, 1), 4108c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD_I2S3_M_SEL, "aud_i2s3_m_sel", aud_i2s0_m_parents, 4118c2ecf20Sopenharmony_ci 0x044, 15, 1), 4128c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD_I2S4_M_SEL, "aud_i2s4_m_sel", aud_i2s0_m_parents, 4138c2ecf20Sopenharmony_ci 0x044, 16, 1), 4148c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD_I2S5_M_SEL, "aud_i2s5_m_sel", aud_i2s0_m_parents, 4158c2ecf20Sopenharmony_ci 0x044, 17, 1), 4168c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD_SPDIF_B_SEL, "aud_spdif_b_sel", aud_i2s0_m_parents, 4178c2ecf20Sopenharmony_ci 0x044, 18, 1), 4188c2ecf20Sopenharmony_ci /* CLK_MUX_SEL13 */ 4198c2ecf20Sopenharmony_ci MUX(CLK_TOP_PWM_SEL, "pwm_sel", pwm_parents, 4208c2ecf20Sopenharmony_ci 0x07c, 0, 1), 4218c2ecf20Sopenharmony_ci MUX(CLK_TOP_SPI_SEL, "spi_sel", spi_parents, 4228c2ecf20Sopenharmony_ci 0x07c, 1, 2), 4238c2ecf20Sopenharmony_ci MUX(CLK_TOP_AUD_SPDIFIN_SEL, "aud_spdifin_sel", aud_spdifin_parents, 4248c2ecf20Sopenharmony_ci 0x07c, 3, 1), 4258c2ecf20Sopenharmony_ci MUX(CLK_TOP_UART2_SEL, "uart2_sel", uart2_parents, 4268c2ecf20Sopenharmony_ci 0x07c, 4, 1), 4278c2ecf20Sopenharmony_ci MUX(CLK_TOP_BSI_SEL, "bsi_sel", bsi_parents, 4288c2ecf20Sopenharmony_ci 0x07c, 5, 2), 4298c2ecf20Sopenharmony_ci MUX(CLK_TOP_DBG_ATCLK_SEL, "dbg_atclk_sel", dbg_atclk_parents, 4308c2ecf20Sopenharmony_ci 0x07c, 7, 3), 4318c2ecf20Sopenharmony_ci MUX(CLK_TOP_CSW_NFIECC_SEL, "csw_nfiecc_sel", csw_nfiecc_parents, 4328c2ecf20Sopenharmony_ci 0x07c, 10, 3), 4338c2ecf20Sopenharmony_ci MUX(CLK_TOP_NFIECC_SEL, "nfiecc_sel", nfiecc_parents, 4348c2ecf20Sopenharmony_ci 0x07c, 13, 3), 4358c2ecf20Sopenharmony_ci}; 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_cistatic const char * const ifr_mux1_parents[] __initconst = { 4388c2ecf20Sopenharmony_ci "clk26m_ck", 4398c2ecf20Sopenharmony_ci "armpll", 4408c2ecf20Sopenharmony_ci "univpll", 4418c2ecf20Sopenharmony_ci "mainpll_d2" 4428c2ecf20Sopenharmony_ci}; 4438c2ecf20Sopenharmony_ci 4448c2ecf20Sopenharmony_cistatic const char * const ifr_eth_25m_parents[] __initconst = { 4458c2ecf20Sopenharmony_ci "eth_d2_ck", 4468c2ecf20Sopenharmony_ci "rg_eth" 4478c2ecf20Sopenharmony_ci}; 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_cistatic const char * const ifr_i2c0_parents[] __initconst = { 4508c2ecf20Sopenharmony_ci "ahb_infra_d2", 4518c2ecf20Sopenharmony_ci "rg_i2c" 4528c2ecf20Sopenharmony_ci}; 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_cistatic const struct mtk_composite ifr_muxes[] __initconst = { 4558c2ecf20Sopenharmony_ci MUX(CLK_IFR_MUX1_SEL, "ifr_mux1_sel", ifr_mux1_parents, 0x000, 4568c2ecf20Sopenharmony_ci 2, 2), 4578c2ecf20Sopenharmony_ci MUX(CLK_IFR_ETH_25M_SEL, "ifr_eth_25m_sel", ifr_eth_25m_parents, 0x080, 4588c2ecf20Sopenharmony_ci 0, 1), 4598c2ecf20Sopenharmony_ci MUX(CLK_IFR_I2C0_SEL, "ifr_i2c0_sel", ifr_i2c0_parents, 0x080, 4608c2ecf20Sopenharmony_ci 1, 1), 4618c2ecf20Sopenharmony_ci MUX(CLK_IFR_I2C1_SEL, "ifr_i2c1_sel", ifr_i2c0_parents, 0x080, 4628c2ecf20Sopenharmony_ci 2, 1), 4638c2ecf20Sopenharmony_ci MUX(CLK_IFR_I2C2_SEL, "ifr_i2c2_sel", ifr_i2c0_parents, 0x080, 4648c2ecf20Sopenharmony_ci 3, 1), 4658c2ecf20Sopenharmony_ci}; 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_ci#define DIV_ADJ(_id, _name, _parent, _reg, _shift, _width) { \ 4688c2ecf20Sopenharmony_ci .id = _id, \ 4698c2ecf20Sopenharmony_ci .name = _name, \ 4708c2ecf20Sopenharmony_ci .parent_name = _parent, \ 4718c2ecf20Sopenharmony_ci .div_reg = _reg, \ 4728c2ecf20Sopenharmony_ci .div_shift = _shift, \ 4738c2ecf20Sopenharmony_ci .div_width = _width, \ 4748c2ecf20Sopenharmony_ci} 4758c2ecf20Sopenharmony_ci 4768c2ecf20Sopenharmony_cistatic const struct mtk_clk_divider top_adj_divs[] = { 4778c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_APLL12_CK_DIV0, "apll12_ck_div0", "aud_i2s0_m_sel", 4788c2ecf20Sopenharmony_ci 0x0048, 0, 8), 4798c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_APLL12_CK_DIV1, "apll12_ck_div1", "aud_i2s1_m_sel", 4808c2ecf20Sopenharmony_ci 0x0048, 8, 8), 4818c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_APLL12_CK_DIV2, "apll12_ck_div2", "aud_i2s2_m_sel", 4828c2ecf20Sopenharmony_ci 0x0048, 16, 8), 4838c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_APLL12_CK_DIV3, "apll12_ck_div3", "aud_i2s3_m_sel", 4848c2ecf20Sopenharmony_ci 0x0048, 24, 8), 4858c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_APLL12_CK_DIV4, "apll12_ck_div4", "aud_i2s4_m_sel", 4868c2ecf20Sopenharmony_ci 0x004c, 0, 8), 4878c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_APLL12_CK_DIV4B, "apll12_ck_div4b", "apll12_div4", 4888c2ecf20Sopenharmony_ci 0x004c, 8, 8), 4898c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_APLL12_CK_DIV5, "apll12_ck_div5", "aud_i2s5_m_sel", 4908c2ecf20Sopenharmony_ci 0x004c, 16, 8), 4918c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_APLL12_CK_DIV5B, "apll12_ck_div5b", "apll12_div5", 4928c2ecf20Sopenharmony_ci 0x004c, 24, 8), 4938c2ecf20Sopenharmony_ci DIV_ADJ(CLK_TOP_APLL12_CK_DIV6, "apll12_ck_div6", "aud_spdif_b_sel", 4948c2ecf20Sopenharmony_ci 0x0078, 0, 8), 4958c2ecf20Sopenharmony_ci}; 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs top1_cg_regs = { 4988c2ecf20Sopenharmony_ci .set_ofs = 0x54, 4998c2ecf20Sopenharmony_ci .clr_ofs = 0x84, 5008c2ecf20Sopenharmony_ci .sta_ofs = 0x24, 5018c2ecf20Sopenharmony_ci}; 5028c2ecf20Sopenharmony_ci 5038c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs top2_cg_regs = { 5048c2ecf20Sopenharmony_ci .set_ofs = 0x6c, 5058c2ecf20Sopenharmony_ci .clr_ofs = 0x9c, 5068c2ecf20Sopenharmony_ci .sta_ofs = 0x3c, 5078c2ecf20Sopenharmony_ci}; 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs top3_cg_regs = { 5108c2ecf20Sopenharmony_ci .set_ofs = 0xa0, 5118c2ecf20Sopenharmony_ci .clr_ofs = 0xb0, 5128c2ecf20Sopenharmony_ci .sta_ofs = 0x70, 5138c2ecf20Sopenharmony_ci}; 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs top4_cg_regs = { 5168c2ecf20Sopenharmony_ci .set_ofs = 0xa4, 5178c2ecf20Sopenharmony_ci .clr_ofs = 0xb4, 5188c2ecf20Sopenharmony_ci .sta_ofs = 0x74, 5198c2ecf20Sopenharmony_ci}; 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs top5_cg_regs = { 5228c2ecf20Sopenharmony_ci .set_ofs = 0x44, 5238c2ecf20Sopenharmony_ci .clr_ofs = 0x44, 5248c2ecf20Sopenharmony_ci .sta_ofs = 0x44, 5258c2ecf20Sopenharmony_ci}; 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_ci#define GATE_TOP1(_id, _name, _parent, _shift) { \ 5288c2ecf20Sopenharmony_ci .id = _id, \ 5298c2ecf20Sopenharmony_ci .name = _name, \ 5308c2ecf20Sopenharmony_ci .parent_name = _parent, \ 5318c2ecf20Sopenharmony_ci .regs = &top1_cg_regs, \ 5328c2ecf20Sopenharmony_ci .shift = _shift, \ 5338c2ecf20Sopenharmony_ci .ops = &mtk_clk_gate_ops_setclr, \ 5348c2ecf20Sopenharmony_ci } 5358c2ecf20Sopenharmony_ci 5368c2ecf20Sopenharmony_ci#define GATE_TOP2(_id, _name, _parent, _shift) { \ 5378c2ecf20Sopenharmony_ci .id = _id, \ 5388c2ecf20Sopenharmony_ci .name = _name, \ 5398c2ecf20Sopenharmony_ci .parent_name = _parent, \ 5408c2ecf20Sopenharmony_ci .regs = &top2_cg_regs, \ 5418c2ecf20Sopenharmony_ci .shift = _shift, \ 5428c2ecf20Sopenharmony_ci .ops = &mtk_clk_gate_ops_setclr, \ 5438c2ecf20Sopenharmony_ci } 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_ci#define GATE_TOP2_I(_id, _name, _parent, _shift) { \ 5468c2ecf20Sopenharmony_ci .id = _id, \ 5478c2ecf20Sopenharmony_ci .name = _name, \ 5488c2ecf20Sopenharmony_ci .parent_name = _parent, \ 5498c2ecf20Sopenharmony_ci .regs = &top2_cg_regs, \ 5508c2ecf20Sopenharmony_ci .shift = _shift, \ 5518c2ecf20Sopenharmony_ci .ops = &mtk_clk_gate_ops_setclr_inv, \ 5528c2ecf20Sopenharmony_ci } 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_ci#define GATE_TOP3(_id, _name, _parent, _shift) { \ 5558c2ecf20Sopenharmony_ci .id = _id, \ 5568c2ecf20Sopenharmony_ci .name = _name, \ 5578c2ecf20Sopenharmony_ci .parent_name = _parent, \ 5588c2ecf20Sopenharmony_ci .regs = &top3_cg_regs, \ 5598c2ecf20Sopenharmony_ci .shift = _shift, \ 5608c2ecf20Sopenharmony_ci .ops = &mtk_clk_gate_ops_setclr, \ 5618c2ecf20Sopenharmony_ci } 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_ci#define GATE_TOP4_I(_id, _name, _parent, _shift) { \ 5648c2ecf20Sopenharmony_ci .id = _id, \ 5658c2ecf20Sopenharmony_ci .name = _name, \ 5668c2ecf20Sopenharmony_ci .parent_name = _parent, \ 5678c2ecf20Sopenharmony_ci .regs = &top4_cg_regs, \ 5688c2ecf20Sopenharmony_ci .shift = _shift, \ 5698c2ecf20Sopenharmony_ci .ops = &mtk_clk_gate_ops_setclr_inv, \ 5708c2ecf20Sopenharmony_ci } 5718c2ecf20Sopenharmony_ci 5728c2ecf20Sopenharmony_ci#define GATE_TOP5(_id, _name, _parent, _shift) { \ 5738c2ecf20Sopenharmony_ci .id = _id, \ 5748c2ecf20Sopenharmony_ci .name = _name, \ 5758c2ecf20Sopenharmony_ci .parent_name = _parent, \ 5768c2ecf20Sopenharmony_ci .regs = &top5_cg_regs, \ 5778c2ecf20Sopenharmony_ci .shift = _shift, \ 5788c2ecf20Sopenharmony_ci .ops = &mtk_clk_gate_ops_no_setclr, \ 5798c2ecf20Sopenharmony_ci } 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_cistatic const struct mtk_gate top_clks[] __initconst = { 5828c2ecf20Sopenharmony_ci /* TOP1 */ 5838c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_THEM, "them", "ahb_infra_sel", 1), 5848c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_APDMA, "apdma", "ahb_infra_sel", 2), 5858c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_I2C0, "i2c0", "ifr_i2c0_sel", 3), 5868c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_I2C1, "i2c1", "ifr_i2c1_sel", 4), 5878c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_AUXADC1, "auxadc1", "ahb_infra_sel", 5), 5888c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_NFI, "nfi", "nfi1x_pad_sel", 6), 5898c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_NFIECC, "nfiecc", "rg_nfiecc", 7), 5908c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_DEBUGSYS, "debugsys", "rg_dbg_atclk", 8), 5918c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_PWM, "pwm", "ahb_infra_sel", 9), 5928c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_UART0, "uart0", "uart0_sel", 10), 5938c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_UART1, "uart1", "uart1_sel", 11), 5948c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_BTIF, "btif", "ahb_infra_sel", 12), 5958c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_USB, "usb", "usb_78m", 13), 5968c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_FLASHIF_26M, "flashif_26m", "clk26m_ck", 14), 5978c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_AUXADC2, "auxadc2", "ahb_infra_sel", 15), 5988c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_I2C2, "i2c2", "ifr_i2c2_sel", 16), 5998c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_MSDC0, "msdc0", "msdc0_sel", 17), 6008c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_MSDC1, "msdc1", "msdc1_sel", 18), 6018c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_NFI2X, "nfi2x", "nfi2x_pad_sel", 19), 6028c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_PMICWRAP_AP, "pwrap_ap", "clk26m_ck", 20), 6038c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_SEJ, "sej", "ahb_infra_sel", 21), 6048c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_MEMSLP_DLYER, "memslp_dlyer", "clk26m_ck", 22), 6058c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_SPI, "spi", "spi_sel", 23), 6068c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_APXGPT, "apxgpt", "clk26m_ck", 24), 6078c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_AUDIO, "audio", "clk26m_ck", 25), 6088c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_PMICWRAP_MD, "pwrap_md", "clk26m_ck", 27), 6098c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_PMICWRAP_CONN, "pwrap_conn", "clk26m_ck", 28), 6108c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_PMICWRAP_26M, "pwrap_26m", "clk26m_ck", 29), 6118c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_AUX_ADC, "aux_adc", "clk26m_ck", 30), 6128c2ecf20Sopenharmony_ci GATE_TOP1(CLK_TOP_AUX_TP, "aux_tp", "clk26m_ck", 31), 6138c2ecf20Sopenharmony_ci /* TOP2 */ 6148c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_MSDC2, "msdc2", "ahb_infra_sel", 0), 6158c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_RBIST, "rbist", "univpll_d12", 1), 6168c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_NFI_BUS, "nfi_bus", "ahb_infra_sel", 2), 6178c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_GCE, "gce", "ahb_infra_sel", 4), 6188c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_TRNG, "trng", "ahb_infra_sel", 5), 6198c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_SEJ_13M, "sej_13m", "clk26m_ck", 6), 6208c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_AES, "aes", "ahb_infra_sel", 7), 6218c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_PWM_B, "pwm_b", "rg_pwm_infra", 8), 6228c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_PWM1_FB, "pwm1_fb", "rg_pwm_infra", 9), 6238c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_PWM2_FB, "pwm2_fb", "rg_pwm_infra", 10), 6248c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_PWM3_FB, "pwm3_fb", "rg_pwm_infra", 11), 6258c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_PWM4_FB, "pwm4_fb", "rg_pwm_infra", 12), 6268c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_PWM5_FB, "pwm5_fb", "rg_pwm_infra", 13), 6278c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_USB_1P, "usb_1p", "usb_78m", 14), 6288c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_FLASHIF_FREERUN, "flashif_freerun", "ahb_infra_sel", 6298c2ecf20Sopenharmony_ci 15), 6308c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_66M_ETH, "eth_66m", "ahb_infra_d2", 19), 6318c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_133M_ETH, "eth_133m", "ahb_infra_sel", 20), 6328c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_FETH_25M, "feth_25m", "ifr_eth_25m_sel", 21), 6338c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_FETH_50M, "feth_50m", "rg_eth", 22), 6348c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_FLASHIF_AXI, "flashif_axi", "ahb_infra_sel", 23), 6358c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_USBIF, "usbif", "ahb_infra_sel", 24), 6368c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_UART2, "uart2", "rg_uart2", 25), 6378c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_BSI, "bsi", "ahb_infra_sel", 26), 6388c2ecf20Sopenharmony_ci GATE_TOP2_I(CLK_TOP_MSDC0_INFRA, "msdc0_infra", "msdc0", 28), 6398c2ecf20Sopenharmony_ci GATE_TOP2_I(CLK_TOP_MSDC1_INFRA, "msdc1_infra", "msdc1", 29), 6408c2ecf20Sopenharmony_ci GATE_TOP2_I(CLK_TOP_MSDC2_INFRA, "msdc2_infra", "rg_msdc2", 30), 6418c2ecf20Sopenharmony_ci GATE_TOP2(CLK_TOP_USB_78M, "usb_78m", "usb_78m_sel", 31), 6428c2ecf20Sopenharmony_ci /* TOP3 */ 6438c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_SPINOR, "rg_spinor", "spinor_sel", 0), 6448c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_MSDC2, "rg_msdc2", "msdc2_sel", 1), 6458c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_ETH, "rg_eth", "eth_sel", 2), 6468c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_AUD1, "rg_aud1", "aud1_sel", 8), 6478c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_AUD2, "rg_aud2", "aud2_sel", 9), 6488c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_AUD_ENGEN1, "rg_aud_engen1", "aud_engen1_sel", 10), 6498c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_AUD_ENGEN2, "rg_aud_engen2", "aud_engen2_sel", 11), 6508c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_I2C, "rg_i2c", "i2c_sel", 12), 6518c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_PWM_INFRA, "rg_pwm_infra", "pwm_sel", 13), 6528c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_AUD_SPDIF_IN, "rg_aud_spdif_in", "aud_spdifin_sel", 6538c2ecf20Sopenharmony_ci 14), 6548c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_UART2, "rg_uart2", "uart2_sel", 15), 6558c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_BSI, "rg_bsi", "bsi_sel", 16), 6568c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_DBG_ATCLK, "rg_dbg_atclk", "dbg_atclk_sel", 17), 6578c2ecf20Sopenharmony_ci GATE_TOP3(CLK_TOP_RG_NFIECC, "rg_nfiecc", "nfiecc_sel", 18), 6588c2ecf20Sopenharmony_ci /* TOP4 */ 6598c2ecf20Sopenharmony_ci GATE_TOP4_I(CLK_TOP_RG_APLL1_D2_EN, "rg_apll1_d2_en", "apll1_d2", 8), 6608c2ecf20Sopenharmony_ci GATE_TOP4_I(CLK_TOP_RG_APLL1_D4_EN, "rg_apll1_d4_en", "apll1_d4", 9), 6618c2ecf20Sopenharmony_ci GATE_TOP4_I(CLK_TOP_RG_APLL1_D8_EN, "rg_apll1_d8_en", "apll1_d8", 10), 6628c2ecf20Sopenharmony_ci GATE_TOP4_I(CLK_TOP_RG_APLL2_D2_EN, "rg_apll2_d2_en", "apll2_d2", 11), 6638c2ecf20Sopenharmony_ci GATE_TOP4_I(CLK_TOP_RG_APLL2_D4_EN, "rg_apll2_d4_en", "apll2_d4", 12), 6648c2ecf20Sopenharmony_ci GATE_TOP4_I(CLK_TOP_RG_APLL2_D8_EN, "rg_apll2_d8_en", "apll2_d8", 13), 6658c2ecf20Sopenharmony_ci /* TOP5 */ 6668c2ecf20Sopenharmony_ci GATE_TOP5(CLK_TOP_APLL12_DIV0, "apll12_div0", "apll12_ck_div0", 0), 6678c2ecf20Sopenharmony_ci GATE_TOP5(CLK_TOP_APLL12_DIV1, "apll12_div1", "apll12_ck_div1", 1), 6688c2ecf20Sopenharmony_ci GATE_TOP5(CLK_TOP_APLL12_DIV2, "apll12_div2", "apll12_ck_div2", 2), 6698c2ecf20Sopenharmony_ci GATE_TOP5(CLK_TOP_APLL12_DIV3, "apll12_div3", "apll12_ck_div3", 3), 6708c2ecf20Sopenharmony_ci GATE_TOP5(CLK_TOP_APLL12_DIV4, "apll12_div4", "apll12_ck_div4", 4), 6718c2ecf20Sopenharmony_ci GATE_TOP5(CLK_TOP_APLL12_DIV4B, "apll12_div4b", "apll12_ck_div4b", 5), 6728c2ecf20Sopenharmony_ci GATE_TOP5(CLK_TOP_APLL12_DIV5, "apll12_div5", "apll12_ck_div5", 6), 6738c2ecf20Sopenharmony_ci GATE_TOP5(CLK_TOP_APLL12_DIV5B, "apll12_div5b", "apll12_ck_div5b", 7), 6748c2ecf20Sopenharmony_ci GATE_TOP5(CLK_TOP_APLL12_DIV6, "apll12_div6", "apll12_ck_div6", 8), 6758c2ecf20Sopenharmony_ci}; 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_cistatic void __init mtk_topckgen_init(struct device_node *node) 6788c2ecf20Sopenharmony_ci{ 6798c2ecf20Sopenharmony_ci struct clk_onecell_data *clk_data; 6808c2ecf20Sopenharmony_ci int r; 6818c2ecf20Sopenharmony_ci void __iomem *base; 6828c2ecf20Sopenharmony_ci 6838c2ecf20Sopenharmony_ci base = of_iomap(node, 0); 6848c2ecf20Sopenharmony_ci if (!base) { 6858c2ecf20Sopenharmony_ci pr_err("%s(): ioremap failed\n", __func__); 6868c2ecf20Sopenharmony_ci return; 6878c2ecf20Sopenharmony_ci } 6888c2ecf20Sopenharmony_ci 6898c2ecf20Sopenharmony_ci clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); 6908c2ecf20Sopenharmony_ci 6918c2ecf20Sopenharmony_ci mtk_clk_register_fixed_clks(fixed_clks, ARRAY_SIZE(fixed_clks), 6928c2ecf20Sopenharmony_ci clk_data); 6938c2ecf20Sopenharmony_ci mtk_clk_register_gates(node, top_clks, ARRAY_SIZE(top_clks), clk_data); 6948c2ecf20Sopenharmony_ci 6958c2ecf20Sopenharmony_ci mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data); 6968c2ecf20Sopenharmony_ci mtk_clk_register_composites(top_muxes, ARRAY_SIZE(top_muxes), base, 6978c2ecf20Sopenharmony_ci &mt8516_clk_lock, clk_data); 6988c2ecf20Sopenharmony_ci mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs), 6998c2ecf20Sopenharmony_ci base, &mt8516_clk_lock, clk_data); 7008c2ecf20Sopenharmony_ci 7018c2ecf20Sopenharmony_ci r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 7028c2ecf20Sopenharmony_ci if (r) 7038c2ecf20Sopenharmony_ci pr_err("%s(): could not register clock provider: %d\n", 7048c2ecf20Sopenharmony_ci __func__, r); 7058c2ecf20Sopenharmony_ci} 7068c2ecf20Sopenharmony_ciCLK_OF_DECLARE(mtk_topckgen, "mediatek,mt8516-topckgen", mtk_topckgen_init); 7078c2ecf20Sopenharmony_ci 7088c2ecf20Sopenharmony_cistatic void __init mtk_infracfg_init(struct device_node *node) 7098c2ecf20Sopenharmony_ci{ 7108c2ecf20Sopenharmony_ci struct clk_onecell_data *clk_data; 7118c2ecf20Sopenharmony_ci int r; 7128c2ecf20Sopenharmony_ci void __iomem *base; 7138c2ecf20Sopenharmony_ci 7148c2ecf20Sopenharmony_ci base = of_iomap(node, 0); 7158c2ecf20Sopenharmony_ci if (!base) { 7168c2ecf20Sopenharmony_ci pr_err("%s(): ioremap failed\n", __func__); 7178c2ecf20Sopenharmony_ci return; 7188c2ecf20Sopenharmony_ci } 7198c2ecf20Sopenharmony_ci 7208c2ecf20Sopenharmony_ci clk_data = mtk_alloc_clk_data(CLK_IFR_NR_CLK); 7218c2ecf20Sopenharmony_ci 7228c2ecf20Sopenharmony_ci mtk_clk_register_composites(ifr_muxes, ARRAY_SIZE(ifr_muxes), base, 7238c2ecf20Sopenharmony_ci &mt8516_clk_lock, clk_data); 7248c2ecf20Sopenharmony_ci 7258c2ecf20Sopenharmony_ci r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 7268c2ecf20Sopenharmony_ci if (r) 7278c2ecf20Sopenharmony_ci pr_err("%s(): could not register clock provider: %d\n", 7288c2ecf20Sopenharmony_ci __func__, r); 7298c2ecf20Sopenharmony_ci} 7308c2ecf20Sopenharmony_ciCLK_OF_DECLARE(mtk_infracfg, "mediatek,mt8516-infracfg", mtk_infracfg_init); 7318c2ecf20Sopenharmony_ci 7328c2ecf20Sopenharmony_ci#define MT8516_PLL_FMAX (1502UL * MHZ) 7338c2ecf20Sopenharmony_ci 7348c2ecf20Sopenharmony_ci#define CON0_MT8516_RST_BAR BIT(27) 7358c2ecf20Sopenharmony_ci 7368c2ecf20Sopenharmony_ci#define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 7378c2ecf20Sopenharmony_ci _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 7388c2ecf20Sopenharmony_ci _pcw_shift, _div_table) { \ 7398c2ecf20Sopenharmony_ci .id = _id, \ 7408c2ecf20Sopenharmony_ci .name = _name, \ 7418c2ecf20Sopenharmony_ci .reg = _reg, \ 7428c2ecf20Sopenharmony_ci .pwr_reg = _pwr_reg, \ 7438c2ecf20Sopenharmony_ci .en_mask = _en_mask, \ 7448c2ecf20Sopenharmony_ci .flags = _flags, \ 7458c2ecf20Sopenharmony_ci .rst_bar_mask = CON0_MT8516_RST_BAR, \ 7468c2ecf20Sopenharmony_ci .fmax = MT8516_PLL_FMAX, \ 7478c2ecf20Sopenharmony_ci .pcwbits = _pcwbits, \ 7488c2ecf20Sopenharmony_ci .pd_reg = _pd_reg, \ 7498c2ecf20Sopenharmony_ci .pd_shift = _pd_shift, \ 7508c2ecf20Sopenharmony_ci .tuner_reg = _tuner_reg, \ 7518c2ecf20Sopenharmony_ci .pcw_reg = _pcw_reg, \ 7528c2ecf20Sopenharmony_ci .pcw_shift = _pcw_shift, \ 7538c2ecf20Sopenharmony_ci .div_table = _div_table, \ 7548c2ecf20Sopenharmony_ci } 7558c2ecf20Sopenharmony_ci 7568c2ecf20Sopenharmony_ci#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 7578c2ecf20Sopenharmony_ci _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 7588c2ecf20Sopenharmony_ci _pcw_shift) \ 7598c2ecf20Sopenharmony_ci PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 7608c2ecf20Sopenharmony_ci _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, \ 7618c2ecf20Sopenharmony_ci NULL) 7628c2ecf20Sopenharmony_ci 7638c2ecf20Sopenharmony_cistatic const struct mtk_pll_div_table mmpll_div_table[] = { 7648c2ecf20Sopenharmony_ci { .div = 0, .freq = MT8516_PLL_FMAX }, 7658c2ecf20Sopenharmony_ci { .div = 1, .freq = 1000000000 }, 7668c2ecf20Sopenharmony_ci { .div = 2, .freq = 604500000 }, 7678c2ecf20Sopenharmony_ci { .div = 3, .freq = 253500000 }, 7688c2ecf20Sopenharmony_ci { .div = 4, .freq = 126750000 }, 7698c2ecf20Sopenharmony_ci { } /* sentinel */ 7708c2ecf20Sopenharmony_ci}; 7718c2ecf20Sopenharmony_ci 7728c2ecf20Sopenharmony_cistatic const struct mtk_pll_data plls[] = { 7738c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0x00000001, 0, 7748c2ecf20Sopenharmony_ci 21, 0x0104, 24, 0, 0x0104, 0), 7758c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0x00000001, 7768c2ecf20Sopenharmony_ci HAVE_RST_BAR, 21, 0x0124, 24, 0, 0x0124, 0), 7778c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x30000001, 7788c2ecf20Sopenharmony_ci HAVE_RST_BAR, 7, 0x0144, 24, 0, 0x0144, 0), 7798c2ecf20Sopenharmony_ci PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0x00000001, 0, 7808c2ecf20Sopenharmony_ci 21, 0x0164, 24, 0, 0x0164, 0, mmpll_div_table), 7818c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0x00000001, 0, 7828c2ecf20Sopenharmony_ci 31, 0x0180, 1, 0x0194, 0x0184, 0), 7838c2ecf20Sopenharmony_ci PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0x00000001, 0, 7848c2ecf20Sopenharmony_ci 31, 0x01A0, 1, 0x01B4, 0x01A4, 0), 7858c2ecf20Sopenharmony_ci}; 7868c2ecf20Sopenharmony_ci 7878c2ecf20Sopenharmony_cistatic void __init mtk_apmixedsys_init(struct device_node *node) 7888c2ecf20Sopenharmony_ci{ 7898c2ecf20Sopenharmony_ci struct clk_onecell_data *clk_data; 7908c2ecf20Sopenharmony_ci void __iomem *base; 7918c2ecf20Sopenharmony_ci int r; 7928c2ecf20Sopenharmony_ci 7938c2ecf20Sopenharmony_ci base = of_iomap(node, 0); 7948c2ecf20Sopenharmony_ci if (!base) { 7958c2ecf20Sopenharmony_ci pr_err("%s(): ioremap failed\n", __func__); 7968c2ecf20Sopenharmony_ci return; 7978c2ecf20Sopenharmony_ci } 7988c2ecf20Sopenharmony_ci 7998c2ecf20Sopenharmony_ci clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 8008c2ecf20Sopenharmony_ci 8018c2ecf20Sopenharmony_ci mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 8028c2ecf20Sopenharmony_ci 8038c2ecf20Sopenharmony_ci r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 8048c2ecf20Sopenharmony_ci if (r) 8058c2ecf20Sopenharmony_ci pr_err("%s(): could not register clock provider: %d\n", 8068c2ecf20Sopenharmony_ci __func__, r); 8078c2ecf20Sopenharmony_ci 8088c2ecf20Sopenharmony_ci} 8098c2ecf20Sopenharmony_ciCLK_OF_DECLARE(mtk_apmixedsys, "mediatek,mt8516-apmixedsys", 8108c2ecf20Sopenharmony_ci mtk_apmixedsys_init); 811