1c19df961SChun-Jie Chen // SPDX-License-Identifier: GPL-2.0-only 2c19df961SChun-Jie Chen // 3c19df961SChun-Jie Chen // Copyright (c) 2022 MediaTek Inc. 4c19df961SChun-Jie Chen // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com> 5c19df961SChun-Jie Chen 6c19df961SChun-Jie Chen #include <linux/clk-provider.h> 7c19df961SChun-Jie Chen #include <linux/platform_device.h> 8c19df961SChun-Jie Chen #include <dt-bindings/clock/mt8186-clk.h> 9c19df961SChun-Jie Chen 10c19df961SChun-Jie Chen #include "clk-mtk.h" 11c19df961SChun-Jie Chen #include "clk-mux.h" 12c19df961SChun-Jie Chen 13c19df961SChun-Jie Chen static DEFINE_SPINLOCK(mt8186_clk_lock); 14c19df961SChun-Jie Chen 15c19df961SChun-Jie Chen static const struct mtk_fixed_clk top_fixed_clks[] = { 16c19df961SChun-Jie Chen FIXED_CLK(CLK_TOP_ULPOSC1, "ulposc1", NULL, 250000000), 17c19df961SChun-Jie Chen FIXED_CLK(CLK_TOP_466M_FMEM, "hd_466m_fmem_ck", NULL, 466000000), 18c19df961SChun-Jie Chen FIXED_CLK(CLK_TOP_MPLL, "mpll", NULL, 208000000), 19c19df961SChun-Jie Chen }; 20c19df961SChun-Jie Chen 21c19df961SChun-Jie Chen static const struct mtk_fixed_factor top_divs[] = { 22295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_MAINPLL_D2, "mainpll_d2", "mainpll", 1, 2, 0), 23295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_MAINPLL_D2_D2, "mainpll_d2_d2", "mainpll_d2", 1, 2, 0), 24295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_MAINPLL_D2_D4, "mainpll_d2_d4", "mainpll_d2", 1, 4, 0), 25295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_MAINPLL_D2_D16, "mainpll_d2_d16", "mainpll_d2", 1, 16, 0), 26295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_MAINPLL_D3, "mainpll_d3", "mainpll", 1, 3, 0), 27295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_MAINPLL_D3_D2, "mainpll_d3_d2", "mainpll_d3", 1, 2, 0), 28295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_MAINPLL_D3_D4, "mainpll_d3_d4", "mainpll_d3", 1, 4, 0), 29295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_MAINPLL_D5, "mainpll_d5", "mainpll", 1, 5, 0), 30295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_MAINPLL_D5_D2, "mainpll_d5_d2", "mainpll_d5", 1, 2, 0), 31295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_MAINPLL_D5_D4, "mainpll_d5_d4", "mainpll_d5", 1, 4, 0), 32295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_MAINPLL_D7, "mainpll_d7", "mainpll", 1, 7, 0), 33295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_MAINPLL_D7_D2, "mainpll_d7_d2", "mainpll_d7", 1, 2, 0), 34295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_MAINPLL_D7_D4, "mainpll_d7_d4", "mainpll_d7", 1, 4, 0), 35295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL, "univpll", "univ2pll", 1, 2, 0), 36295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll", 1, 2, 0), 37295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_D2_D2, "univpll_d2_d2", "univpll_d2", 1, 2, 0), 38295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_D2_D4, "univpll_d2_d4", "univpll_d2", 1, 4, 0), 39295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll", 1, 3, 0), 40295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_D3_D2, "univpll_d3_d2", "univpll_d3", 1, 2, 0), 41295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_D3_D4, "univpll_d3_d4", "univpll_d3", 1, 4, 0), 42295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_D3_D8, "univpll_d3_d8", "univpll_d3", 1, 8, 0), 43295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_D3_D32, "univpll_d3_d32", "univpll_d3", 1, 32, 0), 44295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll", 1, 5, 0), 45295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_D5_D2, "univpll_d5_d2", "univpll_d5", 1, 2, 0), 46295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_D5_D4, "univpll_d5_d4", "univpll_d5", 1, 4, 0), 47295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_D7, "univpll_d7", "univpll", 1, 7, 0), 48295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_192M, "univpll_192m", "univ2pll", 1, 13, 0), 49295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_192M_D4, "univpll_192m_d4", "univpll_192m", 1, 4, 0), 50295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_192M_D8, "univpll_192m_d8", "univpll_192m", 1, 8, 0), 51295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_192M_D16, "univpll_192m_d16", "univpll_192m", 1, 16, 0), 52295de9d0SAngeloGioacchino Del Regno FACTOR_FLAGS(CLK_TOP_UNIVPLL_192M_D32, "univpll_192m_d32", "univpll_192m", 1, 32, 0), 53c19df961SChun-Jie Chen FACTOR(CLK_TOP_APLL1_D2, "apll1_d2", "apll1", 1, 2), 54c19df961SChun-Jie Chen FACTOR(CLK_TOP_APLL1_D4, "apll1_d4", "apll1", 1, 4), 55c19df961SChun-Jie Chen FACTOR(CLK_TOP_APLL1_D8, "apll1_d8", "apll1", 1, 8), 56c19df961SChun-Jie Chen FACTOR(CLK_TOP_APLL2_D2, "apll2_d2", "apll2", 1, 2), 57c19df961SChun-Jie Chen FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "apll2", 1, 4), 58c19df961SChun-Jie Chen FACTOR(CLK_TOP_APLL2_D8, "apll2_d8", "apll2", 1, 8), 59c19df961SChun-Jie Chen FACTOR(CLK_TOP_MMPLL_D2, "mmpll_d2", "mmpll", 1, 2), 60c19df961SChun-Jie Chen FACTOR(CLK_TOP_TVDPLL_D2, "tvdpll_d2", "tvdpll", 1, 2), 61c19df961SChun-Jie Chen FACTOR(CLK_TOP_TVDPLL_D4, "tvdpll_d4", "tvdpll", 1, 4), 62c19df961SChun-Jie Chen FACTOR(CLK_TOP_TVDPLL_D8, "tvdpll_d8", "tvdpll", 1, 8), 63c19df961SChun-Jie Chen FACTOR(CLK_TOP_TVDPLL_D16, "tvdpll_d16", "tvdpll", 1, 16), 64c19df961SChun-Jie Chen FACTOR(CLK_TOP_TVDPLL_D32, "tvdpll_d32", "tvdpll", 1, 32), 65c19df961SChun-Jie Chen FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll", 1, 2), 66c19df961SChun-Jie Chen FACTOR(CLK_TOP_ULPOSC1_D2, "ulposc1_d2", "ulposc1", 1, 2), 67c19df961SChun-Jie Chen FACTOR(CLK_TOP_ULPOSC1_D4, "ulposc1_d4", "ulposc1", 1, 4), 68c19df961SChun-Jie Chen FACTOR(CLK_TOP_ULPOSC1_D8, "ulposc1_d8", "ulposc1", 1, 8), 69c19df961SChun-Jie Chen FACTOR(CLK_TOP_ULPOSC1_D10, "ulposc1_d10", "ulposc1", 1, 10), 70c19df961SChun-Jie Chen FACTOR(CLK_TOP_ULPOSC1_D16, "ulposc1_d16", "ulposc1", 1, 16), 71c19df961SChun-Jie Chen FACTOR(CLK_TOP_ULPOSC1_D32, "ulposc1_d32", "ulposc1", 1, 32), 72c19df961SChun-Jie Chen FACTOR(CLK_TOP_ADSPPLL_D2, "adsppll_d2", "adsppll", 1, 2), 73c19df961SChun-Jie Chen FACTOR(CLK_TOP_ADSPPLL_D4, "adsppll_d4", "adsppll", 1, 4), 74c19df961SChun-Jie Chen FACTOR(CLK_TOP_ADSPPLL_D8, "adsppll_d8", "adsppll", 1, 8), 75c19df961SChun-Jie Chen FACTOR(CLK_TOP_NNAPLL_D2, "nnapll_d2", "nnapll", 1, 2), 76c19df961SChun-Jie Chen FACTOR(CLK_TOP_NNAPLL_D4, "nnapll_d4", "nnapll", 1, 4), 77c19df961SChun-Jie Chen FACTOR(CLK_TOP_NNAPLL_D8, "nnapll_d8", "nnapll", 1, 8), 78c19df961SChun-Jie Chen FACTOR(CLK_TOP_NNA2PLL_D2, "nna2pll_d2", "nna2pll", 1, 2), 79c19df961SChun-Jie Chen FACTOR(CLK_TOP_NNA2PLL_D4, "nna2pll_d4", "nna2pll", 1, 4), 80c19df961SChun-Jie Chen FACTOR(CLK_TOP_NNA2PLL_D8, "nna2pll_d8", "nna2pll", 1, 8), 81c19df961SChun-Jie Chen FACTOR(CLK_TOP_F_BIST2FPC, "f_bist2fpc_ck", "univpll_d3_d2", 1, 1), 82c19df961SChun-Jie Chen }; 83c19df961SChun-Jie Chen 84c19df961SChun-Jie Chen static const char * const axi_parents[] = { 85c19df961SChun-Jie Chen "clk26m", 86c19df961SChun-Jie Chen "mainpll_d7", 87c19df961SChun-Jie Chen "mainpll_d2_d4", 88c19df961SChun-Jie Chen "univpll_d7" 89c19df961SChun-Jie Chen }; 90c19df961SChun-Jie Chen 91c19df961SChun-Jie Chen static const char * const scp_parents[] = { 92c19df961SChun-Jie Chen "clk26m", 93c19df961SChun-Jie Chen "mainpll_d2_d4", 94c19df961SChun-Jie Chen "mainpll_d5", 95c19df961SChun-Jie Chen "mainpll_d2_d2", 96c19df961SChun-Jie Chen "mainpll_d3", 97c19df961SChun-Jie Chen "univpll_d3" 98c19df961SChun-Jie Chen }; 99c19df961SChun-Jie Chen 100c19df961SChun-Jie Chen static const char * const mfg_parents[] = { 101c19df961SChun-Jie Chen "clk26m", 102c19df961SChun-Jie Chen "mfgpll", 103c19df961SChun-Jie Chen "mainpll_d3", 104c19df961SChun-Jie Chen "mainpll_d5" 105c19df961SChun-Jie Chen }; 106c19df961SChun-Jie Chen 107c19df961SChun-Jie Chen static const char * const camtg_parents[] = { 108c19df961SChun-Jie Chen "clk26m", 109c19df961SChun-Jie Chen "univpll_192m_d8", 110c19df961SChun-Jie Chen "univpll_d3_d8", 111c19df961SChun-Jie Chen "univpll_192m_d4", 112c19df961SChun-Jie Chen "univpll_d3_d32", 113c19df961SChun-Jie Chen "univpll_192m_d16", 114c19df961SChun-Jie Chen "univpll_192m_d32" 115c19df961SChun-Jie Chen }; 116c19df961SChun-Jie Chen 117c19df961SChun-Jie Chen static const char * const uart_parents[] = { 118c19df961SChun-Jie Chen "clk26m", 119c19df961SChun-Jie Chen "univpll_d3_d8" 120c19df961SChun-Jie Chen }; 121c19df961SChun-Jie Chen 122c19df961SChun-Jie Chen static const char * const spi_parents[] = { 123c19df961SChun-Jie Chen "clk26m", 124c19df961SChun-Jie Chen "mainpll_d5_d4", 125c19df961SChun-Jie Chen "mainpll_d3_d4", 126c19df961SChun-Jie Chen "mainpll_d5_d2", 127c19df961SChun-Jie Chen "mainpll_d2_d4", 128c19df961SChun-Jie Chen "mainpll_d7", 129c19df961SChun-Jie Chen "mainpll_d3_d2", 130c19df961SChun-Jie Chen "mainpll_d5" 131c19df961SChun-Jie Chen }; 132c19df961SChun-Jie Chen 133c19df961SChun-Jie Chen static const char * const msdc5hclk_parents[] = { 134c19df961SChun-Jie Chen "clk26m", 135c19df961SChun-Jie Chen "mainpll_d2_d2", 136c19df961SChun-Jie Chen "mainpll_d7", 137c19df961SChun-Jie Chen "mainpll_d3_d2" 138c19df961SChun-Jie Chen }; 139c19df961SChun-Jie Chen 140c19df961SChun-Jie Chen static const char * const msdc50_0_parents[] = { 141c19df961SChun-Jie Chen "clk26m", 142c19df961SChun-Jie Chen "msdcpll", 143c19df961SChun-Jie Chen "univpll_d3", 144c19df961SChun-Jie Chen "msdcpll_d2", 145c19df961SChun-Jie Chen "mainpll_d7", 146c19df961SChun-Jie Chen "mainpll_d3_d2", 147c19df961SChun-Jie Chen "univpll_d2_d2" 148c19df961SChun-Jie Chen }; 149c19df961SChun-Jie Chen 150c19df961SChun-Jie Chen static const char * const msdc30_1_parents[] = { 151c19df961SChun-Jie Chen "clk26m", 152c19df961SChun-Jie Chen "msdcpll_d2", 153c19df961SChun-Jie Chen "univpll_d3_d2", 154c19df961SChun-Jie Chen "mainpll_d3_d2", 155c19df961SChun-Jie Chen "mainpll_d7" 156c19df961SChun-Jie Chen }; 157c19df961SChun-Jie Chen 158c19df961SChun-Jie Chen static const char * const audio_parents[] = { 159c19df961SChun-Jie Chen "clk26m", 160c19df961SChun-Jie Chen "mainpll_d5_d4", 161c19df961SChun-Jie Chen "mainpll_d7_d4", 162c19df961SChun-Jie Chen "mainpll_d2_d16" 163c19df961SChun-Jie Chen }; 164c19df961SChun-Jie Chen 165c19df961SChun-Jie Chen static const char * const aud_intbus_parents[] = { 166c19df961SChun-Jie Chen "clk26m", 167c19df961SChun-Jie Chen "mainpll_d2_d4", 168c19df961SChun-Jie Chen "mainpll_d7_d2" 169c19df961SChun-Jie Chen }; 170c19df961SChun-Jie Chen 171c19df961SChun-Jie Chen static const char * const aud_1_parents[] = { 172c19df961SChun-Jie Chen "clk26m", 173c19df961SChun-Jie Chen "apll1" 174c19df961SChun-Jie Chen }; 175c19df961SChun-Jie Chen 176c19df961SChun-Jie Chen static const char * const aud_2_parents[] = { 177c19df961SChun-Jie Chen "clk26m", 178c19df961SChun-Jie Chen "apll2" 179c19df961SChun-Jie Chen }; 180c19df961SChun-Jie Chen 181c19df961SChun-Jie Chen static const char * const aud_engen1_parents[] = { 182c19df961SChun-Jie Chen "clk26m", 183c19df961SChun-Jie Chen "apll1_d2", 184c19df961SChun-Jie Chen "apll1_d4", 185c19df961SChun-Jie Chen "apll1_d8" 186c19df961SChun-Jie Chen }; 187c19df961SChun-Jie Chen 188c19df961SChun-Jie Chen static const char * const aud_engen2_parents[] = { 189c19df961SChun-Jie Chen "clk26m", 190c19df961SChun-Jie Chen "apll2_d2", 191c19df961SChun-Jie Chen "apll2_d4", 192c19df961SChun-Jie Chen "apll2_d8" 193c19df961SChun-Jie Chen }; 194c19df961SChun-Jie Chen 195c19df961SChun-Jie Chen static const char * const disp_pwm_parents[] = { 196c19df961SChun-Jie Chen "clk26m", 197c19df961SChun-Jie Chen "univpll_d5_d2", 198c19df961SChun-Jie Chen "univpll_d3_d4", 199c19df961SChun-Jie Chen "ulposc1_d2", 200c19df961SChun-Jie Chen "ulposc1_d8" 201c19df961SChun-Jie Chen }; 202c19df961SChun-Jie Chen 203c19df961SChun-Jie Chen static const char * const sspm_parents[] = { 204c19df961SChun-Jie Chen "clk26m", 205c19df961SChun-Jie Chen "mainpll_d2_d2", 206c19df961SChun-Jie Chen "mainpll_d3_d2", 207c19df961SChun-Jie Chen "mainpll_d5", 208c19df961SChun-Jie Chen "mainpll_d3" 209c19df961SChun-Jie Chen }; 210c19df961SChun-Jie Chen 211c19df961SChun-Jie Chen static const char * const dxcc_parents[] = { 212c19df961SChun-Jie Chen "clk26m", 213c19df961SChun-Jie Chen "mainpll_d2_d2", 214c19df961SChun-Jie Chen "mainpll_d2_d4" 215c19df961SChun-Jie Chen }; 216c19df961SChun-Jie Chen 217c19df961SChun-Jie Chen static const char * const usb_parents[] = { 218c19df961SChun-Jie Chen "clk26m", 219c19df961SChun-Jie Chen "univpll_d5_d4", 220c19df961SChun-Jie Chen "univpll_d5_d2" 221c19df961SChun-Jie Chen }; 222c19df961SChun-Jie Chen 223c19df961SChun-Jie Chen static const char * const srck_parents[] = { 224c19df961SChun-Jie Chen "clk32k", 225c19df961SChun-Jie Chen "clk26m", 226c19df961SChun-Jie Chen "ulposc1_d10" 227c19df961SChun-Jie Chen }; 228c19df961SChun-Jie Chen 229c19df961SChun-Jie Chen static const char * const spm_parents[] = { 230c19df961SChun-Jie Chen "clk32k", 231c19df961SChun-Jie Chen "ulposc1_d10", 232c19df961SChun-Jie Chen "clk26m", 233c19df961SChun-Jie Chen "mainpll_d7_d2" 234c19df961SChun-Jie Chen }; 235c19df961SChun-Jie Chen 236c19df961SChun-Jie Chen static const char * const i2c_parents[] = { 237c19df961SChun-Jie Chen "clk26m", 238c19df961SChun-Jie Chen "univpll_d5_d4", 239c19df961SChun-Jie Chen "univpll_d3_d4", 240c19df961SChun-Jie Chen "univpll_d5_d2" 241c19df961SChun-Jie Chen }; 242c19df961SChun-Jie Chen 243c19df961SChun-Jie Chen static const char * const pwm_parents[] = { 244c19df961SChun-Jie Chen "clk26m", 245c19df961SChun-Jie Chen "univpll_d3_d8", 246c19df961SChun-Jie Chen "univpll_d3_d4", 247c19df961SChun-Jie Chen "univpll_d2_d4" 248c19df961SChun-Jie Chen }; 249c19df961SChun-Jie Chen 250c19df961SChun-Jie Chen static const char * const seninf_parents[] = { 251c19df961SChun-Jie Chen "clk26m", 252c19df961SChun-Jie Chen "univpll_d2_d4", 253c19df961SChun-Jie Chen "univpll_d2_d2", 254c19df961SChun-Jie Chen "univpll_d3_d2" 255c19df961SChun-Jie Chen }; 256c19df961SChun-Jie Chen 257c19df961SChun-Jie Chen static const char * const aes_msdcfde_parents[] = { 258c19df961SChun-Jie Chen "clk26m", 259c19df961SChun-Jie Chen "univpll_d3", 260c19df961SChun-Jie Chen "mainpll_d3", 261c19df961SChun-Jie Chen "univpll_d2_d2", 262c19df961SChun-Jie Chen "mainpll_d2_d2", 263c19df961SChun-Jie Chen "mainpll_d2_d4" 264c19df961SChun-Jie Chen }; 265c19df961SChun-Jie Chen 266c19df961SChun-Jie Chen static const char * const pwrap_ulposc_parents[] = { 267c19df961SChun-Jie Chen "clk26m", 268c19df961SChun-Jie Chen "univpll_d5_d4", 269c19df961SChun-Jie Chen "ulposc1_d4", 270c19df961SChun-Jie Chen "ulposc1_d8", 271c19df961SChun-Jie Chen "ulposc1_d10", 272c19df961SChun-Jie Chen "ulposc1_d16", 273c19df961SChun-Jie Chen "ulposc1_d32" 274c19df961SChun-Jie Chen }; 275c19df961SChun-Jie Chen 276c19df961SChun-Jie Chen static const char * const camtm_parents[] = { 277c19df961SChun-Jie Chen "clk26m", 278c19df961SChun-Jie Chen "univpll_d2_d4", 279c19df961SChun-Jie Chen "univpll_d3_d2" 280c19df961SChun-Jie Chen }; 281c19df961SChun-Jie Chen 282c19df961SChun-Jie Chen static const char * const venc_parents[] = { 283c19df961SChun-Jie Chen "clk26m", 284c19df961SChun-Jie Chen "mmpll", 285c19df961SChun-Jie Chen "mainpll_d2_d2", 286c19df961SChun-Jie Chen "mainpll_d2", 287c19df961SChun-Jie Chen "univpll_d3", 288c19df961SChun-Jie Chen "univpll_d2_d2", 289c19df961SChun-Jie Chen "mainpll_d3", 290c19df961SChun-Jie Chen "mmpll" 291c19df961SChun-Jie Chen }; 292c19df961SChun-Jie Chen 293c19df961SChun-Jie Chen static const char * const isp_parents[] = { 294c19df961SChun-Jie Chen "clk26m", 295c19df961SChun-Jie Chen "mainpll_d2", 296c19df961SChun-Jie Chen "mainpll_d2_d2", 297c19df961SChun-Jie Chen "univpll_d3", 298c19df961SChun-Jie Chen "mainpll_d3", 299c19df961SChun-Jie Chen "mmpll", 300c19df961SChun-Jie Chen "univpll_d5", 301c19df961SChun-Jie Chen "univpll_d2_d2", 302c19df961SChun-Jie Chen "mmpll_d2" 303c19df961SChun-Jie Chen }; 304c19df961SChun-Jie Chen 305c19df961SChun-Jie Chen static const char * const dpmaif_parents[] = { 306c19df961SChun-Jie Chen "clk26m", 307c19df961SChun-Jie Chen "univpll_d2_d2", 308c19df961SChun-Jie Chen "mainpll_d3", 309c19df961SChun-Jie Chen "mainpll_d2_d2", 310c19df961SChun-Jie Chen "univpll_d3_d2" 311c19df961SChun-Jie Chen }; 312c19df961SChun-Jie Chen 313c19df961SChun-Jie Chen static const char * const vdec_parents[] = { 314c19df961SChun-Jie Chen "clk26m", 315c19df961SChun-Jie Chen "mainpll_d3", 316c19df961SChun-Jie Chen "mainpll_d2_d2", 317c19df961SChun-Jie Chen "univpll_d5", 318c19df961SChun-Jie Chen "mainpll_d2", 319c19df961SChun-Jie Chen "univpll_d3", 320c19df961SChun-Jie Chen "univpll_d2_d2" 321c19df961SChun-Jie Chen }; 322c19df961SChun-Jie Chen 323c19df961SChun-Jie Chen static const char * const disp_parents[] = { 324c19df961SChun-Jie Chen "clk26m", 325c19df961SChun-Jie Chen "univpll_d3_d2", 326c19df961SChun-Jie Chen "mainpll_d5", 327c19df961SChun-Jie Chen "univpll_d5", 328c19df961SChun-Jie Chen "univpll_d2_d2", 329c19df961SChun-Jie Chen "mainpll_d3", 330c19df961SChun-Jie Chen "univpll_d3", 331c19df961SChun-Jie Chen "mainpll_d2", 332c19df961SChun-Jie Chen "mmpll" 333c19df961SChun-Jie Chen }; 334c19df961SChun-Jie Chen 335c19df961SChun-Jie Chen static const char * const mdp_parents[] = { 336c19df961SChun-Jie Chen "clk26m", 337c19df961SChun-Jie Chen "mainpll_d5", 338c19df961SChun-Jie Chen "univpll_d5", 339c19df961SChun-Jie Chen "mainpll_d2_d2", 340c19df961SChun-Jie Chen "univpll_d2_d2", 341c19df961SChun-Jie Chen "mainpll_d3", 342c19df961SChun-Jie Chen "univpll_d3", 343c19df961SChun-Jie Chen "mainpll_d2", 344c19df961SChun-Jie Chen "mmpll" 345c19df961SChun-Jie Chen }; 346c19df961SChun-Jie Chen 347c19df961SChun-Jie Chen static const char * const audio_h_parents[] = { 348c19df961SChun-Jie Chen "clk26m", 349c19df961SChun-Jie Chen "univpll_d7", 350c19df961SChun-Jie Chen "apll1", 351c19df961SChun-Jie Chen "apll2" 352c19df961SChun-Jie Chen }; 353c19df961SChun-Jie Chen 354c19df961SChun-Jie Chen static const char * const ufs_parents[] = { 355c19df961SChun-Jie Chen "clk26m", 356c19df961SChun-Jie Chen "mainpll_d7", 357c19df961SChun-Jie Chen "univpll_d2_d4", 358c19df961SChun-Jie Chen "mainpll_d2_d4" 359c19df961SChun-Jie Chen }; 360c19df961SChun-Jie Chen 361c19df961SChun-Jie Chen static const char * const aes_fde_parents[] = { 362c19df961SChun-Jie Chen "clk26m", 363c19df961SChun-Jie Chen "univpll_d3", 364c19df961SChun-Jie Chen "mainpll_d2_d2", 365c19df961SChun-Jie Chen "univpll_d5" 366c19df961SChun-Jie Chen }; 367c19df961SChun-Jie Chen 368c19df961SChun-Jie Chen static const char * const audiodsp_parents[] = { 369c19df961SChun-Jie Chen "clk26m", 370c19df961SChun-Jie Chen "ulposc1_d10", 371c19df961SChun-Jie Chen "adsppll", 372c19df961SChun-Jie Chen "adsppll_d2", 373c19df961SChun-Jie Chen "adsppll_d4", 374c19df961SChun-Jie Chen "adsppll_d8" 375c19df961SChun-Jie Chen }; 376c19df961SChun-Jie Chen 377c19df961SChun-Jie Chen static const char * const dvfsrc_parents[] = { 378c19df961SChun-Jie Chen "clk26m", 379c19df961SChun-Jie Chen "ulposc1_d10", 380c19df961SChun-Jie Chen }; 381c19df961SChun-Jie Chen 382c19df961SChun-Jie Chen static const char * const dsi_occ_parents[] = { 383c19df961SChun-Jie Chen "clk26m", 384c19df961SChun-Jie Chen "univpll_d3_d2", 385c19df961SChun-Jie Chen "mpll", 386c19df961SChun-Jie Chen "mainpll_d5" 387c19df961SChun-Jie Chen }; 388c19df961SChun-Jie Chen 389c19df961SChun-Jie Chen static const char * const spmi_mst_parents[] = { 390c19df961SChun-Jie Chen "clk26m", 391c19df961SChun-Jie Chen "univpll_d5_d4", 392c19df961SChun-Jie Chen "ulposc1_d4", 393c19df961SChun-Jie Chen "ulposc1_d8", 394c19df961SChun-Jie Chen "ulposc1_d10", 395c19df961SChun-Jie Chen "ulposc1_d16", 396c19df961SChun-Jie Chen "ulposc1_d32" 397c19df961SChun-Jie Chen }; 398c19df961SChun-Jie Chen 399c19df961SChun-Jie Chen static const char * const spinor_parents[] = { 400c19df961SChun-Jie Chen "clk26m", 401c19df961SChun-Jie Chen "clk13m", 402c19df961SChun-Jie Chen "mainpll_d7_d4", 403c19df961SChun-Jie Chen "univpll_d3_d8", 404c19df961SChun-Jie Chen "univpll_d5_d4", 405c19df961SChun-Jie Chen "mainpll_d7_d2" 406c19df961SChun-Jie Chen }; 407c19df961SChun-Jie Chen 408c19df961SChun-Jie Chen static const char * const nna_parents[] = { 409c19df961SChun-Jie Chen "clk26m", 410c19df961SChun-Jie Chen "univpll_d3_d8", 411c19df961SChun-Jie Chen "mainpll_d2_d4", 412c19df961SChun-Jie Chen "univpll_d3_d2", 413c19df961SChun-Jie Chen "mainpll_d2_d2", 414c19df961SChun-Jie Chen "univpll_d2_d2", 415c19df961SChun-Jie Chen "mainpll_d3", 416c19df961SChun-Jie Chen "univpll_d3", 417c19df961SChun-Jie Chen "mmpll", 418c19df961SChun-Jie Chen "mainpll_d2", 419c19df961SChun-Jie Chen "univpll_d2", 420c19df961SChun-Jie Chen "nnapll_d2", 421c19df961SChun-Jie Chen "nnapll_d4", 422c19df961SChun-Jie Chen "nnapll_d8", 423c19df961SChun-Jie Chen "nnapll", 424c19df961SChun-Jie Chen "nna2pll" 425c19df961SChun-Jie Chen }; 426c19df961SChun-Jie Chen 427c19df961SChun-Jie Chen static const char * const nna2_parents[] = { 428c19df961SChun-Jie Chen "clk26m", 429c19df961SChun-Jie Chen "univpll_d3_d8", 430c19df961SChun-Jie Chen "mainpll_d2_d4", 431c19df961SChun-Jie Chen "univpll_d3_d2", 432c19df961SChun-Jie Chen "mainpll_d2_d2", 433c19df961SChun-Jie Chen "univpll_d2_d2", 434c19df961SChun-Jie Chen "mainpll_d3", 435c19df961SChun-Jie Chen "univpll_d3", 436c19df961SChun-Jie Chen "mmpll", 437c19df961SChun-Jie Chen "mainpll_d2", 438c19df961SChun-Jie Chen "univpll_d2", 439c19df961SChun-Jie Chen "nna2pll_d2", 440c19df961SChun-Jie Chen "nna2pll_d4", 441c19df961SChun-Jie Chen "nna2pll_d8", 442c19df961SChun-Jie Chen "nnapll", 443c19df961SChun-Jie Chen "nna2pll" 444c19df961SChun-Jie Chen }; 445c19df961SChun-Jie Chen 446c19df961SChun-Jie Chen static const char * const ssusb_parents[] = { 447c19df961SChun-Jie Chen "clk26m", 448c19df961SChun-Jie Chen "univpll_d5_d4", 449c19df961SChun-Jie Chen "univpll_d5_d2" 450c19df961SChun-Jie Chen }; 451c19df961SChun-Jie Chen 452c19df961SChun-Jie Chen static const char * const wpe_parents[] = { 453c19df961SChun-Jie Chen "clk26m", 454c19df961SChun-Jie Chen "univpll_d3_d2", 455c19df961SChun-Jie Chen "mainpll_d5", 456c19df961SChun-Jie Chen "univpll_d5", 457c19df961SChun-Jie Chen "univpll_d2_d2", 458c19df961SChun-Jie Chen "mainpll_d3", 459c19df961SChun-Jie Chen "univpll_d3", 460c19df961SChun-Jie Chen "mainpll_d2", 461c19df961SChun-Jie Chen "mmpll" 462c19df961SChun-Jie Chen }; 463c19df961SChun-Jie Chen 464c19df961SChun-Jie Chen static const char * const dpi_parents[] = { 465c19df961SChun-Jie Chen "clk26m", 466c19df961SChun-Jie Chen "tvdpll", 467c19df961SChun-Jie Chen "tvdpll_d2", 468c19df961SChun-Jie Chen "tvdpll_d4", 469c19df961SChun-Jie Chen "tvdpll_d8", 470c19df961SChun-Jie Chen "tvdpll_d16", 471c19df961SChun-Jie Chen "tvdpll_d32" 472c19df961SChun-Jie Chen }; 473c19df961SChun-Jie Chen 474c19df961SChun-Jie Chen static const char * const u3_occ_250m_parents[] = { 475c19df961SChun-Jie Chen "clk26m", 476c19df961SChun-Jie Chen "univpll_d5" 477c19df961SChun-Jie Chen }; 478c19df961SChun-Jie Chen 479c19df961SChun-Jie Chen static const char * const u3_occ_500m_parents[] = { 480c19df961SChun-Jie Chen "clk26m", 481c19df961SChun-Jie Chen "nna2pll_d2" 482c19df961SChun-Jie Chen }; 483c19df961SChun-Jie Chen 484c19df961SChun-Jie Chen static const char * const adsp_bus_parents[] = { 485c19df961SChun-Jie Chen "clk26m", 486c19df961SChun-Jie Chen "ulposc1_d2", 487c19df961SChun-Jie Chen "mainpll_d5", 488c19df961SChun-Jie Chen "mainpll_d2_d2", 489c19df961SChun-Jie Chen "mainpll_d3", 490c19df961SChun-Jie Chen "mainpll_d2", 491c19df961SChun-Jie Chen "univpll_d3" 492c19df961SChun-Jie Chen }; 493c19df961SChun-Jie Chen 494c19df961SChun-Jie Chen static const char * const apll_mck_parents[] = { 495c19df961SChun-Jie Chen "top_aud_1", 496c19df961SChun-Jie Chen "top_aud_2" 497c19df961SChun-Jie Chen }; 498c19df961SChun-Jie Chen 499c19df961SChun-Jie Chen static const struct mtk_mux top_mtk_muxes[] = { 500c19df961SChun-Jie Chen /* 501c19df961SChun-Jie Chen * CLK_CFG_0 502c19df961SChun-Jie Chen * top_axi is bus clock, should not be closed by Linux. 503c19df961SChun-Jie Chen * top_scp is main clock in always-on co-processor. 504c19df961SChun-Jie Chen */ 505c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_AXI, "top_axi", axi_parents, 506c19df961SChun-Jie Chen 0x0040, 0x0044, 0x0048, 0, 2, 7, 0x0004, 0, 507*1775790eSAngeloGioacchino Del Regno CLK_IS_CRITICAL | CLK_SET_RATE_PARENT), 508c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SCP, "top_scp", scp_parents, 509c19df961SChun-Jie Chen 0x0040, 0x0044, 0x0048, 8, 3, 15, 0x0004, 1, 510*1775790eSAngeloGioacchino Del Regno CLK_IS_CRITICAL | CLK_SET_RATE_PARENT), 511c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_MFG, "top_mfg", 512c19df961SChun-Jie Chen mfg_parents, 0x0040, 0x0044, 0x0048, 16, 2, 23, 0x0004, 2), 513c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG, "top_camtg", 514c19df961SChun-Jie Chen camtg_parents, 0x0040, 0x0044, 0x0048, 24, 3, 31, 0x0004, 3), 515c19df961SChun-Jie Chen /* CLK_CFG_1 */ 516c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG1, "top_camtg1", 517c19df961SChun-Jie Chen camtg_parents, 0x0050, 0x0054, 0x0058, 0, 3, 7, 0x0004, 4), 518c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG2, "top_camtg2", 519c19df961SChun-Jie Chen camtg_parents, 0x0050, 0x0054, 0x0058, 8, 3, 15, 0x0004, 5), 520c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG3, "top_camtg3", 521c19df961SChun-Jie Chen camtg_parents, 0x0050, 0x0054, 0x0058, 16, 3, 23, 0x0004, 6), 522c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG4, "top_camtg4", 523c19df961SChun-Jie Chen camtg_parents, 0x0050, 0x0054, 0x0058, 24, 3, 31, 0x0004, 7), 524c19df961SChun-Jie Chen /* CLK_CFG_2 */ 525c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG5, "top_camtg5", 526c19df961SChun-Jie Chen camtg_parents, 0x0060, 0x0064, 0x0068, 0, 3, 7, 0x0004, 8), 527c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG6, "top_camtg6", 528c19df961SChun-Jie Chen camtg_parents, 0x0060, 0x0064, 0x0068, 8, 3, 15, 0x0004, 9), 529c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_UART, "top_uart", 530c19df961SChun-Jie Chen uart_parents, 0x0060, 0x0064, 0x0068, 16, 1, 23, 0x0004, 10), 531c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_SPI, "top_spi", 532c19df961SChun-Jie Chen spi_parents, 0x0060, 0x0064, 0x0068, 24, 3, 31, 0x0004, 11), 533c19df961SChun-Jie Chen /* CLK_CFG_3 */ 534c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC50_0_HCLK, "top_msdc5hclk", 535c19df961SChun-Jie Chen msdc5hclk_parents, 0x0070, 0x0074, 0x0078, 0, 2, 7, 0x0004, 12), 536c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC50_0, "top_msdc50_0", 537c19df961SChun-Jie Chen msdc50_0_parents, 0x0070, 0x0074, 0x0078, 8, 3, 15, 0x0004, 13), 538c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC30_1, "top_msdc30_1", 539c19df961SChun-Jie Chen msdc30_1_parents, 0x0070, 0x0074, 0x0078, 16, 3, 23, 0x0004, 14), 540c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_AUDIO, "top_audio", 541c19df961SChun-Jie Chen audio_parents, 0x0070, 0x0074, 0x0078, 24, 2, 31, 0x0004, 15), 542c19df961SChun-Jie Chen /* CLK_CFG_4 */ 543c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_INTBUS, "top_aud_intbus", 544c19df961SChun-Jie Chen aud_intbus_parents, 0x0080, 0x0084, 0x0088, 0, 2, 7, 0x0004, 16), 545c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_1, "top_aud_1", 546c19df961SChun-Jie Chen aud_1_parents, 0x0080, 0x0084, 0x0088, 8, 1, 15, 0x0004, 17), 547c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_2, "top_aud_2", 548c19df961SChun-Jie Chen aud_2_parents, 0x0080, 0x0084, 0x0088, 16, 1, 23, 0x0004, 18), 549c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_ENGEN1, "top_aud_engen1", 550c19df961SChun-Jie Chen aud_engen1_parents, 0x0080, 0x0084, 0x0088, 24, 2, 31, 0x0004, 19), 551c19df961SChun-Jie Chen /* 552c19df961SChun-Jie Chen * CLK_CFG_5 553c19df961SChun-Jie Chen * top_sspm is main clock in always-on co-processor, should not be closed 554c19df961SChun-Jie Chen * in Linux. 555c19df961SChun-Jie Chen */ 556c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_ENGEN2, "top_aud_engen2", 557c19df961SChun-Jie Chen aud_engen2_parents, 0x0090, 0x0094, 0x0098, 0, 2, 7, 0x0004, 20), 558c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_DISP_PWM, "top_disp_pwm", 559c19df961SChun-Jie Chen disp_pwm_parents, 0x0090, 0x0094, 0x0098, 8, 3, 15, 0x0004, 21), 560c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SSPM, "top_sspm", sspm_parents, 561c19df961SChun-Jie Chen 0x0090, 0x0094, 0x0098, 16, 3, 23, 0x0004, 22, 562*1775790eSAngeloGioacchino Del Regno CLK_IS_CRITICAL | CLK_SET_RATE_PARENT), 563c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_DXCC, "top_dxcc", 564c19df961SChun-Jie Chen dxcc_parents, 0x0090, 0x0094, 0x0098, 24, 2, 31, 0x0004, 23), 565c19df961SChun-Jie Chen /* 566c19df961SChun-Jie Chen * CLK_CFG_6 567c19df961SChun-Jie Chen * top_spm and top_srck are main clocks in always-on co-processor. 568c19df961SChun-Jie Chen */ 569c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_TOP, "top_usb", 570c19df961SChun-Jie Chen usb_parents, 0x00a0, 0x00a4, 0x00a8, 0, 2, 7, 0x0004, 24), 571c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SRCK, "top_srck", srck_parents, 572c19df961SChun-Jie Chen 0x00a0, 0x00a4, 0x00a8, 8, 2, 15, 0x0004, 25, 573*1775790eSAngeloGioacchino Del Regno CLK_IS_CRITICAL | CLK_SET_RATE_PARENT), 574c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SPM, "top_spm", spm_parents, 575c19df961SChun-Jie Chen 0x00a0, 0x00a4, 0x00a8, 16, 2, 23, 0x0004, 26, 576*1775790eSAngeloGioacchino Del Regno CLK_IS_CRITICAL | CLK_SET_RATE_PARENT), 577c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_I2C, "top_i2c", 578c19df961SChun-Jie Chen i2c_parents, 0x00a0, 0x00a4, 0x00a8, 24, 2, 31, 0x0004, 27), 579c19df961SChun-Jie Chen /* CLK_CFG_7 */ 580c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_PWM, "top_pwm", 581c19df961SChun-Jie Chen pwm_parents, 0x00b0, 0x00b4, 0x00b8, 0, 2, 7, 0x0004, 28), 582c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_SENINF, "top_seninf", 583c19df961SChun-Jie Chen seninf_parents, 0x00b0, 0x00b4, 0x00b8, 8, 2, 15, 0x0004, 29), 584c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_SENINF1, "top_seninf1", 585c19df961SChun-Jie Chen seninf_parents, 0x00b0, 0x00b4, 0x00b8, 16, 2, 23, 0x0004, 30), 586c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_SENINF2, "top_seninf2", 587c19df961SChun-Jie Chen seninf_parents, 0x00b0, 0x00b4, 0x00b8, 24, 2, 31, 0x0008, 0), 588c19df961SChun-Jie Chen /* CLK_CFG_8 */ 589c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_SENINF3, "top_seninf3", 590c19df961SChun-Jie Chen seninf_parents, 0x00c0, 0x00c4, 0x00c8, 0, 2, 7, 0x0008, 1), 591c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_AES_MSDCFDE, "top_aes_msdcfde", 592c19df961SChun-Jie Chen aes_msdcfde_parents, 0x00c0, 0x00c4, 0x00c8, 8, 3, 15, 0x0008, 2), 593c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_PWRAP_ULPOSC, "top_pwrap_ulposc", 594c19df961SChun-Jie Chen pwrap_ulposc_parents, 0x00c0, 0x00c4, 0x00c8, 16, 3, 23, 0x0008, 3), 595c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTM, "top_camtm", 596c19df961SChun-Jie Chen camtm_parents, 0x00c0, 0x00c4, 0x00c8, 24, 2, 31, 0x0008, 4), 597c19df961SChun-Jie Chen /* CLK_CFG_9 */ 598c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_VENC, "top_venc", 599c19df961SChun-Jie Chen venc_parents, 0x00d0, 0x00d4, 0x00d8, 0, 3, 7, 0x0008, 5), 600c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_CAM, "top_cam", 601c19df961SChun-Jie Chen isp_parents, 0x00d0, 0x00d4, 0x00d8, 8, 4, 15, 0x0008, 6), 602c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_IMG1, "top_img1", 603c19df961SChun-Jie Chen isp_parents, 0x00d0, 0x00d4, 0x00d8, 16, 4, 23, 0x0008, 7), 604c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_IPE, "top_ipe", 605c19df961SChun-Jie Chen isp_parents, 0x00d0, 0x00d4, 0x00d8, 24, 4, 31, 0x0008, 8), 606c19df961SChun-Jie Chen /* CLK_CFG_10 */ 607c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_DPMAIF, "top_dpmaif", 608c19df961SChun-Jie Chen dpmaif_parents, 0x00e0, 0x00e4, 0x00e8, 0, 3, 7, 0x0008, 9), 609c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_VDEC, "top_vdec", 610c19df961SChun-Jie Chen vdec_parents, 0x00e0, 0x00e4, 0x00e8, 8, 3, 15, 0x0008, 10), 611c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_DISP, "top_disp", 612c19df961SChun-Jie Chen disp_parents, 0x00e0, 0x00e4, 0x00e8, 16, 4, 23, 0x0008, 11), 613c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_MDP, "top_mdp", 614c19df961SChun-Jie Chen mdp_parents, 0x00e0, 0x00e4, 0x00e8, 24, 4, 31, 0x0008, 12), 615c19df961SChun-Jie Chen /* CLK_CFG_11 */ 616c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_AUDIO_H, "top_audio_h", 617c19df961SChun-Jie Chen audio_h_parents, 0x00ec, 0x00f0, 0x00f4, 0, 2, 7, 0x0008, 13), 618c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_UFS, "top_ufs", 619c19df961SChun-Jie Chen ufs_parents, 0x00ec, 0x00f0, 0x00f4, 8, 2, 15, 0x0008, 14), 620c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_AES_FDE, "top_aes_fde", 621c19df961SChun-Jie Chen aes_fde_parents, 0x00ec, 0x00f0, 0x00f4, 16, 2, 23, 0x0008, 15), 622c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_AUDIODSP, "top_audiodsp", 623c19df961SChun-Jie Chen audiodsp_parents, 0x00ec, 0x00f0, 0x00f4, 24, 3, 31, 0x0008, 16), 624c19df961SChun-Jie Chen /* 625c19df961SChun-Jie Chen * CLK_CFG_12 626c19df961SChun-Jie Chen * dvfsrc is for internal DVFS usage, should not be closed in Linux. 627c19df961SChun-Jie Chen */ 628c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_DVFSRC, "top_dvfsrc", dvfsrc_parents, 629c19df961SChun-Jie Chen 0x0100, 0x0104, 0x0108, 0, 1, 7, 0x0008, 17, 630*1775790eSAngeloGioacchino Del Regno CLK_IS_CRITICAL | CLK_SET_RATE_PARENT), 631c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_DSI_OCC, "top_dsi_occ", 632c19df961SChun-Jie Chen dsi_occ_parents, 0x0100, 0x0104, 0x0108, 8, 2, 15, 0x0008, 18), 633c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_SPMI_MST, "top_spmi_mst", 634c19df961SChun-Jie Chen spmi_mst_parents, 0x0100, 0x0104, 0x0108, 16, 3, 23, 0x0008, 19), 635c19df961SChun-Jie Chen /* CLK_CFG_13 */ 636c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_SPINOR, "top_spinor", 637c19df961SChun-Jie Chen spinor_parents, 0x0110, 0x0114, 0x0118, 0, 3, 6, 0x0008, 20), 638c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_NNA, "top_nna", 639c19df961SChun-Jie Chen nna_parents, 0x0110, 0x0114, 0x0118, 7, 4, 14, 0x0008, 21), 640c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_NNA1, "top_nna1", 641c19df961SChun-Jie Chen nna_parents, 0x0110, 0x0114, 0x0118, 15, 4, 22, 0x0008, 22), 642c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_NNA2, "top_nna2", 643c19df961SChun-Jie Chen nna2_parents, 0x0110, 0x0114, 0x0118, 23, 4, 30, 0x0008, 23), 644c19df961SChun-Jie Chen /* CLK_CFG_14 */ 645c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI, "top_ssusb_xhci", 646c19df961SChun-Jie Chen ssusb_parents, 0x0120, 0x0124, 0x0128, 0, 2, 5, 0x0008, 24), 647c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_TOP_1P, "top_ssusb_1p", 648c19df961SChun-Jie Chen ssusb_parents, 0x0120, 0x0124, 0x0128, 6, 2, 11, 0x0008, 25), 649c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI_1P, "top_ssusb_xhci_1p", 650c19df961SChun-Jie Chen ssusb_parents, 0x0120, 0x0124, 0x0128, 12, 2, 17, 0x0008, 26), 651c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_WPE, "top_wpe", 652c19df961SChun-Jie Chen wpe_parents, 0x0120, 0x0124, 0x0128, 18, 4, 25, 0x0008, 27), 653c19df961SChun-Jie Chen /* CLK_CFG_15 */ 654c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_DPI, "top_dpi", 655c19df961SChun-Jie Chen dpi_parents, 0x0180, 0x0184, 0x0188, 0, 3, 6, 0x0008, 28), 656c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_U3_OCC_250M, "top_u3_occ_250m", 657c19df961SChun-Jie Chen u3_occ_250m_parents, 0x0180, 0x0184, 0x0188, 7, 1, 11, 0x0008, 29), 658c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_U3_OCC_500M, "top_u3_occ_500m", 659c19df961SChun-Jie Chen u3_occ_500m_parents, 0x0180, 0x0184, 0x0188, 12, 1, 16, 0x0008, 30), 660c19df961SChun-Jie Chen MUX_GATE_CLR_SET_UPD(CLK_TOP_ADSP_BUS, "top_adsp_bus", 661c19df961SChun-Jie Chen adsp_bus_parents, 0x0180, 0x0184, 0x0188, 17, 3, 23, 0x0008, 31), 662c19df961SChun-Jie Chen }; 663c19df961SChun-Jie Chen 664c19df961SChun-Jie Chen static struct mtk_composite top_muxes[] = { 665c19df961SChun-Jie Chen /* CLK_AUDDIV_0 */ 666c19df961SChun-Jie Chen MUX(CLK_TOP_APLL_I2S0_MCK_SEL, "apll_i2s0_mck_sel", apll_mck_parents, 0x0320, 16, 1), 667c19df961SChun-Jie Chen MUX(CLK_TOP_APLL_I2S1_MCK_SEL, "apll_i2s1_mck_sel", apll_mck_parents, 0x0320, 17, 1), 668c19df961SChun-Jie Chen MUX(CLK_TOP_APLL_I2S2_MCK_SEL, "apll_i2s2_mck_sel", apll_mck_parents, 0x0320, 18, 1), 669c19df961SChun-Jie Chen MUX(CLK_TOP_APLL_I2S4_MCK_SEL, "apll_i2s4_mck_sel", apll_mck_parents, 0x0320, 19, 1), 670c19df961SChun-Jie Chen MUX(CLK_TOP_APLL_TDMOUT_MCK_SEL, "apll_tdmout_mck_sel", apll_mck_parents, 671c19df961SChun-Jie Chen 0x0320, 20, 1), 672c19df961SChun-Jie Chen DIV_GATE(CLK_TOP_APLL12_CK_DIV0, "apll12_div0", "apll_i2s0_mck_sel", 673c19df961SChun-Jie Chen 0x0320, 0, 0x0328, 8, 0), 674c19df961SChun-Jie Chen DIV_GATE(CLK_TOP_APLL12_CK_DIV1, "apll12_div1", "apll_i2s1_mck_sel", 675c19df961SChun-Jie Chen 0x0320, 1, 0x0328, 8, 8), 676c19df961SChun-Jie Chen DIV_GATE(CLK_TOP_APLL12_CK_DIV2, "apll12_div2", "apll_i2s2_mck_sel", 677c19df961SChun-Jie Chen 0x0320, 2, 0x0328, 8, 16), 678c19df961SChun-Jie Chen DIV_GATE(CLK_TOP_APLL12_CK_DIV4, "apll12_div4", "apll_i2s4_mck_sel", 679c19df961SChun-Jie Chen 0x0320, 3, 0x0328, 8, 24), 680c19df961SChun-Jie Chen DIV_GATE(CLK_TOP_APLL12_CK_DIV_TDMOUT_M, "apll12_div_tdmout_m", "apll_tdmout_mck_sel", 681c19df961SChun-Jie Chen 0x0320, 4, 0x0334, 8, 0), 682c19df961SChun-Jie Chen }; 683c19df961SChun-Jie Chen 6843256ea4fSAngeloGioacchino Del Regno /* Register mux notifier for MFG mux */ 6853256ea4fSAngeloGioacchino Del Regno static int clk_mt8186_reg_mfg_mux_notifier(struct device *dev, struct clk *clk) 6863256ea4fSAngeloGioacchino Del Regno { 6873256ea4fSAngeloGioacchino Del Regno struct mtk_mux_nb *mfg_mux_nb; 6883256ea4fSAngeloGioacchino Del Regno int i; 6893256ea4fSAngeloGioacchino Del Regno 6903256ea4fSAngeloGioacchino Del Regno mfg_mux_nb = devm_kzalloc(dev, sizeof(*mfg_mux_nb), GFP_KERNEL); 6913256ea4fSAngeloGioacchino Del Regno if (!mfg_mux_nb) 6923256ea4fSAngeloGioacchino Del Regno return -ENOMEM; 6933256ea4fSAngeloGioacchino Del Regno 6943256ea4fSAngeloGioacchino Del Regno for (i = 0; i < ARRAY_SIZE(top_mtk_muxes); i++) 6953256ea4fSAngeloGioacchino Del Regno if (top_mtk_muxes[i].id == CLK_TOP_MFG) 6963256ea4fSAngeloGioacchino Del Regno break; 6973256ea4fSAngeloGioacchino Del Regno if (i == ARRAY_SIZE(top_mtk_muxes)) 6983256ea4fSAngeloGioacchino Del Regno return -EINVAL; 6993256ea4fSAngeloGioacchino Del Regno 7003256ea4fSAngeloGioacchino Del Regno mfg_mux_nb->ops = top_mtk_muxes[i].ops; 7013256ea4fSAngeloGioacchino Del Regno mfg_mux_nb->bypass_index = 0; /* Bypass to 26M crystal */ 7023256ea4fSAngeloGioacchino Del Regno 7033256ea4fSAngeloGioacchino Del Regno return devm_mtk_clk_mux_notifier_register(dev, clk, mfg_mux_nb); 7043256ea4fSAngeloGioacchino Del Regno } 7053256ea4fSAngeloGioacchino Del Regno 70675c12ea3SAngeloGioacchino Del Regno static const struct mtk_clk_desc topck_desc = { 70775c12ea3SAngeloGioacchino Del Regno .fixed_clks = top_fixed_clks, 70875c12ea3SAngeloGioacchino Del Regno .num_fixed_clks = ARRAY_SIZE(top_fixed_clks), 70975c12ea3SAngeloGioacchino Del Regno .factor_clks = top_divs, 71075c12ea3SAngeloGioacchino Del Regno .num_factor_clks = ARRAY_SIZE(top_divs), 71175c12ea3SAngeloGioacchino Del Regno .mux_clks = top_mtk_muxes, 71275c12ea3SAngeloGioacchino Del Regno .num_mux_clks = ARRAY_SIZE(top_mtk_muxes), 71375c12ea3SAngeloGioacchino Del Regno .composite_clks = top_muxes, 71475c12ea3SAngeloGioacchino Del Regno .num_composite_clks = ARRAY_SIZE(top_muxes), 71575c12ea3SAngeloGioacchino Del Regno .clk_lock = &mt8186_clk_lock, 71675c12ea3SAngeloGioacchino Del Regno .clk_notifier_func = clk_mt8186_reg_mfg_mux_notifier, 71775c12ea3SAngeloGioacchino Del Regno .mfg_clk_idx = CLK_TOP_MFG, 71875c12ea3SAngeloGioacchino Del Regno }; 719c19df961SChun-Jie Chen 72075c12ea3SAngeloGioacchino Del Regno static const struct of_device_id of_match_clk_mt8186_topck[] = { 72175c12ea3SAngeloGioacchino Del Regno { .compatible = "mediatek,mt8186-topckgen", .data = &topck_desc }, 72275c12ea3SAngeloGioacchino Del Regno { /* sentinel */ } 72375c12ea3SAngeloGioacchino Del Regno }; 72465c9ad77SAngeloGioacchino Del Regno MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_topck); 725c19df961SChun-Jie Chen 726c19df961SChun-Jie Chen static struct platform_driver clk_mt8186_topck_drv = { 72775c12ea3SAngeloGioacchino Del Regno .probe = mtk_clk_simple_probe, 72875c12ea3SAngeloGioacchino Del Regno .remove = mtk_clk_simple_remove, 729c19df961SChun-Jie Chen .driver = { 730c19df961SChun-Jie Chen .name = "clk-mt8186-topck", 731c19df961SChun-Jie Chen .of_match_table = of_match_clk_mt8186_topck, 732c19df961SChun-Jie Chen }, 733c19df961SChun-Jie Chen }; 734164d240dSAngeloGioacchino Del Regno module_platform_driver(clk_mt8186_topck_drv); 735a451da86SAngeloGioacchino Del Regno MODULE_LICENSE("GPL"); 736