18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Actions Semi S700 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 * Author: Pathiban Nallathambi <pn@denx.de>
98c2ecf20Sopenharmony_ci * Author: Saravanan Sekar <sravanhome@gmail.com>
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
138c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include "owl-common.h"
168c2ecf20Sopenharmony_ci#include "owl-composite.h"
178c2ecf20Sopenharmony_ci#include "owl-divider.h"
188c2ecf20Sopenharmony_ci#include "owl-factor.h"
198c2ecf20Sopenharmony_ci#include "owl-fixed-factor.h"
208c2ecf20Sopenharmony_ci#include "owl-gate.h"
218c2ecf20Sopenharmony_ci#include "owl-mux.h"
228c2ecf20Sopenharmony_ci#include "owl-pll.h"
238c2ecf20Sopenharmony_ci#include "owl-reset.h"
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#include <dt-bindings/clock/actions,s700-cmu.h>
268c2ecf20Sopenharmony_ci#include <dt-bindings/reset/actions,s700-reset.h>
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define CMU_COREPLL		(0x0000)
298c2ecf20Sopenharmony_ci#define CMU_DEVPLL		(0x0004)
308c2ecf20Sopenharmony_ci#define CMU_DDRPLL		(0x0008)
318c2ecf20Sopenharmony_ci#define CMU_NANDPLL		(0x000C)
328c2ecf20Sopenharmony_ci#define CMU_DISPLAYPLL		(0x0010)
338c2ecf20Sopenharmony_ci#define CMU_AUDIOPLL		(0x0014)
348c2ecf20Sopenharmony_ci#define CMU_TVOUTPLL		(0x0018)
358c2ecf20Sopenharmony_ci#define CMU_BUSCLK		(0x001C)
368c2ecf20Sopenharmony_ci#define CMU_SENSORCLK		(0x0020)
378c2ecf20Sopenharmony_ci#define CMU_LCDCLK		(0x0024)
388c2ecf20Sopenharmony_ci#define CMU_DSIPLLCLK		(0x0028)
398c2ecf20Sopenharmony_ci#define CMU_CSICLK		(0x002C)
408c2ecf20Sopenharmony_ci#define CMU_DECLK		(0x0030)
418c2ecf20Sopenharmony_ci#define CMU_SICLK		(0x0034)
428c2ecf20Sopenharmony_ci#define CMU_BUSCLK1		(0x0038)
438c2ecf20Sopenharmony_ci#define CMU_HDECLK		(0x003C)
448c2ecf20Sopenharmony_ci#define CMU_VDECLK		(0x0040)
458c2ecf20Sopenharmony_ci#define CMU_VCECLK		(0x0044)
468c2ecf20Sopenharmony_ci#define CMU_NANDCCLK		(0x004C)
478c2ecf20Sopenharmony_ci#define CMU_SD0CLK		(0x0050)
488c2ecf20Sopenharmony_ci#define CMU_SD1CLK		(0x0054)
498c2ecf20Sopenharmony_ci#define CMU_SD2CLK		(0x0058)
508c2ecf20Sopenharmony_ci#define CMU_UART0CLK		(0x005C)
518c2ecf20Sopenharmony_ci#define CMU_UART1CLK		(0x0060)
528c2ecf20Sopenharmony_ci#define CMU_UART2CLK		(0x0064)
538c2ecf20Sopenharmony_ci#define CMU_UART3CLK		(0x0068)
548c2ecf20Sopenharmony_ci#define CMU_UART4CLK		(0x006C)
558c2ecf20Sopenharmony_ci#define CMU_UART5CLK		(0x0070)
568c2ecf20Sopenharmony_ci#define CMU_UART6CLK		(0x0074)
578c2ecf20Sopenharmony_ci#define CMU_PWM0CLK		(0x0078)
588c2ecf20Sopenharmony_ci#define CMU_PWM1CLK		(0x007C)
598c2ecf20Sopenharmony_ci#define CMU_PWM2CLK		(0x0080)
608c2ecf20Sopenharmony_ci#define CMU_PWM3CLK		(0x0084)
618c2ecf20Sopenharmony_ci#define CMU_PWM4CLK		(0x0088)
628c2ecf20Sopenharmony_ci#define CMU_PWM5CLK		(0x008C)
638c2ecf20Sopenharmony_ci#define CMU_GPU3DCLK		(0x0090)
648c2ecf20Sopenharmony_ci#define CMU_CORECTL		(0x009C)
658c2ecf20Sopenharmony_ci#define CMU_DEVCLKEN0		(0x00A0)
668c2ecf20Sopenharmony_ci#define CMU_DEVCLKEN1		(0x00A4)
678c2ecf20Sopenharmony_ci#define CMU_DEVRST0		(0x00A8)
688c2ecf20Sopenharmony_ci#define CMU_DEVRST1		(0x00AC)
698c2ecf20Sopenharmony_ci#define CMU_USBPLL		(0x00B0)
708c2ecf20Sopenharmony_ci#define CMU_ETHERNETPLL		(0x00B4)
718c2ecf20Sopenharmony_ci#define CMU_CVBSPLL		(0x00B8)
728c2ecf20Sopenharmony_ci#define CMU_SSTSCLK		(0x00C0)
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_cistatic struct clk_pll_table clk_audio_pll_table[] = {
758c2ecf20Sopenharmony_ci	{0, 45158400}, {1, 49152000},
768c2ecf20Sopenharmony_ci	{0, 0},
778c2ecf20Sopenharmony_ci};
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_cistatic struct clk_pll_table clk_cvbs_pll_table[] = {
808c2ecf20Sopenharmony_ci	{27, 29 * 12000000}, {28, 30 * 12000000}, {29, 31 * 12000000},
818c2ecf20Sopenharmony_ci	{30, 32 * 12000000}, {31, 33 * 12000000}, {32, 34 * 12000000},
828c2ecf20Sopenharmony_ci	{33, 35 * 12000000}, {34, 36 * 12000000}, {35, 37 * 12000000},
838c2ecf20Sopenharmony_ci	{36, 38 * 12000000}, {37, 39 * 12000000}, {38, 40 * 12000000},
848c2ecf20Sopenharmony_ci	{39, 41 * 12000000}, {40, 42 * 12000000}, {41, 43 * 12000000},
858c2ecf20Sopenharmony_ci	{42, 44 * 12000000}, {43, 45 * 12000000}, {0, 0},
868c2ecf20Sopenharmony_ci};
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci/* pll clocks */
898c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT(clk_core_pll,   "core_pll", CMU_COREPLL, 12000000, 9, 0, 8,  4, 174, NULL, CLK_IGNORE_UNUSED);
908c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT(clk_dev_pll,    "dev_pll", CMU_DEVPLL,  6000000, 8, 0, 8, 8, 126, NULL, CLK_IGNORE_UNUSED);
918c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT(clk_ddr_pll,    "ddr_pll", CMU_DDRPLL, 6000000, 8, 0, 8,  2,  180, NULL, CLK_IGNORE_UNUSED);
928c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT(clk_nand_pll,   "nand_pll", CMU_NANDPLL,  6000000, 8, 0, 8,  2, 86, NULL, CLK_IGNORE_UNUSED);
938c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT(clk_display_pll, "display_pll", CMU_DISPLAYPLL, 6000000, 8, 0, 8, 2, 140, NULL, CLK_IGNORE_UNUSED);
948c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT(clk_cvbs_pll, "cvbs_pll", CMU_CVBSPLL, 0, 8, 0, 8, 27, 43, clk_cvbs_pll_table, CLK_IGNORE_UNUSED);
958c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT(clk_audio_pll,  "audio_pll", CMU_AUDIOPLL, 0, 4, 0, 1, 0, 0, clk_audio_pll_table, CLK_IGNORE_UNUSED);
968c2ecf20Sopenharmony_cistatic OWL_PLL_NO_PARENT(clk_ethernet_pll, "ethernet_pll", CMU_ETHERNETPLL, 500000000, 0, 0, 0, 0, 0, NULL, CLK_IGNORE_UNUSED);
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cistatic const char *cpu_clk_mux_p[] = {"losc", "hosc", "core_pll", "noc1_clk_div"};
998c2ecf20Sopenharmony_cistatic const char *dev_clk_p[] = { "hosc", "dev_pll"};
1008c2ecf20Sopenharmony_cistatic const char *noc_clk_mux_p[] = { "dev_clk", "display_pll", "nand_pll", "ddr_pll", "cvbs_pll"};
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_cistatic const char *csi_clk_mux_p[] = { "display_pll", "dev_clk"};
1038c2ecf20Sopenharmony_cistatic const char *de_clk_mux_p[] = { "display_pll", "dev_clk"};
1048c2ecf20Sopenharmony_cistatic const char *hde_clk_mux_p[] = { "dev_clk", "display_pll", "nand_pll", "ddr_pll"};
1058c2ecf20Sopenharmony_cistatic const char *nand_clk_mux_p[] = { "nand_pll", "display_pll", "dev_clk", "ddr_pll"};
1068c2ecf20Sopenharmony_cistatic const char *sd_clk_mux_p[] = { "dev_clk", "nand_pll", };
1078c2ecf20Sopenharmony_cistatic const char *uart_clk_mux_p[] = { "hosc", "dev_pll"};
1088c2ecf20Sopenharmony_cistatic const char *pwm_clk_mux_p[] = { "losc", "hosc"};
1098c2ecf20Sopenharmony_cistatic const char *gpu_clk_mux_p[] = { "dev_clk", "display_pll", "nand_pll", "ddr_clk", "cvbs_pll"};
1108c2ecf20Sopenharmony_cistatic const char *lcd_clk_mux_p[] = { "display_pll", "dev_clk" };
1118c2ecf20Sopenharmony_cistatic const char *i2s_clk_mux_p[] = { "audio_pll" };
1128c2ecf20Sopenharmony_cistatic const char *sensor_clk_mux_p[] = { "hosc", "si"};
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci/* mux clocks */
1158c2ecf20Sopenharmony_cistatic OWL_MUX(clk_cpu, "cpu_clk", cpu_clk_mux_p,  CMU_BUSCLK, 0, 2, CLK_SET_RATE_PARENT);
1168c2ecf20Sopenharmony_cistatic OWL_MUX(clk_dev, "dev_clk", dev_clk_p, CMU_DEVPLL, 12, 1, CLK_SET_RATE_PARENT);
1178c2ecf20Sopenharmony_cistatic OWL_MUX(clk_noc0_clk_mux, "noc0_clk_mux", noc_clk_mux_p, CMU_BUSCLK, 4, 3, CLK_SET_RATE_PARENT);
1188c2ecf20Sopenharmony_cistatic OWL_MUX(clk_noc1_clk_mux, "noc1_clk_mux", noc_clk_mux_p, CMU_BUSCLK1, 4, 3, CLK_SET_RATE_PARENT);
1198c2ecf20Sopenharmony_cistatic OWL_MUX(clk_hp_clk_mux, "hp_clk_mux", noc_clk_mux_p, CMU_BUSCLK1, 8, 3, CLK_SET_RATE_PARENT);
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_cistatic struct clk_factor_table sd_factor_table[] = {
1228c2ecf20Sopenharmony_ci	/* bit0 ~ 4 */
1238c2ecf20Sopenharmony_ci	{0, 1, 1}, {1, 1, 2}, {2, 1, 3}, {3, 1, 4},
1248c2ecf20Sopenharmony_ci	{4, 1, 5}, {5, 1, 6}, {6, 1, 7}, {7, 1, 8},
1258c2ecf20Sopenharmony_ci	{8, 1, 9}, {9, 1, 10}, {10, 1, 11}, {11, 1, 12},
1268c2ecf20Sopenharmony_ci	{12, 1, 13}, {13, 1, 14}, {14, 1, 15}, {15, 1, 16},
1278c2ecf20Sopenharmony_ci	{16, 1, 17}, {17, 1, 18}, {18, 1, 19}, {19, 1, 20},
1288c2ecf20Sopenharmony_ci	{20, 1, 21}, {21, 1, 22}, {22, 1, 23}, {23, 1, 24},
1298c2ecf20Sopenharmony_ci	{24, 1, 25}, {25, 1, 26},
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci	/* bit8: /128 */
1328c2ecf20Sopenharmony_ci	{256, 1, 1 * 128}, {257, 1, 2 * 128}, {258, 1, 3 * 128}, {259, 1, 4 * 128},
1338c2ecf20Sopenharmony_ci	{260, 1, 5 * 128}, {261, 1, 6 * 128}, {262, 1, 7 * 128}, {263, 1, 8 * 128},
1348c2ecf20Sopenharmony_ci	{264, 1, 9 * 128}, {265, 1, 10 * 128}, {266, 1, 11 * 128}, {267, 1, 12 * 128},
1358c2ecf20Sopenharmony_ci	{268, 1, 13 * 128}, {269, 1, 14 * 128}, {270, 1, 15 * 128}, {271, 1, 16 * 128},
1368c2ecf20Sopenharmony_ci	{272, 1, 17 * 128}, {273, 1, 18 * 128}, {274, 1, 19 * 128}, {275, 1, 20 * 128},
1378c2ecf20Sopenharmony_ci	{276, 1, 21 * 128}, {277, 1, 22 * 128}, {278, 1, 23 * 128}, {279, 1, 24 * 128},
1388c2ecf20Sopenharmony_ci	{280, 1, 25 * 128}, {281, 1, 26 * 128},
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci	{0, 0},
1418c2ecf20Sopenharmony_ci};
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_cistatic struct clk_factor_table lcd_factor_table[] = {
1448c2ecf20Sopenharmony_ci	/* bit0 ~ 3 */
1458c2ecf20Sopenharmony_ci	{0, 1, 1}, {1, 1, 2}, {2, 1, 3}, {3, 1, 4},
1468c2ecf20Sopenharmony_ci	{4, 1, 5}, {5, 1, 6}, {6, 1, 7}, {7, 1, 8},
1478c2ecf20Sopenharmony_ci	{8, 1, 9}, {9, 1, 10}, {10, 1, 11}, {11, 1, 12},
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci	/* bit8: /7 */
1508c2ecf20Sopenharmony_ci	{256, 1, 1 * 7}, {257, 1, 2 * 7}, {258, 1, 3 * 7}, {259, 1, 4 * 7},
1518c2ecf20Sopenharmony_ci	{260, 1, 5 * 7}, {261, 1, 6 * 7}, {262, 1, 7 * 7}, {263, 1, 8 * 7},
1528c2ecf20Sopenharmony_ci	{264, 1, 9 * 7}, {265, 1, 10 * 7}, {266, 1, 11 * 7}, {267, 1, 12 * 7},
1538c2ecf20Sopenharmony_ci	{0, 0},
1548c2ecf20Sopenharmony_ci};
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_cistatic struct clk_div_table hdmia_div_table[] = {
1578c2ecf20Sopenharmony_ci	{0, 1},   {1, 2},   {2, 3},   {3, 4},
1588c2ecf20Sopenharmony_ci	{4, 6},   {5, 8},   {6, 12},  {7, 16},
1598c2ecf20Sopenharmony_ci	{8, 24},
1608c2ecf20Sopenharmony_ci	{0, 0},
1618c2ecf20Sopenharmony_ci};
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_cistatic struct clk_div_table rmii_div_table[] = {
1648c2ecf20Sopenharmony_ci	{0, 4},   {1, 10},
1658c2ecf20Sopenharmony_ci	{0, 0}
1668c2ecf20Sopenharmony_ci};
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci/* divider clocks */
1698c2ecf20Sopenharmony_cistatic OWL_DIVIDER(clk_noc0, "noc0_clk", "noc0_clk_mux", CMU_BUSCLK, 16, 2, NULL, 0, 0);
1708c2ecf20Sopenharmony_cistatic OWL_DIVIDER(clk_noc1, "noc1_clk", "noc1_clk_mux", CMU_BUSCLK1, 16, 2, NULL, 0, 0);
1718c2ecf20Sopenharmony_cistatic OWL_DIVIDER(clk_noc1_clk_div, "noc1_clk_div", "noc1_clk", CMU_BUSCLK1, 20, 1, NULL, 0, 0);
1728c2ecf20Sopenharmony_cistatic OWL_DIVIDER(clk_hp_clk_div, "hp_clk_div", "hp_clk_mux", CMU_BUSCLK1, 12, 2, NULL, 0, 0);
1738c2ecf20Sopenharmony_cistatic OWL_DIVIDER(clk_ahb, "ahb_clk", "hp_clk_div", CMU_BUSCLK1, 2, 2, NULL, 0, 0);
1748c2ecf20Sopenharmony_cistatic OWL_DIVIDER(clk_apb, "apb_clk", "ahb_clk", CMU_BUSCLK1, 14, 2, NULL, 0, 0);
1758c2ecf20Sopenharmony_cistatic OWL_DIVIDER(clk_sensor0, "sensor0", "sensor_src", CMU_SENSORCLK, 0, 4, NULL, 0, 0);
1768c2ecf20Sopenharmony_cistatic OWL_DIVIDER(clk_sensor1, "sensor1", "sensor_src", CMU_SENSORCLK, 8, 4, NULL, 0, 0);
1778c2ecf20Sopenharmony_cistatic OWL_DIVIDER(clk_rmii_ref, "rmii_ref", "ethernet_pll", CMU_ETHERNETPLL, 2, 1, rmii_div_table, 0, 0);
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_cistatic struct clk_factor_table de_factor_table[] = {
1808c2ecf20Sopenharmony_ci	{0, 1, 1}, {1, 2, 3}, {2, 1, 2}, {3, 2, 5},
1818c2ecf20Sopenharmony_ci	{4, 1, 3}, {5, 1, 4}, {6, 1, 6}, {7, 1, 8},
1828c2ecf20Sopenharmony_ci	{8, 1, 12}, {0, 0, 0},
1838c2ecf20Sopenharmony_ci};
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_cistatic struct clk_factor_table hde_factor_table[] = {
1868c2ecf20Sopenharmony_ci	{0, 1, 1}, {1, 2, 3}, {2, 1, 2}, {3, 2, 5},
1878c2ecf20Sopenharmony_ci	{4, 1, 3}, {5, 1, 4}, {6, 1, 6}, {7, 1, 8},
1888c2ecf20Sopenharmony_ci	{0, 0, 0},
1898c2ecf20Sopenharmony_ci};
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci/* gate clocks */
1928c2ecf20Sopenharmony_cistatic OWL_GATE(clk_gpio, "gpio", "apb_clk", CMU_DEVCLKEN1, 25, 0, 0);
1938c2ecf20Sopenharmony_cistatic OWL_GATE(clk_dmac, "dmac", "hp_clk_div", CMU_DEVCLKEN0, 17, 0, 0);
1948c2ecf20Sopenharmony_cistatic OWL_GATE(clk_timer, "timer", "hosc", CMU_DEVCLKEN1, 22, 0, 0);
1958c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_dsi, "dsi_clk", CMU_DEVCLKEN0, 2, 0, 0);
1968c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_tvout, "tvout_clk", CMU_DEVCLKEN0, 3, 0, 0);
1978c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_hdmi_dev, "hdmi_dev", CMU_DEVCLKEN0, 5, 0, 0);
1988c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_usb3_480mpll0, "usb3_480mpll0", CMU_USBPLL, 3, 0, 0);
1998c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_usb3_480mphy0, "usb3_480mphy0", CMU_USBPLL, 2, 0, 0);
2008c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_usb3_5gphy, "usb3_5gphy", CMU_USBPLL, 1, 0, 0);
2018c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_usb3_cce, "usb3_cce", CMU_DEVCLKEN0, 25, 0, 0);
2028c2ecf20Sopenharmony_cistatic OWL_GATE(clk_i2c0, "i2c0", "hosc", CMU_DEVCLKEN1, 0, 0, 0);
2038c2ecf20Sopenharmony_cistatic OWL_GATE(clk_i2c1, "i2c1", "hosc", CMU_DEVCLKEN1, 1, 0, 0);
2048c2ecf20Sopenharmony_cistatic OWL_GATE(clk_i2c2, "i2c2", "hosc", CMU_DEVCLKEN1, 2, 0, 0);
2058c2ecf20Sopenharmony_cistatic OWL_GATE(clk_i2c3, "i2c3", "hosc", CMU_DEVCLKEN1, 3, 0, 0);
2068c2ecf20Sopenharmony_cistatic OWL_GATE(clk_spi0, "spi0", "ahb_clk", CMU_DEVCLKEN1, 4, 0, 0);
2078c2ecf20Sopenharmony_cistatic OWL_GATE(clk_spi1, "spi1", "ahb_clk", CMU_DEVCLKEN1, 5, 0, 0);
2088c2ecf20Sopenharmony_cistatic OWL_GATE(clk_spi2, "spi2", "ahb_clk", CMU_DEVCLKEN1, 6, 0, 0);
2098c2ecf20Sopenharmony_cistatic OWL_GATE(clk_spi3, "spi3", "ahb_clk", CMU_DEVCLKEN1, 7, 0, 0);
2108c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_usb2h0_pllen, "usbh0_pllen", CMU_USBPLL, 12, 0, 0);
2118c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_usb2h0_phy, "usbh0_phy", CMU_USBPLL, 10, 0, 0);
2128c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_usb2h0_cce, "usbh0_cce", CMU_DEVCLKEN0, 26, 0, 0);
2138c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_usb2h1_pllen, "usbh1_pllen", CMU_USBPLL, 13, 0, 0);
2148c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_usb2h1_phy, "usbh1_phy", CMU_USBPLL, 11, 0, 0);
2158c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_usb2h1_cce, "usbh1_cce", CMU_DEVCLKEN0, 27, 0, 0);
2168c2ecf20Sopenharmony_cistatic OWL_GATE_NO_PARENT(clk_irc_switch, "irc_switch", CMU_DEVCLKEN1, 15, 0, 0);
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci/* composite clocks */
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_csi, "csi", csi_clk_mux_p,
2218c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_CSICLK, 4, 1),
2228c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 13, 0),
2238c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_CSICLK, 0, 4, 0, NULL),
2248c2ecf20Sopenharmony_ci			0);
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_si, "si", csi_clk_mux_p,
2278c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_SICLK, 4, 1),
2288c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 14,  0),
2298c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_SICLK, 0, 4, 0, NULL),
2308c2ecf20Sopenharmony_ci			0);
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(clk_de, "de", de_clk_mux_p,
2338c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_DECLK, 12, 1),
2348c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 0,  0),
2358c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_DECLK, 0, 3, 0, de_factor_table),
2368c2ecf20Sopenharmony_ci			0);
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(clk_hde, "hde", hde_clk_mux_p,
2398c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_HDECLK, 4, 2),
2408c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 9, 0),
2418c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_HDECLK, 0, 3, 0, hde_factor_table),
2428c2ecf20Sopenharmony_ci			0);
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(clk_vde, "vde", hde_clk_mux_p,
2458c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_VDECLK, 4, 2),
2468c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 10,  0),
2478c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_VDECLK, 0, 3, 0, hde_factor_table),
2488c2ecf20Sopenharmony_ci			0);
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(clk_vce, "vce", hde_clk_mux_p,
2518c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_VCECLK, 4, 2),
2528c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 11, 0),
2538c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_VCECLK, 0, 3, 0, hde_factor_table),
2548c2ecf20Sopenharmony_ci			0);
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_nand, "nand", nand_clk_mux_p,
2578c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_NANDCCLK, 8, 2),
2588c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 21, 0),
2598c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_NANDCCLK, 0, 3, 0, NULL),
2608c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT);
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(clk_sd0, "sd0", sd_clk_mux_p,
2638c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_SD0CLK, 9, 1),
2648c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 22, 0),
2658c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_SD0CLK, 0, 9, 0, sd_factor_table),
2668c2ecf20Sopenharmony_ci			0);
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(clk_sd1, "sd1", sd_clk_mux_p,
2698c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_SD1CLK, 9, 1),
2708c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 23, 0),
2718c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_SD1CLK, 0, 9, 0, sd_factor_table),
2728c2ecf20Sopenharmony_ci			0);
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(clk_sd2, "sd2", sd_clk_mux_p,
2758c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_SD2CLK, 9, 1),
2768c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 24, 0),
2778c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_SD2CLK, 0, 9, 0, sd_factor_table),
2788c2ecf20Sopenharmony_ci			0);
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_uart0, "uart0", uart_clk_mux_p,
2818c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART0CLK, 16, 1),
2828c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 8, 0),
2838c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART0CLK, 0, 9, CLK_DIVIDER_ROUND_CLOSEST, NULL),
2848c2ecf20Sopenharmony_ci			0);
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_uart1, "uart1", uart_clk_mux_p,
2878c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART1CLK, 16, 1),
2888c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 9, 0),
2898c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART1CLK, 0, 9, CLK_DIVIDER_ROUND_CLOSEST, NULL),
2908c2ecf20Sopenharmony_ci			0);
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_uart2, "uart2", uart_clk_mux_p,
2938c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART2CLK, 16, 1),
2948c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 10, 0),
2958c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART2CLK, 0, 9,  CLK_DIVIDER_ROUND_CLOSEST, NULL),
2968c2ecf20Sopenharmony_ci			0);
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_uart3, "uart3", uart_clk_mux_p,
2998c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART3CLK, 16, 1),
3008c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 11, 0),
3018c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART3CLK, 0, 9,  CLK_DIVIDER_ROUND_CLOSEST, NULL),
3028c2ecf20Sopenharmony_ci			0);
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_uart4, "uart4", uart_clk_mux_p,
3058c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART4CLK, 16, 1),
3068c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 12, 0),
3078c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART4CLK, 0, 9,  CLK_DIVIDER_ROUND_CLOSEST, NULL),
3088c2ecf20Sopenharmony_ci			0);
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_uart5, "uart5", uart_clk_mux_p,
3118c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART5CLK, 16, 1),
3128c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 13, 0),
3138c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART5CLK, 0, 9,  CLK_DIVIDER_ROUND_CLOSEST, NULL),
3148c2ecf20Sopenharmony_ci			0);
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_uart6, "uart6", uart_clk_mux_p,
3178c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_UART6CLK, 16, 1),
3188c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 14, 0),
3198c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_UART6CLK, 0, 9,  CLK_DIVIDER_ROUND_CLOSEST, NULL),
3208c2ecf20Sopenharmony_ci			0);
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_pwm0, "pwm0", pwm_clk_mux_p,
3238c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_PWM0CLK, 12, 1),
3248c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 16, 0),
3258c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_PWM0CLK, 0, 10, 0, NULL),
3268c2ecf20Sopenharmony_ci			CLK_IGNORE_UNUSED);
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_pwm1, "pwm1", pwm_clk_mux_p,
3298c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_PWM1CLK, 12, 1),
3308c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 17, 0),
3318c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_PWM1CLK, 0, 10, 0, NULL),
3328c2ecf20Sopenharmony_ci			0);
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_pwm2, "pwm2", pwm_clk_mux_p,
3358c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_PWM2CLK, 12, 1),
3368c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 18, 0),
3378c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_PWM2CLK, 0, 10, 0, NULL),
3388c2ecf20Sopenharmony_ci			0);
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_pwm3, "pwm3", pwm_clk_mux_p,
3418c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_PWM3CLK, 12, 1),
3428c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 19, 0),
3438c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_PWM3CLK, 0, 10, 0, NULL),
3448c2ecf20Sopenharmony_ci			0);
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_pwm4, "pwm4", pwm_clk_mux_p,
3478c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_PWM4CLK, 12, 1),
3488c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 20, 0),
3498c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_PWM4CLK, 0, 10, 0, NULL),
3508c2ecf20Sopenharmony_ci			0);
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_pwm5, "pwm5", pwm_clk_mux_p,
3538c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_PWM5CLK, 12, 1),
3548c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 21, 0),
3558c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_PWM5CLK, 0, 10, 0, NULL),
3568c2ecf20Sopenharmony_ci			0);
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(clk_gpu3d, "gpu3d", gpu_clk_mux_p,
3598c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_GPU3DCLK, 4, 3),
3608c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 8, 0),
3618c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_GPU3DCLK, 0, 3, 0, hde_factor_table),
3628c2ecf20Sopenharmony_ci			0);
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_cistatic OWL_COMP_FACTOR(clk_lcd, "lcd", lcd_clk_mux_p,
3658c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_LCDCLK, 12, 2),
3668c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN0, 1, 0),
3678c2ecf20Sopenharmony_ci			OWL_FACTOR_HW(CMU_LCDCLK, 0, 9, 0, lcd_factor_table),
3688c2ecf20Sopenharmony_ci			0);
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_hdmi_audio, "hdmia", i2s_clk_mux_p,
3718c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_AUDIOPLL, 24, 1), /*CMU_AUDIOPLL 24,1 unused*/
3728c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 28, 0),
3738c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_AUDIOPLL, 24, 4, 0, hdmia_div_table),
3748c2ecf20Sopenharmony_ci			0);
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_i2srx, "i2srx", i2s_clk_mux_p,
3778c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_AUDIOPLL, 24, 1),
3788c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 27, 0),
3798c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_AUDIOPLL, 20, 4, 0, hdmia_div_table),
3808c2ecf20Sopenharmony_ci			0);
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_i2stx, "i2stx", i2s_clk_mux_p,
3838c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_AUDIOPLL, 24, 1),
3848c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 26, 0),
3858c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_AUDIOPLL, 16, 4, 0, hdmia_div_table),
3868c2ecf20Sopenharmony_ci			0);
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_ci/* for bluetooth pcm communication */
3898c2ecf20Sopenharmony_cistatic OWL_COMP_FIXED_FACTOR(clk_pcm1, "pcm1", "audio_pll",
3908c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 31, 0),
3918c2ecf20Sopenharmony_ci			1, 2, 0);
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_cistatic OWL_COMP_DIV(clk_sensor_src, "sensor_src", sensor_clk_mux_p,
3948c2ecf20Sopenharmony_ci			OWL_MUX_HW(CMU_SENSORCLK, 4, 1),
3958c2ecf20Sopenharmony_ci			{0},
3968c2ecf20Sopenharmony_ci			OWL_DIVIDER_HW(CMU_SENSORCLK, 5, 2, 0, NULL),
3978c2ecf20Sopenharmony_ci			0);
3988c2ecf20Sopenharmony_ci
3998c2ecf20Sopenharmony_cistatic OWL_COMP_FIXED_FACTOR(clk_ethernet, "ethernet", "ethernet_pll",
4008c2ecf20Sopenharmony_ci			OWL_GATE_HW(CMU_DEVCLKEN1, 23, 0),
4018c2ecf20Sopenharmony_ci			1, 20, 0);
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_cistatic OWL_COMP_DIV_FIXED(clk_thermal_sensor, "thermal_sensor", "hosc",
4048c2ecf20Sopenharmony_ci				OWL_GATE_HW(CMU_DEVCLKEN0, 31, 0),
4058c2ecf20Sopenharmony_ci				OWL_DIVIDER_HW(CMU_SSTSCLK, 20, 10, 0, NULL),
4068c2ecf20Sopenharmony_ci				0);
4078c2ecf20Sopenharmony_ci
4088c2ecf20Sopenharmony_cistatic struct owl_clk_common *s700_clks[] = {
4098c2ecf20Sopenharmony_ci	&clk_core_pll.common,
4108c2ecf20Sopenharmony_ci	&clk_dev_pll.common,
4118c2ecf20Sopenharmony_ci	&clk_ddr_pll.common,
4128c2ecf20Sopenharmony_ci	&clk_nand_pll.common,
4138c2ecf20Sopenharmony_ci	&clk_display_pll.common,
4148c2ecf20Sopenharmony_ci	&clk_cvbs_pll .common,
4158c2ecf20Sopenharmony_ci	&clk_audio_pll.common,
4168c2ecf20Sopenharmony_ci	&clk_ethernet_pll.common,
4178c2ecf20Sopenharmony_ci	&clk_cpu.common,
4188c2ecf20Sopenharmony_ci	&clk_dev.common,
4198c2ecf20Sopenharmony_ci	&clk_ahb.common,
4208c2ecf20Sopenharmony_ci	&clk_apb.common,
4218c2ecf20Sopenharmony_ci	&clk_dmac.common,
4228c2ecf20Sopenharmony_ci	&clk_noc0_clk_mux.common,
4238c2ecf20Sopenharmony_ci	&clk_noc1_clk_mux.common,
4248c2ecf20Sopenharmony_ci	&clk_hp_clk_mux.common,
4258c2ecf20Sopenharmony_ci	&clk_hp_clk_div.common,
4268c2ecf20Sopenharmony_ci	&clk_noc1_clk_div.common,
4278c2ecf20Sopenharmony_ci	&clk_noc0.common,
4288c2ecf20Sopenharmony_ci	&clk_noc1.common,
4298c2ecf20Sopenharmony_ci	&clk_sensor_src.common,
4308c2ecf20Sopenharmony_ci	&clk_gpio.common,
4318c2ecf20Sopenharmony_ci	&clk_timer.common,
4328c2ecf20Sopenharmony_ci	&clk_dsi.common,
4338c2ecf20Sopenharmony_ci	&clk_csi.common,
4348c2ecf20Sopenharmony_ci	&clk_si.common,
4358c2ecf20Sopenharmony_ci	&clk_de.common,
4368c2ecf20Sopenharmony_ci	&clk_hde.common,
4378c2ecf20Sopenharmony_ci	&clk_vde.common,
4388c2ecf20Sopenharmony_ci	&clk_vce.common,
4398c2ecf20Sopenharmony_ci	&clk_nand.common,
4408c2ecf20Sopenharmony_ci	&clk_sd0.common,
4418c2ecf20Sopenharmony_ci	&clk_sd1.common,
4428c2ecf20Sopenharmony_ci	&clk_sd2.common,
4438c2ecf20Sopenharmony_ci	&clk_uart0.common,
4448c2ecf20Sopenharmony_ci	&clk_uart1.common,
4458c2ecf20Sopenharmony_ci	&clk_uart2.common,
4468c2ecf20Sopenharmony_ci	&clk_uart3.common,
4478c2ecf20Sopenharmony_ci	&clk_uart4.common,
4488c2ecf20Sopenharmony_ci	&clk_uart5.common,
4498c2ecf20Sopenharmony_ci	&clk_uart6.common,
4508c2ecf20Sopenharmony_ci	&clk_pwm0.common,
4518c2ecf20Sopenharmony_ci	&clk_pwm1.common,
4528c2ecf20Sopenharmony_ci	&clk_pwm2.common,
4538c2ecf20Sopenharmony_ci	&clk_pwm3.common,
4548c2ecf20Sopenharmony_ci	&clk_pwm4.common,
4558c2ecf20Sopenharmony_ci	&clk_pwm5.common,
4568c2ecf20Sopenharmony_ci	&clk_gpu3d.common,
4578c2ecf20Sopenharmony_ci	&clk_i2c0.common,
4588c2ecf20Sopenharmony_ci	&clk_i2c1.common,
4598c2ecf20Sopenharmony_ci	&clk_i2c2.common,
4608c2ecf20Sopenharmony_ci	&clk_i2c3.common,
4618c2ecf20Sopenharmony_ci	&clk_spi0.common,
4628c2ecf20Sopenharmony_ci	&clk_spi1.common,
4638c2ecf20Sopenharmony_ci	&clk_spi2.common,
4648c2ecf20Sopenharmony_ci	&clk_spi3.common,
4658c2ecf20Sopenharmony_ci	&clk_usb3_480mpll0.common,
4668c2ecf20Sopenharmony_ci	&clk_usb3_480mphy0.common,
4678c2ecf20Sopenharmony_ci	&clk_usb3_5gphy.common,
4688c2ecf20Sopenharmony_ci	&clk_usb3_cce.common,
4698c2ecf20Sopenharmony_ci	&clk_lcd.common,
4708c2ecf20Sopenharmony_ci	&clk_hdmi_audio.common,
4718c2ecf20Sopenharmony_ci	&clk_i2srx.common,
4728c2ecf20Sopenharmony_ci	&clk_i2stx.common,
4738c2ecf20Sopenharmony_ci	&clk_sensor0.common,
4748c2ecf20Sopenharmony_ci	&clk_sensor1.common,
4758c2ecf20Sopenharmony_ci	&clk_hdmi_dev.common,
4768c2ecf20Sopenharmony_ci	&clk_ethernet.common,
4778c2ecf20Sopenharmony_ci	&clk_rmii_ref.common,
4788c2ecf20Sopenharmony_ci	&clk_usb2h0_pllen.common,
4798c2ecf20Sopenharmony_ci	&clk_usb2h0_phy.common,
4808c2ecf20Sopenharmony_ci	&clk_usb2h0_cce.common,
4818c2ecf20Sopenharmony_ci	&clk_usb2h1_pllen.common,
4828c2ecf20Sopenharmony_ci	&clk_usb2h1_phy.common,
4838c2ecf20Sopenharmony_ci	&clk_usb2h1_cce.common,
4848c2ecf20Sopenharmony_ci	&clk_tvout.common,
4858c2ecf20Sopenharmony_ci	&clk_thermal_sensor.common,
4868c2ecf20Sopenharmony_ci	&clk_irc_switch.common,
4878c2ecf20Sopenharmony_ci	&clk_pcm1.common,
4888c2ecf20Sopenharmony_ci};
4898c2ecf20Sopenharmony_ci
4908c2ecf20Sopenharmony_cistatic struct clk_hw_onecell_data s700_hw_clks = {
4918c2ecf20Sopenharmony_ci	.hws    = {
4928c2ecf20Sopenharmony_ci			[CLK_CORE_PLL]				= &clk_core_pll.common.hw,
4938c2ecf20Sopenharmony_ci			[CLK_DEV_PLL]				= &clk_dev_pll.common.hw,
4948c2ecf20Sopenharmony_ci			[CLK_DDR_PLL]				= &clk_ddr_pll.common.hw,
4958c2ecf20Sopenharmony_ci			[CLK_NAND_PLL]				= &clk_nand_pll.common.hw,
4968c2ecf20Sopenharmony_ci			[CLK_DISPLAY_PLL]			= &clk_display_pll.common.hw,
4978c2ecf20Sopenharmony_ci			[CLK_CVBS_PLL]				= &clk_cvbs_pll .common.hw,
4988c2ecf20Sopenharmony_ci			[CLK_AUDIO_PLL]				= &clk_audio_pll.common.hw,
4998c2ecf20Sopenharmony_ci			[CLK_ETHERNET_PLL]			= &clk_ethernet_pll.common.hw,
5008c2ecf20Sopenharmony_ci			[CLK_CPU]				= &clk_cpu.common.hw,
5018c2ecf20Sopenharmony_ci			[CLK_DEV]				= &clk_dev.common.hw,
5028c2ecf20Sopenharmony_ci			[CLK_AHB]				= &clk_ahb.common.hw,
5038c2ecf20Sopenharmony_ci			[CLK_APB]				= &clk_apb.common.hw,
5048c2ecf20Sopenharmony_ci			[CLK_DMAC]				= &clk_dmac.common.hw,
5058c2ecf20Sopenharmony_ci			[CLK_NOC0_CLK_MUX]			= &clk_noc0_clk_mux.common.hw,
5068c2ecf20Sopenharmony_ci			[CLK_NOC1_CLK_MUX]			= &clk_noc1_clk_mux.common.hw,
5078c2ecf20Sopenharmony_ci			[CLK_HP_CLK_MUX]			= &clk_hp_clk_mux.common.hw,
5088c2ecf20Sopenharmony_ci			[CLK_HP_CLK_DIV]			= &clk_hp_clk_div.common.hw,
5098c2ecf20Sopenharmony_ci			[CLK_NOC1_CLK_DIV]			= &clk_noc1_clk_div.common.hw,
5108c2ecf20Sopenharmony_ci			[CLK_NOC0]				= &clk_noc0.common.hw,
5118c2ecf20Sopenharmony_ci			[CLK_NOC1]				= &clk_noc1.common.hw,
5128c2ecf20Sopenharmony_ci			[CLK_SENOR_SRC]				= &clk_sensor_src.common.hw,
5138c2ecf20Sopenharmony_ci			[CLK_GPIO]				= &clk_gpio.common.hw,
5148c2ecf20Sopenharmony_ci			[CLK_TIMER]				= &clk_timer.common.hw,
5158c2ecf20Sopenharmony_ci			[CLK_DSI]				= &clk_dsi.common.hw,
5168c2ecf20Sopenharmony_ci			[CLK_CSI]				= &clk_csi.common.hw,
5178c2ecf20Sopenharmony_ci			[CLK_SI]				= &clk_si.common.hw,
5188c2ecf20Sopenharmony_ci			[CLK_DE]				= &clk_de.common.hw,
5198c2ecf20Sopenharmony_ci			[CLK_HDE]				= &clk_hde.common.hw,
5208c2ecf20Sopenharmony_ci			[CLK_VDE]				= &clk_vde.common.hw,
5218c2ecf20Sopenharmony_ci			[CLK_VCE]				= &clk_vce.common.hw,
5228c2ecf20Sopenharmony_ci			[CLK_NAND]				= &clk_nand.common.hw,
5238c2ecf20Sopenharmony_ci			[CLK_SD0]				= &clk_sd0.common.hw,
5248c2ecf20Sopenharmony_ci			[CLK_SD1]				= &clk_sd1.common.hw,
5258c2ecf20Sopenharmony_ci			[CLK_SD2]				= &clk_sd2.common.hw,
5268c2ecf20Sopenharmony_ci			[CLK_UART0]				= &clk_uart0.common.hw,
5278c2ecf20Sopenharmony_ci			[CLK_UART1]				= &clk_uart1.common.hw,
5288c2ecf20Sopenharmony_ci			[CLK_UART2]				= &clk_uart2.common.hw,
5298c2ecf20Sopenharmony_ci			[CLK_UART3]				= &clk_uart3.common.hw,
5308c2ecf20Sopenharmony_ci			[CLK_UART4]				= &clk_uart4.common.hw,
5318c2ecf20Sopenharmony_ci			[CLK_UART5]				= &clk_uart5.common.hw,
5328c2ecf20Sopenharmony_ci			[CLK_UART6]				= &clk_uart6.common.hw,
5338c2ecf20Sopenharmony_ci			[CLK_PWM0]				= &clk_pwm0.common.hw,
5348c2ecf20Sopenharmony_ci			[CLK_PWM1]				= &clk_pwm1.common.hw,
5358c2ecf20Sopenharmony_ci			[CLK_PWM2]				= &clk_pwm2.common.hw,
5368c2ecf20Sopenharmony_ci			[CLK_PWM3]				= &clk_pwm3.common.hw,
5378c2ecf20Sopenharmony_ci			[CLK_PWM4]				= &clk_pwm4.common.hw,
5388c2ecf20Sopenharmony_ci			[CLK_PWM5]				= &clk_pwm5.common.hw,
5398c2ecf20Sopenharmony_ci			[CLK_GPU3D]				= &clk_gpu3d.common.hw,
5408c2ecf20Sopenharmony_ci			[CLK_I2C0]				= &clk_i2c0.common.hw,
5418c2ecf20Sopenharmony_ci			[CLK_I2C1]				= &clk_i2c1.common.hw,
5428c2ecf20Sopenharmony_ci			[CLK_I2C2]				= &clk_i2c2.common.hw,
5438c2ecf20Sopenharmony_ci			[CLK_I2C3]				= &clk_i2c3.common.hw,
5448c2ecf20Sopenharmony_ci			[CLK_SPI0]				= &clk_spi0.common.hw,
5458c2ecf20Sopenharmony_ci			[CLK_SPI1]				= &clk_spi1.common.hw,
5468c2ecf20Sopenharmony_ci			[CLK_SPI2]				= &clk_spi2.common.hw,
5478c2ecf20Sopenharmony_ci			[CLK_SPI3]				= &clk_spi3.common.hw,
5488c2ecf20Sopenharmony_ci			[CLK_USB3_480MPLL0]			= &clk_usb3_480mpll0.common.hw,
5498c2ecf20Sopenharmony_ci			[CLK_USB3_480MPHY0]			= &clk_usb3_480mphy0.common.hw,
5508c2ecf20Sopenharmony_ci			[CLK_USB3_5GPHY]			= &clk_usb3_5gphy.common.hw,
5518c2ecf20Sopenharmony_ci			[CLK_USB3_CCE]				= &clk_usb3_cce.common.hw,
5528c2ecf20Sopenharmony_ci			[CLK_LCD]				= &clk_lcd.common.hw,
5538c2ecf20Sopenharmony_ci			[CLK_HDMI_AUDIO]			= &clk_hdmi_audio.common.hw,
5548c2ecf20Sopenharmony_ci			[CLK_I2SRX]				= &clk_i2srx.common.hw,
5558c2ecf20Sopenharmony_ci			[CLK_I2STX]				= &clk_i2stx.common.hw,
5568c2ecf20Sopenharmony_ci			[CLK_SENSOR0]				= &clk_sensor0.common.hw,
5578c2ecf20Sopenharmony_ci			[CLK_SENSOR1]				= &clk_sensor1.common.hw,
5588c2ecf20Sopenharmony_ci			[CLK_HDMI_DEV]				= &clk_hdmi_dev.common.hw,
5598c2ecf20Sopenharmony_ci			[CLK_ETHERNET]				= &clk_ethernet.common.hw,
5608c2ecf20Sopenharmony_ci			[CLK_RMII_REF]				= &clk_rmii_ref.common.hw,
5618c2ecf20Sopenharmony_ci			[CLK_USB2H0_PLLEN]			= &clk_usb2h0_pllen.common.hw,
5628c2ecf20Sopenharmony_ci			[CLK_USB2H0_PHY]			= &clk_usb2h0_phy.common.hw,
5638c2ecf20Sopenharmony_ci			[CLK_USB2H0_CCE]			= &clk_usb2h0_cce.common.hw,
5648c2ecf20Sopenharmony_ci			[CLK_USB2H1_PLLEN]			= &clk_usb2h1_pllen.common.hw,
5658c2ecf20Sopenharmony_ci			[CLK_USB2H1_PHY]			= &clk_usb2h1_phy.common.hw,
5668c2ecf20Sopenharmony_ci			[CLK_USB2H1_CCE]			= &clk_usb2h1_cce.common.hw,
5678c2ecf20Sopenharmony_ci			[CLK_TVOUT]				= &clk_tvout.common.hw,
5688c2ecf20Sopenharmony_ci			[CLK_THERMAL_SENSOR]			= &clk_thermal_sensor.common.hw,
5698c2ecf20Sopenharmony_ci			[CLK_IRC_SWITCH]			= &clk_irc_switch.common.hw,
5708c2ecf20Sopenharmony_ci			[CLK_PCM1]				= &clk_pcm1.common.hw,
5718c2ecf20Sopenharmony_ci		},
5728c2ecf20Sopenharmony_ci		.num    = CLK_NR_CLKS,
5738c2ecf20Sopenharmony_ci};
5748c2ecf20Sopenharmony_ci
5758c2ecf20Sopenharmony_cistatic const struct owl_reset_map s700_resets[] = {
5768c2ecf20Sopenharmony_ci	[RESET_DE]	= { CMU_DEVRST0, BIT(0) },
5778c2ecf20Sopenharmony_ci	[RESET_LCD0]	= { CMU_DEVRST0, BIT(1) },
5788c2ecf20Sopenharmony_ci	[RESET_DSI]	= { CMU_DEVRST0, BIT(2) },
5798c2ecf20Sopenharmony_ci	[RESET_CSI]	= { CMU_DEVRST0, BIT(13) },
5808c2ecf20Sopenharmony_ci	[RESET_SI]	= { CMU_DEVRST0, BIT(14) },
5818c2ecf20Sopenharmony_ci	[RESET_I2C0]	= { CMU_DEVRST1, BIT(0) },
5828c2ecf20Sopenharmony_ci	[RESET_I2C1]	= { CMU_DEVRST1, BIT(1) },
5838c2ecf20Sopenharmony_ci	[RESET_I2C2]	= { CMU_DEVRST1, BIT(2) },
5848c2ecf20Sopenharmony_ci	[RESET_I2C3]	= { CMU_DEVRST1, BIT(3) },
5858c2ecf20Sopenharmony_ci	[RESET_SPI0]	= { CMU_DEVRST1, BIT(4) },
5868c2ecf20Sopenharmony_ci	[RESET_SPI1]	= { CMU_DEVRST1, BIT(5) },
5878c2ecf20Sopenharmony_ci	[RESET_SPI2]	= { CMU_DEVRST1, BIT(6) },
5888c2ecf20Sopenharmony_ci	[RESET_SPI3]	= { CMU_DEVRST1, BIT(7) },
5898c2ecf20Sopenharmony_ci	[RESET_UART0]	= { CMU_DEVRST1, BIT(8) },
5908c2ecf20Sopenharmony_ci	[RESET_UART1]	= { CMU_DEVRST1, BIT(9) },
5918c2ecf20Sopenharmony_ci	[RESET_UART2]	= { CMU_DEVRST1, BIT(10) },
5928c2ecf20Sopenharmony_ci	[RESET_UART3]	= { CMU_DEVRST1, BIT(11) },
5938c2ecf20Sopenharmony_ci	[RESET_UART4]	= { CMU_DEVRST1, BIT(12) },
5948c2ecf20Sopenharmony_ci	[RESET_UART5]	= { CMU_DEVRST1, BIT(13) },
5958c2ecf20Sopenharmony_ci	[RESET_UART6]	= { CMU_DEVRST1, BIT(14) },
5968c2ecf20Sopenharmony_ci	[RESET_KEY]	= { CMU_DEVRST1, BIT(24) },
5978c2ecf20Sopenharmony_ci	[RESET_GPIO]	= { CMU_DEVRST1, BIT(25) },
5988c2ecf20Sopenharmony_ci	[RESET_AUDIO]	= { CMU_DEVRST1, BIT(29) },
5998c2ecf20Sopenharmony_ci};
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_cistatic struct owl_clk_desc s700_clk_desc = {
6028c2ecf20Sopenharmony_ci	.clks       = s700_clks,
6038c2ecf20Sopenharmony_ci	.num_clks   = ARRAY_SIZE(s700_clks),
6048c2ecf20Sopenharmony_ci
6058c2ecf20Sopenharmony_ci	.hw_clks    = &s700_hw_clks,
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci	.resets     = s700_resets,
6088c2ecf20Sopenharmony_ci	.num_resets = ARRAY_SIZE(s700_resets),
6098c2ecf20Sopenharmony_ci};
6108c2ecf20Sopenharmony_ci
6118c2ecf20Sopenharmony_cistatic int s700_clk_probe(struct platform_device *pdev)
6128c2ecf20Sopenharmony_ci{
6138c2ecf20Sopenharmony_ci	struct owl_clk_desc *desc;
6148c2ecf20Sopenharmony_ci	struct owl_reset *reset;
6158c2ecf20Sopenharmony_ci	int ret;
6168c2ecf20Sopenharmony_ci
6178c2ecf20Sopenharmony_ci	desc = &s700_clk_desc;
6188c2ecf20Sopenharmony_ci	owl_clk_regmap_init(pdev, desc);
6198c2ecf20Sopenharmony_ci
6208c2ecf20Sopenharmony_ci	/*
6218c2ecf20Sopenharmony_ci	 * FIXME: Reset controller registration should be moved to
6228c2ecf20Sopenharmony_ci	 * common code, once all SoCs of Owl family supports it.
6238c2ecf20Sopenharmony_ci	 */
6248c2ecf20Sopenharmony_ci	reset = devm_kzalloc(&pdev->dev, sizeof(*reset), GFP_KERNEL);
6258c2ecf20Sopenharmony_ci	if (!reset)
6268c2ecf20Sopenharmony_ci		return -ENOMEM;
6278c2ecf20Sopenharmony_ci
6288c2ecf20Sopenharmony_ci	reset->rcdev.of_node = pdev->dev.of_node;
6298c2ecf20Sopenharmony_ci	reset->rcdev.ops = &owl_reset_ops;
6308c2ecf20Sopenharmony_ci	reset->rcdev.nr_resets = desc->num_resets;
6318c2ecf20Sopenharmony_ci	reset->reset_map = desc->resets;
6328c2ecf20Sopenharmony_ci	reset->regmap = desc->regmap;
6338c2ecf20Sopenharmony_ci
6348c2ecf20Sopenharmony_ci	ret = devm_reset_controller_register(&pdev->dev, &reset->rcdev);
6358c2ecf20Sopenharmony_ci	if (ret)
6368c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "Failed to register reset controller\n");
6378c2ecf20Sopenharmony_ci
6388c2ecf20Sopenharmony_ci	return owl_clk_probe(&pdev->dev, desc->hw_clks);
6398c2ecf20Sopenharmony_ci}
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_cistatic const struct of_device_id s700_clk_of_match[] = {
6428c2ecf20Sopenharmony_ci	{ .compatible = "actions,s700-cmu", },
6438c2ecf20Sopenharmony_ci	{ /* sentinel */ }
6448c2ecf20Sopenharmony_ci};
6458c2ecf20Sopenharmony_ci
6468c2ecf20Sopenharmony_cistatic struct platform_driver s700_clk_driver = {
6478c2ecf20Sopenharmony_ci	.probe = s700_clk_probe,
6488c2ecf20Sopenharmony_ci	.driver = {
6498c2ecf20Sopenharmony_ci		.name = "s700-cmu",
6508c2ecf20Sopenharmony_ci		.of_match_table = s700_clk_of_match
6518c2ecf20Sopenharmony_ci	},
6528c2ecf20Sopenharmony_ci};
6538c2ecf20Sopenharmony_ci
6548c2ecf20Sopenharmony_cistatic int __init s700_clk_init(void)
6558c2ecf20Sopenharmony_ci{
6568c2ecf20Sopenharmony_ci	return platform_driver_register(&s700_clk_driver);
6578c2ecf20Sopenharmony_ci}
6588c2ecf20Sopenharmony_cicore_initcall(s700_clk_init);
659