18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * SPEAr6xx machines clock framework source file
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 2012 ST Microelectronics
58c2ecf20Sopenharmony_ci * Viresh Kumar <vireshk@kernel.org>
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public
88c2ecf20Sopenharmony_ci * License version 2. This program is licensed "as is" without any
98c2ecf20Sopenharmony_ci * warranty of any kind, whether express or implied.
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/clkdev.h>
138c2ecf20Sopenharmony_ci#include <linux/io.h>
148c2ecf20Sopenharmony_ci#include <linux/spinlock_types.h>
158c2ecf20Sopenharmony_ci#include "clk.h"
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(_lock);
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define PLL1_CTR			(misc_base + 0x008)
208c2ecf20Sopenharmony_ci#define PLL1_FRQ			(misc_base + 0x00C)
218c2ecf20Sopenharmony_ci#define PLL2_CTR			(misc_base + 0x014)
228c2ecf20Sopenharmony_ci#define PLL2_FRQ			(misc_base + 0x018)
238c2ecf20Sopenharmony_ci#define PLL_CLK_CFG			(misc_base + 0x020)
248c2ecf20Sopenharmony_ci	/* PLL_CLK_CFG register masks */
258c2ecf20Sopenharmony_ci	#define MCTR_CLK_SHIFT		28
268c2ecf20Sopenharmony_ci	#define MCTR_CLK_MASK		3
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define CORE_CLK_CFG			(misc_base + 0x024)
298c2ecf20Sopenharmony_ci	/* CORE CLK CFG register masks */
308c2ecf20Sopenharmony_ci	#define HCLK_RATIO_SHIFT	10
318c2ecf20Sopenharmony_ci	#define HCLK_RATIO_MASK		2
328c2ecf20Sopenharmony_ci	#define PCLK_RATIO_SHIFT	8
338c2ecf20Sopenharmony_ci	#define PCLK_RATIO_MASK		2
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define PERIP_CLK_CFG			(misc_base + 0x028)
368c2ecf20Sopenharmony_ci	/* PERIP_CLK_CFG register masks */
378c2ecf20Sopenharmony_ci	#define CLCD_CLK_SHIFT		2
388c2ecf20Sopenharmony_ci	#define CLCD_CLK_MASK		2
398c2ecf20Sopenharmony_ci	#define UART_CLK_SHIFT		4
408c2ecf20Sopenharmony_ci	#define UART_CLK_MASK		1
418c2ecf20Sopenharmony_ci	#define FIRDA_CLK_SHIFT		5
428c2ecf20Sopenharmony_ci	#define FIRDA_CLK_MASK		2
438c2ecf20Sopenharmony_ci	#define GPT0_CLK_SHIFT		8
448c2ecf20Sopenharmony_ci	#define GPT1_CLK_SHIFT		10
458c2ecf20Sopenharmony_ci	#define GPT2_CLK_SHIFT		11
468c2ecf20Sopenharmony_ci	#define GPT3_CLK_SHIFT		12
478c2ecf20Sopenharmony_ci	#define GPT_CLK_MASK		1
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#define PERIP1_CLK_ENB			(misc_base + 0x02C)
508c2ecf20Sopenharmony_ci	/* PERIP1_CLK_ENB register masks */
518c2ecf20Sopenharmony_ci	#define UART0_CLK_ENB		3
528c2ecf20Sopenharmony_ci	#define UART1_CLK_ENB		4
538c2ecf20Sopenharmony_ci	#define SSP0_CLK_ENB		5
548c2ecf20Sopenharmony_ci	#define SSP1_CLK_ENB		6
558c2ecf20Sopenharmony_ci	#define I2C_CLK_ENB		7
568c2ecf20Sopenharmony_ci	#define JPEG_CLK_ENB		8
578c2ecf20Sopenharmony_ci	#define FSMC_CLK_ENB		9
588c2ecf20Sopenharmony_ci	#define FIRDA_CLK_ENB		10
598c2ecf20Sopenharmony_ci	#define GPT2_CLK_ENB		11
608c2ecf20Sopenharmony_ci	#define GPT3_CLK_ENB		12
618c2ecf20Sopenharmony_ci	#define GPIO2_CLK_ENB		13
628c2ecf20Sopenharmony_ci	#define SSP2_CLK_ENB		14
638c2ecf20Sopenharmony_ci	#define ADC_CLK_ENB		15
648c2ecf20Sopenharmony_ci	#define GPT1_CLK_ENB		11
658c2ecf20Sopenharmony_ci	#define RTC_CLK_ENB		17
668c2ecf20Sopenharmony_ci	#define GPIO1_CLK_ENB		18
678c2ecf20Sopenharmony_ci	#define DMA_CLK_ENB		19
688c2ecf20Sopenharmony_ci	#define SMI_CLK_ENB		21
698c2ecf20Sopenharmony_ci	#define CLCD_CLK_ENB		22
708c2ecf20Sopenharmony_ci	#define GMAC_CLK_ENB		23
718c2ecf20Sopenharmony_ci	#define USBD_CLK_ENB		24
728c2ecf20Sopenharmony_ci	#define USBH0_CLK_ENB		25
738c2ecf20Sopenharmony_ci	#define USBH1_CLK_ENB		26
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#define PRSC0_CLK_CFG			(misc_base + 0x044)
768c2ecf20Sopenharmony_ci#define PRSC1_CLK_CFG			(misc_base + 0x048)
778c2ecf20Sopenharmony_ci#define PRSC2_CLK_CFG			(misc_base + 0x04C)
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#define CLCD_CLK_SYNT			(misc_base + 0x05C)
808c2ecf20Sopenharmony_ci#define FIRDA_CLK_SYNT			(misc_base + 0x060)
818c2ecf20Sopenharmony_ci#define UART_CLK_SYNT			(misc_base + 0x064)
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci/* vco rate configuration table, in ascending order of rates */
848c2ecf20Sopenharmony_cistatic struct pll_rate_tbl pll_rtbl[] = {
858c2ecf20Sopenharmony_ci	{.mode = 0, .m = 0x53, .n = 0x0F, .p = 0x1}, /* vco 332 & pll 166 MHz */
868c2ecf20Sopenharmony_ci	{.mode = 0, .m = 0x85, .n = 0x0F, .p = 0x1}, /* vco 532 & pll 266 MHz */
878c2ecf20Sopenharmony_ci	{.mode = 0, .m = 0xA6, .n = 0x0F, .p = 0x1}, /* vco 664 & pll 332 MHz */
888c2ecf20Sopenharmony_ci};
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci/* aux rate configuration table, in ascending order of rates */
918c2ecf20Sopenharmony_cistatic struct aux_rate_tbl aux_rtbl[] = {
928c2ecf20Sopenharmony_ci	/* For PLL1 = 332 MHz */
938c2ecf20Sopenharmony_ci	{.xscale = 2, .yscale = 27, .eq = 0}, /* 12.296 MHz */
948c2ecf20Sopenharmony_ci	{.xscale = 2, .yscale = 8, .eq = 0}, /* 41.5 MHz */
958c2ecf20Sopenharmony_ci	{.xscale = 2, .yscale = 4, .eq = 0}, /* 83 MHz */
968c2ecf20Sopenharmony_ci	{.xscale = 1, .yscale = 2, .eq = 1}, /* 166 MHz */
978c2ecf20Sopenharmony_ci};
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_cistatic const char *clcd_parents[] = { "pll3_clk", "clcd_syn_gclk", };
1008c2ecf20Sopenharmony_cistatic const char *firda_parents[] = { "pll3_clk", "firda_syn_gclk", };
1018c2ecf20Sopenharmony_cistatic const char *uart_parents[] = { "pll3_clk", "uart_syn_gclk", };
1028c2ecf20Sopenharmony_cistatic const char *gpt0_1_parents[] = { "pll3_clk", "gpt0_1_syn_clk", };
1038c2ecf20Sopenharmony_cistatic const char *gpt2_parents[] = { "pll3_clk", "gpt2_syn_clk", };
1048c2ecf20Sopenharmony_cistatic const char *gpt3_parents[] = { "pll3_clk", "gpt3_syn_clk", };
1058c2ecf20Sopenharmony_cistatic const char *ddr_parents[] = { "ahb_clk", "ahbmult2_clk", "none",
1068c2ecf20Sopenharmony_ci	"pll2_clk", };
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci/* gpt rate configuration table, in ascending order of rates */
1098c2ecf20Sopenharmony_cistatic struct gpt_rate_tbl gpt_rtbl[] = {
1108c2ecf20Sopenharmony_ci	/* For pll1 = 332 MHz */
1118c2ecf20Sopenharmony_ci	{.mscale = 4, .nscale = 0}, /* 41.5 MHz */
1128c2ecf20Sopenharmony_ci	{.mscale = 2, .nscale = 0}, /* 55.3 MHz */
1138c2ecf20Sopenharmony_ci	{.mscale = 1, .nscale = 0}, /* 83 MHz */
1148c2ecf20Sopenharmony_ci};
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_civoid __init spear6xx_clk_init(void __iomem *misc_base)
1178c2ecf20Sopenharmony_ci{
1188c2ecf20Sopenharmony_ci	struct clk *clk, *clk1;
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	clk = clk_register_fixed_rate(NULL, "osc_32k_clk", NULL, 0, 32000);
1218c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "osc_32k_clk", NULL);
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci	clk = clk_register_fixed_rate(NULL, "osc_30m_clk", NULL, 0, 30000000);
1248c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "osc_30m_clk", NULL);
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci	/* clock derived from 32 KHz osc clk */
1278c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "rtc_spear", "osc_32k_clk", 0,
1288c2ecf20Sopenharmony_ci			PERIP1_CLK_ENB, RTC_CLK_ENB, 0, &_lock);
1298c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "rtc-spear");
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci	/* clock derived from 30 MHz osc clk */
1328c2ecf20Sopenharmony_ci	clk = clk_register_fixed_rate(NULL, "pll3_clk", "osc_24m_clk", 0,
1338c2ecf20Sopenharmony_ci			48000000);
1348c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "pll3_clk", NULL);
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	clk = clk_register_vco_pll("vco1_clk", "pll1_clk", NULL, "osc_30m_clk",
1378c2ecf20Sopenharmony_ci			0, PLL1_CTR, PLL1_FRQ, pll_rtbl, ARRAY_SIZE(pll_rtbl),
1388c2ecf20Sopenharmony_ci			&_lock, &clk1, NULL);
1398c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "vco1_clk", NULL);
1408c2ecf20Sopenharmony_ci	clk_register_clkdev(clk1, "pll1_clk", NULL);
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci	clk = clk_register_vco_pll("vco2_clk", "pll2_clk", NULL, "osc_30m_clk",
1438c2ecf20Sopenharmony_ci			0, PLL2_CTR, PLL2_FRQ, pll_rtbl, ARRAY_SIZE(pll_rtbl),
1448c2ecf20Sopenharmony_ci			&_lock, &clk1, NULL);
1458c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "vco2_clk", NULL);
1468c2ecf20Sopenharmony_ci	clk_register_clkdev(clk1, "pll2_clk", NULL);
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "wdt_clk", "osc_30m_clk", 0, 1,
1498c2ecf20Sopenharmony_ci			1);
1508c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "fc880000.wdt");
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci	/* clock derived from pll1 clk */
1538c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "cpu_clk", "pll1_clk",
1548c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, 1, 1);
1558c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "cpu_clk", NULL);
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci	clk = clk_register_divider(NULL, "ahb_clk", "pll1_clk",
1588c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, CORE_CLK_CFG, HCLK_RATIO_SHIFT,
1598c2ecf20Sopenharmony_ci			HCLK_RATIO_MASK, 0, &_lock);
1608c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ahb_clk", NULL);
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci	clk = clk_register_aux("uart_syn_clk", "uart_syn_gclk", "pll1_clk", 0,
1638c2ecf20Sopenharmony_ci			UART_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
1648c2ecf20Sopenharmony_ci			&_lock, &clk1);
1658c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "uart_syn_clk", NULL);
1668c2ecf20Sopenharmony_ci	clk_register_clkdev(clk1, "uart_syn_gclk", NULL);
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "uart_mclk", uart_parents,
1698c2ecf20Sopenharmony_ci			ARRAY_SIZE(uart_parents), CLK_SET_RATE_NO_REPARENT,
1708c2ecf20Sopenharmony_ci			PERIP_CLK_CFG, UART_CLK_SHIFT, UART_CLK_MASK, 0,
1718c2ecf20Sopenharmony_ci			&_lock);
1728c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "uart_mclk", NULL);
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "uart0", "uart_mclk", 0, PERIP1_CLK_ENB,
1758c2ecf20Sopenharmony_ci			UART0_CLK_ENB, 0, &_lock);
1768c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "d0000000.serial");
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "uart1", "uart_mclk", 0, PERIP1_CLK_ENB,
1798c2ecf20Sopenharmony_ci			UART1_CLK_ENB, 0, &_lock);
1808c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "d0080000.serial");
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci	clk = clk_register_aux("firda_syn_clk", "firda_syn_gclk", "pll1_clk",
1838c2ecf20Sopenharmony_ci			0, FIRDA_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
1848c2ecf20Sopenharmony_ci			&_lock, &clk1);
1858c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "firda_syn_clk", NULL);
1868c2ecf20Sopenharmony_ci	clk_register_clkdev(clk1, "firda_syn_gclk", NULL);
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "firda_mclk", firda_parents,
1898c2ecf20Sopenharmony_ci			ARRAY_SIZE(firda_parents), CLK_SET_RATE_NO_REPARENT,
1908c2ecf20Sopenharmony_ci			PERIP_CLK_CFG, FIRDA_CLK_SHIFT, FIRDA_CLK_MASK, 0,
1918c2ecf20Sopenharmony_ci			&_lock);
1928c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "firda_mclk", NULL);
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "firda_clk", "firda_mclk", 0,
1958c2ecf20Sopenharmony_ci			PERIP1_CLK_ENB, FIRDA_CLK_ENB, 0, &_lock);
1968c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "firda");
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci	clk = clk_register_aux("clcd_syn_clk", "clcd_syn_gclk", "pll1_clk",
1998c2ecf20Sopenharmony_ci			0, CLCD_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
2008c2ecf20Sopenharmony_ci			&_lock, &clk1);
2018c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "clcd_syn_clk", NULL);
2028c2ecf20Sopenharmony_ci	clk_register_clkdev(clk1, "clcd_syn_gclk", NULL);
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "clcd_mclk", clcd_parents,
2058c2ecf20Sopenharmony_ci			ARRAY_SIZE(clcd_parents), CLK_SET_RATE_NO_REPARENT,
2068c2ecf20Sopenharmony_ci			PERIP_CLK_CFG, CLCD_CLK_SHIFT, CLCD_CLK_MASK, 0,
2078c2ecf20Sopenharmony_ci			&_lock);
2088c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "clcd_mclk", NULL);
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "clcd_clk", "clcd_mclk", 0,
2118c2ecf20Sopenharmony_ci			PERIP1_CLK_ENB, CLCD_CLK_ENB, 0, &_lock);
2128c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "clcd");
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci	/* gpt clocks */
2158c2ecf20Sopenharmony_ci	clk = clk_register_gpt("gpt0_1_syn_clk", "pll1_clk", 0, PRSC0_CLK_CFG,
2168c2ecf20Sopenharmony_ci			gpt_rtbl, ARRAY_SIZE(gpt_rtbl), &_lock);
2178c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "gpt0_1_syn_clk", NULL);
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "gpt0_mclk", gpt0_1_parents,
2208c2ecf20Sopenharmony_ci			ARRAY_SIZE(gpt0_1_parents), CLK_SET_RATE_NO_REPARENT,
2218c2ecf20Sopenharmony_ci			PERIP_CLK_CFG, GPT0_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
2228c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "gpt0");
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "gpt1_mclk", gpt0_1_parents,
2258c2ecf20Sopenharmony_ci			ARRAY_SIZE(gpt0_1_parents), CLK_SET_RATE_NO_REPARENT,
2268c2ecf20Sopenharmony_ci			PERIP_CLK_CFG, GPT1_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
2278c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "gpt1_mclk", NULL);
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "gpt1_clk", "gpt1_mclk", 0,
2308c2ecf20Sopenharmony_ci			PERIP1_CLK_ENB, GPT1_CLK_ENB, 0, &_lock);
2318c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "gpt1");
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci	clk = clk_register_gpt("gpt2_syn_clk", "pll1_clk", 0, PRSC1_CLK_CFG,
2348c2ecf20Sopenharmony_ci			gpt_rtbl, ARRAY_SIZE(gpt_rtbl), &_lock);
2358c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "gpt2_syn_clk", NULL);
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "gpt2_mclk", gpt2_parents,
2388c2ecf20Sopenharmony_ci			ARRAY_SIZE(gpt2_parents), CLK_SET_RATE_NO_REPARENT,
2398c2ecf20Sopenharmony_ci			PERIP_CLK_CFG, GPT2_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
2408c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "gpt2_mclk", NULL);
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "gpt2_clk", "gpt2_mclk", 0,
2438c2ecf20Sopenharmony_ci			PERIP1_CLK_ENB, GPT2_CLK_ENB, 0, &_lock);
2448c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "gpt2");
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci	clk = clk_register_gpt("gpt3_syn_clk", "pll1_clk", 0, PRSC2_CLK_CFG,
2478c2ecf20Sopenharmony_ci			gpt_rtbl, ARRAY_SIZE(gpt_rtbl), &_lock);
2488c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "gpt3_syn_clk", NULL);
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "gpt3_mclk", gpt3_parents,
2518c2ecf20Sopenharmony_ci			ARRAY_SIZE(gpt3_parents), CLK_SET_RATE_NO_REPARENT,
2528c2ecf20Sopenharmony_ci			PERIP_CLK_CFG, GPT3_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
2538c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "gpt3_mclk", NULL);
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "gpt3_clk", "gpt3_mclk", 0,
2568c2ecf20Sopenharmony_ci			PERIP1_CLK_ENB, GPT3_CLK_ENB, 0, &_lock);
2578c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "gpt3");
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	/* clock derived from pll3 clk */
2608c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "usbh0_clk", "pll3_clk", 0,
2618c2ecf20Sopenharmony_ci			PERIP1_CLK_ENB, USBH0_CLK_ENB, 0, &_lock);
2628c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "e1800000.ehci");
2638c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "e1900000.ohci");
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "usbh1_clk", "pll3_clk", 0,
2668c2ecf20Sopenharmony_ci			PERIP1_CLK_ENB, USBH1_CLK_ENB, 0, &_lock);
2678c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "e2000000.ehci");
2688c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "e2100000.ohci");
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "usbd_clk", "pll3_clk", 0, PERIP1_CLK_ENB,
2718c2ecf20Sopenharmony_ci			USBD_CLK_ENB, 0, &_lock);
2728c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "designware_udc");
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci	/* clock derived from ahb clk */
2758c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "ahbmult2_clk", "ahb_clk", 0, 2,
2768c2ecf20Sopenharmony_ci			1);
2778c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ahbmult2_clk", NULL);
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "ddr_clk", ddr_parents,
2808c2ecf20Sopenharmony_ci			ARRAY_SIZE(ddr_parents), CLK_SET_RATE_NO_REPARENT,
2818c2ecf20Sopenharmony_ci			PLL_CLK_CFG, MCTR_CLK_SHIFT, MCTR_CLK_MASK, 0, &_lock);
2828c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ddr_clk", NULL);
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci	clk = clk_register_divider(NULL, "apb_clk", "ahb_clk",
2858c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, CORE_CLK_CFG, PCLK_RATIO_SHIFT,
2868c2ecf20Sopenharmony_ci			PCLK_RATIO_MASK, 0, &_lock);
2878c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "apb_clk", NULL);
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "dma_clk", "ahb_clk", 0, PERIP1_CLK_ENB,
2908c2ecf20Sopenharmony_ci			DMA_CLK_ENB, 0, &_lock);
2918c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "fc400000.dma");
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "fsmc_clk", "ahb_clk", 0, PERIP1_CLK_ENB,
2948c2ecf20Sopenharmony_ci			FSMC_CLK_ENB, 0, &_lock);
2958c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "d1800000.flash");
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "gmac_clk", "ahb_clk", 0, PERIP1_CLK_ENB,
2988c2ecf20Sopenharmony_ci			GMAC_CLK_ENB, 0, &_lock);
2998c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "e0800000.ethernet");
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "i2c_clk", "ahb_clk", 0, PERIP1_CLK_ENB,
3028c2ecf20Sopenharmony_ci			I2C_CLK_ENB, 0, &_lock);
3038c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "d0200000.i2c");
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "jpeg_clk", "ahb_clk", 0, PERIP1_CLK_ENB,
3068c2ecf20Sopenharmony_ci			JPEG_CLK_ENB, 0, &_lock);
3078c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "jpeg");
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "smi_clk", "ahb_clk", 0, PERIP1_CLK_ENB,
3108c2ecf20Sopenharmony_ci			SMI_CLK_ENB, 0, &_lock);
3118c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "fc000000.flash");
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	/* clock derived from apb clk */
3148c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "adc_clk", "apb_clk", 0, PERIP1_CLK_ENB,
3158c2ecf20Sopenharmony_ci			ADC_CLK_ENB, 0, &_lock);
3168c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "d820b000.adc");
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "gpio0_clk", "apb_clk", 0, 1, 1);
3198c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "f0100000.gpio");
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "gpio1_clk", "apb_clk", 0, PERIP1_CLK_ENB,
3228c2ecf20Sopenharmony_ci			GPIO1_CLK_ENB, 0, &_lock);
3238c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "fc980000.gpio");
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "gpio2_clk", "apb_clk", 0, PERIP1_CLK_ENB,
3268c2ecf20Sopenharmony_ci			GPIO2_CLK_ENB, 0, &_lock);
3278c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "d8100000.gpio");
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ssp0_clk", "apb_clk", 0, PERIP1_CLK_ENB,
3308c2ecf20Sopenharmony_ci			SSP0_CLK_ENB, 0, &_lock);
3318c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "ssp-pl022.0");
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ssp1_clk", "apb_clk", 0, PERIP1_CLK_ENB,
3348c2ecf20Sopenharmony_ci			SSP1_CLK_ENB, 0, &_lock);
3358c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "ssp-pl022.1");
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ssp2_clk", "apb_clk", 0, PERIP1_CLK_ENB,
3388c2ecf20Sopenharmony_ci			SSP2_CLK_ENB, 0, &_lock);
3398c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "ssp-pl022.2");
3408c2ecf20Sopenharmony_ci}
341