18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2015 - 2016 ZTE Corporation. 48c2ecf20Sopenharmony_ci * Copyright (C) 2016 Linaro Ltd. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 78c2ecf20Sopenharmony_ci#include <linux/device.h> 88c2ecf20Sopenharmony_ci#include <linux/kernel.h> 98c2ecf20Sopenharmony_ci#include <linux/of_address.h> 108c2ecf20Sopenharmony_ci#include <linux/of_device.h> 118c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <dt-bindings/clock/zx296718-clock.h> 148c2ecf20Sopenharmony_ci#include "clk.h" 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* TOP CRM */ 178c2ecf20Sopenharmony_ci#define TOP_CLK_MUX0 0x04 188c2ecf20Sopenharmony_ci#define TOP_CLK_MUX1 0x08 198c2ecf20Sopenharmony_ci#define TOP_CLK_MUX2 0x0c 208c2ecf20Sopenharmony_ci#define TOP_CLK_MUX3 0x10 218c2ecf20Sopenharmony_ci#define TOP_CLK_MUX4 0x14 228c2ecf20Sopenharmony_ci#define TOP_CLK_MUX5 0x18 238c2ecf20Sopenharmony_ci#define TOP_CLK_MUX6 0x1c 248c2ecf20Sopenharmony_ci#define TOP_CLK_MUX7 0x20 258c2ecf20Sopenharmony_ci#define TOP_CLK_MUX9 0x28 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define TOP_CLK_GATE0 0x34 298c2ecf20Sopenharmony_ci#define TOP_CLK_GATE1 0x38 308c2ecf20Sopenharmony_ci#define TOP_CLK_GATE2 0x3c 318c2ecf20Sopenharmony_ci#define TOP_CLK_GATE3 0x40 328c2ecf20Sopenharmony_ci#define TOP_CLK_GATE4 0x44 338c2ecf20Sopenharmony_ci#define TOP_CLK_GATE5 0x48 348c2ecf20Sopenharmony_ci#define TOP_CLK_GATE6 0x4c 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define TOP_CLK_DIV0 0x58 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define PLL_CPU_REG 0x80 398c2ecf20Sopenharmony_ci#define PLL_VGA_REG 0xb0 408c2ecf20Sopenharmony_ci#define PLL_DDR_REG 0xa0 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* LSP0 CRM */ 438c2ecf20Sopenharmony_ci#define LSP0_TIMER3_CLK 0x4 448c2ecf20Sopenharmony_ci#define LSP0_TIMER4_CLK 0x8 458c2ecf20Sopenharmony_ci#define LSP0_TIMER5_CLK 0xc 468c2ecf20Sopenharmony_ci#define LSP0_UART3_CLK 0x10 478c2ecf20Sopenharmony_ci#define LSP0_UART1_CLK 0x14 488c2ecf20Sopenharmony_ci#define LSP0_UART2_CLK 0x18 498c2ecf20Sopenharmony_ci#define LSP0_SPIFC0_CLK 0x1c 508c2ecf20Sopenharmony_ci#define LSP0_I2C4_CLK 0x20 518c2ecf20Sopenharmony_ci#define LSP0_I2C5_CLK 0x24 528c2ecf20Sopenharmony_ci#define LSP0_SSP0_CLK 0x28 538c2ecf20Sopenharmony_ci#define LSP0_SSP1_CLK 0x2c 548c2ecf20Sopenharmony_ci#define LSP0_USIM0_CLK 0x30 558c2ecf20Sopenharmony_ci#define LSP0_GPIO_CLK 0x34 568c2ecf20Sopenharmony_ci#define LSP0_I2C3_CLK 0x38 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* LSP1 CRM */ 598c2ecf20Sopenharmony_ci#define LSP1_UART4_CLK 0x08 608c2ecf20Sopenharmony_ci#define LSP1_UART5_CLK 0x0c 618c2ecf20Sopenharmony_ci#define LSP1_PWM_CLK 0x10 628c2ecf20Sopenharmony_ci#define LSP1_I2C2_CLK 0x14 638c2ecf20Sopenharmony_ci#define LSP1_SSP2_CLK 0x1c 648c2ecf20Sopenharmony_ci#define LSP1_SSP3_CLK 0x20 658c2ecf20Sopenharmony_ci#define LSP1_SSP4_CLK 0x24 668c2ecf20Sopenharmony_ci#define LSP1_USIM1_CLK 0x28 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* audio lsp */ 698c2ecf20Sopenharmony_ci#define AUDIO_I2S0_DIV_CFG1 0x10 708c2ecf20Sopenharmony_ci#define AUDIO_I2S0_DIV_CFG2 0x14 718c2ecf20Sopenharmony_ci#define AUDIO_I2S0_CLK 0x18 728c2ecf20Sopenharmony_ci#define AUDIO_I2S1_DIV_CFG1 0x20 738c2ecf20Sopenharmony_ci#define AUDIO_I2S1_DIV_CFG2 0x24 748c2ecf20Sopenharmony_ci#define AUDIO_I2S1_CLK 0x28 758c2ecf20Sopenharmony_ci#define AUDIO_I2S2_DIV_CFG1 0x30 768c2ecf20Sopenharmony_ci#define AUDIO_I2S2_DIV_CFG2 0x34 778c2ecf20Sopenharmony_ci#define AUDIO_I2S2_CLK 0x38 788c2ecf20Sopenharmony_ci#define AUDIO_I2S3_DIV_CFG1 0x40 798c2ecf20Sopenharmony_ci#define AUDIO_I2S3_DIV_CFG2 0x44 808c2ecf20Sopenharmony_ci#define AUDIO_I2S3_CLK 0x48 818c2ecf20Sopenharmony_ci#define AUDIO_I2C0_CLK 0x50 828c2ecf20Sopenharmony_ci#define AUDIO_SPDIF0_DIV_CFG1 0x60 838c2ecf20Sopenharmony_ci#define AUDIO_SPDIF0_DIV_CFG2 0x64 848c2ecf20Sopenharmony_ci#define AUDIO_SPDIF0_CLK 0x68 858c2ecf20Sopenharmony_ci#define AUDIO_SPDIF1_DIV_CFG1 0x70 868c2ecf20Sopenharmony_ci#define AUDIO_SPDIF1_DIV_CFG2 0x74 878c2ecf20Sopenharmony_ci#define AUDIO_SPDIF1_CLK 0x78 888c2ecf20Sopenharmony_ci#define AUDIO_TIMER_CLK 0x80 898c2ecf20Sopenharmony_ci#define AUDIO_TDM_CLK 0x90 908c2ecf20Sopenharmony_ci#define AUDIO_TS_CLK 0xa0 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(clk_lock); 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cistatic const struct zx_pll_config pll_cpu_table[] = { 958c2ecf20Sopenharmony_ci PLL_RATE(1312000000, 0x00103621, 0x04aaaaaa), 968c2ecf20Sopenharmony_ci PLL_RATE(1407000000, 0x00103a21, 0x04aaaaaa), 978c2ecf20Sopenharmony_ci PLL_RATE(1503000000, 0x00103e21, 0x04aaaaaa), 988c2ecf20Sopenharmony_ci PLL_RATE(1600000000, 0x00104221, 0x04aaaaaa), 998c2ecf20Sopenharmony_ci}; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_cistatic const struct zx_pll_config pll_vga_table[] = { 1028c2ecf20Sopenharmony_ci PLL_RATE(36000000, 0x00102464, 0x04000000), /* 800x600@56 */ 1038c2ecf20Sopenharmony_ci PLL_RATE(40000000, 0x00102864, 0x04000000), /* 800x600@60 */ 1048c2ecf20Sopenharmony_ci PLL_RATE(49500000, 0x00103164, 0x04800000), /* 800x600@75 */ 1058c2ecf20Sopenharmony_ci PLL_RATE(50000000, 0x00103264, 0x04000000), /* 800x600@72 */ 1068c2ecf20Sopenharmony_ci PLL_RATE(56250000, 0x00103864, 0x04400000), /* 800x600@85 */ 1078c2ecf20Sopenharmony_ci PLL_RATE(65000000, 0x00104164, 0x04000000), /* 1024x768@60 */ 1088c2ecf20Sopenharmony_ci PLL_RATE(74375000, 0x00104a64, 0x04600000), /* 1280x720@60 */ 1098c2ecf20Sopenharmony_ci PLL_RATE(75000000, 0x00104b64, 0x04800000), /* 1024x768@70 */ 1108c2ecf20Sopenharmony_ci PLL_RATE(78750000, 0x00104e64, 0x04c00000), /* 1024x768@75 */ 1118c2ecf20Sopenharmony_ci PLL_RATE(85500000, 0x00105564, 0x04800000), /* 1360x768@60 */ 1128c2ecf20Sopenharmony_ci PLL_RATE(106500000, 0x00106a64, 0x04800000), /* 1440x900@60 */ 1138c2ecf20Sopenharmony_ci PLL_RATE(108000000, 0x00106c64, 0x04000000), /* 1280x1024@60 */ 1148c2ecf20Sopenharmony_ci PLL_RATE(110000000, 0x00106e64, 0x04000000), /* 1024x768@85 */ 1158c2ecf20Sopenharmony_ci PLL_RATE(135000000, 0x00105a44, 0x04000000), /* 1280x1024@75 */ 1168c2ecf20Sopenharmony_ci PLL_RATE(136750000, 0x00104462, 0x04600000), /* 1440x900@75 */ 1178c2ecf20Sopenharmony_ci PLL_RATE(148500000, 0x00104a62, 0x04400000), /* 1920x1080@60 */ 1188c2ecf20Sopenharmony_ci PLL_RATE(157000000, 0x00104e62, 0x04800000), /* 1440x900@85 */ 1198c2ecf20Sopenharmony_ci PLL_RATE(157500000, 0x00104e62, 0x04c00000), /* 1280x1024@85 */ 1208c2ecf20Sopenharmony_ci PLL_RATE(162000000, 0x00105162, 0x04000000), /* 1600x1200@60 */ 1218c2ecf20Sopenharmony_ci PLL_RATE(193250000, 0x00106062, 0x04a00000), /* 1920x1200@60 */ 1228c2ecf20Sopenharmony_ci}; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ciPNAME(osc) = { 1258c2ecf20Sopenharmony_ci "osc24m", 1268c2ecf20Sopenharmony_ci "osc32k", 1278c2ecf20Sopenharmony_ci}; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ciPNAME(dbg_wclk_p) = { 1308c2ecf20Sopenharmony_ci "clk334m", 1318c2ecf20Sopenharmony_ci "clk466m", 1328c2ecf20Sopenharmony_ci "clk396m", 1338c2ecf20Sopenharmony_ci "clk250m", 1348c2ecf20Sopenharmony_ci}; 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ciPNAME(a72_coreclk_p) = { 1378c2ecf20Sopenharmony_ci "osc24m", 1388c2ecf20Sopenharmony_ci "pll_mm0_1188m", 1398c2ecf20Sopenharmony_ci "pll_mm1_1296m", 1408c2ecf20Sopenharmony_ci "clk1000m", 1418c2ecf20Sopenharmony_ci "clk648m", 1428c2ecf20Sopenharmony_ci "clk1600m", 1438c2ecf20Sopenharmony_ci "pll_audio_1800m", 1448c2ecf20Sopenharmony_ci "pll_vga_1800m", 1458c2ecf20Sopenharmony_ci}; 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ciPNAME(cpu_periclk_p) = { 1488c2ecf20Sopenharmony_ci "osc24m", 1498c2ecf20Sopenharmony_ci "clk500m", 1508c2ecf20Sopenharmony_ci "clk594m", 1518c2ecf20Sopenharmony_ci "clk466m", 1528c2ecf20Sopenharmony_ci "clk294m", 1538c2ecf20Sopenharmony_ci "clk334m", 1548c2ecf20Sopenharmony_ci "clk250m", 1558c2ecf20Sopenharmony_ci "clk125m", 1568c2ecf20Sopenharmony_ci}; 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ciPNAME(a53_coreclk_p) = { 1598c2ecf20Sopenharmony_ci "osc24m", 1608c2ecf20Sopenharmony_ci "clk1000m", 1618c2ecf20Sopenharmony_ci "pll_mm0_1188m", 1628c2ecf20Sopenharmony_ci "clk648m", 1638c2ecf20Sopenharmony_ci "clk500m", 1648c2ecf20Sopenharmony_ci "clk800m", 1658c2ecf20Sopenharmony_ci "clk1600m", 1668c2ecf20Sopenharmony_ci "pll_audio_1800m", 1678c2ecf20Sopenharmony_ci}; 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ciPNAME(sec_wclk_p) = { 1708c2ecf20Sopenharmony_ci "osc24m", 1718c2ecf20Sopenharmony_ci "clk396m", 1728c2ecf20Sopenharmony_ci "clk334m", 1738c2ecf20Sopenharmony_ci "clk297m", 1748c2ecf20Sopenharmony_ci "clk250m", 1758c2ecf20Sopenharmony_ci "clk198m", 1768c2ecf20Sopenharmony_ci "clk148m5", 1778c2ecf20Sopenharmony_ci "clk99m", 1788c2ecf20Sopenharmony_ci}; 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ciPNAME(sd_nand_wclk_p) = { 1818c2ecf20Sopenharmony_ci "osc24m", 1828c2ecf20Sopenharmony_ci "clk49m5", 1838c2ecf20Sopenharmony_ci "clk99m", 1848c2ecf20Sopenharmony_ci "clk198m", 1858c2ecf20Sopenharmony_ci "clk167m", 1868c2ecf20Sopenharmony_ci "clk148m5", 1878c2ecf20Sopenharmony_ci "clk125m", 1888c2ecf20Sopenharmony_ci "clk216m", 1898c2ecf20Sopenharmony_ci}; 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ciPNAME(emmc_wclk_p) = { 1928c2ecf20Sopenharmony_ci "osc24m", 1938c2ecf20Sopenharmony_ci "clk198m", 1948c2ecf20Sopenharmony_ci "clk99m", 1958c2ecf20Sopenharmony_ci "clk396m", 1968c2ecf20Sopenharmony_ci "clk334m", 1978c2ecf20Sopenharmony_ci "clk297m", 1988c2ecf20Sopenharmony_ci "clk250m", 1998c2ecf20Sopenharmony_ci "clk148m5", 2008c2ecf20Sopenharmony_ci}; 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ciPNAME(clk32_p) = { 2038c2ecf20Sopenharmony_ci "osc32k", 2048c2ecf20Sopenharmony_ci "clk32k768", 2058c2ecf20Sopenharmony_ci}; 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ciPNAME(usb_ref24m_p) = { 2088c2ecf20Sopenharmony_ci "osc32k", 2098c2ecf20Sopenharmony_ci "clk32k768", 2108c2ecf20Sopenharmony_ci}; 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ciPNAME(sys_noc_alck_p) = { 2138c2ecf20Sopenharmony_ci "osc24m", 2148c2ecf20Sopenharmony_ci "clk250m", 2158c2ecf20Sopenharmony_ci "clk198m", 2168c2ecf20Sopenharmony_ci "clk148m5", 2178c2ecf20Sopenharmony_ci "clk108m", 2188c2ecf20Sopenharmony_ci "clk54m", 2198c2ecf20Sopenharmony_ci "clk216m", 2208c2ecf20Sopenharmony_ci "clk240m", 2218c2ecf20Sopenharmony_ci}; 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ciPNAME(vde_aclk_p) = { 2248c2ecf20Sopenharmony_ci "clk334m", 2258c2ecf20Sopenharmony_ci "clk594m", 2268c2ecf20Sopenharmony_ci "clk500m", 2278c2ecf20Sopenharmony_ci "clk432m", 2288c2ecf20Sopenharmony_ci "clk480m", 2298c2ecf20Sopenharmony_ci "clk297m", 2308c2ecf20Sopenharmony_ci "clk_vga", /*600MHz*/ 2318c2ecf20Sopenharmony_ci "clk294m", 2328c2ecf20Sopenharmony_ci}; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ciPNAME(vce_aclk_p) = { 2358c2ecf20Sopenharmony_ci "clk334m", 2368c2ecf20Sopenharmony_ci "clk594m", 2378c2ecf20Sopenharmony_ci "clk500m", 2388c2ecf20Sopenharmony_ci "clk432m", 2398c2ecf20Sopenharmony_ci "clk396m", 2408c2ecf20Sopenharmony_ci "clk297m", 2418c2ecf20Sopenharmony_ci "clk_vga", /*600MHz*/ 2428c2ecf20Sopenharmony_ci "clk294m", 2438c2ecf20Sopenharmony_ci}; 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ciPNAME(hde_aclk_p) = { 2468c2ecf20Sopenharmony_ci "clk334m", 2478c2ecf20Sopenharmony_ci "clk594m", 2488c2ecf20Sopenharmony_ci "clk500m", 2498c2ecf20Sopenharmony_ci "clk432m", 2508c2ecf20Sopenharmony_ci "clk396m", 2518c2ecf20Sopenharmony_ci "clk297m", 2528c2ecf20Sopenharmony_ci "clk_vga", /*600MHz*/ 2538c2ecf20Sopenharmony_ci "clk294m", 2548c2ecf20Sopenharmony_ci}; 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ciPNAME(gpu_aclk_p) = { 2578c2ecf20Sopenharmony_ci "clk334m", 2588c2ecf20Sopenharmony_ci "clk648m", 2598c2ecf20Sopenharmony_ci "clk594m", 2608c2ecf20Sopenharmony_ci "clk500m", 2618c2ecf20Sopenharmony_ci "clk396m", 2628c2ecf20Sopenharmony_ci "clk297m", 2638c2ecf20Sopenharmony_ci "clk_vga", /*600MHz*/ 2648c2ecf20Sopenharmony_ci "clk294m", 2658c2ecf20Sopenharmony_ci}; 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ciPNAME(sappu_aclk_p) = { 2688c2ecf20Sopenharmony_ci "clk396m", 2698c2ecf20Sopenharmony_ci "clk500m", 2708c2ecf20Sopenharmony_ci "clk250m", 2718c2ecf20Sopenharmony_ci "clk148m5", 2728c2ecf20Sopenharmony_ci}; 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ciPNAME(sappu_wclk_p) = { 2758c2ecf20Sopenharmony_ci "clk198m", 2768c2ecf20Sopenharmony_ci "clk396m", 2778c2ecf20Sopenharmony_ci "clk334m", 2788c2ecf20Sopenharmony_ci "clk297m", 2798c2ecf20Sopenharmony_ci "clk250m", 2808c2ecf20Sopenharmony_ci "clk148m5", 2818c2ecf20Sopenharmony_ci "clk125m", 2828c2ecf20Sopenharmony_ci "clk99m", 2838c2ecf20Sopenharmony_ci}; 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ciPNAME(vou_aclk_p) = { 2868c2ecf20Sopenharmony_ci "clk334m", 2878c2ecf20Sopenharmony_ci "clk594m", 2888c2ecf20Sopenharmony_ci "clk500m", 2898c2ecf20Sopenharmony_ci "clk432m", 2908c2ecf20Sopenharmony_ci "clk396m", 2918c2ecf20Sopenharmony_ci "clk297m", 2928c2ecf20Sopenharmony_ci "clk_vga", /*600MHz*/ 2938c2ecf20Sopenharmony_ci "clk294m", 2948c2ecf20Sopenharmony_ci}; 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ciPNAME(vou_main_wclk_p) = { 2978c2ecf20Sopenharmony_ci "clk108m", 2988c2ecf20Sopenharmony_ci "clk594m", 2998c2ecf20Sopenharmony_ci "clk297m", 3008c2ecf20Sopenharmony_ci "clk148m5", 3018c2ecf20Sopenharmony_ci "clk74m25", 3028c2ecf20Sopenharmony_ci "clk54m", 3038c2ecf20Sopenharmony_ci "clk27m", 3048c2ecf20Sopenharmony_ci "clk_vga", 3058c2ecf20Sopenharmony_ci}; 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ciPNAME(vou_aux_wclk_p) = { 3088c2ecf20Sopenharmony_ci "clk108m", 3098c2ecf20Sopenharmony_ci "clk148m5", 3108c2ecf20Sopenharmony_ci "clk74m25", 3118c2ecf20Sopenharmony_ci "clk54m", 3128c2ecf20Sopenharmony_ci "clk27m", 3138c2ecf20Sopenharmony_ci "clk_vga", 3148c2ecf20Sopenharmony_ci "clk54m_mm0", 3158c2ecf20Sopenharmony_ci "clk" 3168c2ecf20Sopenharmony_ci}; 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ciPNAME(vou_ppu_wclk_p) = { 3198c2ecf20Sopenharmony_ci "clk334m", 3208c2ecf20Sopenharmony_ci "clk432m", 3218c2ecf20Sopenharmony_ci "clk396m", 3228c2ecf20Sopenharmony_ci "clk297m", 3238c2ecf20Sopenharmony_ci "clk250m", 3248c2ecf20Sopenharmony_ci "clk125m", 3258c2ecf20Sopenharmony_ci "clk198m", 3268c2ecf20Sopenharmony_ci "clk99m", 3278c2ecf20Sopenharmony_ci}; 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ciPNAME(vga_i2c_wclk_p) = { 3308c2ecf20Sopenharmony_ci "osc24m", 3318c2ecf20Sopenharmony_ci "clk99m", 3328c2ecf20Sopenharmony_ci}; 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ciPNAME(viu_m0_aclk_p) = { 3358c2ecf20Sopenharmony_ci "clk334m", 3368c2ecf20Sopenharmony_ci "clk432m", 3378c2ecf20Sopenharmony_ci "clk396m", 3388c2ecf20Sopenharmony_ci "clk297m", 3398c2ecf20Sopenharmony_ci "clk250m", 3408c2ecf20Sopenharmony_ci "clk125m", 3418c2ecf20Sopenharmony_ci "clk198m", 3428c2ecf20Sopenharmony_ci "osc24m", 3438c2ecf20Sopenharmony_ci}; 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ciPNAME(viu_m1_aclk_p) = { 3468c2ecf20Sopenharmony_ci "clk198m", 3478c2ecf20Sopenharmony_ci "clk250m", 3488c2ecf20Sopenharmony_ci "clk297m", 3498c2ecf20Sopenharmony_ci "clk125m", 3508c2ecf20Sopenharmony_ci "clk396m", 3518c2ecf20Sopenharmony_ci "clk334m", 3528c2ecf20Sopenharmony_ci "clk148m5", 3538c2ecf20Sopenharmony_ci "osc24m", 3548c2ecf20Sopenharmony_ci}; 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_ciPNAME(viu_clk_p) = { 3578c2ecf20Sopenharmony_ci "clk198m", 3588c2ecf20Sopenharmony_ci "clk334m", 3598c2ecf20Sopenharmony_ci "clk297m", 3608c2ecf20Sopenharmony_ci "clk250m", 3618c2ecf20Sopenharmony_ci "clk396m", 3628c2ecf20Sopenharmony_ci "clk125m", 3638c2ecf20Sopenharmony_ci "clk99m", 3648c2ecf20Sopenharmony_ci "clk148m5", 3658c2ecf20Sopenharmony_ci}; 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ciPNAME(viu_jpeg_clk_p) = { 3688c2ecf20Sopenharmony_ci "clk334m", 3698c2ecf20Sopenharmony_ci "clk480m", 3708c2ecf20Sopenharmony_ci "clk432m", 3718c2ecf20Sopenharmony_ci "clk396m", 3728c2ecf20Sopenharmony_ci "clk297m", 3738c2ecf20Sopenharmony_ci "clk250m", 3748c2ecf20Sopenharmony_ci "clk125m", 3758c2ecf20Sopenharmony_ci "clk198m", 3768c2ecf20Sopenharmony_ci}; 3778c2ecf20Sopenharmony_ci 3788c2ecf20Sopenharmony_ciPNAME(ts_sys_clk_p) = { 3798c2ecf20Sopenharmony_ci "clk192m", 3808c2ecf20Sopenharmony_ci "clk167m", 3818c2ecf20Sopenharmony_ci "clk125m", 3828c2ecf20Sopenharmony_ci "clk99m", 3838c2ecf20Sopenharmony_ci}; 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ciPNAME(wdt_ares_p) = { 3868c2ecf20Sopenharmony_ci "osc24m", 3878c2ecf20Sopenharmony_ci "clk32k" 3888c2ecf20Sopenharmony_ci}; 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_cistatic struct clk_zx_pll zx296718_pll_clk[] = { 3918c2ecf20Sopenharmony_ci ZX296718_PLL("pll_cpu", "osc24m", PLL_CPU_REG, pll_cpu_table), 3928c2ecf20Sopenharmony_ci ZX296718_PLL("pll_vga", "osc24m", PLL_VGA_REG, pll_vga_table), 3938c2ecf20Sopenharmony_ci}; 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_cistatic struct zx_clk_fixed_factor top_ffactor_clk[] = { 3968c2ecf20Sopenharmony_ci FFACTOR(0, "clk4m", "osc24m", 1, 6, 0), 3978c2ecf20Sopenharmony_ci FFACTOR(0, "clk2m", "osc24m", 1, 12, 0), 3988c2ecf20Sopenharmony_ci /* pll cpu */ 3998c2ecf20Sopenharmony_ci FFACTOR(0, "clk1600m", "pll_cpu", 1, 1, CLK_SET_RATE_PARENT), 4008c2ecf20Sopenharmony_ci FFACTOR(0, "clk800m", "pll_cpu", 1, 2, CLK_SET_RATE_PARENT), 4018c2ecf20Sopenharmony_ci /* pll mac */ 4028c2ecf20Sopenharmony_ci FFACTOR(0, "clk25m", "pll_mac", 1, 40, 0), 4038c2ecf20Sopenharmony_ci FFACTOR(0, "clk125m", "pll_mac", 1, 8, 0), 4048c2ecf20Sopenharmony_ci FFACTOR(0, "clk250m", "pll_mac", 1, 4, 0), 4058c2ecf20Sopenharmony_ci FFACTOR(0, "clk50m", "pll_mac", 1, 20, 0), 4068c2ecf20Sopenharmony_ci FFACTOR(0, "clk500m", "pll_mac", 1, 2, 0), 4078c2ecf20Sopenharmony_ci FFACTOR(0, "clk1000m", "pll_mac", 1, 1, 0), 4088c2ecf20Sopenharmony_ci FFACTOR(0, "clk334m", "pll_mac", 1, 3, 0), 4098c2ecf20Sopenharmony_ci FFACTOR(0, "clk167m", "pll_mac", 1, 6, 0), 4108c2ecf20Sopenharmony_ci /* pll mm */ 4118c2ecf20Sopenharmony_ci FFACTOR(0, "clk54m_mm0", "pll_mm0", 1, 22, 0), 4128c2ecf20Sopenharmony_ci FFACTOR(0, "clk74m25", "pll_mm0", 1, 16, 0), 4138c2ecf20Sopenharmony_ci FFACTOR(0, "clk148m5", "pll_mm0", 1, 8, 0), 4148c2ecf20Sopenharmony_ci FFACTOR(0, "clk297m", "pll_mm0", 1, 4, 0), 4158c2ecf20Sopenharmony_ci FFACTOR(0, "clk594m", "pll_mm0", 1, 2, 0), 4168c2ecf20Sopenharmony_ci FFACTOR(0, "pll_mm0_1188m", "pll_mm0", 1, 1, 0), 4178c2ecf20Sopenharmony_ci FFACTOR(0, "clk396m", "pll_mm0", 1, 3, 0), 4188c2ecf20Sopenharmony_ci FFACTOR(0, "clk198m", "pll_mm0", 1, 6, 0), 4198c2ecf20Sopenharmony_ci FFACTOR(0, "clk99m", "pll_mm0", 1, 12, 0), 4208c2ecf20Sopenharmony_ci FFACTOR(0, "clk49m5", "pll_mm0", 1, 24, 0), 4218c2ecf20Sopenharmony_ci /* pll mm */ 4228c2ecf20Sopenharmony_ci FFACTOR(0, "clk324m", "pll_mm1", 1, 4, 0), 4238c2ecf20Sopenharmony_ci FFACTOR(0, "clk648m", "pll_mm1", 1, 2, 0), 4248c2ecf20Sopenharmony_ci FFACTOR(0, "pll_mm1_1296m", "pll_mm1", 1, 1, 0), 4258c2ecf20Sopenharmony_ci FFACTOR(0, "clk216m", "pll_mm1", 1, 6, 0), 4268c2ecf20Sopenharmony_ci FFACTOR(0, "clk432m", "pll_mm1", 1, 3, 0), 4278c2ecf20Sopenharmony_ci FFACTOR(0, "clk108m", "pll_mm1", 1, 12, 0), 4288c2ecf20Sopenharmony_ci FFACTOR(0, "clk72m", "pll_mm1", 1, 18, 0), 4298c2ecf20Sopenharmony_ci FFACTOR(0, "clk27m", "pll_mm1", 1, 48, 0), 4308c2ecf20Sopenharmony_ci FFACTOR(0, "clk54m", "pll_mm1", 1, 24, 0), 4318c2ecf20Sopenharmony_ci /* vga */ 4328c2ecf20Sopenharmony_ci FFACTOR(0, "pll_vga_1800m", "pll_vga", 1, 1, 0), 4338c2ecf20Sopenharmony_ci FFACTOR(0, "clk_vga", "pll_vga", 1, 1, CLK_SET_RATE_PARENT), 4348c2ecf20Sopenharmony_ci /* pll ddr */ 4358c2ecf20Sopenharmony_ci FFACTOR(0, "clk466m", "pll_ddr", 1, 2, 0), 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci /* pll audio */ 4388c2ecf20Sopenharmony_ci FFACTOR(0, "pll_audio_1800m", "pll_audio", 1, 1, 0), 4398c2ecf20Sopenharmony_ci FFACTOR(0, "clk32k768", "pll_audio", 1, 27000, 0), 4408c2ecf20Sopenharmony_ci FFACTOR(0, "clk16m384", "pll_audio", 1, 54, 0), 4418c2ecf20Sopenharmony_ci FFACTOR(0, "clk294m", "pll_audio", 1, 3, 0), 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci /* pll hsic*/ 4448c2ecf20Sopenharmony_ci FFACTOR(0, "clk240m", "pll_hsic", 1, 4, 0), 4458c2ecf20Sopenharmony_ci FFACTOR(0, "clk480m", "pll_hsic", 1, 2, 0), 4468c2ecf20Sopenharmony_ci FFACTOR(0, "clk192m", "pll_hsic", 1, 5, 0), 4478c2ecf20Sopenharmony_ci FFACTOR(0, "clk_pll_24m", "pll_hsic", 1, 40, 0), 4488c2ecf20Sopenharmony_ci FFACTOR(0, "emmc_mux_div2", "emmc_mux", 1, 2, CLK_SET_RATE_PARENT), 4498c2ecf20Sopenharmony_ci}; 4508c2ecf20Sopenharmony_ci 4518c2ecf20Sopenharmony_cistatic const struct clk_div_table noc_div_table[] = { 4528c2ecf20Sopenharmony_ci { .val = 1, .div = 2, }, 4538c2ecf20Sopenharmony_ci { .val = 3, .div = 4, }, 4548c2ecf20Sopenharmony_ci}; 4558c2ecf20Sopenharmony_cistatic struct zx_clk_div top_div_clk[] = { 4568c2ecf20Sopenharmony_ci DIV_T(0, "sys_noc_hclk", "sys_noc_aclk", TOP_CLK_DIV0, 0, 2, 0, noc_div_table), 4578c2ecf20Sopenharmony_ci DIV_T(0, "sys_noc_pclk", "sys_noc_aclk", TOP_CLK_DIV0, 4, 2, 0, noc_div_table), 4588c2ecf20Sopenharmony_ci}; 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_cistatic struct zx_clk_mux top_mux_clk[] = { 4618c2ecf20Sopenharmony_ci MUX(0, "dbg_mux", dbg_wclk_p, TOP_CLK_MUX0, 12, 2), 4628c2ecf20Sopenharmony_ci MUX(0, "a72_mux", a72_coreclk_p, TOP_CLK_MUX0, 8, 3), 4638c2ecf20Sopenharmony_ci MUX(0, "cpu_peri_mux", cpu_periclk_p, TOP_CLK_MUX0, 4, 3), 4648c2ecf20Sopenharmony_ci MUX_F(0, "a53_mux", a53_coreclk_p, TOP_CLK_MUX0, 0, 3, CLK_SET_RATE_PARENT, 0), 4658c2ecf20Sopenharmony_ci MUX(0, "sys_noc_aclk", sys_noc_alck_p, TOP_CLK_MUX1, 0, 3), 4668c2ecf20Sopenharmony_ci MUX(0, "sec_mux", sec_wclk_p, TOP_CLK_MUX2, 16, 3), 4678c2ecf20Sopenharmony_ci MUX(0, "sd1_mux", sd_nand_wclk_p, TOP_CLK_MUX2, 12, 3), 4688c2ecf20Sopenharmony_ci MUX(0, "sd0_mux", sd_nand_wclk_p, TOP_CLK_MUX2, 8, 3), 4698c2ecf20Sopenharmony_ci MUX(0, "emmc_mux", emmc_wclk_p, TOP_CLK_MUX2, 4, 3), 4708c2ecf20Sopenharmony_ci MUX(0, "nand_mux", sd_nand_wclk_p, TOP_CLK_MUX2, 0, 3), 4718c2ecf20Sopenharmony_ci MUX(0, "usb_ref24m_mux", usb_ref24m_p, TOP_CLK_MUX9, 16, 1), 4728c2ecf20Sopenharmony_ci MUX(0, "clk32k", clk32_p, TOP_CLK_MUX9, 12, 1), 4738c2ecf20Sopenharmony_ci MUX_F(0, "wdt_mux", wdt_ares_p, TOP_CLK_MUX9, 8, 1, CLK_SET_RATE_PARENT, 0), 4748c2ecf20Sopenharmony_ci MUX(0, "timer_mux", osc, TOP_CLK_MUX9, 4, 1), 4758c2ecf20Sopenharmony_ci MUX(0, "vde_mux", vde_aclk_p, TOP_CLK_MUX4, 0, 3), 4768c2ecf20Sopenharmony_ci MUX(0, "vce_mux", vce_aclk_p, TOP_CLK_MUX4, 4, 3), 4778c2ecf20Sopenharmony_ci MUX(0, "hde_mux", hde_aclk_p, TOP_CLK_MUX4, 8, 3), 4788c2ecf20Sopenharmony_ci MUX(0, "gpu_mux", gpu_aclk_p, TOP_CLK_MUX5, 0, 3), 4798c2ecf20Sopenharmony_ci MUX(0, "sappu_a_mux", sappu_aclk_p, TOP_CLK_MUX5, 4, 2), 4808c2ecf20Sopenharmony_ci MUX(0, "sappu_w_mux", sappu_wclk_p, TOP_CLK_MUX5, 8, 3), 4818c2ecf20Sopenharmony_ci MUX(0, "vou_a_mux", vou_aclk_p, TOP_CLK_MUX7, 0, 3), 4828c2ecf20Sopenharmony_ci MUX_F(0, "vou_main_w_mux", vou_main_wclk_p, TOP_CLK_MUX7, 4, 3, CLK_SET_RATE_PARENT, 0), 4838c2ecf20Sopenharmony_ci MUX_F(0, "vou_aux_w_mux", vou_aux_wclk_p, TOP_CLK_MUX7, 8, 3, CLK_SET_RATE_PARENT, 0), 4848c2ecf20Sopenharmony_ci MUX(0, "vou_ppu_w_mux", vou_ppu_wclk_p, TOP_CLK_MUX7, 12, 3), 4858c2ecf20Sopenharmony_ci MUX(0, "vga_i2c_mux", vga_i2c_wclk_p, TOP_CLK_MUX7, 16, 1), 4868c2ecf20Sopenharmony_ci MUX(0, "viu_m0_a_mux", viu_m0_aclk_p, TOP_CLK_MUX6, 0, 3), 4878c2ecf20Sopenharmony_ci MUX(0, "viu_m1_a_mux", viu_m1_aclk_p, TOP_CLK_MUX6, 4, 3), 4888c2ecf20Sopenharmony_ci MUX(0, "viu_w_mux", viu_clk_p, TOP_CLK_MUX6, 8, 3), 4898c2ecf20Sopenharmony_ci MUX(0, "viu_jpeg_w_mux", viu_jpeg_clk_p, TOP_CLK_MUX6, 12, 3), 4908c2ecf20Sopenharmony_ci MUX(0, "ts_sys_mux", ts_sys_clk_p, TOP_CLK_MUX6, 16, 2), 4918c2ecf20Sopenharmony_ci}; 4928c2ecf20Sopenharmony_ci 4938c2ecf20Sopenharmony_cistatic struct zx_clk_gate top_gate_clk[] = { 4948c2ecf20Sopenharmony_ci GATE(CPU_DBG_GATE, "dbg_wclk", "dbg_mux", TOP_CLK_GATE0, 4, CLK_SET_RATE_PARENT, 0), 4958c2ecf20Sopenharmony_ci GATE(A72_GATE, "a72_coreclk", "a72_mux", TOP_CLK_GATE0, 3, CLK_SET_RATE_PARENT, 0), 4968c2ecf20Sopenharmony_ci GATE(CPU_PERI_GATE, "cpu_peri", "cpu_peri_mux", TOP_CLK_GATE0, 1, CLK_SET_RATE_PARENT, 0), 4978c2ecf20Sopenharmony_ci GATE(A53_GATE, "a53_coreclk", "a53_mux", TOP_CLK_GATE0, 0, CLK_SET_RATE_PARENT, 0), 4988c2ecf20Sopenharmony_ci GATE(SD1_WCLK, "sd1_wclk", "sd1_mux", TOP_CLK_GATE1, 13, CLK_SET_RATE_PARENT, 0), 4998c2ecf20Sopenharmony_ci GATE(SD0_WCLK, "sd0_wclk", "sd0_mux", TOP_CLK_GATE1, 9, CLK_SET_RATE_PARENT, 0), 5008c2ecf20Sopenharmony_ci GATE(EMMC_WCLK, "emmc_wclk", "emmc_mux_div2", TOP_CLK_GATE0, 5, CLK_SET_RATE_PARENT, 0), 5018c2ecf20Sopenharmony_ci GATE(EMMC_NAND_AXI, "emmc_nand_aclk", "sys_noc_aclk", TOP_CLK_GATE1, 4, CLK_SET_RATE_PARENT, 0), 5028c2ecf20Sopenharmony_ci GATE(NAND_WCLK, "nand_wclk", "nand_mux", TOP_CLK_GATE0, 1, CLK_SET_RATE_PARENT, 0), 5038c2ecf20Sopenharmony_ci GATE(EMMC_NAND_AHB, "emmc_nand_hclk", "sys_noc_hclk", TOP_CLK_GATE1, 0, CLK_SET_RATE_PARENT, 0), 5048c2ecf20Sopenharmony_ci GATE(0, "lsp1_pclk", "sys_noc_pclk", TOP_CLK_GATE2, 31, 0, 0), 5058c2ecf20Sopenharmony_ci GATE(LSP1_148M5, "lsp1_148m5", "clk148m5", TOP_CLK_GATE2, 30, 0, 0), 5068c2ecf20Sopenharmony_ci GATE(LSP1_99M, "lsp1_99m", "clk99m", TOP_CLK_GATE2, 29, 0, 0), 5078c2ecf20Sopenharmony_ci GATE(LSP1_24M, "lsp1_24m", "osc24m", TOP_CLK_GATE2, 28, 0, 0), 5088c2ecf20Sopenharmony_ci GATE(LSP0_74M25, "lsp0_74m25", "clk74m25", TOP_CLK_GATE2, 25, 0, 0), 5098c2ecf20Sopenharmony_ci GATE(0, "lsp0_pclk", "sys_noc_pclk", TOP_CLK_GATE2, 24, 0, 0), 5108c2ecf20Sopenharmony_ci GATE(LSP0_32K, "lsp0_32k", "osc32k", TOP_CLK_GATE2, 23, 0, 0), 5118c2ecf20Sopenharmony_ci GATE(LSP0_148M5, "lsp0_148m5", "clk148m5", TOP_CLK_GATE2, 22, 0, 0), 5128c2ecf20Sopenharmony_ci GATE(LSP0_99M, "lsp0_99m", "clk99m", TOP_CLK_GATE2, 21, 0, 0), 5138c2ecf20Sopenharmony_ci GATE(LSP0_24M, "lsp0_24m", "osc24m", TOP_CLK_GATE2, 20, 0, 0), 5148c2ecf20Sopenharmony_ci GATE(AUDIO_99M, "audio_99m", "clk99m", TOP_CLK_GATE5, 27, 0, 0), 5158c2ecf20Sopenharmony_ci GATE(AUDIO_24M, "audio_24m", "osc24m", TOP_CLK_GATE5, 28, 0, 0), 5168c2ecf20Sopenharmony_ci GATE(AUDIO_16M384, "audio_16m384", "clk16m384", TOP_CLK_GATE5, 29, 0, 0), 5178c2ecf20Sopenharmony_ci GATE(AUDIO_32K, "audio_32k", "clk32k", TOP_CLK_GATE5, 30, 0, 0), 5188c2ecf20Sopenharmony_ci GATE(WDT_WCLK, "wdt_wclk", "wdt_mux", TOP_CLK_GATE6, 9, CLK_SET_RATE_PARENT, 0), 5198c2ecf20Sopenharmony_ci GATE(TIMER_WCLK, "timer_wclk", "timer_mux", TOP_CLK_GATE6, 5, CLK_SET_RATE_PARENT, 0), 5208c2ecf20Sopenharmony_ci GATE(VDE_ACLK, "vde_aclk", "vde_mux", TOP_CLK_GATE3, 0, CLK_SET_RATE_PARENT, 0), 5218c2ecf20Sopenharmony_ci GATE(VCE_ACLK, "vce_aclk", "vce_mux", TOP_CLK_GATE3, 4, CLK_SET_RATE_PARENT, 0), 5228c2ecf20Sopenharmony_ci GATE(HDE_ACLK, "hde_aclk", "hde_mux", TOP_CLK_GATE3, 8, CLK_SET_RATE_PARENT, 0), 5238c2ecf20Sopenharmony_ci GATE(GPU_ACLK, "gpu_aclk", "gpu_mux", TOP_CLK_GATE3, 16, CLK_SET_RATE_PARENT, 0), 5248c2ecf20Sopenharmony_ci GATE(SAPPU_ACLK, "sappu_aclk", "sappu_a_mux", TOP_CLK_GATE3, 20, CLK_SET_RATE_PARENT, 0), 5258c2ecf20Sopenharmony_ci GATE(SAPPU_WCLK, "sappu_wclk", "sappu_w_mux", TOP_CLK_GATE3, 22, CLK_SET_RATE_PARENT, 0), 5268c2ecf20Sopenharmony_ci GATE(VOU_ACLK, "vou_aclk", "vou_a_mux", TOP_CLK_GATE4, 16, CLK_SET_RATE_PARENT, 0), 5278c2ecf20Sopenharmony_ci GATE(VOU_MAIN_WCLK, "vou_main_wclk", "vou_main_w_mux", TOP_CLK_GATE4, 18, CLK_SET_RATE_PARENT, 0), 5288c2ecf20Sopenharmony_ci GATE(VOU_AUX_WCLK, "vou_aux_wclk", "vou_aux_w_mux", TOP_CLK_GATE4, 19, CLK_SET_RATE_PARENT, 0), 5298c2ecf20Sopenharmony_ci GATE(VOU_PPU_WCLK, "vou_ppu_wclk", "vou_ppu_w_mux", TOP_CLK_GATE4, 20, CLK_SET_RATE_PARENT, 0), 5308c2ecf20Sopenharmony_ci GATE(MIPI_CFG_CLK, "mipi_cfg_clk", "osc24m", TOP_CLK_GATE4, 21, 0, 0), 5318c2ecf20Sopenharmony_ci GATE(VGA_I2C_WCLK, "vga_i2c_wclk", "vga_i2c_mux", TOP_CLK_GATE4, 23, CLK_SET_RATE_PARENT, 0), 5328c2ecf20Sopenharmony_ci GATE(MIPI_REF_CLK, "mipi_ref_clk", "clk27m", TOP_CLK_GATE4, 24, 0, 0), 5338c2ecf20Sopenharmony_ci GATE(HDMI_OSC_CEC, "hdmi_osc_cec", "clk2m", TOP_CLK_GATE4, 22, 0, 0), 5348c2ecf20Sopenharmony_ci GATE(HDMI_OSC_CLK, "hdmi_osc_clk", "clk240m", TOP_CLK_GATE4, 25, 0, 0), 5358c2ecf20Sopenharmony_ci GATE(HDMI_XCLK, "hdmi_xclk", "osc24m", TOP_CLK_GATE4, 26, 0, 0), 5368c2ecf20Sopenharmony_ci GATE(VIU_M0_ACLK, "viu_m0_aclk", "viu_m0_a_mux", TOP_CLK_GATE4, 0, CLK_SET_RATE_PARENT, 0), 5378c2ecf20Sopenharmony_ci GATE(VIU_M1_ACLK, "viu_m1_aclk", "viu_m1_a_mux", TOP_CLK_GATE4, 1, CLK_SET_RATE_PARENT, 0), 5388c2ecf20Sopenharmony_ci GATE(VIU_WCLK, "viu_wclk", "viu_w_mux", TOP_CLK_GATE4, 2, CLK_SET_RATE_PARENT, 0), 5398c2ecf20Sopenharmony_ci GATE(VIU_JPEG_WCLK, "viu_jpeg_wclk", "viu_jpeg_w_mux", TOP_CLK_GATE4, 3, CLK_SET_RATE_PARENT, 0), 5408c2ecf20Sopenharmony_ci GATE(VIU_CFG_CLK, "viu_cfg_clk", "osc24m", TOP_CLK_GATE4, 6, 0, 0), 5418c2ecf20Sopenharmony_ci GATE(TS_SYS_WCLK, "ts_sys_wclk", "ts_sys_mux", TOP_CLK_GATE5, 2, CLK_SET_RATE_PARENT, 0), 5428c2ecf20Sopenharmony_ci GATE(TS_SYS_108M, "ts_sys_108m", "clk108m", TOP_CLK_GATE5, 3, 0, 0), 5438c2ecf20Sopenharmony_ci GATE(USB20_HCLK, "usb20_hclk", "sys_noc_hclk", TOP_CLK_GATE2, 12, 0, 0), 5448c2ecf20Sopenharmony_ci GATE(USB20_PHY_CLK, "usb20_phy_clk", "usb_ref24m_mux", TOP_CLK_GATE2, 13, 0, 0), 5458c2ecf20Sopenharmony_ci GATE(USB21_HCLK, "usb21_hclk", "sys_noc_hclk", TOP_CLK_GATE2, 14, 0, 0), 5468c2ecf20Sopenharmony_ci GATE(USB21_PHY_CLK, "usb21_phy_clk", "usb_ref24m_mux", TOP_CLK_GATE2, 15, 0, 0), 5478c2ecf20Sopenharmony_ci GATE(GMAC_RMIICLK, "gmac_rmii_clk", "clk50m", TOP_CLK_GATE2, 3, 0, 0), 5488c2ecf20Sopenharmony_ci GATE(GMAC_PCLK, "gmac_pclk", "clk198m", TOP_CLK_GATE2, 1, 0, 0), 5498c2ecf20Sopenharmony_ci GATE(GMAC_ACLK, "gmac_aclk", "clk49m5", TOP_CLK_GATE2, 0, 0, 0), 5508c2ecf20Sopenharmony_ci GATE(GMAC_RFCLK, "gmac_refclk", "clk25m", TOP_CLK_GATE2, 4, 0, 0), 5518c2ecf20Sopenharmony_ci GATE(SD1_AHB, "sd1_hclk", "sys_noc_hclk", TOP_CLK_GATE1, 12, 0, 0), 5528c2ecf20Sopenharmony_ci GATE(SD0_AHB, "sd0_hclk", "sys_noc_hclk", TOP_CLK_GATE1, 8, 0, 0), 5538c2ecf20Sopenharmony_ci GATE(TEMPSENSOR_GATE, "tempsensor_gate", "clk4m", TOP_CLK_GATE5, 31, 0, 0), 5548c2ecf20Sopenharmony_ci}; 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_cistatic struct clk_hw_onecell_data top_hw_onecell_data = { 5578c2ecf20Sopenharmony_ci .num = TOP_NR_CLKS, 5588c2ecf20Sopenharmony_ci .hws = { 5598c2ecf20Sopenharmony_ci [TOP_NR_CLKS - 1] = NULL, 5608c2ecf20Sopenharmony_ci }, 5618c2ecf20Sopenharmony_ci}; 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_cistatic int __init top_clocks_init(struct device_node *np) 5648c2ecf20Sopenharmony_ci{ 5658c2ecf20Sopenharmony_ci void __iomem *reg_base; 5668c2ecf20Sopenharmony_ci int i, ret; 5678c2ecf20Sopenharmony_ci const char *name; 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ci reg_base = of_iomap(np, 0); 5708c2ecf20Sopenharmony_ci if (!reg_base) { 5718c2ecf20Sopenharmony_ci pr_err("%s: Unable to map clk base\n", __func__); 5728c2ecf20Sopenharmony_ci return -ENXIO; 5738c2ecf20Sopenharmony_ci } 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(zx296718_pll_clk); i++) { 5768c2ecf20Sopenharmony_ci zx296718_pll_clk[i].reg_base += (uintptr_t)reg_base; 5778c2ecf20Sopenharmony_ci name = zx296718_pll_clk[i].hw.init->name; 5788c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &zx296718_pll_clk[i].hw); 5798c2ecf20Sopenharmony_ci if (ret) 5808c2ecf20Sopenharmony_ci pr_warn("top clk %s init error!\n", name); 5818c2ecf20Sopenharmony_ci } 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(top_ffactor_clk); i++) { 5848c2ecf20Sopenharmony_ci if (top_ffactor_clk[i].id) 5858c2ecf20Sopenharmony_ci top_hw_onecell_data.hws[top_ffactor_clk[i].id] = 5868c2ecf20Sopenharmony_ci &top_ffactor_clk[i].factor.hw; 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_ci name = top_ffactor_clk[i].factor.hw.init->name; 5898c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &top_ffactor_clk[i].factor.hw); 5908c2ecf20Sopenharmony_ci if (ret) 5918c2ecf20Sopenharmony_ci pr_warn("top clk %s init error!\n", name); 5928c2ecf20Sopenharmony_ci } 5938c2ecf20Sopenharmony_ci 5948c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(top_mux_clk); i++) { 5958c2ecf20Sopenharmony_ci if (top_mux_clk[i].id) 5968c2ecf20Sopenharmony_ci top_hw_onecell_data.hws[top_mux_clk[i].id] = 5978c2ecf20Sopenharmony_ci &top_mux_clk[i].mux.hw; 5988c2ecf20Sopenharmony_ci 5998c2ecf20Sopenharmony_ci top_mux_clk[i].mux.reg += (uintptr_t)reg_base; 6008c2ecf20Sopenharmony_ci name = top_mux_clk[i].mux.hw.init->name; 6018c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &top_mux_clk[i].mux.hw); 6028c2ecf20Sopenharmony_ci if (ret) 6038c2ecf20Sopenharmony_ci pr_warn("top clk %s init error!\n", name); 6048c2ecf20Sopenharmony_ci } 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(top_gate_clk); i++) { 6078c2ecf20Sopenharmony_ci if (top_gate_clk[i].id) 6088c2ecf20Sopenharmony_ci top_hw_onecell_data.hws[top_gate_clk[i].id] = 6098c2ecf20Sopenharmony_ci &top_gate_clk[i].gate.hw; 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci top_gate_clk[i].gate.reg += (uintptr_t)reg_base; 6128c2ecf20Sopenharmony_ci name = top_gate_clk[i].gate.hw.init->name; 6138c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &top_gate_clk[i].gate.hw); 6148c2ecf20Sopenharmony_ci if (ret) 6158c2ecf20Sopenharmony_ci pr_warn("top clk %s init error!\n", name); 6168c2ecf20Sopenharmony_ci } 6178c2ecf20Sopenharmony_ci 6188c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(top_div_clk); i++) { 6198c2ecf20Sopenharmony_ci if (top_div_clk[i].id) 6208c2ecf20Sopenharmony_ci top_hw_onecell_data.hws[top_div_clk[i].id] = 6218c2ecf20Sopenharmony_ci &top_div_clk[i].div.hw; 6228c2ecf20Sopenharmony_ci 6238c2ecf20Sopenharmony_ci top_div_clk[i].div.reg += (uintptr_t)reg_base; 6248c2ecf20Sopenharmony_ci name = top_div_clk[i].div.hw.init->name; 6258c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &top_div_clk[i].div.hw); 6268c2ecf20Sopenharmony_ci if (ret) 6278c2ecf20Sopenharmony_ci pr_warn("top clk %s init error!\n", name); 6288c2ecf20Sopenharmony_ci } 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_ci ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, 6318c2ecf20Sopenharmony_ci &top_hw_onecell_data); 6328c2ecf20Sopenharmony_ci if (ret) { 6338c2ecf20Sopenharmony_ci pr_err("failed to register top clk provider: %d\n", ret); 6348c2ecf20Sopenharmony_ci return ret; 6358c2ecf20Sopenharmony_ci } 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ci return 0; 6388c2ecf20Sopenharmony_ci} 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_cistatic const struct clk_div_table common_even_div_table[] = { 6418c2ecf20Sopenharmony_ci { .val = 0, .div = 1, }, 6428c2ecf20Sopenharmony_ci { .val = 1, .div = 2, }, 6438c2ecf20Sopenharmony_ci { .val = 3, .div = 4, }, 6448c2ecf20Sopenharmony_ci { .val = 5, .div = 6, }, 6458c2ecf20Sopenharmony_ci { .val = 7, .div = 8, }, 6468c2ecf20Sopenharmony_ci { .val = 9, .div = 10, }, 6478c2ecf20Sopenharmony_ci { .val = 11, .div = 12, }, 6488c2ecf20Sopenharmony_ci { .val = 13, .div = 14, }, 6498c2ecf20Sopenharmony_ci { .val = 15, .div = 16, }, 6508c2ecf20Sopenharmony_ci}; 6518c2ecf20Sopenharmony_ci 6528c2ecf20Sopenharmony_cistatic const struct clk_div_table common_div_table[] = { 6538c2ecf20Sopenharmony_ci { .val = 0, .div = 1, }, 6548c2ecf20Sopenharmony_ci { .val = 1, .div = 2, }, 6558c2ecf20Sopenharmony_ci { .val = 2, .div = 3, }, 6568c2ecf20Sopenharmony_ci { .val = 3, .div = 4, }, 6578c2ecf20Sopenharmony_ci { .val = 4, .div = 5, }, 6588c2ecf20Sopenharmony_ci { .val = 5, .div = 6, }, 6598c2ecf20Sopenharmony_ci { .val = 6, .div = 7, }, 6608c2ecf20Sopenharmony_ci { .val = 7, .div = 8, }, 6618c2ecf20Sopenharmony_ci { .val = 8, .div = 9, }, 6628c2ecf20Sopenharmony_ci { .val = 9, .div = 10, }, 6638c2ecf20Sopenharmony_ci { .val = 10, .div = 11, }, 6648c2ecf20Sopenharmony_ci { .val = 11, .div = 12, }, 6658c2ecf20Sopenharmony_ci { .val = 12, .div = 13, }, 6668c2ecf20Sopenharmony_ci { .val = 13, .div = 14, }, 6678c2ecf20Sopenharmony_ci { .val = 14, .div = 15, }, 6688c2ecf20Sopenharmony_ci { .val = 15, .div = 16, }, 6698c2ecf20Sopenharmony_ci}; 6708c2ecf20Sopenharmony_ci 6718c2ecf20Sopenharmony_ciPNAME(lsp0_wclk_common_p) = { 6728c2ecf20Sopenharmony_ci "lsp0_24m", 6738c2ecf20Sopenharmony_ci "lsp0_99m", 6748c2ecf20Sopenharmony_ci}; 6758c2ecf20Sopenharmony_ci 6768c2ecf20Sopenharmony_ciPNAME(lsp0_wclk_timer3_p) = { 6778c2ecf20Sopenharmony_ci "timer3_div", 6788c2ecf20Sopenharmony_ci "lsp0_32k" 6798c2ecf20Sopenharmony_ci}; 6808c2ecf20Sopenharmony_ci 6818c2ecf20Sopenharmony_ciPNAME(lsp0_wclk_timer4_p) = { 6828c2ecf20Sopenharmony_ci "timer4_div", 6838c2ecf20Sopenharmony_ci "lsp0_32k" 6848c2ecf20Sopenharmony_ci}; 6858c2ecf20Sopenharmony_ci 6868c2ecf20Sopenharmony_ciPNAME(lsp0_wclk_timer5_p) = { 6878c2ecf20Sopenharmony_ci "timer5_div", 6888c2ecf20Sopenharmony_ci "lsp0_32k" 6898c2ecf20Sopenharmony_ci}; 6908c2ecf20Sopenharmony_ci 6918c2ecf20Sopenharmony_ciPNAME(lsp0_wclk_spifc0_p) = { 6928c2ecf20Sopenharmony_ci "lsp0_148m5", 6938c2ecf20Sopenharmony_ci "lsp0_24m", 6948c2ecf20Sopenharmony_ci "lsp0_99m", 6958c2ecf20Sopenharmony_ci "lsp0_74m25" 6968c2ecf20Sopenharmony_ci}; 6978c2ecf20Sopenharmony_ci 6988c2ecf20Sopenharmony_ciPNAME(lsp0_wclk_ssp_p) = { 6998c2ecf20Sopenharmony_ci "lsp0_148m5", 7008c2ecf20Sopenharmony_ci "lsp0_99m", 7018c2ecf20Sopenharmony_ci "lsp0_24m", 7028c2ecf20Sopenharmony_ci}; 7038c2ecf20Sopenharmony_ci 7048c2ecf20Sopenharmony_cistatic struct zx_clk_mux lsp0_mux_clk[] = { 7058c2ecf20Sopenharmony_ci MUX(0, "timer3_wclk_mux", lsp0_wclk_timer3_p, LSP0_TIMER3_CLK, 4, 1), 7068c2ecf20Sopenharmony_ci MUX(0, "timer4_wclk_mux", lsp0_wclk_timer4_p, LSP0_TIMER4_CLK, 4, 1), 7078c2ecf20Sopenharmony_ci MUX(0, "timer5_wclk_mux", lsp0_wclk_timer5_p, LSP0_TIMER5_CLK, 4, 1), 7088c2ecf20Sopenharmony_ci MUX(0, "uart3_wclk_mux", lsp0_wclk_common_p, LSP0_UART3_CLK, 4, 1), 7098c2ecf20Sopenharmony_ci MUX(0, "uart1_wclk_mux", lsp0_wclk_common_p, LSP0_UART1_CLK, 4, 1), 7108c2ecf20Sopenharmony_ci MUX(0, "uart2_wclk_mux", lsp0_wclk_common_p, LSP0_UART2_CLK, 4, 1), 7118c2ecf20Sopenharmony_ci MUX(0, "spifc0_wclk_mux", lsp0_wclk_spifc0_p, LSP0_SPIFC0_CLK, 4, 2), 7128c2ecf20Sopenharmony_ci MUX(0, "i2c4_wclk_mux", lsp0_wclk_common_p, LSP0_I2C4_CLK, 4, 1), 7138c2ecf20Sopenharmony_ci MUX(0, "i2c5_wclk_mux", lsp0_wclk_common_p, LSP0_I2C5_CLK, 4, 1), 7148c2ecf20Sopenharmony_ci MUX(0, "ssp0_wclk_mux", lsp0_wclk_ssp_p, LSP0_SSP0_CLK, 4, 1), 7158c2ecf20Sopenharmony_ci MUX(0, "ssp1_wclk_mux", lsp0_wclk_ssp_p, LSP0_SSP1_CLK, 4, 1), 7168c2ecf20Sopenharmony_ci MUX(0, "i2c3_wclk_mux", lsp0_wclk_common_p, LSP0_I2C3_CLK, 4, 1), 7178c2ecf20Sopenharmony_ci}; 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_cistatic struct zx_clk_gate lsp0_gate_clk[] = { 7208c2ecf20Sopenharmony_ci GATE(LSP0_TIMER3_WCLK, "timer3_wclk", "timer3_wclk_mux", LSP0_TIMER3_CLK, 1, CLK_SET_RATE_PARENT, 0), 7218c2ecf20Sopenharmony_ci GATE(LSP0_TIMER4_WCLK, "timer4_wclk", "timer4_wclk_mux", LSP0_TIMER4_CLK, 1, CLK_SET_RATE_PARENT, 0), 7228c2ecf20Sopenharmony_ci GATE(LSP0_TIMER5_WCLK, "timer5_wclk", "timer5_wclk_mux", LSP0_TIMER5_CLK, 1, CLK_SET_RATE_PARENT, 0), 7238c2ecf20Sopenharmony_ci GATE(LSP0_UART3_WCLK, "uart3_wclk", "uart3_wclk_mux", LSP0_UART3_CLK, 1, CLK_SET_RATE_PARENT, 0), 7248c2ecf20Sopenharmony_ci GATE(LSP0_UART1_WCLK, "uart1_wclk", "uart1_wclk_mux", LSP0_UART1_CLK, 1, CLK_SET_RATE_PARENT, 0), 7258c2ecf20Sopenharmony_ci GATE(LSP0_UART2_WCLK, "uart2_wclk", "uart2_wclk_mux", LSP0_UART2_CLK, 1, CLK_SET_RATE_PARENT, 0), 7268c2ecf20Sopenharmony_ci GATE(LSP0_SPIFC0_WCLK, "spifc0_wclk", "spifc0_wclk_mux", LSP0_SPIFC0_CLK, 1, CLK_SET_RATE_PARENT, 0), 7278c2ecf20Sopenharmony_ci GATE(LSP0_I2C4_WCLK, "i2c4_wclk", "i2c4_wclk_mux", LSP0_I2C4_CLK, 1, CLK_SET_RATE_PARENT, 0), 7288c2ecf20Sopenharmony_ci GATE(LSP0_I2C5_WCLK, "i2c5_wclk", "i2c5_wclk_mux", LSP0_I2C5_CLK, 1, CLK_SET_RATE_PARENT, 0), 7298c2ecf20Sopenharmony_ci GATE(LSP0_SSP0_WCLK, "ssp0_wclk", "ssp0_div", LSP0_SSP0_CLK, 1, CLK_SET_RATE_PARENT, 0), 7308c2ecf20Sopenharmony_ci GATE(LSP0_SSP1_WCLK, "ssp1_wclk", "ssp1_div", LSP0_SSP1_CLK, 1, CLK_SET_RATE_PARENT, 0), 7318c2ecf20Sopenharmony_ci GATE(LSP0_I2C3_WCLK, "i2c3_wclk", "i2c3_wclk_mux", LSP0_I2C3_CLK, 1, CLK_SET_RATE_PARENT, 0), 7328c2ecf20Sopenharmony_ci}; 7338c2ecf20Sopenharmony_ci 7348c2ecf20Sopenharmony_cistatic struct zx_clk_div lsp0_div_clk[] = { 7358c2ecf20Sopenharmony_ci DIV_T(0, "timer3_div", "lsp0_24m", LSP0_TIMER3_CLK, 12, 4, 0, common_even_div_table), 7368c2ecf20Sopenharmony_ci DIV_T(0, "timer4_div", "lsp0_24m", LSP0_TIMER4_CLK, 12, 4, 0, common_even_div_table), 7378c2ecf20Sopenharmony_ci DIV_T(0, "timer5_div", "lsp0_24m", LSP0_TIMER5_CLK, 12, 4, 0, common_even_div_table), 7388c2ecf20Sopenharmony_ci DIV_T(0, "ssp0_div", "ssp0_wclk_mux", LSP0_SSP0_CLK, 12, 4, 0, common_even_div_table), 7398c2ecf20Sopenharmony_ci DIV_T(0, "ssp1_div", "ssp1_wclk_mux", LSP0_SSP1_CLK, 12, 4, 0, common_even_div_table), 7408c2ecf20Sopenharmony_ci}; 7418c2ecf20Sopenharmony_ci 7428c2ecf20Sopenharmony_cistatic struct clk_hw_onecell_data lsp0_hw_onecell_data = { 7438c2ecf20Sopenharmony_ci .num = LSP0_NR_CLKS, 7448c2ecf20Sopenharmony_ci .hws = { 7458c2ecf20Sopenharmony_ci [LSP0_NR_CLKS - 1] = NULL, 7468c2ecf20Sopenharmony_ci }, 7478c2ecf20Sopenharmony_ci}; 7488c2ecf20Sopenharmony_ci 7498c2ecf20Sopenharmony_cistatic int __init lsp0_clocks_init(struct device_node *np) 7508c2ecf20Sopenharmony_ci{ 7518c2ecf20Sopenharmony_ci void __iomem *reg_base; 7528c2ecf20Sopenharmony_ci int i, ret; 7538c2ecf20Sopenharmony_ci const char *name; 7548c2ecf20Sopenharmony_ci 7558c2ecf20Sopenharmony_ci reg_base = of_iomap(np, 0); 7568c2ecf20Sopenharmony_ci if (!reg_base) { 7578c2ecf20Sopenharmony_ci pr_err("%s: Unable to map clk base\n", __func__); 7588c2ecf20Sopenharmony_ci return -ENXIO; 7598c2ecf20Sopenharmony_ci } 7608c2ecf20Sopenharmony_ci 7618c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(lsp0_mux_clk); i++) { 7628c2ecf20Sopenharmony_ci if (lsp0_mux_clk[i].id) 7638c2ecf20Sopenharmony_ci lsp0_hw_onecell_data.hws[lsp0_mux_clk[i].id] = 7648c2ecf20Sopenharmony_ci &lsp0_mux_clk[i].mux.hw; 7658c2ecf20Sopenharmony_ci 7668c2ecf20Sopenharmony_ci lsp0_mux_clk[i].mux.reg += (uintptr_t)reg_base; 7678c2ecf20Sopenharmony_ci name = lsp0_mux_clk[i].mux.hw.init->name; 7688c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &lsp0_mux_clk[i].mux.hw); 7698c2ecf20Sopenharmony_ci if (ret) 7708c2ecf20Sopenharmony_ci pr_warn("lsp0 clk %s init error!\n", name); 7718c2ecf20Sopenharmony_ci } 7728c2ecf20Sopenharmony_ci 7738c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(lsp0_gate_clk); i++) { 7748c2ecf20Sopenharmony_ci if (lsp0_gate_clk[i].id) 7758c2ecf20Sopenharmony_ci lsp0_hw_onecell_data.hws[lsp0_gate_clk[i].id] = 7768c2ecf20Sopenharmony_ci &lsp0_gate_clk[i].gate.hw; 7778c2ecf20Sopenharmony_ci 7788c2ecf20Sopenharmony_ci lsp0_gate_clk[i].gate.reg += (uintptr_t)reg_base; 7798c2ecf20Sopenharmony_ci name = lsp0_gate_clk[i].gate.hw.init->name; 7808c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &lsp0_gate_clk[i].gate.hw); 7818c2ecf20Sopenharmony_ci if (ret) 7828c2ecf20Sopenharmony_ci pr_warn("lsp0 clk %s init error!\n", name); 7838c2ecf20Sopenharmony_ci } 7848c2ecf20Sopenharmony_ci 7858c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(lsp0_div_clk); i++) { 7868c2ecf20Sopenharmony_ci if (lsp0_div_clk[i].id) 7878c2ecf20Sopenharmony_ci lsp0_hw_onecell_data.hws[lsp0_div_clk[i].id] = 7888c2ecf20Sopenharmony_ci &lsp0_div_clk[i].div.hw; 7898c2ecf20Sopenharmony_ci 7908c2ecf20Sopenharmony_ci lsp0_div_clk[i].div.reg += (uintptr_t)reg_base; 7918c2ecf20Sopenharmony_ci name = lsp0_div_clk[i].div.hw.init->name; 7928c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &lsp0_div_clk[i].div.hw); 7938c2ecf20Sopenharmony_ci if (ret) 7948c2ecf20Sopenharmony_ci pr_warn("lsp0 clk %s init error!\n", name); 7958c2ecf20Sopenharmony_ci } 7968c2ecf20Sopenharmony_ci 7978c2ecf20Sopenharmony_ci ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, 7988c2ecf20Sopenharmony_ci &lsp0_hw_onecell_data); 7998c2ecf20Sopenharmony_ci if (ret) { 8008c2ecf20Sopenharmony_ci pr_err("failed to register lsp0 clk provider: %d\n", ret); 8018c2ecf20Sopenharmony_ci return ret; 8028c2ecf20Sopenharmony_ci } 8038c2ecf20Sopenharmony_ci 8048c2ecf20Sopenharmony_ci return 0; 8058c2ecf20Sopenharmony_ci} 8068c2ecf20Sopenharmony_ci 8078c2ecf20Sopenharmony_ciPNAME(lsp1_wclk_common_p) = { 8088c2ecf20Sopenharmony_ci "lsp1_24m", 8098c2ecf20Sopenharmony_ci "lsp1_99m", 8108c2ecf20Sopenharmony_ci}; 8118c2ecf20Sopenharmony_ci 8128c2ecf20Sopenharmony_ciPNAME(lsp1_wclk_ssp_p) = { 8138c2ecf20Sopenharmony_ci "lsp1_148m5", 8148c2ecf20Sopenharmony_ci "lsp1_99m", 8158c2ecf20Sopenharmony_ci "lsp1_24m", 8168c2ecf20Sopenharmony_ci}; 8178c2ecf20Sopenharmony_ci 8188c2ecf20Sopenharmony_cistatic struct zx_clk_mux lsp1_mux_clk[] = { 8198c2ecf20Sopenharmony_ci MUX(0, "uart4_wclk_mux", lsp1_wclk_common_p, LSP1_UART4_CLK, 4, 1), 8208c2ecf20Sopenharmony_ci MUX(0, "uart5_wclk_mux", lsp1_wclk_common_p, LSP1_UART5_CLK, 4, 1), 8218c2ecf20Sopenharmony_ci MUX(0, "pwm_wclk_mux", lsp1_wclk_common_p, LSP1_PWM_CLK, 4, 1), 8228c2ecf20Sopenharmony_ci MUX(0, "i2c2_wclk_mux", lsp1_wclk_common_p, LSP1_I2C2_CLK, 4, 1), 8238c2ecf20Sopenharmony_ci MUX(0, "ssp2_wclk_mux", lsp1_wclk_ssp_p, LSP1_SSP2_CLK, 4, 2), 8248c2ecf20Sopenharmony_ci MUX(0, "ssp3_wclk_mux", lsp1_wclk_ssp_p, LSP1_SSP3_CLK, 4, 2), 8258c2ecf20Sopenharmony_ci MUX(0, "ssp4_wclk_mux", lsp1_wclk_ssp_p, LSP1_SSP4_CLK, 4, 2), 8268c2ecf20Sopenharmony_ci MUX(0, "usim1_wclk_mux", lsp1_wclk_common_p, LSP1_USIM1_CLK, 4, 1), 8278c2ecf20Sopenharmony_ci}; 8288c2ecf20Sopenharmony_ci 8298c2ecf20Sopenharmony_cistatic struct zx_clk_div lsp1_div_clk[] = { 8308c2ecf20Sopenharmony_ci DIV_T(0, "pwm_div", "pwm_wclk_mux", LSP1_PWM_CLK, 12, 4, CLK_SET_RATE_PARENT, common_div_table), 8318c2ecf20Sopenharmony_ci DIV_T(0, "ssp2_div", "ssp2_wclk_mux", LSP1_SSP2_CLK, 12, 4, CLK_SET_RATE_PARENT, common_even_div_table), 8328c2ecf20Sopenharmony_ci DIV_T(0, "ssp3_div", "ssp3_wclk_mux", LSP1_SSP3_CLK, 12, 4, CLK_SET_RATE_PARENT, common_even_div_table), 8338c2ecf20Sopenharmony_ci DIV_T(0, "ssp4_div", "ssp4_wclk_mux", LSP1_SSP4_CLK, 12, 4, CLK_SET_RATE_PARENT, common_even_div_table), 8348c2ecf20Sopenharmony_ci}; 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_cistatic struct zx_clk_gate lsp1_gate_clk[] = { 8378c2ecf20Sopenharmony_ci GATE(LSP1_UART4_WCLK, "lsp1_uart4_wclk", "uart4_wclk_mux", LSP1_UART4_CLK, 1, CLK_SET_RATE_PARENT, 0), 8388c2ecf20Sopenharmony_ci GATE(LSP1_UART5_WCLK, "lsp1_uart5_wclk", "uart5_wclk_mux", LSP1_UART5_CLK, 1, CLK_SET_RATE_PARENT, 0), 8398c2ecf20Sopenharmony_ci GATE(LSP1_PWM_WCLK, "lsp1_pwm_wclk", "pwm_div", LSP1_PWM_CLK, 1, CLK_SET_RATE_PARENT, 0), 8408c2ecf20Sopenharmony_ci GATE(LSP1_PWM_PCLK, "lsp1_pwm_pclk", "lsp1_pclk", LSP1_PWM_CLK, 0, 0, 0), 8418c2ecf20Sopenharmony_ci GATE(LSP1_I2C2_WCLK, "lsp1_i2c2_wclk", "i2c2_wclk_mux", LSP1_I2C2_CLK, 1, CLK_SET_RATE_PARENT, 0), 8428c2ecf20Sopenharmony_ci GATE(LSP1_SSP2_WCLK, "lsp1_ssp2_wclk", "ssp2_div", LSP1_SSP2_CLK, 1, CLK_SET_RATE_PARENT, 0), 8438c2ecf20Sopenharmony_ci GATE(LSP1_SSP3_WCLK, "lsp1_ssp3_wclk", "ssp3_div", LSP1_SSP3_CLK, 1, CLK_SET_RATE_PARENT, 0), 8448c2ecf20Sopenharmony_ci GATE(LSP1_SSP4_WCLK, "lsp1_ssp4_wclk", "ssp4_div", LSP1_SSP4_CLK, 1, CLK_SET_RATE_PARENT, 0), 8458c2ecf20Sopenharmony_ci GATE(LSP1_USIM1_WCLK, "lsp1_usim1_wclk", "usim1_wclk_mux", LSP1_USIM1_CLK, 1, CLK_SET_RATE_PARENT, 0), 8468c2ecf20Sopenharmony_ci}; 8478c2ecf20Sopenharmony_ci 8488c2ecf20Sopenharmony_cistatic struct clk_hw_onecell_data lsp1_hw_onecell_data = { 8498c2ecf20Sopenharmony_ci .num = LSP1_NR_CLKS, 8508c2ecf20Sopenharmony_ci .hws = { 8518c2ecf20Sopenharmony_ci [LSP1_NR_CLKS - 1] = NULL, 8528c2ecf20Sopenharmony_ci }, 8538c2ecf20Sopenharmony_ci}; 8548c2ecf20Sopenharmony_ci 8558c2ecf20Sopenharmony_cistatic int __init lsp1_clocks_init(struct device_node *np) 8568c2ecf20Sopenharmony_ci{ 8578c2ecf20Sopenharmony_ci void __iomem *reg_base; 8588c2ecf20Sopenharmony_ci int i, ret; 8598c2ecf20Sopenharmony_ci const char *name; 8608c2ecf20Sopenharmony_ci 8618c2ecf20Sopenharmony_ci reg_base = of_iomap(np, 0); 8628c2ecf20Sopenharmony_ci if (!reg_base) { 8638c2ecf20Sopenharmony_ci pr_err("%s: Unable to map clk base\n", __func__); 8648c2ecf20Sopenharmony_ci return -ENXIO; 8658c2ecf20Sopenharmony_ci } 8668c2ecf20Sopenharmony_ci 8678c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(lsp1_mux_clk); i++) { 8688c2ecf20Sopenharmony_ci if (lsp1_mux_clk[i].id) 8698c2ecf20Sopenharmony_ci lsp1_hw_onecell_data.hws[lsp1_mux_clk[i].id] = 8708c2ecf20Sopenharmony_ci &lsp0_mux_clk[i].mux.hw; 8718c2ecf20Sopenharmony_ci 8728c2ecf20Sopenharmony_ci lsp1_mux_clk[i].mux.reg += (uintptr_t)reg_base; 8738c2ecf20Sopenharmony_ci name = lsp1_mux_clk[i].mux.hw.init->name; 8748c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &lsp1_mux_clk[i].mux.hw); 8758c2ecf20Sopenharmony_ci if (ret) 8768c2ecf20Sopenharmony_ci pr_warn("lsp1 clk %s init error!\n", name); 8778c2ecf20Sopenharmony_ci } 8788c2ecf20Sopenharmony_ci 8798c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(lsp1_gate_clk); i++) { 8808c2ecf20Sopenharmony_ci if (lsp1_gate_clk[i].id) 8818c2ecf20Sopenharmony_ci lsp1_hw_onecell_data.hws[lsp1_gate_clk[i].id] = 8828c2ecf20Sopenharmony_ci &lsp1_gate_clk[i].gate.hw; 8838c2ecf20Sopenharmony_ci 8848c2ecf20Sopenharmony_ci lsp1_gate_clk[i].gate.reg += (uintptr_t)reg_base; 8858c2ecf20Sopenharmony_ci name = lsp1_gate_clk[i].gate.hw.init->name; 8868c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &lsp1_gate_clk[i].gate.hw); 8878c2ecf20Sopenharmony_ci if (ret) 8888c2ecf20Sopenharmony_ci pr_warn("lsp1 clk %s init error!\n", name); 8898c2ecf20Sopenharmony_ci } 8908c2ecf20Sopenharmony_ci 8918c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(lsp1_div_clk); i++) { 8928c2ecf20Sopenharmony_ci if (lsp1_div_clk[i].id) 8938c2ecf20Sopenharmony_ci lsp1_hw_onecell_data.hws[lsp1_div_clk[i].id] = 8948c2ecf20Sopenharmony_ci &lsp1_div_clk[i].div.hw; 8958c2ecf20Sopenharmony_ci 8968c2ecf20Sopenharmony_ci lsp1_div_clk[i].div.reg += (uintptr_t)reg_base; 8978c2ecf20Sopenharmony_ci name = lsp1_div_clk[i].div.hw.init->name; 8988c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &lsp1_div_clk[i].div.hw); 8998c2ecf20Sopenharmony_ci if (ret) 9008c2ecf20Sopenharmony_ci pr_warn("lsp1 clk %s init error!\n", name); 9018c2ecf20Sopenharmony_ci } 9028c2ecf20Sopenharmony_ci 9038c2ecf20Sopenharmony_ci ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, 9048c2ecf20Sopenharmony_ci &lsp1_hw_onecell_data); 9058c2ecf20Sopenharmony_ci if (ret) { 9068c2ecf20Sopenharmony_ci pr_err("failed to register lsp1 clk provider: %d\n", ret); 9078c2ecf20Sopenharmony_ci return ret; 9088c2ecf20Sopenharmony_ci } 9098c2ecf20Sopenharmony_ci 9108c2ecf20Sopenharmony_ci return 0; 9118c2ecf20Sopenharmony_ci} 9128c2ecf20Sopenharmony_ci 9138c2ecf20Sopenharmony_ciPNAME(audio_wclk_common_p) = { 9148c2ecf20Sopenharmony_ci "audio_99m", 9158c2ecf20Sopenharmony_ci "audio_24m", 9168c2ecf20Sopenharmony_ci}; 9178c2ecf20Sopenharmony_ci 9188c2ecf20Sopenharmony_ciPNAME(audio_timer_p) = { 9198c2ecf20Sopenharmony_ci "audio_24m", 9208c2ecf20Sopenharmony_ci "audio_32k", 9218c2ecf20Sopenharmony_ci}; 9228c2ecf20Sopenharmony_ci 9238c2ecf20Sopenharmony_cistatic struct zx_clk_mux audio_mux_clk[] = { 9248c2ecf20Sopenharmony_ci MUX(I2S0_WCLK_MUX, "i2s0_wclk_mux", audio_wclk_common_p, AUDIO_I2S0_CLK, 0, 1), 9258c2ecf20Sopenharmony_ci MUX(I2S1_WCLK_MUX, "i2s1_wclk_mux", audio_wclk_common_p, AUDIO_I2S1_CLK, 0, 1), 9268c2ecf20Sopenharmony_ci MUX(I2S2_WCLK_MUX, "i2s2_wclk_mux", audio_wclk_common_p, AUDIO_I2S2_CLK, 0, 1), 9278c2ecf20Sopenharmony_ci MUX(I2S3_WCLK_MUX, "i2s3_wclk_mux", audio_wclk_common_p, AUDIO_I2S3_CLK, 0, 1), 9288c2ecf20Sopenharmony_ci MUX(0, "i2c0_wclk_mux", audio_wclk_common_p, AUDIO_I2C0_CLK, 0, 1), 9298c2ecf20Sopenharmony_ci MUX(0, "spdif0_wclk_mux", audio_wclk_common_p, AUDIO_SPDIF0_CLK, 0, 1), 9308c2ecf20Sopenharmony_ci MUX(0, "spdif1_wclk_mux", audio_wclk_common_p, AUDIO_SPDIF1_CLK, 0, 1), 9318c2ecf20Sopenharmony_ci MUX(0, "timer_wclk_mux", audio_timer_p, AUDIO_TIMER_CLK, 0, 1), 9328c2ecf20Sopenharmony_ci}; 9338c2ecf20Sopenharmony_ci 9348c2ecf20Sopenharmony_cistatic struct clk_zx_audio_divider audio_adiv_clk[] = { 9358c2ecf20Sopenharmony_ci AUDIO_DIV(0, "i2s0_wclk_div", "i2s0_wclk_mux", AUDIO_I2S0_DIV_CFG1), 9368c2ecf20Sopenharmony_ci AUDIO_DIV(0, "i2s1_wclk_div", "i2s1_wclk_mux", AUDIO_I2S1_DIV_CFG1), 9378c2ecf20Sopenharmony_ci AUDIO_DIV(0, "i2s2_wclk_div", "i2s2_wclk_mux", AUDIO_I2S2_DIV_CFG1), 9388c2ecf20Sopenharmony_ci AUDIO_DIV(0, "i2s3_wclk_div", "i2s3_wclk_mux", AUDIO_I2S3_DIV_CFG1), 9398c2ecf20Sopenharmony_ci AUDIO_DIV(0, "spdif0_wclk_div", "spdif0_wclk_mux", AUDIO_SPDIF0_DIV_CFG1), 9408c2ecf20Sopenharmony_ci AUDIO_DIV(0, "spdif1_wclk_div", "spdif1_wclk_mux", AUDIO_SPDIF1_DIV_CFG1), 9418c2ecf20Sopenharmony_ci}; 9428c2ecf20Sopenharmony_ci 9438c2ecf20Sopenharmony_cistatic struct zx_clk_div audio_div_clk[] = { 9448c2ecf20Sopenharmony_ci DIV_T(0, "tdm_wclk_div", "audio_16m384", AUDIO_TDM_CLK, 8, 4, 0, common_div_table), 9458c2ecf20Sopenharmony_ci}; 9468c2ecf20Sopenharmony_ci 9478c2ecf20Sopenharmony_cistatic struct zx_clk_gate audio_gate_clk[] = { 9488c2ecf20Sopenharmony_ci GATE(AUDIO_I2S0_WCLK, "i2s0_wclk", "i2s0_wclk_div", AUDIO_I2S0_CLK, 9, CLK_SET_RATE_PARENT, 0), 9498c2ecf20Sopenharmony_ci GATE(AUDIO_I2S1_WCLK, "i2s1_wclk", "i2s1_wclk_div", AUDIO_I2S1_CLK, 9, CLK_SET_RATE_PARENT, 0), 9508c2ecf20Sopenharmony_ci GATE(AUDIO_I2S2_WCLK, "i2s2_wclk", "i2s2_wclk_div", AUDIO_I2S2_CLK, 9, CLK_SET_RATE_PARENT, 0), 9518c2ecf20Sopenharmony_ci GATE(AUDIO_I2S3_WCLK, "i2s3_wclk", "i2s3_wclk_div", AUDIO_I2S3_CLK, 9, CLK_SET_RATE_PARENT, 0), 9528c2ecf20Sopenharmony_ci GATE(AUDIO_I2S0_PCLK, "i2s0_pclk", "clk49m5", AUDIO_I2S0_CLK, 8, 0, 0), 9538c2ecf20Sopenharmony_ci GATE(AUDIO_I2S1_PCLK, "i2s1_pclk", "clk49m5", AUDIO_I2S1_CLK, 8, 0, 0), 9548c2ecf20Sopenharmony_ci GATE(AUDIO_I2S2_PCLK, "i2s2_pclk", "clk49m5", AUDIO_I2S2_CLK, 8, 0, 0), 9558c2ecf20Sopenharmony_ci GATE(AUDIO_I2S3_PCLK, "i2s3_pclk", "clk49m5", AUDIO_I2S3_CLK, 8, 0, 0), 9568c2ecf20Sopenharmony_ci GATE(AUDIO_I2C0_WCLK, "i2c0_wclk", "i2c0_wclk_mux", AUDIO_I2C0_CLK, 9, CLK_SET_RATE_PARENT, 0), 9578c2ecf20Sopenharmony_ci GATE(AUDIO_SPDIF0_WCLK, "spdif0_wclk", "spdif0_wclk_div", AUDIO_SPDIF0_CLK, 9, CLK_SET_RATE_PARENT, 0), 9588c2ecf20Sopenharmony_ci GATE(AUDIO_SPDIF1_WCLK, "spdif1_wclk", "spdif1_wclk_div", AUDIO_SPDIF1_CLK, 9, CLK_SET_RATE_PARENT, 0), 9598c2ecf20Sopenharmony_ci GATE(AUDIO_TDM_WCLK, "tdm_wclk", "tdm_wclk_div", AUDIO_TDM_CLK, 17, CLK_SET_RATE_PARENT, 0), 9608c2ecf20Sopenharmony_ci GATE(AUDIO_TS_PCLK, "tempsensor_pclk", "clk49m5", AUDIO_TS_CLK, 1, 0, 0), 9618c2ecf20Sopenharmony_ci}; 9628c2ecf20Sopenharmony_ci 9638c2ecf20Sopenharmony_cistatic struct clk_hw_onecell_data audio_hw_onecell_data = { 9648c2ecf20Sopenharmony_ci .num = AUDIO_NR_CLKS, 9658c2ecf20Sopenharmony_ci .hws = { 9668c2ecf20Sopenharmony_ci [AUDIO_NR_CLKS - 1] = NULL, 9678c2ecf20Sopenharmony_ci }, 9688c2ecf20Sopenharmony_ci}; 9698c2ecf20Sopenharmony_ci 9708c2ecf20Sopenharmony_cistatic int __init audio_clocks_init(struct device_node *np) 9718c2ecf20Sopenharmony_ci{ 9728c2ecf20Sopenharmony_ci void __iomem *reg_base; 9738c2ecf20Sopenharmony_ci int i, ret; 9748c2ecf20Sopenharmony_ci const char *name; 9758c2ecf20Sopenharmony_ci 9768c2ecf20Sopenharmony_ci reg_base = of_iomap(np, 0); 9778c2ecf20Sopenharmony_ci if (!reg_base) { 9788c2ecf20Sopenharmony_ci pr_err("%s: Unable to map audio clk base\n", __func__); 9798c2ecf20Sopenharmony_ci return -ENXIO; 9808c2ecf20Sopenharmony_ci } 9818c2ecf20Sopenharmony_ci 9828c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(audio_mux_clk); i++) { 9838c2ecf20Sopenharmony_ci if (audio_mux_clk[i].id) 9848c2ecf20Sopenharmony_ci audio_hw_onecell_data.hws[audio_mux_clk[i].id] = 9858c2ecf20Sopenharmony_ci &audio_mux_clk[i].mux.hw; 9868c2ecf20Sopenharmony_ci 9878c2ecf20Sopenharmony_ci audio_mux_clk[i].mux.reg += (uintptr_t)reg_base; 9888c2ecf20Sopenharmony_ci name = audio_mux_clk[i].mux.hw.init->name; 9898c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &audio_mux_clk[i].mux.hw); 9908c2ecf20Sopenharmony_ci if (ret) 9918c2ecf20Sopenharmony_ci pr_warn("audio clk %s init error!\n", name); 9928c2ecf20Sopenharmony_ci } 9938c2ecf20Sopenharmony_ci 9948c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(audio_adiv_clk); i++) { 9958c2ecf20Sopenharmony_ci if (audio_adiv_clk[i].id) 9968c2ecf20Sopenharmony_ci audio_hw_onecell_data.hws[audio_adiv_clk[i].id] = 9978c2ecf20Sopenharmony_ci &audio_adiv_clk[i].hw; 9988c2ecf20Sopenharmony_ci 9998c2ecf20Sopenharmony_ci audio_adiv_clk[i].reg_base += (uintptr_t)reg_base; 10008c2ecf20Sopenharmony_ci name = audio_adiv_clk[i].hw.init->name; 10018c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &audio_adiv_clk[i].hw); 10028c2ecf20Sopenharmony_ci if (ret) 10038c2ecf20Sopenharmony_ci pr_warn("audio clk %s init error!\n", name); 10048c2ecf20Sopenharmony_ci } 10058c2ecf20Sopenharmony_ci 10068c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(audio_div_clk); i++) { 10078c2ecf20Sopenharmony_ci if (audio_div_clk[i].id) 10088c2ecf20Sopenharmony_ci audio_hw_onecell_data.hws[audio_div_clk[i].id] = 10098c2ecf20Sopenharmony_ci &audio_div_clk[i].div.hw; 10108c2ecf20Sopenharmony_ci 10118c2ecf20Sopenharmony_ci audio_div_clk[i].div.reg += (uintptr_t)reg_base; 10128c2ecf20Sopenharmony_ci name = audio_div_clk[i].div.hw.init->name; 10138c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &audio_div_clk[i].div.hw); 10148c2ecf20Sopenharmony_ci if (ret) 10158c2ecf20Sopenharmony_ci pr_warn("audio clk %s init error!\n", name); 10168c2ecf20Sopenharmony_ci } 10178c2ecf20Sopenharmony_ci 10188c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(audio_gate_clk); i++) { 10198c2ecf20Sopenharmony_ci if (audio_gate_clk[i].id) 10208c2ecf20Sopenharmony_ci audio_hw_onecell_data.hws[audio_gate_clk[i].id] = 10218c2ecf20Sopenharmony_ci &audio_gate_clk[i].gate.hw; 10228c2ecf20Sopenharmony_ci 10238c2ecf20Sopenharmony_ci audio_gate_clk[i].gate.reg += (uintptr_t)reg_base; 10248c2ecf20Sopenharmony_ci name = audio_gate_clk[i].gate.hw.init->name; 10258c2ecf20Sopenharmony_ci ret = clk_hw_register(NULL, &audio_gate_clk[i].gate.hw); 10268c2ecf20Sopenharmony_ci if (ret) 10278c2ecf20Sopenharmony_ci pr_warn("audio clk %s init error!\n", name); 10288c2ecf20Sopenharmony_ci } 10298c2ecf20Sopenharmony_ci 10308c2ecf20Sopenharmony_ci ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, 10318c2ecf20Sopenharmony_ci &audio_hw_onecell_data); 10328c2ecf20Sopenharmony_ci if (ret) { 10338c2ecf20Sopenharmony_ci pr_err("failed to register audio clk provider: %d\n", ret); 10348c2ecf20Sopenharmony_ci return ret; 10358c2ecf20Sopenharmony_ci } 10368c2ecf20Sopenharmony_ci 10378c2ecf20Sopenharmony_ci return 0; 10388c2ecf20Sopenharmony_ci} 10398c2ecf20Sopenharmony_ci 10408c2ecf20Sopenharmony_cistatic const struct of_device_id zx_clkc_match_table[] = { 10418c2ecf20Sopenharmony_ci { .compatible = "zte,zx296718-topcrm", .data = &top_clocks_init }, 10428c2ecf20Sopenharmony_ci { .compatible = "zte,zx296718-lsp0crm", .data = &lsp0_clocks_init }, 10438c2ecf20Sopenharmony_ci { .compatible = "zte,zx296718-lsp1crm", .data = &lsp1_clocks_init }, 10448c2ecf20Sopenharmony_ci { .compatible = "zte,zx296718-audiocrm", .data = &audio_clocks_init }, 10458c2ecf20Sopenharmony_ci { } 10468c2ecf20Sopenharmony_ci}; 10478c2ecf20Sopenharmony_ci 10488c2ecf20Sopenharmony_cistatic int zx_clkc_probe(struct platform_device *pdev) 10498c2ecf20Sopenharmony_ci{ 10508c2ecf20Sopenharmony_ci int (*init_fn)(struct device_node *np); 10518c2ecf20Sopenharmony_ci struct device_node *np = pdev->dev.of_node; 10528c2ecf20Sopenharmony_ci 10538c2ecf20Sopenharmony_ci init_fn = of_device_get_match_data(&pdev->dev); 10548c2ecf20Sopenharmony_ci if (!init_fn) { 10558c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "Error: No device match found\n"); 10568c2ecf20Sopenharmony_ci return -ENODEV; 10578c2ecf20Sopenharmony_ci } 10588c2ecf20Sopenharmony_ci 10598c2ecf20Sopenharmony_ci return init_fn(np); 10608c2ecf20Sopenharmony_ci} 10618c2ecf20Sopenharmony_ci 10628c2ecf20Sopenharmony_cistatic struct platform_driver zx_clk_driver = { 10638c2ecf20Sopenharmony_ci .probe = zx_clkc_probe, 10648c2ecf20Sopenharmony_ci .driver = { 10658c2ecf20Sopenharmony_ci .name = "zx296718-clkc", 10668c2ecf20Sopenharmony_ci .of_match_table = zx_clkc_match_table, 10678c2ecf20Sopenharmony_ci }, 10688c2ecf20Sopenharmony_ci}; 10698c2ecf20Sopenharmony_ci 10708c2ecf20Sopenharmony_cistatic int __init zx_clk_init(void) 10718c2ecf20Sopenharmony_ci{ 10728c2ecf20Sopenharmony_ci return platform_driver_register(&zx_clk_driver); 10738c2ecf20Sopenharmony_ci} 10748c2ecf20Sopenharmony_cicore_initcall(zx_clk_init); 1075