18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * SPEAr3xx 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/clk.h>
138c2ecf20Sopenharmony_ci#include <linux/clkdev.h>
148c2ecf20Sopenharmony_ci#include <linux/err.h>
158c2ecf20Sopenharmony_ci#include <linux/io.h>
168c2ecf20Sopenharmony_ci#include <linux/of_platform.h>
178c2ecf20Sopenharmony_ci#include <linux/spinlock_types.h>
188c2ecf20Sopenharmony_ci#include "clk.h"
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(_lock);
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define PLL1_CTR			(misc_base + 0x008)
238c2ecf20Sopenharmony_ci#define PLL1_FRQ			(misc_base + 0x00C)
248c2ecf20Sopenharmony_ci#define PLL2_CTR			(misc_base + 0x014)
258c2ecf20Sopenharmony_ci#define PLL2_FRQ			(misc_base + 0x018)
268c2ecf20Sopenharmony_ci#define PLL_CLK_CFG			(misc_base + 0x020)
278c2ecf20Sopenharmony_ci	/* PLL_CLK_CFG register masks */
288c2ecf20Sopenharmony_ci	#define MCTR_CLK_SHIFT		28
298c2ecf20Sopenharmony_ci	#define MCTR_CLK_MASK		3
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define CORE_CLK_CFG			(misc_base + 0x024)
328c2ecf20Sopenharmony_ci	/* CORE CLK CFG register masks */
338c2ecf20Sopenharmony_ci	#define GEN_SYNTH2_3_CLK_SHIFT	18
348c2ecf20Sopenharmony_ci	#define GEN_SYNTH2_3_CLK_MASK	1
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci	#define HCLK_RATIO_SHIFT	10
378c2ecf20Sopenharmony_ci	#define HCLK_RATIO_MASK		2
388c2ecf20Sopenharmony_ci	#define PCLK_RATIO_SHIFT	8
398c2ecf20Sopenharmony_ci	#define PCLK_RATIO_MASK		2
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define PERIP_CLK_CFG			(misc_base + 0x028)
428c2ecf20Sopenharmony_ci	/* PERIP_CLK_CFG register masks */
438c2ecf20Sopenharmony_ci	#define UART_CLK_SHIFT		4
448c2ecf20Sopenharmony_ci	#define UART_CLK_MASK		1
458c2ecf20Sopenharmony_ci	#define FIRDA_CLK_SHIFT		5
468c2ecf20Sopenharmony_ci	#define FIRDA_CLK_MASK		2
478c2ecf20Sopenharmony_ci	#define GPT0_CLK_SHIFT		8
488c2ecf20Sopenharmony_ci	#define GPT1_CLK_SHIFT		11
498c2ecf20Sopenharmony_ci	#define GPT2_CLK_SHIFT		12
508c2ecf20Sopenharmony_ci	#define GPT_CLK_MASK		1
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define PERIP1_CLK_ENB			(misc_base + 0x02C)
538c2ecf20Sopenharmony_ci	/* PERIP1_CLK_ENB register masks */
548c2ecf20Sopenharmony_ci	#define UART_CLK_ENB		3
558c2ecf20Sopenharmony_ci	#define SSP_CLK_ENB		5
568c2ecf20Sopenharmony_ci	#define I2C_CLK_ENB		7
578c2ecf20Sopenharmony_ci	#define JPEG_CLK_ENB		8
588c2ecf20Sopenharmony_ci	#define FIRDA_CLK_ENB		10
598c2ecf20Sopenharmony_ci	#define GPT1_CLK_ENB		11
608c2ecf20Sopenharmony_ci	#define GPT2_CLK_ENB		12
618c2ecf20Sopenharmony_ci	#define ADC_CLK_ENB		15
628c2ecf20Sopenharmony_ci	#define RTC_CLK_ENB		17
638c2ecf20Sopenharmony_ci	#define GPIO_CLK_ENB		18
648c2ecf20Sopenharmony_ci	#define DMA_CLK_ENB		19
658c2ecf20Sopenharmony_ci	#define SMI_CLK_ENB		21
668c2ecf20Sopenharmony_ci	#define GMAC_CLK_ENB		23
678c2ecf20Sopenharmony_ci	#define USBD_CLK_ENB		24
688c2ecf20Sopenharmony_ci	#define USBH_CLK_ENB		25
698c2ecf20Sopenharmony_ci	#define C3_CLK_ENB		31
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define RAS_CLK_ENB			(misc_base + 0x034)
728c2ecf20Sopenharmony_ci	#define RAS_AHB_CLK_ENB		0
738c2ecf20Sopenharmony_ci	#define RAS_PLL1_CLK_ENB	1
748c2ecf20Sopenharmony_ci	#define RAS_APB_CLK_ENB		2
758c2ecf20Sopenharmony_ci	#define RAS_32K_CLK_ENB		3
768c2ecf20Sopenharmony_ci	#define RAS_24M_CLK_ENB		4
778c2ecf20Sopenharmony_ci	#define RAS_48M_CLK_ENB		5
788c2ecf20Sopenharmony_ci	#define RAS_PLL2_CLK_ENB	7
798c2ecf20Sopenharmony_ci	#define RAS_SYNT0_CLK_ENB	8
808c2ecf20Sopenharmony_ci	#define RAS_SYNT1_CLK_ENB	9
818c2ecf20Sopenharmony_ci	#define RAS_SYNT2_CLK_ENB	10
828c2ecf20Sopenharmony_ci	#define RAS_SYNT3_CLK_ENB	11
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define PRSC0_CLK_CFG			(misc_base + 0x044)
858c2ecf20Sopenharmony_ci#define PRSC1_CLK_CFG			(misc_base + 0x048)
868c2ecf20Sopenharmony_ci#define PRSC2_CLK_CFG			(misc_base + 0x04C)
878c2ecf20Sopenharmony_ci#define AMEM_CLK_CFG			(misc_base + 0x050)
888c2ecf20Sopenharmony_ci	#define AMEM_CLK_ENB		0
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci#define CLCD_CLK_SYNT			(misc_base + 0x05C)
918c2ecf20Sopenharmony_ci#define FIRDA_CLK_SYNT			(misc_base + 0x060)
928c2ecf20Sopenharmony_ci#define UART_CLK_SYNT			(misc_base + 0x064)
938c2ecf20Sopenharmony_ci#define GMAC_CLK_SYNT			(misc_base + 0x068)
948c2ecf20Sopenharmony_ci#define GEN0_CLK_SYNT			(misc_base + 0x06C)
958c2ecf20Sopenharmony_ci#define GEN1_CLK_SYNT			(misc_base + 0x070)
968c2ecf20Sopenharmony_ci#define GEN2_CLK_SYNT			(misc_base + 0x074)
978c2ecf20Sopenharmony_ci#define GEN3_CLK_SYNT			(misc_base + 0x078)
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci/* pll rate configuration table, in ascending order of rates */
1008c2ecf20Sopenharmony_cistatic struct pll_rate_tbl pll_rtbl[] = {
1018c2ecf20Sopenharmony_ci	{.mode = 0, .m = 0x53, .n = 0x0C, .p = 0x1}, /* vco 332 & pll 166 MHz */
1028c2ecf20Sopenharmony_ci	{.mode = 0, .m = 0x85, .n = 0x0C, .p = 0x1}, /* vco 532 & pll 266 MHz */
1038c2ecf20Sopenharmony_ci	{.mode = 0, .m = 0xA6, .n = 0x0C, .p = 0x1}, /* vco 664 & pll 332 MHz */
1048c2ecf20Sopenharmony_ci};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci/* aux rate configuration table, in ascending order of rates */
1078c2ecf20Sopenharmony_cistatic struct aux_rate_tbl aux_rtbl[] = {
1088c2ecf20Sopenharmony_ci	/* For PLL1 = 332 MHz */
1098c2ecf20Sopenharmony_ci	{.xscale = 1, .yscale = 81, .eq = 0}, /* 2.049 MHz */
1108c2ecf20Sopenharmony_ci	{.xscale = 1, .yscale = 59, .eq = 0}, /* 2.822 MHz */
1118c2ecf20Sopenharmony_ci	{.xscale = 2, .yscale = 81, .eq = 0}, /* 4.098 MHz */
1128c2ecf20Sopenharmony_ci	{.xscale = 3, .yscale = 89, .eq = 0}, /* 5.644 MHz */
1138c2ecf20Sopenharmony_ci	{.xscale = 4, .yscale = 81, .eq = 0}, /* 8.197 MHz */
1148c2ecf20Sopenharmony_ci	{.xscale = 4, .yscale = 59, .eq = 0}, /* 11.254 MHz */
1158c2ecf20Sopenharmony_ci	{.xscale = 2, .yscale = 27, .eq = 0}, /* 12.296 MHz */
1168c2ecf20Sopenharmony_ci	{.xscale = 2, .yscale = 8, .eq = 0}, /* 41.5 MHz */
1178c2ecf20Sopenharmony_ci	{.xscale = 2, .yscale = 4, .eq = 0}, /* 83 MHz */
1188c2ecf20Sopenharmony_ci	{.xscale = 1, .yscale = 2, .eq = 1}, /* 166 MHz */
1198c2ecf20Sopenharmony_ci};
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/* gpt rate configuration table, in ascending order of rates */
1228c2ecf20Sopenharmony_cistatic struct gpt_rate_tbl gpt_rtbl[] = {
1238c2ecf20Sopenharmony_ci	/* For pll1 = 332 MHz */
1248c2ecf20Sopenharmony_ci	{.mscale = 4, .nscale = 0}, /* 41.5 MHz */
1258c2ecf20Sopenharmony_ci	{.mscale = 2, .nscale = 0}, /* 55.3 MHz */
1268c2ecf20Sopenharmony_ci	{.mscale = 1, .nscale = 0}, /* 83 MHz */
1278c2ecf20Sopenharmony_ci};
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci/* clock parents */
1308c2ecf20Sopenharmony_cistatic const char *uart0_parents[] = { "pll3_clk", "uart_syn_gclk", };
1318c2ecf20Sopenharmony_cistatic const char *firda_parents[] = { "pll3_clk", "firda_syn_gclk",
1328c2ecf20Sopenharmony_ci};
1338c2ecf20Sopenharmony_cistatic const char *gpt0_parents[] = { "pll3_clk", "gpt0_syn_clk", };
1348c2ecf20Sopenharmony_cistatic const char *gpt1_parents[] = { "pll3_clk", "gpt1_syn_clk", };
1358c2ecf20Sopenharmony_cistatic const char *gpt2_parents[] = { "pll3_clk", "gpt2_syn_clk", };
1368c2ecf20Sopenharmony_cistatic const char *gen2_3_parents[] = { "pll1_clk", "pll2_clk", };
1378c2ecf20Sopenharmony_cistatic const char *ddr_parents[] = { "ahb_clk", "ahbmult2_clk", "none",
1388c2ecf20Sopenharmony_ci	"pll2_clk", };
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci#ifdef CONFIG_MACH_SPEAR300
1418c2ecf20Sopenharmony_cistatic void __init spear300_clk_init(void)
1428c2ecf20Sopenharmony_ci{
1438c2ecf20Sopenharmony_ci	struct clk *clk;
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "clcd_clk", "ras_pll3_clk", 0,
1468c2ecf20Sopenharmony_ci			1, 1);
1478c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "60000000.clcd");
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "fsmc_clk", "ras_ahb_clk", 0, 1,
1508c2ecf20Sopenharmony_ci			1);
1518c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "94000000.flash");
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "sdhci_clk", "ras_ahb_clk", 0, 1,
1548c2ecf20Sopenharmony_ci			1);
1558c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "70000000.sdhci");
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "gpio1_clk", "ras_apb_clk", 0, 1,
1588c2ecf20Sopenharmony_ci			1);
1598c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "a9000000.gpio");
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "kbd_clk", "ras_apb_clk", 0, 1,
1628c2ecf20Sopenharmony_ci			1);
1638c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "a0000000.kbd");
1648c2ecf20Sopenharmony_ci}
1658c2ecf20Sopenharmony_ci#else
1668c2ecf20Sopenharmony_cistatic inline void spear300_clk_init(void) { }
1678c2ecf20Sopenharmony_ci#endif
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci/* array of all spear 310 clock lookups */
1708c2ecf20Sopenharmony_ci#ifdef CONFIG_MACH_SPEAR310
1718c2ecf20Sopenharmony_cistatic void __init spear310_clk_init(void)
1728c2ecf20Sopenharmony_ci{
1738c2ecf20Sopenharmony_ci	struct clk *clk;
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "emi_clk", "ras_ahb_clk", 0, 1,
1768c2ecf20Sopenharmony_ci			1);
1778c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "emi", NULL);
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "fsmc_clk", "ras_ahb_clk", 0, 1,
1808c2ecf20Sopenharmony_ci			1);
1818c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "44000000.flash");
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "tdm_clk", "ras_ahb_clk", 0, 1,
1848c2ecf20Sopenharmony_ci			1);
1858c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "tdm");
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "uart1_clk", "ras_apb_clk", 0, 1,
1888c2ecf20Sopenharmony_ci			1);
1898c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "b2000000.serial");
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "uart2_clk", "ras_apb_clk", 0, 1,
1928c2ecf20Sopenharmony_ci			1);
1938c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "b2080000.serial");
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "uart3_clk", "ras_apb_clk", 0, 1,
1968c2ecf20Sopenharmony_ci			1);
1978c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "b2100000.serial");
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "uart4_clk", "ras_apb_clk", 0, 1,
2008c2ecf20Sopenharmony_ci			1);
2018c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "b2180000.serial");
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "uart5_clk", "ras_apb_clk", 0, 1,
2048c2ecf20Sopenharmony_ci			1);
2058c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "b2200000.serial");
2068c2ecf20Sopenharmony_ci}
2078c2ecf20Sopenharmony_ci#else
2088c2ecf20Sopenharmony_cistatic inline void spear310_clk_init(void) { }
2098c2ecf20Sopenharmony_ci#endif
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci/* array of all spear 320 clock lookups */
2128c2ecf20Sopenharmony_ci#ifdef CONFIG_MACH_SPEAR320
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci#define SPEAR320_CONTROL_REG		(soc_config_base + 0x0010)
2158c2ecf20Sopenharmony_ci#define SPEAR320_EXT_CTRL_REG		(soc_config_base + 0x0018)
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci	#define SPEAR320_UARTX_PCLK_MASK		0x1
2188c2ecf20Sopenharmony_ci	#define SPEAR320_UART2_PCLK_SHIFT		8
2198c2ecf20Sopenharmony_ci	#define SPEAR320_UART3_PCLK_SHIFT		9
2208c2ecf20Sopenharmony_ci	#define SPEAR320_UART4_PCLK_SHIFT		10
2218c2ecf20Sopenharmony_ci	#define SPEAR320_UART5_PCLK_SHIFT		11
2228c2ecf20Sopenharmony_ci	#define SPEAR320_UART6_PCLK_SHIFT		12
2238c2ecf20Sopenharmony_ci	#define SPEAR320_RS485_PCLK_SHIFT		13
2248c2ecf20Sopenharmony_ci	#define SMII_PCLK_SHIFT				18
2258c2ecf20Sopenharmony_ci	#define SMII_PCLK_MASK				2
2268c2ecf20Sopenharmony_ci	#define SMII_PCLK_VAL_PAD			0x0
2278c2ecf20Sopenharmony_ci	#define SMII_PCLK_VAL_PLL2			0x1
2288c2ecf20Sopenharmony_ci	#define SMII_PCLK_VAL_SYNTH0			0x2
2298c2ecf20Sopenharmony_ci	#define SDHCI_PCLK_SHIFT			15
2308c2ecf20Sopenharmony_ci	#define SDHCI_PCLK_MASK				1
2318c2ecf20Sopenharmony_ci	#define SDHCI_PCLK_VAL_48M			0x0
2328c2ecf20Sopenharmony_ci	#define SDHCI_PCLK_VAL_SYNTH3			0x1
2338c2ecf20Sopenharmony_ci	#define I2S_REF_PCLK_SHIFT			8
2348c2ecf20Sopenharmony_ci	#define I2S_REF_PCLK_MASK			1
2358c2ecf20Sopenharmony_ci	#define I2S_REF_PCLK_SYNTH_VAL			0x1
2368c2ecf20Sopenharmony_ci	#define I2S_REF_PCLK_PLL2_VAL			0x0
2378c2ecf20Sopenharmony_ci	#define UART1_PCLK_SHIFT			6
2388c2ecf20Sopenharmony_ci	#define UART1_PCLK_MASK				1
2398c2ecf20Sopenharmony_ci	#define SPEAR320_UARTX_PCLK_VAL_SYNTH1		0x0
2408c2ecf20Sopenharmony_ci	#define SPEAR320_UARTX_PCLK_VAL_APB		0x1
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_cistatic const char *i2s_ref_parents[] = { "ras_pll2_clk", "ras_syn2_gclk", };
2438c2ecf20Sopenharmony_cistatic const char *sdhci_parents[] = { "ras_pll3_clk", "ras_syn3_gclk", };
2448c2ecf20Sopenharmony_cistatic const char *smii0_parents[] = { "smii_125m_pad", "ras_pll2_clk",
2458c2ecf20Sopenharmony_ci	"ras_syn0_gclk", };
2468c2ecf20Sopenharmony_cistatic const char *uartx_parents[] = { "ras_syn1_gclk", "ras_apb_clk", };
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_cistatic void __init spear320_clk_init(void __iomem *soc_config_base,
2498c2ecf20Sopenharmony_ci				     struct clk *ras_apb_clk)
2508c2ecf20Sopenharmony_ci{
2518c2ecf20Sopenharmony_ci	struct clk *clk;
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci	clk = clk_register_fixed_rate(NULL, "smii_125m_pad_clk", NULL,
2548c2ecf20Sopenharmony_ci			0, 125000000);
2558c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "smii_125m_pad", NULL);
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "clcd_clk", "ras_pll3_clk", 0,
2588c2ecf20Sopenharmony_ci			1, 1);
2598c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "90000000.clcd");
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "emi_clk", "ras_ahb_clk", 0, 1,
2628c2ecf20Sopenharmony_ci			1);
2638c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "emi", NULL);
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "fsmc_clk", "ras_ahb_clk", 0, 1,
2668c2ecf20Sopenharmony_ci			1);
2678c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "4c000000.flash");
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "i2c1_clk", "ras_ahb_clk", 0, 1,
2708c2ecf20Sopenharmony_ci			1);
2718c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "a7000000.i2c");
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "pwm_clk", "ras_ahb_clk", 0, 1,
2748c2ecf20Sopenharmony_ci			1);
2758c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "a8000000.pwm");
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "ssp1_clk", "ras_ahb_clk", 0, 1,
2788c2ecf20Sopenharmony_ci			1);
2798c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "a5000000.spi");
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "ssp2_clk", "ras_ahb_clk", 0, 1,
2828c2ecf20Sopenharmony_ci			1);
2838c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "a6000000.spi");
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "can0_clk", "ras_apb_clk", 0, 1,
2868c2ecf20Sopenharmony_ci			1);
2878c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "c_can_platform.0");
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "can1_clk", "ras_apb_clk", 0, 1,
2908c2ecf20Sopenharmony_ci			1);
2918c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "c_can_platform.1");
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "i2s_clk", "ras_apb_clk", 0, 1,
2948c2ecf20Sopenharmony_ci			1);
2958c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "a9400000.i2s");
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "i2s_ref_clk", i2s_ref_parents,
2988c2ecf20Sopenharmony_ci			ARRAY_SIZE(i2s_ref_parents),
2998c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
3008c2ecf20Sopenharmony_ci			SPEAR320_CONTROL_REG, I2S_REF_PCLK_SHIFT,
3018c2ecf20Sopenharmony_ci			I2S_REF_PCLK_MASK, 0, &_lock);
3028c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "i2s_ref_clk", NULL);
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "i2s_sclk", "i2s_ref_clk",
3058c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, 1,
3068c2ecf20Sopenharmony_ci			4);
3078c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "i2s_sclk", NULL);
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "macb1_clk", "ras_apb_clk", 0, 1,
3108c2ecf20Sopenharmony_ci			1);
3118c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "hclk", "aa000000.eth");
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "macb2_clk", "ras_apb_clk", 0, 1,
3148c2ecf20Sopenharmony_ci			1);
3158c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "hclk", "ab000000.eth");
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "rs485_clk", uartx_parents,
3188c2ecf20Sopenharmony_ci			ARRAY_SIZE(uartx_parents),
3198c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
3208c2ecf20Sopenharmony_ci			SPEAR320_EXT_CTRL_REG, SPEAR320_RS485_PCLK_SHIFT,
3218c2ecf20Sopenharmony_ci			SPEAR320_UARTX_PCLK_MASK, 0, &_lock);
3228c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "a9300000.serial");
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "sdhci_clk", sdhci_parents,
3258c2ecf20Sopenharmony_ci			ARRAY_SIZE(sdhci_parents),
3268c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
3278c2ecf20Sopenharmony_ci			SPEAR320_CONTROL_REG, SDHCI_PCLK_SHIFT, SDHCI_PCLK_MASK,
3288c2ecf20Sopenharmony_ci			0, &_lock);
3298c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "70000000.sdhci");
3308c2ecf20Sopenharmony_ci
3318c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "smii_pclk", smii0_parents,
3328c2ecf20Sopenharmony_ci			ARRAY_SIZE(smii0_parents), CLK_SET_RATE_NO_REPARENT,
3338c2ecf20Sopenharmony_ci			SPEAR320_CONTROL_REG, SMII_PCLK_SHIFT, SMII_PCLK_MASK,
3348c2ecf20Sopenharmony_ci			0, &_lock);
3358c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "smii_pclk");
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "smii_clk", "smii_pclk", 0, 1, 1);
3388c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "smii");
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "uart1_clk", uartx_parents,
3418c2ecf20Sopenharmony_ci			ARRAY_SIZE(uartx_parents),
3428c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
3438c2ecf20Sopenharmony_ci			SPEAR320_CONTROL_REG, UART1_PCLK_SHIFT, UART1_PCLK_MASK,
3448c2ecf20Sopenharmony_ci			0, &_lock);
3458c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "a3000000.serial");
3468c2ecf20Sopenharmony_ci	/* Enforce ras_apb_clk */
3478c2ecf20Sopenharmony_ci	clk_set_parent(clk, ras_apb_clk);
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "uart2_clk", uartx_parents,
3508c2ecf20Sopenharmony_ci			ARRAY_SIZE(uartx_parents),
3518c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
3528c2ecf20Sopenharmony_ci			SPEAR320_EXT_CTRL_REG, SPEAR320_UART2_PCLK_SHIFT,
3538c2ecf20Sopenharmony_ci			SPEAR320_UARTX_PCLK_MASK, 0, &_lock);
3548c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "a4000000.serial");
3558c2ecf20Sopenharmony_ci	/* Enforce ras_apb_clk */
3568c2ecf20Sopenharmony_ci	clk_set_parent(clk, ras_apb_clk);
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "uart3_clk", uartx_parents,
3598c2ecf20Sopenharmony_ci			ARRAY_SIZE(uartx_parents),
3608c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
3618c2ecf20Sopenharmony_ci			SPEAR320_EXT_CTRL_REG, SPEAR320_UART3_PCLK_SHIFT,
3628c2ecf20Sopenharmony_ci			SPEAR320_UARTX_PCLK_MASK, 0, &_lock);
3638c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "a9100000.serial");
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "uart4_clk", uartx_parents,
3668c2ecf20Sopenharmony_ci			ARRAY_SIZE(uartx_parents),
3678c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
3688c2ecf20Sopenharmony_ci			SPEAR320_EXT_CTRL_REG, SPEAR320_UART4_PCLK_SHIFT,
3698c2ecf20Sopenharmony_ci			SPEAR320_UARTX_PCLK_MASK, 0, &_lock);
3708c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "a9200000.serial");
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "uart5_clk", uartx_parents,
3738c2ecf20Sopenharmony_ci			ARRAY_SIZE(uartx_parents),
3748c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
3758c2ecf20Sopenharmony_ci			SPEAR320_EXT_CTRL_REG, SPEAR320_UART5_PCLK_SHIFT,
3768c2ecf20Sopenharmony_ci			SPEAR320_UARTX_PCLK_MASK, 0, &_lock);
3778c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "60000000.serial");
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "uart6_clk", uartx_parents,
3808c2ecf20Sopenharmony_ci			ARRAY_SIZE(uartx_parents),
3818c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
3828c2ecf20Sopenharmony_ci			SPEAR320_EXT_CTRL_REG, SPEAR320_UART6_PCLK_SHIFT,
3838c2ecf20Sopenharmony_ci			SPEAR320_UARTX_PCLK_MASK, 0, &_lock);
3848c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "60100000.serial");
3858c2ecf20Sopenharmony_ci}
3868c2ecf20Sopenharmony_ci#else
3878c2ecf20Sopenharmony_cistatic inline void spear320_clk_init(void __iomem *sb, struct clk *rc) { }
3888c2ecf20Sopenharmony_ci#endif
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_civoid __init spear3xx_clk_init(void __iomem *misc_base, void __iomem *soc_config_base)
3918c2ecf20Sopenharmony_ci{
3928c2ecf20Sopenharmony_ci	struct clk *clk, *clk1, *ras_apb_clk;
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ci	clk = clk_register_fixed_rate(NULL, "osc_32k_clk", NULL, 0, 32000);
3958c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "osc_32k_clk", NULL);
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci	clk = clk_register_fixed_rate(NULL, "osc_24m_clk", NULL, 0, 24000000);
3988c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "osc_24m_clk", NULL);
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_ci	/* clock derived from 32 KHz osc clk */
4018c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "rtc-spear", "osc_32k_clk", 0,
4028c2ecf20Sopenharmony_ci			PERIP1_CLK_ENB, RTC_CLK_ENB, 0, &_lock);
4038c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "fc900000.rtc");
4048c2ecf20Sopenharmony_ci
4058c2ecf20Sopenharmony_ci	/* clock derived from 24 MHz osc clk */
4068c2ecf20Sopenharmony_ci	clk = clk_register_fixed_rate(NULL, "pll3_clk", "osc_24m_clk", 0,
4078c2ecf20Sopenharmony_ci			48000000);
4088c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "pll3_clk", NULL);
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "wdt_clk", "osc_24m_clk", 0, 1,
4118c2ecf20Sopenharmony_ci			1);
4128c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "fc880000.wdt");
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci	clk = clk_register_vco_pll("vco1_clk", "pll1_clk", NULL,
4158c2ecf20Sopenharmony_ci			"osc_24m_clk", 0, PLL1_CTR, PLL1_FRQ, pll_rtbl,
4168c2ecf20Sopenharmony_ci			ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL);
4178c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "vco1_clk", NULL);
4188c2ecf20Sopenharmony_ci	clk_register_clkdev(clk1, "pll1_clk", NULL);
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_ci	clk = clk_register_vco_pll("vco2_clk", "pll2_clk", NULL,
4218c2ecf20Sopenharmony_ci			"osc_24m_clk", 0, PLL2_CTR, PLL2_FRQ, pll_rtbl,
4228c2ecf20Sopenharmony_ci			ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL);
4238c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "vco2_clk", NULL);
4248c2ecf20Sopenharmony_ci	clk_register_clkdev(clk1, "pll2_clk", NULL);
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci	/* clock derived from pll1 clk */
4278c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "cpu_clk", "pll1_clk",
4288c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, 1, 1);
4298c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "cpu_clk", NULL);
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci	clk = clk_register_divider(NULL, "ahb_clk", "pll1_clk",
4328c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, CORE_CLK_CFG, HCLK_RATIO_SHIFT,
4338c2ecf20Sopenharmony_ci			HCLK_RATIO_MASK, 0, &_lock);
4348c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ahb_clk", NULL);
4358c2ecf20Sopenharmony_ci
4368c2ecf20Sopenharmony_ci	clk = clk_register_aux("uart_syn_clk", "uart_syn_gclk", "pll1_clk", 0,
4378c2ecf20Sopenharmony_ci			UART_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
4388c2ecf20Sopenharmony_ci			&_lock, &clk1);
4398c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "uart_syn_clk", NULL);
4408c2ecf20Sopenharmony_ci	clk_register_clkdev(clk1, "uart_syn_gclk", NULL);
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "uart0_mclk", uart0_parents,
4438c2ecf20Sopenharmony_ci			ARRAY_SIZE(uart0_parents),
4448c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
4458c2ecf20Sopenharmony_ci			PERIP_CLK_CFG, UART_CLK_SHIFT, UART_CLK_MASK, 0,
4468c2ecf20Sopenharmony_ci			&_lock);
4478c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "uart0_mclk", NULL);
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "uart0", "uart0_mclk",
4508c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, PERIP1_CLK_ENB, UART_CLK_ENB, 0,
4518c2ecf20Sopenharmony_ci			&_lock);
4528c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "d0000000.serial");
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci	clk = clk_register_aux("firda_syn_clk", "firda_syn_gclk", "pll1_clk", 0,
4558c2ecf20Sopenharmony_ci			FIRDA_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
4568c2ecf20Sopenharmony_ci			&_lock, &clk1);
4578c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "firda_syn_clk", NULL);
4588c2ecf20Sopenharmony_ci	clk_register_clkdev(clk1, "firda_syn_gclk", NULL);
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "firda_mclk", firda_parents,
4618c2ecf20Sopenharmony_ci			ARRAY_SIZE(firda_parents),
4628c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
4638c2ecf20Sopenharmony_ci			PERIP_CLK_CFG, FIRDA_CLK_SHIFT, FIRDA_CLK_MASK, 0,
4648c2ecf20Sopenharmony_ci			&_lock);
4658c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "firda_mclk", NULL);
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "firda_clk", "firda_mclk",
4688c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, PERIP1_CLK_ENB, FIRDA_CLK_ENB, 0,
4698c2ecf20Sopenharmony_ci			&_lock);
4708c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "firda");
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_ci	/* gpt clocks */
4738c2ecf20Sopenharmony_ci	clk_register_gpt("gpt0_syn_clk", "pll1_clk", 0, PRSC0_CLK_CFG, gpt_rtbl,
4748c2ecf20Sopenharmony_ci			ARRAY_SIZE(gpt_rtbl), &_lock);
4758c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "gpt0_clk", gpt0_parents,
4768c2ecf20Sopenharmony_ci			ARRAY_SIZE(gpt0_parents),
4778c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
4788c2ecf20Sopenharmony_ci			PERIP_CLK_CFG, GPT0_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
4798c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "gpt0");
4808c2ecf20Sopenharmony_ci
4818c2ecf20Sopenharmony_ci	clk_register_gpt("gpt1_syn_clk", "pll1_clk", 0, PRSC1_CLK_CFG, gpt_rtbl,
4828c2ecf20Sopenharmony_ci			ARRAY_SIZE(gpt_rtbl), &_lock);
4838c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "gpt1_mclk", gpt1_parents,
4848c2ecf20Sopenharmony_ci			ARRAY_SIZE(gpt1_parents),
4858c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
4868c2ecf20Sopenharmony_ci			PERIP_CLK_CFG, GPT1_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
4878c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "gpt1_mclk", NULL);
4888c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "gpt1_clk", "gpt1_mclk",
4898c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, PERIP1_CLK_ENB, GPT1_CLK_ENB, 0,
4908c2ecf20Sopenharmony_ci			&_lock);
4918c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "gpt1");
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_ci	clk_register_gpt("gpt2_syn_clk", "pll1_clk", 0, PRSC2_CLK_CFG, gpt_rtbl,
4948c2ecf20Sopenharmony_ci			ARRAY_SIZE(gpt_rtbl), &_lock);
4958c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "gpt2_mclk", gpt2_parents,
4968c2ecf20Sopenharmony_ci			ARRAY_SIZE(gpt2_parents),
4978c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
4988c2ecf20Sopenharmony_ci			PERIP_CLK_CFG, GPT2_CLK_SHIFT, GPT_CLK_MASK, 0, &_lock);
4998c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "gpt2_mclk", NULL);
5008c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "gpt2_clk", "gpt2_mclk",
5018c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, PERIP1_CLK_ENB, GPT2_CLK_ENB, 0,
5028c2ecf20Sopenharmony_ci			&_lock);
5038c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "gpt2");
5048c2ecf20Sopenharmony_ci
5058c2ecf20Sopenharmony_ci	/* general synths clocks */
5068c2ecf20Sopenharmony_ci	clk = clk_register_aux("gen0_syn_clk", "gen0_syn_gclk", "pll1_clk",
5078c2ecf20Sopenharmony_ci			0, GEN0_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
5088c2ecf20Sopenharmony_ci			&_lock, &clk1);
5098c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "gen0_syn_clk", NULL);
5108c2ecf20Sopenharmony_ci	clk_register_clkdev(clk1, "gen0_syn_gclk", NULL);
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci	clk = clk_register_aux("gen1_syn_clk", "gen1_syn_gclk", "pll1_clk",
5138c2ecf20Sopenharmony_ci			0, GEN1_CLK_SYNT, NULL, aux_rtbl, ARRAY_SIZE(aux_rtbl),
5148c2ecf20Sopenharmony_ci			&_lock, &clk1);
5158c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "gen1_syn_clk", NULL);
5168c2ecf20Sopenharmony_ci	clk_register_clkdev(clk1, "gen1_syn_gclk", NULL);
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "gen2_3_par_clk", gen2_3_parents,
5198c2ecf20Sopenharmony_ci			ARRAY_SIZE(gen2_3_parents), CLK_SET_RATE_NO_REPARENT,
5208c2ecf20Sopenharmony_ci			CORE_CLK_CFG, GEN_SYNTH2_3_CLK_SHIFT,
5218c2ecf20Sopenharmony_ci			GEN_SYNTH2_3_CLK_MASK, 0, &_lock);
5228c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "gen2_3_par_clk", NULL);
5238c2ecf20Sopenharmony_ci
5248c2ecf20Sopenharmony_ci	clk = clk_register_aux("gen2_syn_clk", "gen2_syn_gclk",
5258c2ecf20Sopenharmony_ci			"gen2_3_par_clk", 0, GEN2_CLK_SYNT, NULL, aux_rtbl,
5268c2ecf20Sopenharmony_ci			ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
5278c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "gen2_syn_clk", NULL);
5288c2ecf20Sopenharmony_ci	clk_register_clkdev(clk1, "gen2_syn_gclk", NULL);
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_ci	clk = clk_register_aux("gen3_syn_clk", "gen3_syn_gclk",
5318c2ecf20Sopenharmony_ci			"gen2_3_par_clk", 0, GEN3_CLK_SYNT, NULL, aux_rtbl,
5328c2ecf20Sopenharmony_ci			ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
5338c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "gen3_syn_clk", NULL);
5348c2ecf20Sopenharmony_ci	clk_register_clkdev(clk1, "gen3_syn_gclk", NULL);
5358c2ecf20Sopenharmony_ci
5368c2ecf20Sopenharmony_ci	/* clock derived from pll3 clk */
5378c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "usbh_clk", "pll3_clk", 0, PERIP1_CLK_ENB,
5388c2ecf20Sopenharmony_ci			USBH_CLK_ENB, 0, &_lock);
5398c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "e1800000.ehci");
5408c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "e1900000.ohci");
5418c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "e2100000.ohci");
5428c2ecf20Sopenharmony_ci
5438c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "usbh.0_clk", "usbh_clk", 0, 1,
5448c2ecf20Sopenharmony_ci			1);
5458c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "usbh.0_clk", NULL);
5468c2ecf20Sopenharmony_ci
5478c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "usbh.1_clk", "usbh_clk", 0, 1,
5488c2ecf20Sopenharmony_ci			1);
5498c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "usbh.1_clk", NULL);
5508c2ecf20Sopenharmony_ci
5518c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "usbd_clk", "pll3_clk", 0, PERIP1_CLK_ENB,
5528c2ecf20Sopenharmony_ci			USBD_CLK_ENB, 0, &_lock);
5538c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "e1100000.usbd");
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_ci	/* clock derived from ahb clk */
5568c2ecf20Sopenharmony_ci	clk = clk_register_fixed_factor(NULL, "ahbmult2_clk", "ahb_clk", 0, 2,
5578c2ecf20Sopenharmony_ci			1);
5588c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ahbmult2_clk", NULL);
5598c2ecf20Sopenharmony_ci
5608c2ecf20Sopenharmony_ci	clk = clk_register_mux(NULL, "ddr_clk", ddr_parents,
5618c2ecf20Sopenharmony_ci			ARRAY_SIZE(ddr_parents), CLK_SET_RATE_NO_REPARENT,
5628c2ecf20Sopenharmony_ci			PLL_CLK_CFG, MCTR_CLK_SHIFT, MCTR_CLK_MASK, 0, &_lock);
5638c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ddr_clk", NULL);
5648c2ecf20Sopenharmony_ci
5658c2ecf20Sopenharmony_ci	clk = clk_register_divider(NULL, "apb_clk", "ahb_clk",
5668c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, CORE_CLK_CFG, PCLK_RATIO_SHIFT,
5678c2ecf20Sopenharmony_ci			PCLK_RATIO_MASK, 0, &_lock);
5688c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "apb_clk", NULL);
5698c2ecf20Sopenharmony_ci
5708c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "amem_clk", "ahb_clk", 0, AMEM_CLK_CFG,
5718c2ecf20Sopenharmony_ci			AMEM_CLK_ENB, 0, &_lock);
5728c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "amem_clk", NULL);
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "c3_clk", "ahb_clk", 0, PERIP1_CLK_ENB,
5758c2ecf20Sopenharmony_ci			C3_CLK_ENB, 0, &_lock);
5768c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "c3_clk");
5778c2ecf20Sopenharmony_ci
5788c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "dma_clk", "ahb_clk", 0, PERIP1_CLK_ENB,
5798c2ecf20Sopenharmony_ci			DMA_CLK_ENB, 0, &_lock);
5808c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "fc400000.dma");
5818c2ecf20Sopenharmony_ci
5828c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "gmac_clk", "ahb_clk", 0, PERIP1_CLK_ENB,
5838c2ecf20Sopenharmony_ci			GMAC_CLK_ENB, 0, &_lock);
5848c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "e0800000.eth");
5858c2ecf20Sopenharmony_ci
5868c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "i2c0_clk", "ahb_clk", 0, PERIP1_CLK_ENB,
5878c2ecf20Sopenharmony_ci			I2C_CLK_ENB, 0, &_lock);
5888c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "d0180000.i2c");
5898c2ecf20Sopenharmony_ci
5908c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "jpeg_clk", "ahb_clk", 0, PERIP1_CLK_ENB,
5918c2ecf20Sopenharmony_ci			JPEG_CLK_ENB, 0, &_lock);
5928c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "jpeg");
5938c2ecf20Sopenharmony_ci
5948c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "smi_clk", "ahb_clk", 0, PERIP1_CLK_ENB,
5958c2ecf20Sopenharmony_ci			SMI_CLK_ENB, 0, &_lock);
5968c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "fc000000.flash");
5978c2ecf20Sopenharmony_ci
5988c2ecf20Sopenharmony_ci	/* clock derived from apb clk */
5998c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "adc_clk", "apb_clk", 0, PERIP1_CLK_ENB,
6008c2ecf20Sopenharmony_ci			ADC_CLK_ENB, 0, &_lock);
6018c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "d0080000.adc");
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "gpio0_clk", "apb_clk", 0, PERIP1_CLK_ENB,
6048c2ecf20Sopenharmony_ci			GPIO_CLK_ENB, 0, &_lock);
6058c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "fc980000.gpio");
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ssp0_clk", "apb_clk", 0, PERIP1_CLK_ENB,
6088c2ecf20Sopenharmony_ci			SSP_CLK_ENB, 0, &_lock);
6098c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, NULL, "d0100000.spi");
6108c2ecf20Sopenharmony_ci
6118c2ecf20Sopenharmony_ci	/* RAS clk enable */
6128c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ras_ahb_clk", "ahb_clk", 0, RAS_CLK_ENB,
6138c2ecf20Sopenharmony_ci			RAS_AHB_CLK_ENB, 0, &_lock);
6148c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ras_ahb_clk", NULL);
6158c2ecf20Sopenharmony_ci
6168c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ras_apb_clk", "apb_clk", 0, RAS_CLK_ENB,
6178c2ecf20Sopenharmony_ci			RAS_APB_CLK_ENB, 0, &_lock);
6188c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ras_apb_clk", NULL);
6198c2ecf20Sopenharmony_ci	ras_apb_clk = clk;
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ras_32k_clk", "osc_32k_clk", 0,
6228c2ecf20Sopenharmony_ci			RAS_CLK_ENB, RAS_32K_CLK_ENB, 0, &_lock);
6238c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ras_32k_clk", NULL);
6248c2ecf20Sopenharmony_ci
6258c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ras_24m_clk", "osc_24m_clk", 0,
6268c2ecf20Sopenharmony_ci			RAS_CLK_ENB, RAS_24M_CLK_ENB, 0, &_lock);
6278c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ras_24m_clk", NULL);
6288c2ecf20Sopenharmony_ci
6298c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ras_pll1_clk", "pll1_clk", 0,
6308c2ecf20Sopenharmony_ci			RAS_CLK_ENB, RAS_PLL1_CLK_ENB, 0, &_lock);
6318c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ras_pll1_clk", NULL);
6328c2ecf20Sopenharmony_ci
6338c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ras_pll2_clk", "pll2_clk", 0,
6348c2ecf20Sopenharmony_ci			RAS_CLK_ENB, RAS_PLL2_CLK_ENB, 0, &_lock);
6358c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ras_pll2_clk", NULL);
6368c2ecf20Sopenharmony_ci
6378c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ras_pll3_clk", "pll3_clk", 0,
6388c2ecf20Sopenharmony_ci			RAS_CLK_ENB, RAS_48M_CLK_ENB, 0, &_lock);
6398c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ras_pll3_clk", NULL);
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ras_syn0_gclk", "gen0_syn_gclk",
6428c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, RAS_CLK_ENB, RAS_SYNT0_CLK_ENB, 0,
6438c2ecf20Sopenharmony_ci			&_lock);
6448c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ras_syn0_gclk", NULL);
6458c2ecf20Sopenharmony_ci
6468c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ras_syn1_gclk", "gen1_syn_gclk",
6478c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, RAS_CLK_ENB, RAS_SYNT1_CLK_ENB, 0,
6488c2ecf20Sopenharmony_ci			&_lock);
6498c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ras_syn1_gclk", NULL);
6508c2ecf20Sopenharmony_ci
6518c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ras_syn2_gclk", "gen2_syn_gclk",
6528c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, RAS_CLK_ENB, RAS_SYNT2_CLK_ENB, 0,
6538c2ecf20Sopenharmony_ci			&_lock);
6548c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ras_syn2_gclk", NULL);
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_ci	clk = clk_register_gate(NULL, "ras_syn3_gclk", "gen3_syn_gclk",
6578c2ecf20Sopenharmony_ci			CLK_SET_RATE_PARENT, RAS_CLK_ENB, RAS_SYNT3_CLK_ENB, 0,
6588c2ecf20Sopenharmony_ci			&_lock);
6598c2ecf20Sopenharmony_ci	clk_register_clkdev(clk, "ras_syn3_gclk", NULL);
6608c2ecf20Sopenharmony_ci
6618c2ecf20Sopenharmony_ci	if (of_machine_is_compatible("st,spear300"))
6628c2ecf20Sopenharmony_ci		spear300_clk_init();
6638c2ecf20Sopenharmony_ci	else if (of_machine_is_compatible("st,spear310"))
6648c2ecf20Sopenharmony_ci		spear310_clk_init();
6658c2ecf20Sopenharmony_ci	else if (of_machine_is_compatible("st,spear320"))
6668c2ecf20Sopenharmony_ci		spear320_clk_init(soc_config_base, ras_apb_clk);
6678c2ecf20Sopenharmony_ci}
668