18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright 2014 Linaro Ltd. 48c2ecf20Sopenharmony_ci * Copyright (C) 2014 ZTE Corporation. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 88c2ecf20Sopenharmony_ci#include <linux/of_address.h> 98c2ecf20Sopenharmony_ci#include <dt-bindings/clock/zx296702-clock.h> 108c2ecf20Sopenharmony_ci#include "clk.h" 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(reg_lock); 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistatic void __iomem *topcrm_base; 158c2ecf20Sopenharmony_cistatic void __iomem *lsp0crpm_base; 168c2ecf20Sopenharmony_cistatic void __iomem *lsp1crpm_base; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistatic struct clk *topclk[ZX296702_TOPCLK_END]; 198c2ecf20Sopenharmony_cistatic struct clk *lsp0clk[ZX296702_LSP0CLK_END]; 208c2ecf20Sopenharmony_cistatic struct clk *lsp1clk[ZX296702_LSP1CLK_END]; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistatic struct clk_onecell_data topclk_data; 238c2ecf20Sopenharmony_cistatic struct clk_onecell_data lsp0clk_data; 248c2ecf20Sopenharmony_cistatic struct clk_onecell_data lsp1clk_data; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define CLK_MUX (topcrm_base + 0x04) 278c2ecf20Sopenharmony_ci#define CLK_DIV (topcrm_base + 0x08) 288c2ecf20Sopenharmony_ci#define CLK_EN0 (topcrm_base + 0x0c) 298c2ecf20Sopenharmony_ci#define CLK_EN1 (topcrm_base + 0x10) 308c2ecf20Sopenharmony_ci#define VOU_LOCAL_CLKEN (topcrm_base + 0x68) 318c2ecf20Sopenharmony_ci#define VOU_LOCAL_CLKSEL (topcrm_base + 0x70) 328c2ecf20Sopenharmony_ci#define VOU_LOCAL_DIV2_SET (topcrm_base + 0x74) 338c2ecf20Sopenharmony_ci#define CLK_MUX1 (topcrm_base + 0x8c) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define CLK_SDMMC1 (lsp0crpm_base + 0x0c) 368c2ecf20Sopenharmony_ci#define CLK_GPIO (lsp0crpm_base + 0x2c) 378c2ecf20Sopenharmony_ci#define CLK_SPDIF0 (lsp0crpm_base + 0x10) 388c2ecf20Sopenharmony_ci#define SPDIF0_DIV (lsp0crpm_base + 0x14) 398c2ecf20Sopenharmony_ci#define CLK_I2S0 (lsp0crpm_base + 0x18) 408c2ecf20Sopenharmony_ci#define I2S0_DIV (lsp0crpm_base + 0x1c) 418c2ecf20Sopenharmony_ci#define CLK_I2S1 (lsp0crpm_base + 0x20) 428c2ecf20Sopenharmony_ci#define I2S1_DIV (lsp0crpm_base + 0x24) 438c2ecf20Sopenharmony_ci#define CLK_I2S2 (lsp0crpm_base + 0x34) 448c2ecf20Sopenharmony_ci#define I2S2_DIV (lsp0crpm_base + 0x38) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define CLK_UART0 (lsp1crpm_base + 0x20) 478c2ecf20Sopenharmony_ci#define CLK_UART1 (lsp1crpm_base + 0x24) 488c2ecf20Sopenharmony_ci#define CLK_SDMMC0 (lsp1crpm_base + 0x2c) 498c2ecf20Sopenharmony_ci#define CLK_SPDIF1 (lsp1crpm_base + 0x30) 508c2ecf20Sopenharmony_ci#define SPDIF1_DIV (lsp1crpm_base + 0x34) 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic const struct zx_pll_config pll_a9_config[] = { 538c2ecf20Sopenharmony_ci { .rate = 700000000, .cfg0 = 0x800405d1, .cfg1 = 0x04555555 }, 548c2ecf20Sopenharmony_ci { .rate = 800000000, .cfg0 = 0x80040691, .cfg1 = 0x04aaaaaa }, 558c2ecf20Sopenharmony_ci { .rate = 900000000, .cfg0 = 0x80040791, .cfg1 = 0x04000000 }, 568c2ecf20Sopenharmony_ci { .rate = 1000000000, .cfg0 = 0x80040851, .cfg1 = 0x04555555 }, 578c2ecf20Sopenharmony_ci { .rate = 1100000000, .cfg0 = 0x80040911, .cfg1 = 0x04aaaaaa }, 588c2ecf20Sopenharmony_ci { .rate = 1200000000, .cfg0 = 0x80040a11, .cfg1 = 0x04000000 }, 598c2ecf20Sopenharmony_ci}; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistatic const struct clk_div_table main_hlk_div[] = { 628c2ecf20Sopenharmony_ci { .val = 1, .div = 2, }, 638c2ecf20Sopenharmony_ci { .val = 3, .div = 4, }, 648c2ecf20Sopenharmony_ci { /* sentinel */ } 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cistatic const struct clk_div_table a9_as1_aclk_divider[] = { 688c2ecf20Sopenharmony_ci { .val = 0, .div = 1, }, 698c2ecf20Sopenharmony_ci { .val = 1, .div = 2, }, 708c2ecf20Sopenharmony_ci { .val = 3, .div = 4, }, 718c2ecf20Sopenharmony_ci { /* sentinel */ } 728c2ecf20Sopenharmony_ci}; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_cistatic const struct clk_div_table sec_wclk_divider[] = { 758c2ecf20Sopenharmony_ci { .val = 0, .div = 1, }, 768c2ecf20Sopenharmony_ci { .val = 1, .div = 2, }, 778c2ecf20Sopenharmony_ci { .val = 3, .div = 4, }, 788c2ecf20Sopenharmony_ci { .val = 5, .div = 6, }, 798c2ecf20Sopenharmony_ci { .val = 7, .div = 8, }, 808c2ecf20Sopenharmony_ci { /* sentinel */ } 818c2ecf20Sopenharmony_ci}; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cistatic const char * const matrix_aclk_sel[] = { 848c2ecf20Sopenharmony_ci "pll_mm0_198M", 858c2ecf20Sopenharmony_ci "osc", 868c2ecf20Sopenharmony_ci "clk_148M5", 878c2ecf20Sopenharmony_ci "pll_lsp_104M", 888c2ecf20Sopenharmony_ci}; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_cistatic const char * const a9_wclk_sel[] = { 918c2ecf20Sopenharmony_ci "pll_a9", 928c2ecf20Sopenharmony_ci "osc", 938c2ecf20Sopenharmony_ci "clk_500", 948c2ecf20Sopenharmony_ci "clk_250", 958c2ecf20Sopenharmony_ci}; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cistatic const char * const a9_as1_aclk_sel[] = { 988c2ecf20Sopenharmony_ci "clk_250", 998c2ecf20Sopenharmony_ci "osc", 1008c2ecf20Sopenharmony_ci "pll_mm0_396M", 1018c2ecf20Sopenharmony_ci "pll_mac_333M", 1028c2ecf20Sopenharmony_ci}; 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cistatic const char * const a9_trace_clkin_sel[] = { 1058c2ecf20Sopenharmony_ci "clk_74M25", 1068c2ecf20Sopenharmony_ci "pll_mm1_108M", 1078c2ecf20Sopenharmony_ci "clk_125", 1088c2ecf20Sopenharmony_ci "clk_148M5", 1098c2ecf20Sopenharmony_ci}; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_cistatic const char * const decppu_aclk_sel[] = { 1128c2ecf20Sopenharmony_ci "clk_250", 1138c2ecf20Sopenharmony_ci "pll_mm0_198M", 1148c2ecf20Sopenharmony_ci "pll_lsp_104M", 1158c2ecf20Sopenharmony_ci "pll_audio_294M912", 1168c2ecf20Sopenharmony_ci}; 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_cistatic const char * const vou_main_wclk_sel[] = { 1198c2ecf20Sopenharmony_ci "clk_148M5", 1208c2ecf20Sopenharmony_ci "clk_74M25", 1218c2ecf20Sopenharmony_ci "clk_27", 1228c2ecf20Sopenharmony_ci "pll_mm1_54M", 1238c2ecf20Sopenharmony_ci}; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_cistatic const char * const vou_scaler_wclk_sel[] = { 1268c2ecf20Sopenharmony_ci "clk_250", 1278c2ecf20Sopenharmony_ci "pll_mac_333M", 1288c2ecf20Sopenharmony_ci "pll_audio_294M912", 1298c2ecf20Sopenharmony_ci "pll_mm0_198M", 1308c2ecf20Sopenharmony_ci}; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_cistatic const char * const r2d_wclk_sel[] = { 1338c2ecf20Sopenharmony_ci "pll_audio_294M912", 1348c2ecf20Sopenharmony_ci "pll_mac_333M", 1358c2ecf20Sopenharmony_ci "pll_a9_350M", 1368c2ecf20Sopenharmony_ci "pll_mm0_396M", 1378c2ecf20Sopenharmony_ci}; 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_cistatic const char * const ddr_wclk_sel[] = { 1408c2ecf20Sopenharmony_ci "pll_mac_333M", 1418c2ecf20Sopenharmony_ci "pll_ddr_266M", 1428c2ecf20Sopenharmony_ci "pll_audio_294M912", 1438c2ecf20Sopenharmony_ci "pll_mm0_198M", 1448c2ecf20Sopenharmony_ci}; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cistatic const char * const nand_wclk_sel[] = { 1478c2ecf20Sopenharmony_ci "pll_lsp_104M", 1488c2ecf20Sopenharmony_ci "osc", 1498c2ecf20Sopenharmony_ci}; 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_cistatic const char * const lsp_26_wclk_sel[] = { 1528c2ecf20Sopenharmony_ci "pll_lsp_26M", 1538c2ecf20Sopenharmony_ci "osc", 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_cistatic const char * const vl0_sel[] = { 1578c2ecf20Sopenharmony_ci "vou_main_channel_div", 1588c2ecf20Sopenharmony_ci "vou_aux_channel_div", 1598c2ecf20Sopenharmony_ci}; 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_cistatic const char * const hdmi_sel[] = { 1628c2ecf20Sopenharmony_ci "vou_main_channel_wclk", 1638c2ecf20Sopenharmony_ci "vou_aux_channel_wclk", 1648c2ecf20Sopenharmony_ci}; 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_cistatic const char * const sdmmc0_wclk_sel[] = { 1678c2ecf20Sopenharmony_ci "lsp1_104M_wclk", 1688c2ecf20Sopenharmony_ci "lsp1_26M_wclk", 1698c2ecf20Sopenharmony_ci}; 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_cistatic const char * const sdmmc1_wclk_sel[] = { 1728c2ecf20Sopenharmony_ci "lsp0_104M_wclk", 1738c2ecf20Sopenharmony_ci "lsp0_26M_wclk", 1748c2ecf20Sopenharmony_ci}; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_cistatic const char * const uart_wclk_sel[] = { 1778c2ecf20Sopenharmony_ci "lsp1_104M_wclk", 1788c2ecf20Sopenharmony_ci "lsp1_26M_wclk", 1798c2ecf20Sopenharmony_ci}; 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_cistatic const char * const spdif0_wclk_sel[] = { 1828c2ecf20Sopenharmony_ci "lsp0_104M_wclk", 1838c2ecf20Sopenharmony_ci "lsp0_26M_wclk", 1848c2ecf20Sopenharmony_ci}; 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_cistatic const char * const spdif1_wclk_sel[] = { 1878c2ecf20Sopenharmony_ci "lsp1_104M_wclk", 1888c2ecf20Sopenharmony_ci "lsp1_26M_wclk", 1898c2ecf20Sopenharmony_ci}; 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_cistatic const char * const i2s_wclk_sel[] = { 1928c2ecf20Sopenharmony_ci "lsp0_104M_wclk", 1938c2ecf20Sopenharmony_ci "lsp0_26M_wclk", 1948c2ecf20Sopenharmony_ci}; 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_cistatic inline struct clk *zx_divtbl(const char *name, const char *parent, 1978c2ecf20Sopenharmony_ci void __iomem *reg, u8 shift, u8 width, 1988c2ecf20Sopenharmony_ci const struct clk_div_table *table) 1998c2ecf20Sopenharmony_ci{ 2008c2ecf20Sopenharmony_ci return clk_register_divider_table(NULL, name, parent, 0, reg, shift, 2018c2ecf20Sopenharmony_ci width, 0, table, ®_lock); 2028c2ecf20Sopenharmony_ci} 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_cistatic inline struct clk *zx_div(const char *name, const char *parent, 2058c2ecf20Sopenharmony_ci void __iomem *reg, u8 shift, u8 width) 2068c2ecf20Sopenharmony_ci{ 2078c2ecf20Sopenharmony_ci return clk_register_divider(NULL, name, parent, 0, 2088c2ecf20Sopenharmony_ci reg, shift, width, 0, ®_lock); 2098c2ecf20Sopenharmony_ci} 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_cistatic inline struct clk *zx_mux(const char *name, const char * const *parents, 2128c2ecf20Sopenharmony_ci int num_parents, void __iomem *reg, u8 shift, u8 width) 2138c2ecf20Sopenharmony_ci{ 2148c2ecf20Sopenharmony_ci return clk_register_mux(NULL, name, parents, num_parents, 2158c2ecf20Sopenharmony_ci 0, reg, shift, width, 0, ®_lock); 2168c2ecf20Sopenharmony_ci} 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_cistatic inline struct clk *zx_gate(const char *name, const char *parent, 2198c2ecf20Sopenharmony_ci void __iomem *reg, u8 shift) 2208c2ecf20Sopenharmony_ci{ 2218c2ecf20Sopenharmony_ci return clk_register_gate(NULL, name, parent, CLK_IGNORE_UNUSED, 2228c2ecf20Sopenharmony_ci reg, shift, CLK_SET_RATE_PARENT, ®_lock); 2238c2ecf20Sopenharmony_ci} 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_cistatic void __init zx296702_top_clocks_init(struct device_node *np) 2268c2ecf20Sopenharmony_ci{ 2278c2ecf20Sopenharmony_ci struct clk **clk = topclk; 2288c2ecf20Sopenharmony_ci int i; 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci topcrm_base = of_iomap(np, 0); 2318c2ecf20Sopenharmony_ci WARN_ON(!topcrm_base); 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci clk[ZX296702_OSC] = 2348c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "osc", NULL, 0, 30000000); 2358c2ecf20Sopenharmony_ci clk[ZX296702_PLL_A9] = 2368c2ecf20Sopenharmony_ci clk_register_zx_pll("pll_a9", "osc", 0, topcrm_base 2378c2ecf20Sopenharmony_ci + 0x01c, pll_a9_config, 2388c2ecf20Sopenharmony_ci ARRAY_SIZE(pll_a9_config), ®_lock); 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci /* TODO: pll_a9_350M look like changeble follow a9 pll */ 2418c2ecf20Sopenharmony_ci clk[ZX296702_PLL_A9_350M] = 2428c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "pll_a9_350M", "osc", 0, 2438c2ecf20Sopenharmony_ci 350000000); 2448c2ecf20Sopenharmony_ci clk[ZX296702_PLL_MAC_1000M] = 2458c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "pll_mac_1000M", "osc", 0, 2468c2ecf20Sopenharmony_ci 1000000000); 2478c2ecf20Sopenharmony_ci clk[ZX296702_PLL_MAC_333M] = 2488c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "pll_mac_333M", "osc", 0, 2498c2ecf20Sopenharmony_ci 333000000); 2508c2ecf20Sopenharmony_ci clk[ZX296702_PLL_MM0_1188M] = 2518c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "pll_mm0_1188M", "osc", 0, 2528c2ecf20Sopenharmony_ci 1188000000); 2538c2ecf20Sopenharmony_ci clk[ZX296702_PLL_MM0_396M] = 2548c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "pll_mm0_396M", "osc", 0, 2558c2ecf20Sopenharmony_ci 396000000); 2568c2ecf20Sopenharmony_ci clk[ZX296702_PLL_MM0_198M] = 2578c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "pll_mm0_198M", "osc", 0, 2588c2ecf20Sopenharmony_ci 198000000); 2598c2ecf20Sopenharmony_ci clk[ZX296702_PLL_MM1_108M] = 2608c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "pll_mm1_108M", "osc", 0, 2618c2ecf20Sopenharmony_ci 108000000); 2628c2ecf20Sopenharmony_ci clk[ZX296702_PLL_MM1_72M] = 2638c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "pll_mm1_72M", "osc", 0, 2648c2ecf20Sopenharmony_ci 72000000); 2658c2ecf20Sopenharmony_ci clk[ZX296702_PLL_MM1_54M] = 2668c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "pll_mm1_54M", "osc", 0, 2678c2ecf20Sopenharmony_ci 54000000); 2688c2ecf20Sopenharmony_ci clk[ZX296702_PLL_LSP_104M] = 2698c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "pll_lsp_104M", "osc", 0, 2708c2ecf20Sopenharmony_ci 104000000); 2718c2ecf20Sopenharmony_ci clk[ZX296702_PLL_LSP_26M] = 2728c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "pll_lsp_26M", "osc", 0, 2738c2ecf20Sopenharmony_ci 26000000); 2748c2ecf20Sopenharmony_ci clk[ZX296702_PLL_DDR_266M] = 2758c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "pll_ddr_266M", "osc", 0, 2768c2ecf20Sopenharmony_ci 266000000); 2778c2ecf20Sopenharmony_ci clk[ZX296702_PLL_AUDIO_294M912] = 2788c2ecf20Sopenharmony_ci clk_register_fixed_rate(NULL, "pll_audio_294M912", "osc", 0, 2798c2ecf20Sopenharmony_ci 294912000); 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci /* bus clock */ 2828c2ecf20Sopenharmony_ci clk[ZX296702_MATRIX_ACLK] = 2838c2ecf20Sopenharmony_ci zx_mux("matrix_aclk", matrix_aclk_sel, 2848c2ecf20Sopenharmony_ci ARRAY_SIZE(matrix_aclk_sel), CLK_MUX, 2, 2); 2858c2ecf20Sopenharmony_ci clk[ZX296702_MAIN_HCLK] = 2868c2ecf20Sopenharmony_ci zx_divtbl("main_hclk", "matrix_aclk", CLK_DIV, 0, 2, 2878c2ecf20Sopenharmony_ci main_hlk_div); 2888c2ecf20Sopenharmony_ci clk[ZX296702_MAIN_PCLK] = 2898c2ecf20Sopenharmony_ci zx_divtbl("main_pclk", "matrix_aclk", CLK_DIV, 2, 2, 2908c2ecf20Sopenharmony_ci main_hlk_div); 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci /* cpu clock */ 2938c2ecf20Sopenharmony_ci clk[ZX296702_CLK_500] = 2948c2ecf20Sopenharmony_ci clk_register_fixed_factor(NULL, "clk_500", "pll_mac_1000M", 0, 2958c2ecf20Sopenharmony_ci 1, 2); 2968c2ecf20Sopenharmony_ci clk[ZX296702_CLK_250] = 2978c2ecf20Sopenharmony_ci clk_register_fixed_factor(NULL, "clk_250", "pll_mac_1000M", 0, 2988c2ecf20Sopenharmony_ci 1, 4); 2998c2ecf20Sopenharmony_ci clk[ZX296702_CLK_125] = 3008c2ecf20Sopenharmony_ci clk_register_fixed_factor(NULL, "clk_125", "clk_250", 0, 1, 2); 3018c2ecf20Sopenharmony_ci clk[ZX296702_CLK_148M5] = 3028c2ecf20Sopenharmony_ci clk_register_fixed_factor(NULL, "clk_148M5", "pll_mm0_1188M", 0, 3038c2ecf20Sopenharmony_ci 1, 8); 3048c2ecf20Sopenharmony_ci clk[ZX296702_CLK_74M25] = 3058c2ecf20Sopenharmony_ci clk_register_fixed_factor(NULL, "clk_74M25", "pll_mm0_1188M", 0, 3068c2ecf20Sopenharmony_ci 1, 16); 3078c2ecf20Sopenharmony_ci clk[ZX296702_A9_WCLK] = 3088c2ecf20Sopenharmony_ci zx_mux("a9_wclk", a9_wclk_sel, ARRAY_SIZE(a9_wclk_sel), CLK_MUX, 3098c2ecf20Sopenharmony_ci 0, 2); 3108c2ecf20Sopenharmony_ci clk[ZX296702_A9_AS1_ACLK_MUX] = 3118c2ecf20Sopenharmony_ci zx_mux("a9_as1_aclk_mux", a9_as1_aclk_sel, 3128c2ecf20Sopenharmony_ci ARRAY_SIZE(a9_as1_aclk_sel), CLK_MUX, 4, 2); 3138c2ecf20Sopenharmony_ci clk[ZX296702_A9_TRACE_CLKIN_MUX] = 3148c2ecf20Sopenharmony_ci zx_mux("a9_trace_clkin_mux", a9_trace_clkin_sel, 3158c2ecf20Sopenharmony_ci ARRAY_SIZE(a9_trace_clkin_sel), CLK_MUX1, 0, 2); 3168c2ecf20Sopenharmony_ci clk[ZX296702_A9_AS1_ACLK_DIV] = 3178c2ecf20Sopenharmony_ci zx_divtbl("a9_as1_aclk_div", "a9_as1_aclk_mux", CLK_DIV, 4, 2, 3188c2ecf20Sopenharmony_ci a9_as1_aclk_divider); 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci /* multi-media clock */ 3218c2ecf20Sopenharmony_ci clk[ZX296702_CLK_2] = 3228c2ecf20Sopenharmony_ci clk_register_fixed_factor(NULL, "clk_2", "pll_mm1_72M", 0, 3238c2ecf20Sopenharmony_ci 1, 36); 3248c2ecf20Sopenharmony_ci clk[ZX296702_CLK_27] = 3258c2ecf20Sopenharmony_ci clk_register_fixed_factor(NULL, "clk_27", "pll_mm1_54M", 0, 3268c2ecf20Sopenharmony_ci 1, 2); 3278c2ecf20Sopenharmony_ci clk[ZX296702_DECPPU_ACLK_MUX] = 3288c2ecf20Sopenharmony_ci zx_mux("decppu_aclk_mux", decppu_aclk_sel, 3298c2ecf20Sopenharmony_ci ARRAY_SIZE(decppu_aclk_sel), CLK_MUX, 6, 2); 3308c2ecf20Sopenharmony_ci clk[ZX296702_PPU_ACLK_MUX] = 3318c2ecf20Sopenharmony_ci zx_mux("ppu_aclk_mux", decppu_aclk_sel, 3328c2ecf20Sopenharmony_ci ARRAY_SIZE(decppu_aclk_sel), CLK_MUX, 8, 2); 3338c2ecf20Sopenharmony_ci clk[ZX296702_MALI400_ACLK_MUX] = 3348c2ecf20Sopenharmony_ci zx_mux("mali400_aclk_mux", decppu_aclk_sel, 3358c2ecf20Sopenharmony_ci ARRAY_SIZE(decppu_aclk_sel), CLK_MUX, 12, 2); 3368c2ecf20Sopenharmony_ci clk[ZX296702_VOU_ACLK_MUX] = 3378c2ecf20Sopenharmony_ci zx_mux("vou_aclk_mux", decppu_aclk_sel, 3388c2ecf20Sopenharmony_ci ARRAY_SIZE(decppu_aclk_sel), CLK_MUX, 10, 2); 3398c2ecf20Sopenharmony_ci clk[ZX296702_VOU_MAIN_WCLK_MUX] = 3408c2ecf20Sopenharmony_ci zx_mux("vou_main_wclk_mux", vou_main_wclk_sel, 3418c2ecf20Sopenharmony_ci ARRAY_SIZE(vou_main_wclk_sel), CLK_MUX, 14, 2); 3428c2ecf20Sopenharmony_ci clk[ZX296702_VOU_AUX_WCLK_MUX] = 3438c2ecf20Sopenharmony_ci zx_mux("vou_aux_wclk_mux", vou_main_wclk_sel, 3448c2ecf20Sopenharmony_ci ARRAY_SIZE(vou_main_wclk_sel), CLK_MUX, 16, 2); 3458c2ecf20Sopenharmony_ci clk[ZX296702_VOU_SCALER_WCLK_MUX] = 3468c2ecf20Sopenharmony_ci zx_mux("vou_scaler_wclk_mux", vou_scaler_wclk_sel, 3478c2ecf20Sopenharmony_ci ARRAY_SIZE(vou_scaler_wclk_sel), CLK_MUX, 3488c2ecf20Sopenharmony_ci 18, 2); 3498c2ecf20Sopenharmony_ci clk[ZX296702_R2D_ACLK_MUX] = 3508c2ecf20Sopenharmony_ci zx_mux("r2d_aclk_mux", decppu_aclk_sel, 3518c2ecf20Sopenharmony_ci ARRAY_SIZE(decppu_aclk_sel), CLK_MUX, 20, 2); 3528c2ecf20Sopenharmony_ci clk[ZX296702_R2D_WCLK_MUX] = 3538c2ecf20Sopenharmony_ci zx_mux("r2d_wclk_mux", r2d_wclk_sel, 3548c2ecf20Sopenharmony_ci ARRAY_SIZE(r2d_wclk_sel), CLK_MUX, 22, 2); 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_ci /* other clock */ 3578c2ecf20Sopenharmony_ci clk[ZX296702_CLK_50] = 3588c2ecf20Sopenharmony_ci clk_register_fixed_factor(NULL, "clk_50", "pll_mac_1000M", 3598c2ecf20Sopenharmony_ci 0, 1, 20); 3608c2ecf20Sopenharmony_ci clk[ZX296702_CLK_25] = 3618c2ecf20Sopenharmony_ci clk_register_fixed_factor(NULL, "clk_25", "pll_mac_1000M", 3628c2ecf20Sopenharmony_ci 0, 1, 40); 3638c2ecf20Sopenharmony_ci clk[ZX296702_CLK_12] = 3648c2ecf20Sopenharmony_ci clk_register_fixed_factor(NULL, "clk_12", "pll_mm1_72M", 3658c2ecf20Sopenharmony_ci 0, 1, 6); 3668c2ecf20Sopenharmony_ci clk[ZX296702_CLK_16M384] = 3678c2ecf20Sopenharmony_ci clk_register_fixed_factor(NULL, "clk_16M384", 3688c2ecf20Sopenharmony_ci "pll_audio_294M912", 0, 1, 18); 3698c2ecf20Sopenharmony_ci clk[ZX296702_CLK_32K768] = 3708c2ecf20Sopenharmony_ci clk_register_fixed_factor(NULL, "clk_32K768", "clk_16M384", 3718c2ecf20Sopenharmony_ci 0, 1, 500); 3728c2ecf20Sopenharmony_ci clk[ZX296702_SEC_WCLK_DIV] = 3738c2ecf20Sopenharmony_ci zx_divtbl("sec_wclk_div", "pll_lsp_104M", CLK_DIV, 6, 3, 3748c2ecf20Sopenharmony_ci sec_wclk_divider); 3758c2ecf20Sopenharmony_ci clk[ZX296702_DDR_WCLK_MUX] = 3768c2ecf20Sopenharmony_ci zx_mux("ddr_wclk_mux", ddr_wclk_sel, 3778c2ecf20Sopenharmony_ci ARRAY_SIZE(ddr_wclk_sel), CLK_MUX, 24, 2); 3788c2ecf20Sopenharmony_ci clk[ZX296702_NAND_WCLK_MUX] = 3798c2ecf20Sopenharmony_ci zx_mux("nand_wclk_mux", nand_wclk_sel, 3808c2ecf20Sopenharmony_ci ARRAY_SIZE(nand_wclk_sel), CLK_MUX, 24, 2); 3818c2ecf20Sopenharmony_ci clk[ZX296702_LSP_26_WCLK_MUX] = 3828c2ecf20Sopenharmony_ci zx_mux("lsp_26_wclk_mux", lsp_26_wclk_sel, 3838c2ecf20Sopenharmony_ci ARRAY_SIZE(lsp_26_wclk_sel), CLK_MUX, 27, 1); 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ci /* gates */ 3868c2ecf20Sopenharmony_ci clk[ZX296702_A9_AS0_ACLK] = 3878c2ecf20Sopenharmony_ci zx_gate("a9_as0_aclk", "matrix_aclk", CLK_EN0, 0); 3888c2ecf20Sopenharmony_ci clk[ZX296702_A9_AS1_ACLK] = 3898c2ecf20Sopenharmony_ci zx_gate("a9_as1_aclk", "a9_as1_aclk_div", CLK_EN0, 1); 3908c2ecf20Sopenharmony_ci clk[ZX296702_A9_TRACE_CLKIN] = 3918c2ecf20Sopenharmony_ci zx_gate("a9_trace_clkin", "a9_trace_clkin_mux", CLK_EN0, 2); 3928c2ecf20Sopenharmony_ci clk[ZX296702_DECPPU_AXI_M_ACLK] = 3938c2ecf20Sopenharmony_ci zx_gate("decppu_axi_m_aclk", "decppu_aclk_mux", CLK_EN0, 3); 3948c2ecf20Sopenharmony_ci clk[ZX296702_DECPPU_AHB_S_HCLK] = 3958c2ecf20Sopenharmony_ci zx_gate("decppu_ahb_s_hclk", "main_hclk", CLK_EN0, 4); 3968c2ecf20Sopenharmony_ci clk[ZX296702_PPU_AXI_M_ACLK] = 3978c2ecf20Sopenharmony_ci zx_gate("ppu_axi_m_aclk", "ppu_aclk_mux", CLK_EN0, 5); 3988c2ecf20Sopenharmony_ci clk[ZX296702_PPU_AHB_S_HCLK] = 3998c2ecf20Sopenharmony_ci zx_gate("ppu_ahb_s_hclk", "main_hclk", CLK_EN0, 6); 4008c2ecf20Sopenharmony_ci clk[ZX296702_VOU_AXI_M_ACLK] = 4018c2ecf20Sopenharmony_ci zx_gate("vou_axi_m_aclk", "vou_aclk_mux", CLK_EN0, 7); 4028c2ecf20Sopenharmony_ci clk[ZX296702_VOU_APB_PCLK] = 4038c2ecf20Sopenharmony_ci zx_gate("vou_apb_pclk", "main_pclk", CLK_EN0, 8); 4048c2ecf20Sopenharmony_ci clk[ZX296702_VOU_MAIN_CHANNEL_WCLK] = 4058c2ecf20Sopenharmony_ci zx_gate("vou_main_channel_wclk", "vou_main_wclk_mux", 4068c2ecf20Sopenharmony_ci CLK_EN0, 9); 4078c2ecf20Sopenharmony_ci clk[ZX296702_VOU_AUX_CHANNEL_WCLK] = 4088c2ecf20Sopenharmony_ci zx_gate("vou_aux_channel_wclk", "vou_aux_wclk_mux", 4098c2ecf20Sopenharmony_ci CLK_EN0, 10); 4108c2ecf20Sopenharmony_ci clk[ZX296702_VOU_HDMI_OSCLK_CEC] = 4118c2ecf20Sopenharmony_ci zx_gate("vou_hdmi_osclk_cec", "clk_2", CLK_EN0, 11); 4128c2ecf20Sopenharmony_ci clk[ZX296702_VOU_SCALER_WCLK] = 4138c2ecf20Sopenharmony_ci zx_gate("vou_scaler_wclk", "vou_scaler_wclk_mux", CLK_EN0, 12); 4148c2ecf20Sopenharmony_ci clk[ZX296702_MALI400_AXI_M_ACLK] = 4158c2ecf20Sopenharmony_ci zx_gate("mali400_axi_m_aclk", "mali400_aclk_mux", CLK_EN0, 13); 4168c2ecf20Sopenharmony_ci clk[ZX296702_MALI400_APB_PCLK] = 4178c2ecf20Sopenharmony_ci zx_gate("mali400_apb_pclk", "main_pclk", CLK_EN0, 14); 4188c2ecf20Sopenharmony_ci clk[ZX296702_R2D_WCLK] = 4198c2ecf20Sopenharmony_ci zx_gate("r2d_wclk", "r2d_wclk_mux", CLK_EN0, 15); 4208c2ecf20Sopenharmony_ci clk[ZX296702_R2D_AXI_M_ACLK] = 4218c2ecf20Sopenharmony_ci zx_gate("r2d_axi_m_aclk", "r2d_aclk_mux", CLK_EN0, 16); 4228c2ecf20Sopenharmony_ci clk[ZX296702_R2D_AHB_HCLK] = 4238c2ecf20Sopenharmony_ci zx_gate("r2d_ahb_hclk", "main_hclk", CLK_EN0, 17); 4248c2ecf20Sopenharmony_ci clk[ZX296702_DDR3_AXI_S0_ACLK] = 4258c2ecf20Sopenharmony_ci zx_gate("ddr3_axi_s0_aclk", "matrix_aclk", CLK_EN0, 18); 4268c2ecf20Sopenharmony_ci clk[ZX296702_DDR3_APB_PCLK] = 4278c2ecf20Sopenharmony_ci zx_gate("ddr3_apb_pclk", "main_pclk", CLK_EN0, 19); 4288c2ecf20Sopenharmony_ci clk[ZX296702_DDR3_WCLK] = 4298c2ecf20Sopenharmony_ci zx_gate("ddr3_wclk", "ddr_wclk_mux", CLK_EN0, 20); 4308c2ecf20Sopenharmony_ci clk[ZX296702_USB20_0_AHB_HCLK] = 4318c2ecf20Sopenharmony_ci zx_gate("usb20_0_ahb_hclk", "main_hclk", CLK_EN0, 21); 4328c2ecf20Sopenharmony_ci clk[ZX296702_USB20_0_EXTREFCLK] = 4338c2ecf20Sopenharmony_ci zx_gate("usb20_0_extrefclk", "clk_12", CLK_EN0, 22); 4348c2ecf20Sopenharmony_ci clk[ZX296702_USB20_1_AHB_HCLK] = 4358c2ecf20Sopenharmony_ci zx_gate("usb20_1_ahb_hclk", "main_hclk", CLK_EN0, 23); 4368c2ecf20Sopenharmony_ci clk[ZX296702_USB20_1_EXTREFCLK] = 4378c2ecf20Sopenharmony_ci zx_gate("usb20_1_extrefclk", "clk_12", CLK_EN0, 24); 4388c2ecf20Sopenharmony_ci clk[ZX296702_USB20_2_AHB_HCLK] = 4398c2ecf20Sopenharmony_ci zx_gate("usb20_2_ahb_hclk", "main_hclk", CLK_EN0, 25); 4408c2ecf20Sopenharmony_ci clk[ZX296702_USB20_2_EXTREFCLK] = 4418c2ecf20Sopenharmony_ci zx_gate("usb20_2_extrefclk", "clk_12", CLK_EN0, 26); 4428c2ecf20Sopenharmony_ci clk[ZX296702_GMAC_AXI_M_ACLK] = 4438c2ecf20Sopenharmony_ci zx_gate("gmac_axi_m_aclk", "matrix_aclk", CLK_EN0, 27); 4448c2ecf20Sopenharmony_ci clk[ZX296702_GMAC_APB_PCLK] = 4458c2ecf20Sopenharmony_ci zx_gate("gmac_apb_pclk", "main_pclk", CLK_EN0, 28); 4468c2ecf20Sopenharmony_ci clk[ZX296702_GMAC_125_CLKIN] = 4478c2ecf20Sopenharmony_ci zx_gate("gmac_125_clkin", "clk_125", CLK_EN0, 29); 4488c2ecf20Sopenharmony_ci clk[ZX296702_GMAC_RMII_CLKIN] = 4498c2ecf20Sopenharmony_ci zx_gate("gmac_rmii_clkin", "clk_50", CLK_EN0, 30); 4508c2ecf20Sopenharmony_ci clk[ZX296702_GMAC_25M_CLK] = 4518c2ecf20Sopenharmony_ci zx_gate("gmac_25M_clk", "clk_25", CLK_EN0, 31); 4528c2ecf20Sopenharmony_ci clk[ZX296702_NANDFLASH_AHB_HCLK] = 4538c2ecf20Sopenharmony_ci zx_gate("nandflash_ahb_hclk", "main_hclk", CLK_EN1, 0); 4548c2ecf20Sopenharmony_ci clk[ZX296702_NANDFLASH_WCLK] = 4558c2ecf20Sopenharmony_ci zx_gate("nandflash_wclk", "nand_wclk_mux", CLK_EN1, 1); 4568c2ecf20Sopenharmony_ci clk[ZX296702_LSP0_APB_PCLK] = 4578c2ecf20Sopenharmony_ci zx_gate("lsp0_apb_pclk", "main_pclk", CLK_EN1, 2); 4588c2ecf20Sopenharmony_ci clk[ZX296702_LSP0_AHB_HCLK] = 4598c2ecf20Sopenharmony_ci zx_gate("lsp0_ahb_hclk", "main_hclk", CLK_EN1, 3); 4608c2ecf20Sopenharmony_ci clk[ZX296702_LSP0_26M_WCLK] = 4618c2ecf20Sopenharmony_ci zx_gate("lsp0_26M_wclk", "lsp_26_wclk_mux", CLK_EN1, 4); 4628c2ecf20Sopenharmony_ci clk[ZX296702_LSP0_104M_WCLK] = 4638c2ecf20Sopenharmony_ci zx_gate("lsp0_104M_wclk", "pll_lsp_104M", CLK_EN1, 5); 4648c2ecf20Sopenharmony_ci clk[ZX296702_LSP0_16M384_WCLK] = 4658c2ecf20Sopenharmony_ci zx_gate("lsp0_16M384_wclk", "clk_16M384", CLK_EN1, 6); 4668c2ecf20Sopenharmony_ci clk[ZX296702_LSP1_APB_PCLK] = 4678c2ecf20Sopenharmony_ci zx_gate("lsp1_apb_pclk", "main_pclk", CLK_EN1, 7); 4688c2ecf20Sopenharmony_ci /* FIXME: wclk enable bit is bit8. We hack it as reserved 31 for 4698c2ecf20Sopenharmony_ci * UART does not work after parent clk is disabled/enabled */ 4708c2ecf20Sopenharmony_ci clk[ZX296702_LSP1_26M_WCLK] = 4718c2ecf20Sopenharmony_ci zx_gate("lsp1_26M_wclk", "lsp_26_wclk_mux", CLK_EN1, 31); 4728c2ecf20Sopenharmony_ci clk[ZX296702_LSP1_104M_WCLK] = 4738c2ecf20Sopenharmony_ci zx_gate("lsp1_104M_wclk", "pll_lsp_104M", CLK_EN1, 9); 4748c2ecf20Sopenharmony_ci clk[ZX296702_LSP1_32K_CLK] = 4758c2ecf20Sopenharmony_ci zx_gate("lsp1_32K_clk", "clk_32K768", CLK_EN1, 10); 4768c2ecf20Sopenharmony_ci clk[ZX296702_AON_HCLK] = 4778c2ecf20Sopenharmony_ci zx_gate("aon_hclk", "main_hclk", CLK_EN1, 11); 4788c2ecf20Sopenharmony_ci clk[ZX296702_SYS_CTRL_PCLK] = 4798c2ecf20Sopenharmony_ci zx_gate("sys_ctrl_pclk", "main_pclk", CLK_EN1, 12); 4808c2ecf20Sopenharmony_ci clk[ZX296702_DMA_PCLK] = 4818c2ecf20Sopenharmony_ci zx_gate("dma_pclk", "main_pclk", CLK_EN1, 13); 4828c2ecf20Sopenharmony_ci clk[ZX296702_DMA_ACLK] = 4838c2ecf20Sopenharmony_ci zx_gate("dma_aclk", "matrix_aclk", CLK_EN1, 14); 4848c2ecf20Sopenharmony_ci clk[ZX296702_SEC_HCLK] = 4858c2ecf20Sopenharmony_ci zx_gate("sec_hclk", "main_hclk", CLK_EN1, 15); 4868c2ecf20Sopenharmony_ci clk[ZX296702_AES_WCLK] = 4878c2ecf20Sopenharmony_ci zx_gate("aes_wclk", "sec_wclk_div", CLK_EN1, 16); 4888c2ecf20Sopenharmony_ci clk[ZX296702_DES_WCLK] = 4898c2ecf20Sopenharmony_ci zx_gate("des_wclk", "sec_wclk_div", CLK_EN1, 17); 4908c2ecf20Sopenharmony_ci clk[ZX296702_IRAM_ACLK] = 4918c2ecf20Sopenharmony_ci zx_gate("iram_aclk", "matrix_aclk", CLK_EN1, 18); 4928c2ecf20Sopenharmony_ci clk[ZX296702_IROM_ACLK] = 4938c2ecf20Sopenharmony_ci zx_gate("irom_aclk", "matrix_aclk", CLK_EN1, 19); 4948c2ecf20Sopenharmony_ci clk[ZX296702_BOOT_CTRL_HCLK] = 4958c2ecf20Sopenharmony_ci zx_gate("boot_ctrl_hclk", "main_hclk", CLK_EN1, 20); 4968c2ecf20Sopenharmony_ci clk[ZX296702_EFUSE_CLK_30] = 4978c2ecf20Sopenharmony_ci zx_gate("efuse_clk_30", "osc", CLK_EN1, 21); 4988c2ecf20Sopenharmony_ci 4998c2ecf20Sopenharmony_ci /* TODO: add VOU Local clocks */ 5008c2ecf20Sopenharmony_ci clk[ZX296702_VOU_MAIN_CHANNEL_DIV] = 5018c2ecf20Sopenharmony_ci zx_div("vou_main_channel_div", "vou_main_channel_wclk", 5028c2ecf20Sopenharmony_ci VOU_LOCAL_DIV2_SET, 1, 1); 5038c2ecf20Sopenharmony_ci clk[ZX296702_VOU_AUX_CHANNEL_DIV] = 5048c2ecf20Sopenharmony_ci zx_div("vou_aux_channel_div", "vou_aux_channel_wclk", 5058c2ecf20Sopenharmony_ci VOU_LOCAL_DIV2_SET, 0, 1); 5068c2ecf20Sopenharmony_ci clk[ZX296702_VOU_TV_ENC_HD_DIV] = 5078c2ecf20Sopenharmony_ci zx_div("vou_tv_enc_hd_div", "vou_tv_enc_hd_mux", 5088c2ecf20Sopenharmony_ci VOU_LOCAL_DIV2_SET, 3, 1); 5098c2ecf20Sopenharmony_ci clk[ZX296702_VOU_TV_ENC_SD_DIV] = 5108c2ecf20Sopenharmony_ci zx_div("vou_tv_enc_sd_div", "vou_tv_enc_sd_mux", 5118c2ecf20Sopenharmony_ci VOU_LOCAL_DIV2_SET, 2, 1); 5128c2ecf20Sopenharmony_ci clk[ZX296702_VL0_MUX] = 5138c2ecf20Sopenharmony_ci zx_mux("vl0_mux", vl0_sel, ARRAY_SIZE(vl0_sel), 5148c2ecf20Sopenharmony_ci VOU_LOCAL_CLKSEL, 8, 1); 5158c2ecf20Sopenharmony_ci clk[ZX296702_VL1_MUX] = 5168c2ecf20Sopenharmony_ci zx_mux("vl1_mux", vl0_sel, ARRAY_SIZE(vl0_sel), 5178c2ecf20Sopenharmony_ci VOU_LOCAL_CLKSEL, 9, 1); 5188c2ecf20Sopenharmony_ci clk[ZX296702_VL2_MUX] = 5198c2ecf20Sopenharmony_ci zx_mux("vl2_mux", vl0_sel, ARRAY_SIZE(vl0_sel), 5208c2ecf20Sopenharmony_ci VOU_LOCAL_CLKSEL, 10, 1); 5218c2ecf20Sopenharmony_ci clk[ZX296702_GL0_MUX] = 5228c2ecf20Sopenharmony_ci zx_mux("gl0_mux", vl0_sel, ARRAY_SIZE(vl0_sel), 5238c2ecf20Sopenharmony_ci VOU_LOCAL_CLKSEL, 5, 1); 5248c2ecf20Sopenharmony_ci clk[ZX296702_GL1_MUX] = 5258c2ecf20Sopenharmony_ci zx_mux("gl1_mux", vl0_sel, ARRAY_SIZE(vl0_sel), 5268c2ecf20Sopenharmony_ci VOU_LOCAL_CLKSEL, 6, 1); 5278c2ecf20Sopenharmony_ci clk[ZX296702_GL2_MUX] = 5288c2ecf20Sopenharmony_ci zx_mux("gl2_mux", vl0_sel, ARRAY_SIZE(vl0_sel), 5298c2ecf20Sopenharmony_ci VOU_LOCAL_CLKSEL, 7, 1); 5308c2ecf20Sopenharmony_ci clk[ZX296702_WB_MUX] = 5318c2ecf20Sopenharmony_ci zx_mux("wb_mux", vl0_sel, ARRAY_SIZE(vl0_sel), 5328c2ecf20Sopenharmony_ci VOU_LOCAL_CLKSEL, 11, 1); 5338c2ecf20Sopenharmony_ci clk[ZX296702_HDMI_MUX] = 5348c2ecf20Sopenharmony_ci zx_mux("hdmi_mux", hdmi_sel, ARRAY_SIZE(hdmi_sel), 5358c2ecf20Sopenharmony_ci VOU_LOCAL_CLKSEL, 4, 1); 5368c2ecf20Sopenharmony_ci clk[ZX296702_VOU_TV_ENC_HD_MUX] = 5378c2ecf20Sopenharmony_ci zx_mux("vou_tv_enc_hd_mux", hdmi_sel, ARRAY_SIZE(hdmi_sel), 5388c2ecf20Sopenharmony_ci VOU_LOCAL_CLKSEL, 3, 1); 5398c2ecf20Sopenharmony_ci clk[ZX296702_VOU_TV_ENC_SD_MUX] = 5408c2ecf20Sopenharmony_ci zx_mux("vou_tv_enc_sd_mux", hdmi_sel, ARRAY_SIZE(hdmi_sel), 5418c2ecf20Sopenharmony_ci VOU_LOCAL_CLKSEL, 2, 1); 5428c2ecf20Sopenharmony_ci clk[ZX296702_VL0_CLK] = 5438c2ecf20Sopenharmony_ci zx_gate("vl0_clk", "vl0_mux", VOU_LOCAL_CLKEN, 8); 5448c2ecf20Sopenharmony_ci clk[ZX296702_VL1_CLK] = 5458c2ecf20Sopenharmony_ci zx_gate("vl1_clk", "vl1_mux", VOU_LOCAL_CLKEN, 9); 5468c2ecf20Sopenharmony_ci clk[ZX296702_VL2_CLK] = 5478c2ecf20Sopenharmony_ci zx_gate("vl2_clk", "vl2_mux", VOU_LOCAL_CLKEN, 10); 5488c2ecf20Sopenharmony_ci clk[ZX296702_GL0_CLK] = 5498c2ecf20Sopenharmony_ci zx_gate("gl0_clk", "gl0_mux", VOU_LOCAL_CLKEN, 5); 5508c2ecf20Sopenharmony_ci clk[ZX296702_GL1_CLK] = 5518c2ecf20Sopenharmony_ci zx_gate("gl1_clk", "gl1_mux", VOU_LOCAL_CLKEN, 6); 5528c2ecf20Sopenharmony_ci clk[ZX296702_GL2_CLK] = 5538c2ecf20Sopenharmony_ci zx_gate("gl2_clk", "gl2_mux", VOU_LOCAL_CLKEN, 7); 5548c2ecf20Sopenharmony_ci clk[ZX296702_WB_CLK] = 5558c2ecf20Sopenharmony_ci zx_gate("wb_clk", "wb_mux", VOU_LOCAL_CLKEN, 11); 5568c2ecf20Sopenharmony_ci clk[ZX296702_CL_CLK] = 5578c2ecf20Sopenharmony_ci zx_gate("cl_clk", "vou_main_channel_div", VOU_LOCAL_CLKEN, 12); 5588c2ecf20Sopenharmony_ci clk[ZX296702_MAIN_MIX_CLK] = 5598c2ecf20Sopenharmony_ci zx_gate("main_mix_clk", "vou_main_channel_div", 5608c2ecf20Sopenharmony_ci VOU_LOCAL_CLKEN, 4); 5618c2ecf20Sopenharmony_ci clk[ZX296702_AUX_MIX_CLK] = 5628c2ecf20Sopenharmony_ci zx_gate("aux_mix_clk", "vou_aux_channel_div", 5638c2ecf20Sopenharmony_ci VOU_LOCAL_CLKEN, 3); 5648c2ecf20Sopenharmony_ci clk[ZX296702_HDMI_CLK] = 5658c2ecf20Sopenharmony_ci zx_gate("hdmi_clk", "hdmi_mux", VOU_LOCAL_CLKEN, 2); 5668c2ecf20Sopenharmony_ci clk[ZX296702_VOU_TV_ENC_HD_DAC_CLK] = 5678c2ecf20Sopenharmony_ci zx_gate("vou_tv_enc_hd_dac_clk", "vou_tv_enc_hd_div", 5688c2ecf20Sopenharmony_ci VOU_LOCAL_CLKEN, 1); 5698c2ecf20Sopenharmony_ci clk[ZX296702_VOU_TV_ENC_SD_DAC_CLK] = 5708c2ecf20Sopenharmony_ci zx_gate("vou_tv_enc_sd_dac_clk", "vou_tv_enc_sd_div", 5718c2ecf20Sopenharmony_ci VOU_LOCAL_CLKEN, 0); 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_ci /* CA9 PERIPHCLK = a9_wclk / 2 */ 5748c2ecf20Sopenharmony_ci clk[ZX296702_A9_PERIPHCLK] = 5758c2ecf20Sopenharmony_ci clk_register_fixed_factor(NULL, "a9_periphclk", "a9_wclk", 5768c2ecf20Sopenharmony_ci 0, 1, 2); 5778c2ecf20Sopenharmony_ci 5788c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(topclk); i++) { 5798c2ecf20Sopenharmony_ci if (IS_ERR(clk[i])) { 5808c2ecf20Sopenharmony_ci pr_err("zx296702 clk %d: register failed with %ld\n", 5818c2ecf20Sopenharmony_ci i, PTR_ERR(clk[i])); 5828c2ecf20Sopenharmony_ci return; 5838c2ecf20Sopenharmony_ci } 5848c2ecf20Sopenharmony_ci } 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ci topclk_data.clks = topclk; 5878c2ecf20Sopenharmony_ci topclk_data.clk_num = ARRAY_SIZE(topclk); 5888c2ecf20Sopenharmony_ci of_clk_add_provider(np, of_clk_src_onecell_get, &topclk_data); 5898c2ecf20Sopenharmony_ci} 5908c2ecf20Sopenharmony_ciCLK_OF_DECLARE(zx296702_top_clk, "zte,zx296702-topcrm-clk", 5918c2ecf20Sopenharmony_ci zx296702_top_clocks_init); 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_cistatic void __init zx296702_lsp0_clocks_init(struct device_node *np) 5948c2ecf20Sopenharmony_ci{ 5958c2ecf20Sopenharmony_ci struct clk **clk = lsp0clk; 5968c2ecf20Sopenharmony_ci int i; 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ci lsp0crpm_base = of_iomap(np, 0); 5998c2ecf20Sopenharmony_ci WARN_ON(!lsp0crpm_base); 6008c2ecf20Sopenharmony_ci 6018c2ecf20Sopenharmony_ci /* SDMMC1 */ 6028c2ecf20Sopenharmony_ci clk[ZX296702_SDMMC1_WCLK_MUX] = 6038c2ecf20Sopenharmony_ci zx_mux("sdmmc1_wclk_mux", sdmmc1_wclk_sel, 6048c2ecf20Sopenharmony_ci ARRAY_SIZE(sdmmc1_wclk_sel), CLK_SDMMC1, 4, 1); 6058c2ecf20Sopenharmony_ci clk[ZX296702_SDMMC1_WCLK_DIV] = 6068c2ecf20Sopenharmony_ci zx_div("sdmmc1_wclk_div", "sdmmc1_wclk_mux", CLK_SDMMC1, 12, 4); 6078c2ecf20Sopenharmony_ci clk[ZX296702_SDMMC1_WCLK] = 6088c2ecf20Sopenharmony_ci zx_gate("sdmmc1_wclk", "sdmmc1_wclk_div", CLK_SDMMC1, 1); 6098c2ecf20Sopenharmony_ci clk[ZX296702_SDMMC1_PCLK] = 6108c2ecf20Sopenharmony_ci zx_gate("sdmmc1_pclk", "lsp0_apb_pclk", CLK_SDMMC1, 0); 6118c2ecf20Sopenharmony_ci 6128c2ecf20Sopenharmony_ci clk[ZX296702_GPIO_CLK] = 6138c2ecf20Sopenharmony_ci zx_gate("gpio_clk", "lsp0_apb_pclk", CLK_GPIO, 0); 6148c2ecf20Sopenharmony_ci 6158c2ecf20Sopenharmony_ci /* SPDIF */ 6168c2ecf20Sopenharmony_ci clk[ZX296702_SPDIF0_WCLK_MUX] = 6178c2ecf20Sopenharmony_ci zx_mux("spdif0_wclk_mux", spdif0_wclk_sel, 6188c2ecf20Sopenharmony_ci ARRAY_SIZE(spdif0_wclk_sel), CLK_SPDIF0, 4, 1); 6198c2ecf20Sopenharmony_ci clk[ZX296702_SPDIF0_WCLK] = 6208c2ecf20Sopenharmony_ci zx_gate("spdif0_wclk", "spdif0_wclk_mux", CLK_SPDIF0, 1); 6218c2ecf20Sopenharmony_ci clk[ZX296702_SPDIF0_PCLK] = 6228c2ecf20Sopenharmony_ci zx_gate("spdif0_pclk", "lsp0_apb_pclk", CLK_SPDIF0, 0); 6238c2ecf20Sopenharmony_ci 6248c2ecf20Sopenharmony_ci clk[ZX296702_SPDIF0_DIV] = 6258c2ecf20Sopenharmony_ci clk_register_zx_audio("spdif0_div", "spdif0_wclk", 0, 6268c2ecf20Sopenharmony_ci SPDIF0_DIV); 6278c2ecf20Sopenharmony_ci 6288c2ecf20Sopenharmony_ci /* I2S */ 6298c2ecf20Sopenharmony_ci clk[ZX296702_I2S0_WCLK_MUX] = 6308c2ecf20Sopenharmony_ci zx_mux("i2s0_wclk_mux", i2s_wclk_sel, 6318c2ecf20Sopenharmony_ci ARRAY_SIZE(i2s_wclk_sel), CLK_I2S0, 4, 1); 6328c2ecf20Sopenharmony_ci clk[ZX296702_I2S0_WCLK] = 6338c2ecf20Sopenharmony_ci zx_gate("i2s0_wclk", "i2s0_wclk_mux", CLK_I2S0, 1); 6348c2ecf20Sopenharmony_ci clk[ZX296702_I2S0_PCLK] = 6358c2ecf20Sopenharmony_ci zx_gate("i2s0_pclk", "lsp0_apb_pclk", CLK_I2S0, 0); 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ci clk[ZX296702_I2S0_DIV] = 6388c2ecf20Sopenharmony_ci clk_register_zx_audio("i2s0_div", "i2s0_wclk", 0, I2S0_DIV); 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_ci clk[ZX296702_I2S1_WCLK_MUX] = 6418c2ecf20Sopenharmony_ci zx_mux("i2s1_wclk_mux", i2s_wclk_sel, 6428c2ecf20Sopenharmony_ci ARRAY_SIZE(i2s_wclk_sel), CLK_I2S1, 4, 1); 6438c2ecf20Sopenharmony_ci clk[ZX296702_I2S1_WCLK] = 6448c2ecf20Sopenharmony_ci zx_gate("i2s1_wclk", "i2s1_wclk_mux", CLK_I2S1, 1); 6458c2ecf20Sopenharmony_ci clk[ZX296702_I2S1_PCLK] = 6468c2ecf20Sopenharmony_ci zx_gate("i2s1_pclk", "lsp0_apb_pclk", CLK_I2S1, 0); 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_ci clk[ZX296702_I2S1_DIV] = 6498c2ecf20Sopenharmony_ci clk_register_zx_audio("i2s1_div", "i2s1_wclk", 0, I2S1_DIV); 6508c2ecf20Sopenharmony_ci 6518c2ecf20Sopenharmony_ci clk[ZX296702_I2S2_WCLK_MUX] = 6528c2ecf20Sopenharmony_ci zx_mux("i2s2_wclk_mux", i2s_wclk_sel, 6538c2ecf20Sopenharmony_ci ARRAY_SIZE(i2s_wclk_sel), CLK_I2S2, 4, 1); 6548c2ecf20Sopenharmony_ci clk[ZX296702_I2S2_WCLK] = 6558c2ecf20Sopenharmony_ci zx_gate("i2s2_wclk", "i2s2_wclk_mux", CLK_I2S2, 1); 6568c2ecf20Sopenharmony_ci clk[ZX296702_I2S2_PCLK] = 6578c2ecf20Sopenharmony_ci zx_gate("i2s2_pclk", "lsp0_apb_pclk", CLK_I2S2, 0); 6588c2ecf20Sopenharmony_ci 6598c2ecf20Sopenharmony_ci clk[ZX296702_I2S2_DIV] = 6608c2ecf20Sopenharmony_ci clk_register_zx_audio("i2s2_div", "i2s2_wclk", 0, I2S2_DIV); 6618c2ecf20Sopenharmony_ci 6628c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(lsp0clk); i++) { 6638c2ecf20Sopenharmony_ci if (IS_ERR(clk[i])) { 6648c2ecf20Sopenharmony_ci pr_err("zx296702 clk %d: register failed with %ld\n", 6658c2ecf20Sopenharmony_ci i, PTR_ERR(clk[i])); 6668c2ecf20Sopenharmony_ci return; 6678c2ecf20Sopenharmony_ci } 6688c2ecf20Sopenharmony_ci } 6698c2ecf20Sopenharmony_ci 6708c2ecf20Sopenharmony_ci lsp0clk_data.clks = lsp0clk; 6718c2ecf20Sopenharmony_ci lsp0clk_data.clk_num = ARRAY_SIZE(lsp0clk); 6728c2ecf20Sopenharmony_ci of_clk_add_provider(np, of_clk_src_onecell_get, &lsp0clk_data); 6738c2ecf20Sopenharmony_ci} 6748c2ecf20Sopenharmony_ciCLK_OF_DECLARE(zx296702_lsp0_clk, "zte,zx296702-lsp0crpm-clk", 6758c2ecf20Sopenharmony_ci zx296702_lsp0_clocks_init); 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_cistatic void __init zx296702_lsp1_clocks_init(struct device_node *np) 6788c2ecf20Sopenharmony_ci{ 6798c2ecf20Sopenharmony_ci struct clk **clk = lsp1clk; 6808c2ecf20Sopenharmony_ci int i; 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_ci lsp1crpm_base = of_iomap(np, 0); 6838c2ecf20Sopenharmony_ci WARN_ON(!lsp1crpm_base); 6848c2ecf20Sopenharmony_ci 6858c2ecf20Sopenharmony_ci /* UART0 */ 6868c2ecf20Sopenharmony_ci clk[ZX296702_UART0_WCLK_MUX] = 6878c2ecf20Sopenharmony_ci zx_mux("uart0_wclk_mux", uart_wclk_sel, 6888c2ecf20Sopenharmony_ci ARRAY_SIZE(uart_wclk_sel), CLK_UART0, 4, 1); 6898c2ecf20Sopenharmony_ci /* FIXME: uart wclk enable bit is bit1 in. We hack it as reserved 31 for 6908c2ecf20Sopenharmony_ci * UART does not work after parent clk is disabled/enabled */ 6918c2ecf20Sopenharmony_ci clk[ZX296702_UART0_WCLK] = 6928c2ecf20Sopenharmony_ci zx_gate("uart0_wclk", "uart0_wclk_mux", CLK_UART0, 31); 6938c2ecf20Sopenharmony_ci clk[ZX296702_UART0_PCLK] = 6948c2ecf20Sopenharmony_ci zx_gate("uart0_pclk", "lsp1_apb_pclk", CLK_UART0, 0); 6958c2ecf20Sopenharmony_ci 6968c2ecf20Sopenharmony_ci /* UART1 */ 6978c2ecf20Sopenharmony_ci clk[ZX296702_UART1_WCLK_MUX] = 6988c2ecf20Sopenharmony_ci zx_mux("uart1_wclk_mux", uart_wclk_sel, 6998c2ecf20Sopenharmony_ci ARRAY_SIZE(uart_wclk_sel), CLK_UART1, 4, 1); 7008c2ecf20Sopenharmony_ci clk[ZX296702_UART1_WCLK] = 7018c2ecf20Sopenharmony_ci zx_gate("uart1_wclk", "uart1_wclk_mux", CLK_UART1, 1); 7028c2ecf20Sopenharmony_ci clk[ZX296702_UART1_PCLK] = 7038c2ecf20Sopenharmony_ci zx_gate("uart1_pclk", "lsp1_apb_pclk", CLK_UART1, 0); 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_ci /* SDMMC0 */ 7068c2ecf20Sopenharmony_ci clk[ZX296702_SDMMC0_WCLK_MUX] = 7078c2ecf20Sopenharmony_ci zx_mux("sdmmc0_wclk_mux", sdmmc0_wclk_sel, 7088c2ecf20Sopenharmony_ci ARRAY_SIZE(sdmmc0_wclk_sel), CLK_SDMMC0, 4, 1); 7098c2ecf20Sopenharmony_ci clk[ZX296702_SDMMC0_WCLK_DIV] = 7108c2ecf20Sopenharmony_ci zx_div("sdmmc0_wclk_div", "sdmmc0_wclk_mux", CLK_SDMMC0, 12, 4); 7118c2ecf20Sopenharmony_ci clk[ZX296702_SDMMC0_WCLK] = 7128c2ecf20Sopenharmony_ci zx_gate("sdmmc0_wclk", "sdmmc0_wclk_div", CLK_SDMMC0, 1); 7138c2ecf20Sopenharmony_ci clk[ZX296702_SDMMC0_PCLK] = 7148c2ecf20Sopenharmony_ci zx_gate("sdmmc0_pclk", "lsp1_apb_pclk", CLK_SDMMC0, 0); 7158c2ecf20Sopenharmony_ci 7168c2ecf20Sopenharmony_ci clk[ZX296702_SPDIF1_WCLK_MUX] = 7178c2ecf20Sopenharmony_ci zx_mux("spdif1_wclk_mux", spdif1_wclk_sel, 7188c2ecf20Sopenharmony_ci ARRAY_SIZE(spdif1_wclk_sel), CLK_SPDIF1, 4, 1); 7198c2ecf20Sopenharmony_ci clk[ZX296702_SPDIF1_WCLK] = 7208c2ecf20Sopenharmony_ci zx_gate("spdif1_wclk", "spdif1_wclk_mux", CLK_SPDIF1, 1); 7218c2ecf20Sopenharmony_ci clk[ZX296702_SPDIF1_PCLK] = 7228c2ecf20Sopenharmony_ci zx_gate("spdif1_pclk", "lsp1_apb_pclk", CLK_SPDIF1, 0); 7238c2ecf20Sopenharmony_ci 7248c2ecf20Sopenharmony_ci clk[ZX296702_SPDIF1_DIV] = 7258c2ecf20Sopenharmony_ci clk_register_zx_audio("spdif1_div", "spdif1_wclk", 0, 7268c2ecf20Sopenharmony_ci SPDIF1_DIV); 7278c2ecf20Sopenharmony_ci 7288c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(lsp1clk); i++) { 7298c2ecf20Sopenharmony_ci if (IS_ERR(clk[i])) { 7308c2ecf20Sopenharmony_ci pr_err("zx296702 clk %d: register failed with %ld\n", 7318c2ecf20Sopenharmony_ci i, PTR_ERR(clk[i])); 7328c2ecf20Sopenharmony_ci return; 7338c2ecf20Sopenharmony_ci } 7348c2ecf20Sopenharmony_ci } 7358c2ecf20Sopenharmony_ci 7368c2ecf20Sopenharmony_ci lsp1clk_data.clks = lsp1clk; 7378c2ecf20Sopenharmony_ci lsp1clk_data.clk_num = ARRAY_SIZE(lsp1clk); 7388c2ecf20Sopenharmony_ci of_clk_add_provider(np, of_clk_src_onecell_get, &lsp1clk_data); 7398c2ecf20Sopenharmony_ci} 7408c2ecf20Sopenharmony_ciCLK_OF_DECLARE(zx296702_lsp1_clk, "zte,zx296702-lsp1crpm-clk", 7418c2ecf20Sopenharmony_ci zx296702_lsp1_clocks_init); 742