18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Actions Semi Owl S500 SoC clock driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 2014 Actions Semi Inc.
68c2ecf20Sopenharmony_ci * Author: David Liu <liuwei@actions-semi.com>
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Copyright (c) 2018 Linaro Ltd.
98c2ecf20Sopenharmony_ci * Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * Copyright (c) 2018 LSI-TEC - Caninos Loucos
128c2ecf20Sopenharmony_ci * Author: Edgar Bernardi Righi <edgar.righi@lsitec.org.br>
138c2ecf20Sopenharmony_ci */
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
168c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#include "owl-common.h"
198c2ecf20Sopenharmony_ci#include "owl-composite.h"
208c2ecf20Sopenharmony_ci#include "owl-divider.h"
218c2ecf20Sopenharmony_ci#include "owl-factor.h"
228c2ecf20Sopenharmony_ci#include "owl-fixed-factor.h"
238c2ecf20Sopenharmony_ci#include "owl-gate.h"
248c2ecf20Sopenharmony_ci#include "owl-mux.h"
258c2ecf20Sopenharmony_ci#include "owl-pll.h"
268c2ecf20Sopenharmony_ci#include "owl-reset.h"
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#include <dt-bindings/clock/actions,s500-cmu.h>
298c2ecf20Sopenharmony_ci#include <dt-bindings/reset/actions,s500-reset.h>
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define CMU_COREPLL			(0x0000)
328c2ecf20Sopenharmony_ci#define CMU_DEVPLL			(0x0004)
338c2ecf20Sopenharmony_ci#define CMU_DDRPLL			(0x0008)
348c2ecf20Sopenharmony_ci#define CMU_NANDPLL			(0x000C)
358c2ecf20Sopenharmony_ci#define CMU_DISPLAYPLL			(0x0010)
368c2ecf20Sopenharmony_ci#define CMU_AUDIOPLL			(0x0014)
378c2ecf20Sopenharmony_ci#define CMU_TVOUTPLL			(0x0018)
388c2ecf20Sopenharmony_ci#define CMU_BUSCLK			(0x001C)
398c2ecf20Sopenharmony_ci#define CMU_SENSORCLK			(0x0020)
408c2ecf20Sopenharmony_ci#define CMU_LCDCLK			(0x0024)
418c2ecf20Sopenharmony_ci#define CMU_DSICLK			(0x0028)
428c2ecf20Sopenharmony_ci#define CMU_CSICLK			(0x002C)
438c2ecf20Sopenharmony_ci#define CMU_DECLK			(0x0030)
448c2ecf20Sopenharmony_ci#define CMU_BISPCLK			(0x0034)
458c2ecf20Sopenharmony_ci#define CMU_BUSCLK1			(0x0038)
468c2ecf20Sopenharmony_ci#define CMU_VDECLK			(0x0040)
478c2ecf20Sopenharmony_ci#define CMU_VCECLK			(0x0044)
488c2ecf20Sopenharmony_ci#define CMU_NANDCCLK			(0x004C)
498c2ecf20Sopenharmony_ci#define CMU_SD0CLK			(0x0050)
508c2ecf20Sopenharmony_ci#define CMU_SD1CLK			(0x0054)
518c2ecf20Sopenharmony_ci#define CMU_SD2CLK			(0x0058)
528c2ecf20Sopenharmony_ci#define CMU_UART0CLK			(0x005C)
538c2ecf20Sopenharmony_ci#define CMU_UART1CLK			(0x0060)
548c2ecf20Sopenharmony_ci#define CMU_UART2CLK			(0x0064)
558c2ecf20Sopenharmony_ci#define CMU_PWM4CLK			(0x0068)
568c2ecf20Sopenharmony_ci#define CMU_PWM5CLK			(0x006C)
578c2ecf20Sopenharmony_ci#define CMU_PWM0CLK			(0x0070)
588c2ecf20Sopenharmony_ci#define CMU_PWM1CLK			(0x0074)
598c2ecf20Sopenharmony_ci#define CMU_PWM2CLK			(0x0078)
608c2ecf20Sopenharmony_ci#define CMU_PWM3CLK			(0x007C)
618c2ecf20Sopenharmony_ci#define CMU_USBPLL			(0x0080)
628c2ecf20Sopenharmony_ci#define CMU_ETHERNETPLL			(0x0084)
638c2ecf20Sopenharmony_ci#define CMU_CVBSPLL			(0x0088)
648c2ecf20Sopenharmony_ci#define CMU_LENSCLK			(0x008C)
658c2ecf20Sopenharmony_ci#define CMU_GPU3DCLK			(0x0090)
668c2ecf20Sopenharmony_ci#define CMU_CORECTL			(0x009C)
678c2ecf20Sopenharmony_ci#define CMU_DEVCLKEN0			(0x00A0)
688c2ecf20Sopenharmony_ci#define CMU_DEVCLKEN1			(0x00A4)
698c2ecf20Sopenharmony_ci#define CMU_DEVRST0			(0x00A8)
708c2ecf20Sopenharmony_ci#define CMU_DEVRST1			(0x00AC)
718c2ecf20Sopenharmony_ci#define CMU_UART3CLK			(0x00B0)
728c2ecf20Sopenharmony_ci#define CMU_UART4CLK			(0x00B4)
738c2ecf20Sopenharmony_ci#define CMU_UART5CLK			(0x00B8)
748c2ecf20Sopenharmony_ci#define CMU_UART6CLK			(0x00BC)
758c2ecf20Sopenharmony_ci#define CMU_SSCLK			(0x00C0)
768c2ecf20Sopenharmony_ci#define CMU_DIGITALDEBUG		(0x00D0)
778c2ecf20Sopenharmony_ci#define CMU_ANALOGDEBUG			(0x00D4)
788c2ecf20Sopenharmony_ci#define CMU_COREPLLDEBUG		(0x00D8)
798c2ecf20Sopenharmony_ci#define CMU_DEVPLLDEBUG			(0x00DC)
808c2ecf20Sopenharmony_ci#define CMU_DDRPLLDEBUG			(0x00E0)
818c2ecf20Sopenharmony_ci#define CMU_NANDPLLDEBUG		(0x00E4)
828c2ecf20Sopenharmony_ci#define CMU_DISPLAYPLLDEBUG		(0x00E8)
838c2ecf20Sopenharmony_ci#define CMU_TVOUTPLLDEBUG		(0x00EC)
848c2ecf20Sopenharmony_ci#define CMU_DEEPCOLORPLLDEBUG		(0x00F4)
858c2ecf20Sopenharmony_ci#define CMU_AUDIOPLL_ETHPLLDEBUG	(0x00F8)
868c2ecf20Sopenharmony_ci#define CMU_CVBSPLLDEBUG		(0x00FC)
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#define OWL_S500_COREPLL_DELAY		(150)
898c2ecf20Sopenharmony_ci#define OWL_S500_DDRPLL_DELAY		(63)
908c2ecf20Sopenharmony_ci#define OWL_S500_DEVPLL_DELAY		(28)
918c2ecf20Sopenharmony_ci#define OWL_S500_NANDPLL_DELAY		(44)
928c2ecf20Sopenharmony_ci#define OWL_S500_DISPLAYPLL_DELAY	(57)
938c2ecf20Sopenharmony_ci#define OWL_S500_ETHERNETPLL_DELAY	(25)
948c2ecf20Sopenharmony_ci#define OWL_S500_AUDIOPLL_DELAY		(100)
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_cistatic const struct clk_pll_table clk_audio_pll_table[] = {
978c2ecf20Sopenharmony_ci	{ 0, 45158400 }, { 1, 49152000 },
988c2ecf20Sopenharmony_ci	{ 0, 0 },
998c2ecf20Sopenharmony_ci};
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci/* pll clocks */
1028c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT_DELAY(ethernet_pll_clk, "ethernet_pll_clk", CMU_ETHERNETPLL, 500000000, 0, 0, 0, 0, 0, OWL_S500_ETHERNETPLL_DELAY, NULL, CLK_IGNORE_UNUSED);
1038c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT_DELAY(core_pll_clk, "core_pll_clk", CMU_COREPLL, 12000000, 9, 0, 8, 4, 134, OWL_S500_COREPLL_DELAY, NULL, CLK_IGNORE_UNUSED);
1048c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT_DELAY(ddr_pll_clk, "ddr_pll_clk", CMU_DDRPLL, 12000000, 8, 0, 8, 1, 67, OWL_S500_DDRPLL_DELAY, NULL, CLK_IGNORE_UNUSED);
1058c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT_DELAY(nand_pll_clk, "nand_pll_clk", CMU_NANDPLL, 6000000, 8, 0, 7, 2, 86, OWL_S500_NANDPLL_DELAY, NULL, CLK_IGNORE_UNUSED);
1068c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT_DELAY(display_pll_clk, "display_pll_clk", CMU_DISPLAYPLL, 6000000, 8, 0, 8, 2, 126, OWL_S500_DISPLAYPLL_DELAY, NULL, CLK_IGNORE_UNUSED);
1078c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT_DELAY(dev_pll_clk, "dev_pll_clk", CMU_DEVPLL, 6000000, 8, 0, 7, 8, 126, OWL_S500_DEVPLL_DELAY, NULL, CLK_IGNORE_UNUSED);
1088c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT_DELAY(audio_pll_clk, "audio_pll_clk", CMU_AUDIOPLL, 0, 4, 0, 1, 0, 0, OWL_S500_AUDIOPLL_DELAY, clk_audio_pll_table, CLK_IGNORE_UNUSED);
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_cistatic const char * const dev_clk_mux_p[] = { "hosc", "dev_pll_clk" };
1118c2ecf20Sopenharmony_cistatic const char * const bisp_clk_mux_p[] = { "display_pll_clk", "dev_clk" };
1128c2ecf20Sopenharmony_cistatic const char * const sensor_clk_mux_p[] = { "hosc", "bisp_clk" };
1138c2ecf20Sopenharmony_cistatic const char * const sd_clk_mux_p[] = { "dev_clk", "nand_pll_clk" };
1148c2ecf20Sopenharmony_cistatic const char * const pwm_clk_mux_p[] = { "losc", "hosc" };
1158c2ecf20Sopenharmony_cistatic const char * const ahbprediv_clk_mux_p[] = { "dev_clk", "display_pll_clk", "nand_pll_clk", "ddr_pll_clk" };
1168c2ecf20Sopenharmony_cistatic const char * const uart_clk_mux_p[] = { "hosc", "dev_pll_clk" };
1178c2ecf20Sopenharmony_cistatic const char * const de_clk_mux_p[] = { "display_pll_clk", "dev_clk" };
1188c2ecf20Sopenharmony_cistatic const char * const i2s_clk_mux_p[] = { "audio_pll_clk" };
1198c2ecf20Sopenharmony_cistatic const char * const hde_clk_mux_p[] = { "dev_clk", "display_pll_clk", "nand_pll_clk", "ddr_pll_clk" };
1208c2ecf20Sopenharmony_cistatic const char * const nand_clk_mux_p[] = { "nand_pll_clk", "display_pll_clk", "dev_clk", "ddr_pll_clk" };
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_cistatic struct clk_factor_table sd_factor_table[] = {
1238c2ecf20Sopenharmony_ci	/* bit0 ~ 4 */
1248c2ecf20Sopenharmony_ci	{ 0, 1, 1 }, { 1, 1, 2 }, { 2, 1, 3 }, { 3, 1, 4 },
1258c2ecf20Sopenharmony_ci	{ 4, 1, 5 }, { 5, 1, 6 }, { 6, 1, 7 }, { 7, 1, 8 },
1268c2ecf20Sopenharmony_ci	{ 8, 1, 9 }, { 9, 1, 10 }, { 10, 1, 11 }, { 11, 1, 12 },
1278c2ecf20Sopenharmony_ci	{ 12, 1, 13 }, { 13, 1, 14 }, { 14, 1, 15 }, { 15, 1, 16 },
1288c2ecf20Sopenharmony_ci	{ 16, 1, 17 }, { 17, 1, 18 }, { 18, 1, 19 }, { 19, 1, 20 },
1298c2ecf20Sopenharmony_ci	{ 20, 1, 21 }, { 21, 1, 22 }, { 22, 1, 23 }, { 23, 1, 24 },
1308c2ecf20Sopenharmony_ci	{ 24, 1, 25 },
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci	/* bit8: /128 */
1338c2ecf20Sopenharmony_ci	{ 256, 1, 1 * 128 }, { 257, 1, 2 * 128 }, { 258, 1, 3 * 128 }, { 259, 1, 4 * 128 },
1348c2ecf20Sopenharmony_ci	{ 260, 1, 5 * 128 }, { 261, 1, 6 * 128 }, { 262, 1, 7 * 128 }, { 263, 1, 8 * 128 },
1358c2ecf20Sopenharmony_ci	{ 264, 1, 9 * 128 }, { 265, 1, 10 * 128 }, { 266, 1, 11 * 128 }, { 267, 1, 12 * 128 },
1368c2ecf20Sopenharmony_ci	{ 268, 1, 13 * 128 }, { 269, 1, 14 * 128 }, { 270, 1, 15 * 128 }, { 271, 1, 16 * 128 },
1378c2ecf20Sopenharmony_ci	{ 272, 1, 17 * 128 }, { 273, 1, 18 * 128 }, { 274, 1, 19 * 128 }, { 275, 1, 20 * 128 },
1388c2ecf20Sopenharmony_ci	{ 276, 1, 21 * 128 }, { 277, 1, 22 * 128 }, { 278, 1, 23 * 128 }, { 279, 1, 24 * 128 },
1398c2ecf20Sopenharmony_ci	{ 280, 1, 25 * 128 },
1408c2ecf20Sopenharmony_ci	{ 0, 0, 0 },
1418c2ecf20Sopenharmony_ci};
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_cistatic struct clk_factor_table de_factor_table[] = {
1448c2ecf20Sopenharmony_ci	{ 0, 1, 1 }, { 1, 2, 3 }, { 2, 1, 2 }, { 3, 2, 5 },
1458c2ecf20Sopenharmony_ci	{ 4, 1, 3 }, { 5, 1, 4 }, { 6, 1, 6 }, { 7, 1, 8 },
1468c2ecf20Sopenharmony_ci	{ 8, 1, 12 },
1478c2ecf20Sopenharmony_ci	{ 0, 0, 0 },
1488c2ecf20Sopenharmony_ci};
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_cistatic struct clk_factor_table hde_factor_table[] = {
1518c2ecf20Sopenharmony_ci	{ 0, 1, 1 }, { 1, 2, 3 }, { 2, 1, 2 }, { 3, 2, 5 },
1528c2ecf20Sopenharmony_ci	{ 4, 1, 3 }, { 5, 1, 4 }, { 6, 1, 6 }, { 7, 1, 8 },
1538c2ecf20Sopenharmony_ci	{ 0, 0, 0 },
1548c2ecf20Sopenharmony_ci};
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_cistatic struct clk_div_table rmii_ref_div_table[] = {
1578c2ecf20Sopenharmony_ci	{ 0, 4 }, { 1, 10 },
1588c2ecf20Sopenharmony_ci	{ 0, 0 },
1598c2ecf20Sopenharmony_ci};
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_cistatic struct clk_div_table std12rate_div_table[] = {
1628c2ecf20Sopenharmony_ci	{ 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 4 },
1638c2ecf20Sopenharmony_ci	{ 4, 5 }, { 5, 6 }, { 6, 7 }, { 7, 8 },
1648c2ecf20Sopenharmony_ci	{ 8, 9 }, { 9, 10 }, { 10, 11 }, { 11, 12 },
1658c2ecf20Sopenharmony_ci	{ 0, 0 },
1668c2ecf20Sopenharmony_ci};
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_cistatic struct clk_div_table i2s_div_table[] = {
1698c2ecf20Sopenharmony_ci	{ 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 4 },
1708c2ecf20Sopenharmony_ci	{ 4, 6 }, { 5, 8 }, { 6, 12 }, { 7, 16 },
1718c2ecf20Sopenharmony_ci	{ 8, 24 },
1728c2ecf20Sopenharmony_ci	{ 0, 0 },
1738c2ecf20Sopenharmony_ci};
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_cistatic struct clk_div_table nand_div_table[] = {
1768c2ecf20Sopenharmony_ci	{ 0, 1 }, { 1, 2 }, { 2, 4 }, { 3, 6 },
1778c2ecf20Sopenharmony_ci	{ 4, 8 }, { 5, 10 }, { 6, 12 }, { 7, 14 },
1788c2ecf20Sopenharmony_ci	{ 8, 16 }, { 9, 18 }, { 10, 20 }, { 11, 22 },
1798c2ecf20Sopenharmony_ci	{ 0, 0 },
1808c2ecf20Sopenharmony_ci};
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci/* mux clock */
1838c2ecf20Sopenharmony_cistatic OWL_MUX(dev_clk, "dev_clk", dev_clk_mux_p, CMU_DEVPLL, 12, 1, CLK_SET_RATE_PARENT);
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci/* gate clocks */
1868c2ecf20Sopenharmony_cistatic OWL_GATE(gpio_clk, "gpio_clk", "apb_clk", CMU_DEVCLKEN0, 18, 0, 0);
1878c2ecf20Sopenharmony_cistatic OWL_GATE(dmac_clk, "dmac_clk", "h_clk", CMU_DEVCLKEN0, 1, 0, 0);
1888c2ecf20Sopenharmony_cistatic OWL_GATE(spi0_clk, "spi0_clk", "ahb_clk", CMU_DEVCLKEN1, 10, 0, CLK_IGNORE_UNUSED);
1898c2ecf20Sopenharmony_cistatic OWL_GATE(spi1_clk, "spi1_clk", "ahb_clk", CMU_DEVCLKEN1, 11, 0, CLK_IGNORE_UNUSED);
1908c2ecf20Sopenharmony_cistatic OWL_GATE(spi2_clk, "spi2_clk", "ahb_clk", CMU_DEVCLKEN1, 12, 0, CLK_IGNORE_UNUSED);
1918c2ecf20Sopenharmony_cistatic OWL_GATE(spi3_clk, "spi3_clk", "ahb_clk", CMU_DEVCLKEN1, 13, 0, CLK_IGNORE_UNUSED);
1928c2ecf20Sopenharmony_cistatic OWL_GATE(timer_clk, "timer_clk", "hosc", CMU_DEVCLKEN1, 27, 0, 0);
1938c2ecf20Sopenharmony_cistatic OWL_GATE(hdmi_clk, "hdmi_clk", "hosc", CMU_DEVCLKEN1, 3, 0, 0);
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci/* divider clocks */
1968c2ecf20Sopenharmony_cistatic OWL_DIVIDER(h_clk, "h_clk", "ahbprediv_clk", CMU_BUSCLK1, 2, 2, NULL, 0, 0);
1978c2ecf20Sopenharmony_cistatic OWL_DIVIDER(apb_clk, "apb_clk", "ahb_clk", CMU_BUSCLK1, 14, 2, NULL, 0, 0);
1988c2ecf20Sopenharmony_cistatic OWL_DIVIDER(rmii_ref_clk, "rmii_ref_clk", "ethernet_pll_clk", CMU_ETHERNETPLL, 1, 1, rmii_ref_div_table, 0, 0);
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci/* factor clocks */
2018c2ecf20Sopenharmony_cistatic OWL_FACTOR(de1_clk, "de_clk1", "de_clk", CMU_DECLK, 0, 4, de_factor_table, 0, 0);
2028c2ecf20Sopenharmony_cistatic OWL_FACTOR(de2_clk, "de_clk2", "de_clk", CMU_DECLK, 4, 4, de_factor_table, 0, 0);
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci/* composite clocks */
2058c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(ahbprediv_clk, "ahbprediv_clk", ahbprediv_clk_mux_p,
2068c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_BUSCLK1, 8, 3),
2078c2ecf20Sopenharmony_ci			{ 0 },
2088c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_BUSCLK1, 12, 2, 0, NULL),
2098c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT);
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_cistatic OWL_COMP_FIXED_FACTOR(ahb_clk, "ahb_clk", "h_clk",
2128c2ecf20Sopenharmony_ci			{ 0 },
2138c2ecf20Sopenharmony_ci			1, 1, 0);
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(vce_clk, "vce_clk", hde_clk_mux_p,
2168c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_VCECLK, 4, 2),
2178c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 26, 0),
2188c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_VCECLK, 0, 3, 0, hde_factor_table),
2198c2ecf20Sopenharmony_ci			0);
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(vde_clk, "vde_clk", hde_clk_mux_p,
2228c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_VDECLK, 4, 2),
2238c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 25, 0),
2248c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_VDECLK, 0, 3, 0, hde_factor_table),
2258c2ecf20Sopenharmony_ci			0);
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(bisp_clk, "bisp_clk", bisp_clk_mux_p,
2288c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_BISPCLK, 4, 1),
2298c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 14, 0),
2308c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_BISPCLK, 0, 4, 0, std12rate_div_table),
2318c2ecf20Sopenharmony_ci			0);
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(sensor0_clk, "sensor0_clk", sensor_clk_mux_p,
2348c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_SENSORCLK, 4, 1),
2358c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 14, 0),
2368c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_SENSORCLK, 0, 4, 0, std12rate_div_table),
2378c2ecf20Sopenharmony_ci			0);
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(sensor1_clk, "sensor1_clk", sensor_clk_mux_p,
2408c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_SENSORCLK, 4, 1),
2418c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 14, 0),
2428c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_SENSORCLK, 8, 4, 0, std12rate_div_table),
2438c2ecf20Sopenharmony_ci			0);
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(sd0_clk, "sd0_clk", sd_clk_mux_p,
2468c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_SD0CLK, 9, 1),
2478c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 5, 0),
2488c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_SD0CLK, 0, 9, 0, sd_factor_table),
2498c2ecf20Sopenharmony_ci			0);
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(sd1_clk, "sd1_clk", sd_clk_mux_p,
2528c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_SD1CLK, 9, 1),
2538c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 6, 0),
2548c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_SD1CLK, 0, 9, 0, sd_factor_table),
2558c2ecf20Sopenharmony_ci			0);
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(sd2_clk, "sd2_clk", sd_clk_mux_p,
2588c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_SD2CLK, 9, 1),
2598c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 7, 0),
2608c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_SD2CLK, 0, 9, 0, sd_factor_table),
2618c2ecf20Sopenharmony_ci			0);
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(pwm0_clk, "pwm0_clk", pwm_clk_mux_p,
2648c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_PWM0CLK, 12, 1),
2658c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 23, 0),
2668c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_PWM0CLK, 0, 10, 0, NULL),
2678c2ecf20Sopenharmony_ci			0);
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(pwm1_clk, "pwm1_clk", pwm_clk_mux_p,
2708c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_PWM1CLK, 12, 1),
2718c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 24, 0),
2728c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_PWM1CLK, 0, 10, 0, NULL),
2738c2ecf20Sopenharmony_ci			0);
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(pwm2_clk, "pwm2_clk", pwm_clk_mux_p,
2768c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_PWM2CLK, 12, 1),
2778c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 25, 0),
2788c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_PWM2CLK, 0, 10, 0, NULL),
2798c2ecf20Sopenharmony_ci			0);
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(pwm3_clk, "pwm3_clk", pwm_clk_mux_p,
2828c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_PWM3CLK, 12, 1),
2838c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 26, 0),
2848c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_PWM3CLK, 0, 10, 0, NULL),
2858c2ecf20Sopenharmony_ci			0);
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(pwm4_clk, "pwm4_clk", pwm_clk_mux_p,
2888c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_PWM4CLK, 12, 1),
2898c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 11, 0),
2908c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_PWM4CLK, 0, 10, 0, NULL),
2918c2ecf20Sopenharmony_ci			0);
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(pwm5_clk, "pwm5_clk", pwm_clk_mux_p,
2948c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_PWM5CLK, 12, 1),
2958c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 0, 0),
2968c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_PWM5CLK, 0, 10, 0, NULL),
2978c2ecf20Sopenharmony_ci			0);
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_cistatic OWL_COMP_PASS(de_clk, "de_clk", de_clk_mux_p,
3008c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_DECLK, 12, 1),
3018c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 8, 0),
3028c2ecf20Sopenharmony_ci			0);
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_cistatic OWL_COMP_FIXED_FACTOR(i2c0_clk, "i2c0_clk", "ethernet_pll_clk",
3058c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 14, 0),
3068c2ecf20Sopenharmony_ci			1, 5, 0);
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_cistatic OWL_COMP_FIXED_FACTOR(i2c1_clk, "i2c1_clk", "ethernet_pll_clk",
3098c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 15, 0),
3108c2ecf20Sopenharmony_ci			1, 5, 0);
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_cistatic OWL_COMP_FIXED_FACTOR(i2c2_clk, "i2c2_clk", "ethernet_pll_clk",
3138c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 30, 0),
3148c2ecf20Sopenharmony_ci			1, 5, 0);
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_cistatic OWL_COMP_FIXED_FACTOR(i2c3_clk, "i2c3_clk", "ethernet_pll_clk",
3178c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 31, 0),
3188c2ecf20Sopenharmony_ci			1, 5, 0);
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(uart0_clk, "uart0_clk", uart_clk_mux_p,
3218c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART0CLK, 16, 1),
3228c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 6, 0),
3238c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART0CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
3248c2ecf20Sopenharmony_ci			CLK_IGNORE_UNUSED);
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(uart1_clk, "uart1_clk", uart_clk_mux_p,
3278c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART1CLK, 16, 1),
3288c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 7, 0),
3298c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART1CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
3308c2ecf20Sopenharmony_ci			CLK_IGNORE_UNUSED);
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(uart2_clk, "uart2_clk", uart_clk_mux_p,
3338c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART2CLK, 16, 1),
3348c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 8, 0),
3358c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART2CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
3368c2ecf20Sopenharmony_ci			CLK_IGNORE_UNUSED);
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(uart3_clk, "uart3_clk", uart_clk_mux_p,
3398c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART3CLK, 16, 1),
3408c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 19, 0),
3418c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART3CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
3428c2ecf20Sopenharmony_ci			CLK_IGNORE_UNUSED);
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(uart4_clk, "uart4_clk", uart_clk_mux_p,
3458c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART4CLK, 16, 1),
3468c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 20, 0),
3478c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART4CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
3488c2ecf20Sopenharmony_ci			CLK_IGNORE_UNUSED);
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(uart5_clk, "uart5_clk", uart_clk_mux_p,
3518c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART5CLK, 16, 1),
3528c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 21, 0),
3538c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART5CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
3548c2ecf20Sopenharmony_ci			CLK_IGNORE_UNUSED);
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(uart6_clk, "uart6_clk", uart_clk_mux_p,
3578c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART6CLK, 16, 1),
3588c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 18, 0),
3598c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART6CLK, 0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL),
3608c2ecf20Sopenharmony_ci			CLK_IGNORE_UNUSED);
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(i2srx_clk, "i2srx_clk", i2s_clk_mux_p,
3638c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_AUDIOPLL, 24, 1),
3648c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 21, 0),
3658c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_AUDIOPLL, 20, 4, 0, i2s_div_table),
3668c2ecf20Sopenharmony_ci			0);
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(i2stx_clk, "i2stx_clk", i2s_clk_mux_p,
3698c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_AUDIOPLL, 24, 1),
3708c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 20, 0),
3718c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_AUDIOPLL, 16, 4, 0, i2s_div_table),
3728c2ecf20Sopenharmony_ci			0);
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(hdmia_clk, "hdmia_clk", i2s_clk_mux_p,
3758c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_AUDIOPLL, 24, 1),
3768c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 22, 0),
3778c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_AUDIOPLL, 24, 4, 0, i2s_div_table),
3788c2ecf20Sopenharmony_ci			0);
3798c2ecf20Sopenharmony_ci
3808c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(spdif_clk, "spdif_clk", i2s_clk_mux_p,
3818c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_AUDIOPLL, 24, 1),
3828c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 23, 0),
3838c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_AUDIOPLL, 28, 4, 0, i2s_div_table),
3848c2ecf20Sopenharmony_ci			0);
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(nand_clk, "nand_clk", nand_clk_mux_p,
3878c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_NANDCCLK, 8, 2),
3888c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 4, 0),
3898c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_NANDCCLK, 0, 3, 0, nand_div_table),
3908c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT);
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(ecc_clk, "ecc_clk", nand_clk_mux_p,
3938c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_NANDCCLK, 8, 2),
3948c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 4, 0),
3958c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_NANDCCLK, 4, 3, 0, nand_div_table),
3968c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT);
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_cistatic struct owl_clk_common *s500_clks[] = {
3998c2ecf20Sopenharmony_ci	&ethernet_pll_clk.common,
4008c2ecf20Sopenharmony_ci	&core_pll_clk.common,
4018c2ecf20Sopenharmony_ci	&ddr_pll_clk.common,
4028c2ecf20Sopenharmony_ci	&dev_pll_clk.common,
4038c2ecf20Sopenharmony_ci	&nand_pll_clk.common,
4048c2ecf20Sopenharmony_ci	&audio_pll_clk.common,
4058c2ecf20Sopenharmony_ci	&display_pll_clk.common,
4068c2ecf20Sopenharmony_ci	&dev_clk.common,
4078c2ecf20Sopenharmony_ci	&timer_clk.common,
4088c2ecf20Sopenharmony_ci	&i2c0_clk.common,
4098c2ecf20Sopenharmony_ci	&i2c1_clk.common,
4108c2ecf20Sopenharmony_ci	&i2c2_clk.common,
4118c2ecf20Sopenharmony_ci	&i2c3_clk.common,
4128c2ecf20Sopenharmony_ci	&uart0_clk.common,
4138c2ecf20Sopenharmony_ci	&uart1_clk.common,
4148c2ecf20Sopenharmony_ci	&uart2_clk.common,
4158c2ecf20Sopenharmony_ci	&uart3_clk.common,
4168c2ecf20Sopenharmony_ci	&uart4_clk.common,
4178c2ecf20Sopenharmony_ci	&uart5_clk.common,
4188c2ecf20Sopenharmony_ci	&uart6_clk.common,
4198c2ecf20Sopenharmony_ci	&pwm0_clk.common,
4208c2ecf20Sopenharmony_ci	&pwm1_clk.common,
4218c2ecf20Sopenharmony_ci	&pwm2_clk.common,
4228c2ecf20Sopenharmony_ci	&pwm3_clk.common,
4238c2ecf20Sopenharmony_ci	&pwm4_clk.common,
4248c2ecf20Sopenharmony_ci	&pwm5_clk.common,
4258c2ecf20Sopenharmony_ci	&sensor0_clk.common,
4268c2ecf20Sopenharmony_ci	&sensor1_clk.common,
4278c2ecf20Sopenharmony_ci	&sd0_clk.common,
4288c2ecf20Sopenharmony_ci	&sd1_clk.common,
4298c2ecf20Sopenharmony_ci	&sd2_clk.common,
4308c2ecf20Sopenharmony_ci	&bisp_clk.common,
4318c2ecf20Sopenharmony_ci	&ahb_clk.common,
4328c2ecf20Sopenharmony_ci	&ahbprediv_clk.common,
4338c2ecf20Sopenharmony_ci	&h_clk.common,
4348c2ecf20Sopenharmony_ci	&spi0_clk.common,
4358c2ecf20Sopenharmony_ci	&spi1_clk.common,
4368c2ecf20Sopenharmony_ci	&spi2_clk.common,
4378c2ecf20Sopenharmony_ci	&spi3_clk.common,
4388c2ecf20Sopenharmony_ci	&rmii_ref_clk.common,
4398c2ecf20Sopenharmony_ci	&de_clk.common,
4408c2ecf20Sopenharmony_ci	&de1_clk.common,
4418c2ecf20Sopenharmony_ci	&de2_clk.common,
4428c2ecf20Sopenharmony_ci	&i2srx_clk.common,
4438c2ecf20Sopenharmony_ci	&i2stx_clk.common,
4448c2ecf20Sopenharmony_ci	&hdmia_clk.common,
4458c2ecf20Sopenharmony_ci	&hdmi_clk.common,
4468c2ecf20Sopenharmony_ci	&vce_clk.common,
4478c2ecf20Sopenharmony_ci	&vde_clk.common,
4488c2ecf20Sopenharmony_ci	&spdif_clk.common,
4498c2ecf20Sopenharmony_ci	&nand_clk.common,
4508c2ecf20Sopenharmony_ci	&ecc_clk.common,
4518c2ecf20Sopenharmony_ci	&apb_clk.common,
4528c2ecf20Sopenharmony_ci	&dmac_clk.common,
4538c2ecf20Sopenharmony_ci	&gpio_clk.common,
4548c2ecf20Sopenharmony_ci};
4558c2ecf20Sopenharmony_ci
4568c2ecf20Sopenharmony_cistatic struct clk_hw_onecell_data s500_hw_clks = {
4578c2ecf20Sopenharmony_ci	.hws = {
4588c2ecf20Sopenharmony_ci		[CLK_ETHERNET_PLL]	= &ethernet_pll_clk.common.hw,
4598c2ecf20Sopenharmony_ci		[CLK_CORE_PLL]		= &core_pll_clk.common.hw,
4608c2ecf20Sopenharmony_ci		[CLK_DDR_PLL]		= &ddr_pll_clk.common.hw,
4618c2ecf20Sopenharmony_ci		[CLK_NAND_PLL]		= &nand_pll_clk.common.hw,
4628c2ecf20Sopenharmony_ci		[CLK_DISPLAY_PLL]	= &display_pll_clk.common.hw,
4638c2ecf20Sopenharmony_ci		[CLK_DEV_PLL]		= &dev_pll_clk.common.hw,
4648c2ecf20Sopenharmony_ci		[CLK_AUDIO_PLL]		= &audio_pll_clk.common.hw,
4658c2ecf20Sopenharmony_ci		[CLK_TIMER]		= &timer_clk.common.hw,
4668c2ecf20Sopenharmony_ci		[CLK_DEV]		= &dev_clk.common.hw,
4678c2ecf20Sopenharmony_ci		[CLK_DE]		= &de_clk.common.hw,
4688c2ecf20Sopenharmony_ci		[CLK_DE1]		= &de1_clk.common.hw,
4698c2ecf20Sopenharmony_ci		[CLK_DE2]		= &de2_clk.common.hw,
4708c2ecf20Sopenharmony_ci		[CLK_I2C0]		= &i2c0_clk.common.hw,
4718c2ecf20Sopenharmony_ci		[CLK_I2C1]		= &i2c1_clk.common.hw,
4728c2ecf20Sopenharmony_ci		[CLK_I2C2]		= &i2c2_clk.common.hw,
4738c2ecf20Sopenharmony_ci		[CLK_I2C3]		= &i2c3_clk.common.hw,
4748c2ecf20Sopenharmony_ci		[CLK_I2SRX]		= &i2srx_clk.common.hw,
4758c2ecf20Sopenharmony_ci		[CLK_I2STX]		= &i2stx_clk.common.hw,
4768c2ecf20Sopenharmony_ci		[CLK_UART0]		= &uart0_clk.common.hw,
4778c2ecf20Sopenharmony_ci		[CLK_UART1]		= &uart1_clk.common.hw,
4788c2ecf20Sopenharmony_ci		[CLK_UART2]		= &uart2_clk.common.hw,
4798c2ecf20Sopenharmony_ci		[CLK_UART3]		= &uart3_clk.common.hw,
4808c2ecf20Sopenharmony_ci		[CLK_UART4]		= &uart4_clk.common.hw,
4818c2ecf20Sopenharmony_ci		[CLK_UART5]		= &uart5_clk.common.hw,
4828c2ecf20Sopenharmony_ci		[CLK_UART6]		= &uart6_clk.common.hw,
4838c2ecf20Sopenharmony_ci		[CLK_PWM0]		= &pwm0_clk.common.hw,
4848c2ecf20Sopenharmony_ci		[CLK_PWM1]		= &pwm1_clk.common.hw,
4858c2ecf20Sopenharmony_ci		[CLK_PWM2]		= &pwm2_clk.common.hw,
4868c2ecf20Sopenharmony_ci		[CLK_PWM3]		= &pwm3_clk.common.hw,
4878c2ecf20Sopenharmony_ci		[CLK_PWM4]		= &pwm4_clk.common.hw,
4888c2ecf20Sopenharmony_ci		[CLK_PWM5]		= &pwm5_clk.common.hw,
4898c2ecf20Sopenharmony_ci		[CLK_SENSOR0]		= &sensor0_clk.common.hw,
4908c2ecf20Sopenharmony_ci		[CLK_SENSOR1]		= &sensor1_clk.common.hw,
4918c2ecf20Sopenharmony_ci		[CLK_SD0]		= &sd0_clk.common.hw,
4928c2ecf20Sopenharmony_ci		[CLK_SD1]		= &sd1_clk.common.hw,
4938c2ecf20Sopenharmony_ci		[CLK_SD2]		= &sd2_clk.common.hw,
4948c2ecf20Sopenharmony_ci		[CLK_BISP]		= &bisp_clk.common.hw,
4958c2ecf20Sopenharmony_ci		[CLK_SPI0]		= &spi0_clk.common.hw,
4968c2ecf20Sopenharmony_ci		[CLK_SPI1]		= &spi1_clk.common.hw,
4978c2ecf20Sopenharmony_ci		[CLK_SPI2]		= &spi2_clk.common.hw,
4988c2ecf20Sopenharmony_ci		[CLK_SPI3]		= &spi3_clk.common.hw,
4998c2ecf20Sopenharmony_ci		[CLK_AHB]		= &ahb_clk.common.hw,
5008c2ecf20Sopenharmony_ci		[CLK_H]			= &h_clk.common.hw,
5018c2ecf20Sopenharmony_ci		[CLK_AHBPREDIV]		= &ahbprediv_clk.common.hw,
5028c2ecf20Sopenharmony_ci		[CLK_RMII_REF]		= &rmii_ref_clk.common.hw,
5038c2ecf20Sopenharmony_ci		[CLK_HDMI_AUDIO]	= &hdmia_clk.common.hw,
5048c2ecf20Sopenharmony_ci		[CLK_HDMI]		= &hdmi_clk.common.hw,
5058c2ecf20Sopenharmony_ci		[CLK_VDE]		= &vde_clk.common.hw,
5068c2ecf20Sopenharmony_ci		[CLK_VCE]		= &vce_clk.common.hw,
5078c2ecf20Sopenharmony_ci		[CLK_SPDIF]		= &spdif_clk.common.hw,
5088c2ecf20Sopenharmony_ci		[CLK_NAND]		= &nand_clk.common.hw,
5098c2ecf20Sopenharmony_ci		[CLK_ECC]		= &ecc_clk.common.hw,
5108c2ecf20Sopenharmony_ci		[CLK_APB]		= &apb_clk.common.hw,
5118c2ecf20Sopenharmony_ci		[CLK_DMAC]		= &dmac_clk.common.hw,
5128c2ecf20Sopenharmony_ci		[CLK_GPIO]		= &gpio_clk.common.hw,
5138c2ecf20Sopenharmony_ci	},
5148c2ecf20Sopenharmony_ci	.num = CLK_NR_CLKS,
5158c2ecf20Sopenharmony_ci};
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_cistatic const struct owl_reset_map s500_resets[] = {
5188c2ecf20Sopenharmony_ci	[RESET_DMAC]	= { CMU_DEVRST0, BIT(0) },
5198c2ecf20Sopenharmony_ci	[RESET_NORIF]	= { CMU_DEVRST0, BIT(1) },
5208c2ecf20Sopenharmony_ci	[RESET_DDR]	= { CMU_DEVRST0, BIT(2) },
5218c2ecf20Sopenharmony_ci	[RESET_NANDC]	= { CMU_DEVRST0, BIT(3) },
5228c2ecf20Sopenharmony_ci	[RESET_SD0]	= { CMU_DEVRST0, BIT(4) },
5238c2ecf20Sopenharmony_ci	[RESET_SD1]	= { CMU_DEVRST0, BIT(5) },
5248c2ecf20Sopenharmony_ci	[RESET_PCM1]	= { CMU_DEVRST0, BIT(6) },
5258c2ecf20Sopenharmony_ci	[RESET_DE]	= { CMU_DEVRST0, BIT(7) },
5268c2ecf20Sopenharmony_ci	[RESET_LCD]	= { CMU_DEVRST0, BIT(8) },
5278c2ecf20Sopenharmony_ci	[RESET_SD2]	= { CMU_DEVRST0, BIT(9) },
5288c2ecf20Sopenharmony_ci	[RESET_DSI]	= { CMU_DEVRST0, BIT(10) },
5298c2ecf20Sopenharmony_ci	[RESET_CSI]	= { CMU_DEVRST0, BIT(11) },
5308c2ecf20Sopenharmony_ci	[RESET_BISP]	= { CMU_DEVRST0, BIT(12) },
5318c2ecf20Sopenharmony_ci	[RESET_KEY]	= { CMU_DEVRST0, BIT(14) },
5328c2ecf20Sopenharmony_ci	[RESET_GPIO]	= { CMU_DEVRST0, BIT(15) },
5338c2ecf20Sopenharmony_ci	[RESET_AUDIO]	= { CMU_DEVRST0, BIT(17) },
5348c2ecf20Sopenharmony_ci	[RESET_PCM0]	= { CMU_DEVRST0, BIT(18) },
5358c2ecf20Sopenharmony_ci	[RESET_VDE]	= { CMU_DEVRST0, BIT(19) },
5368c2ecf20Sopenharmony_ci	[RESET_VCE]	= { CMU_DEVRST0, BIT(20) },
5378c2ecf20Sopenharmony_ci	[RESET_GPU3D]	= { CMU_DEVRST0, BIT(22) },
5388c2ecf20Sopenharmony_ci	[RESET_NIC301]	= { CMU_DEVRST0, BIT(23) },
5398c2ecf20Sopenharmony_ci	[RESET_LENS]	= { CMU_DEVRST0, BIT(26) },
5408c2ecf20Sopenharmony_ci	[RESET_PERIPHRESET] = { CMU_DEVRST0, BIT(27) },
5418c2ecf20Sopenharmony_ci	[RESET_USB2_0]	= { CMU_DEVRST1, BIT(0) },
5428c2ecf20Sopenharmony_ci	[RESET_TVOUT]	= { CMU_DEVRST1, BIT(1) },
5438c2ecf20Sopenharmony_ci	[RESET_HDMI]	= { CMU_DEVRST1, BIT(2) },
5448c2ecf20Sopenharmony_ci	[RESET_HDCP2TX]	= { CMU_DEVRST1, BIT(3) },
5458c2ecf20Sopenharmony_ci	[RESET_UART6]	= { CMU_DEVRST1, BIT(4) },
5468c2ecf20Sopenharmony_ci	[RESET_UART0]	= { CMU_DEVRST1, BIT(5) },
5478c2ecf20Sopenharmony_ci	[RESET_UART1]	= { CMU_DEVRST1, BIT(6) },
5488c2ecf20Sopenharmony_ci	[RESET_UART2]	= { CMU_DEVRST1, BIT(7) },
5498c2ecf20Sopenharmony_ci	[RESET_SPI0]	= { CMU_DEVRST1, BIT(8) },
5508c2ecf20Sopenharmony_ci	[RESET_SPI1]	= { CMU_DEVRST1, BIT(9) },
5518c2ecf20Sopenharmony_ci	[RESET_SPI2]	= { CMU_DEVRST1, BIT(10) },
5528c2ecf20Sopenharmony_ci	[RESET_SPI3]	= { CMU_DEVRST1, BIT(11) },
5538c2ecf20Sopenharmony_ci	[RESET_I2C0]	= { CMU_DEVRST1, BIT(12) },
5548c2ecf20Sopenharmony_ci	[RESET_I2C1]	= { CMU_DEVRST1, BIT(13) },
5558c2ecf20Sopenharmony_ci	[RESET_USB3]	= { CMU_DEVRST1, BIT(14) },
5568c2ecf20Sopenharmony_ci	[RESET_UART3]	= { CMU_DEVRST1, BIT(15) },
5578c2ecf20Sopenharmony_ci	[RESET_UART4]	= { CMU_DEVRST1, BIT(16) },
5588c2ecf20Sopenharmony_ci	[RESET_UART5]	= { CMU_DEVRST1, BIT(17) },
5598c2ecf20Sopenharmony_ci	[RESET_I2C2]	= { CMU_DEVRST1, BIT(18) },
5608c2ecf20Sopenharmony_ci	[RESET_I2C3]	= { CMU_DEVRST1, BIT(19) },
5618c2ecf20Sopenharmony_ci	[RESET_ETHERNET] = { CMU_DEVRST1, BIT(20) },
5628c2ecf20Sopenharmony_ci	[RESET_CHIPID]	= { CMU_DEVRST1, BIT(21) },
5638c2ecf20Sopenharmony_ci	[RESET_USB2_1]	= { CMU_DEVRST1, BIT(22) },
5648c2ecf20Sopenharmony_ci	[RESET_WD0RESET] = { CMU_DEVRST1, BIT(24) },
5658c2ecf20Sopenharmony_ci	[RESET_WD1RESET] = { CMU_DEVRST1, BIT(25) },
5668c2ecf20Sopenharmony_ci	[RESET_WD2RESET] = { CMU_DEVRST1, BIT(26) },
5678c2ecf20Sopenharmony_ci	[RESET_WD3RESET] = { CMU_DEVRST1, BIT(27) },
5688c2ecf20Sopenharmony_ci	[RESET_DBG0RESET] = { CMU_DEVRST1, BIT(28) },
5698c2ecf20Sopenharmony_ci	[RESET_DBG1RESET] = { CMU_DEVRST1, BIT(29) },
5708c2ecf20Sopenharmony_ci	[RESET_DBG2RESET] = { CMU_DEVRST1, BIT(30) },
5718c2ecf20Sopenharmony_ci	[RESET_DBG3RESET] = { CMU_DEVRST1, BIT(31) },
5728c2ecf20Sopenharmony_ci};
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_cistatic struct owl_clk_desc s500_clk_desc = {
5758c2ecf20Sopenharmony_ci	.clks	    = s500_clks,
5768c2ecf20Sopenharmony_ci	.num_clks   = ARRAY_SIZE(s500_clks),
5778c2ecf20Sopenharmony_ci
5788c2ecf20Sopenharmony_ci	.hw_clks    = &s500_hw_clks,
5798c2ecf20Sopenharmony_ci
5808c2ecf20Sopenharmony_ci	.resets     = s500_resets,
5818c2ecf20Sopenharmony_ci	.num_resets = ARRAY_SIZE(s500_resets),
5828c2ecf20Sopenharmony_ci};
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_cistatic int s500_clk_probe(struct platform_device *pdev)
5858c2ecf20Sopenharmony_ci{
5868c2ecf20Sopenharmony_ci	struct owl_clk_desc *desc;
5878c2ecf20Sopenharmony_ci	struct owl_reset *reset;
5888c2ecf20Sopenharmony_ci	int ret;
5898c2ecf20Sopenharmony_ci
5908c2ecf20Sopenharmony_ci	desc = &s500_clk_desc;
5918c2ecf20Sopenharmony_ci	owl_clk_regmap_init(pdev, desc);
5928c2ecf20Sopenharmony_ci
5938c2ecf20Sopenharmony_ci	reset = devm_kzalloc(&pdev->dev, sizeof(*reset), GFP_KERNEL);
5948c2ecf20Sopenharmony_ci	if (!reset)
5958c2ecf20Sopenharmony_ci		return -ENOMEM;
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_ci	reset->rcdev.of_node = pdev->dev.of_node;
5988c2ecf20Sopenharmony_ci	reset->rcdev.ops = &owl_reset_ops;
5998c2ecf20Sopenharmony_ci	reset->rcdev.nr_resets = desc->num_resets;
6008c2ecf20Sopenharmony_ci	reset->reset_map = desc->resets;
6018c2ecf20Sopenharmony_ci	reset->regmap = desc->regmap;
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_ci	ret = devm_reset_controller_register(&pdev->dev, &reset->rcdev);
6048c2ecf20Sopenharmony_ci	if (ret)
6058c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "Failed to register reset controller\n");
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci	return owl_clk_probe(&pdev->dev, desc->hw_clks);
6088c2ecf20Sopenharmony_ci}
6098c2ecf20Sopenharmony_ci
6108c2ecf20Sopenharmony_cistatic const struct of_device_id s500_clk_of_match[] = {
6118c2ecf20Sopenharmony_ci	{ .compatible = "actions,s500-cmu", },
6128c2ecf20Sopenharmony_ci	{ /* sentinel */ }
6138c2ecf20Sopenharmony_ci};
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_cistatic struct platform_driver s500_clk_driver = {
6168c2ecf20Sopenharmony_ci	.probe = s500_clk_probe,
6178c2ecf20Sopenharmony_ci	.driver = {
6188c2ecf20Sopenharmony_ci		.name = "s500-cmu",
6198c2ecf20Sopenharmony_ci		.of_match_table = s500_clk_of_match,
6208c2ecf20Sopenharmony_ci	},
6218c2ecf20Sopenharmony_ci};
6228c2ecf20Sopenharmony_ci
6238c2ecf20Sopenharmony_cistatic int __init s500_clk_init(void)
6248c2ecf20Sopenharmony_ci{
6258c2ecf20Sopenharmony_ci	return platform_driver_register(&s500_clk_driver);
6268c2ecf20Sopenharmony_ci}
6278c2ecf20Sopenharmony_cicore_initcall(s500_clk_init);
628