1*3bb16560SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
20b928af1SViresh Kumar /*
30b928af1SViresh Kumar * arch/arm/mach-spear13xx/spear1340_clock.c
40b928af1SViresh Kumar *
50b928af1SViresh Kumar * SPEAr1340 machine clock framework source file
60b928af1SViresh Kumar *
70b928af1SViresh Kumar * Copyright (C) 2012 ST Microelectronics
8da89947bSViresh Kumar * Viresh Kumar <vireshk@kernel.org>
90b928af1SViresh Kumar */
100b928af1SViresh Kumar
110b928af1SViresh Kumar #include <linux/clkdev.h>
12f2ad937bSLee Jones #include <linux/clk/spear.h>
130b928af1SViresh Kumar #include <linux/err.h>
140b928af1SViresh Kumar #include <linux/io.h>
150b928af1SViresh Kumar #include <linux/spinlock_types.h>
160b928af1SViresh Kumar #include "clk.h"
170b928af1SViresh Kumar
180b928af1SViresh Kumar /* Clock Configuration Registers */
19d9909ebeSArnd Bergmann #define SPEAR1340_SYS_CLK_CTRL (misc_base + 0x200)
200b928af1SViresh Kumar #define SPEAR1340_HCLK_SRC_SEL_SHIFT 27
210b928af1SViresh Kumar #define SPEAR1340_HCLK_SRC_SEL_MASK 1
220b928af1SViresh Kumar #define SPEAR1340_SCLK_SRC_SEL_SHIFT 23
230b928af1SViresh Kumar #define SPEAR1340_SCLK_SRC_SEL_MASK 3
240b928af1SViresh Kumar
250b928af1SViresh Kumar /* PLL related registers and bit values */
26d9909ebeSArnd Bergmann #define SPEAR1340_PLL_CFG (misc_base + 0x210)
270b928af1SViresh Kumar /* PLL_CFG bit values */
280b928af1SViresh Kumar #define SPEAR1340_CLCD_SYNT_CLK_MASK 1
290b928af1SViresh Kumar #define SPEAR1340_CLCD_SYNT_CLK_SHIFT 31
300b928af1SViresh Kumar #define SPEAR1340_GEN_SYNT2_3_CLK_SHIFT 29
310b928af1SViresh Kumar #define SPEAR1340_GEN_SYNT_CLK_MASK 2
320b928af1SViresh Kumar #define SPEAR1340_GEN_SYNT0_1_CLK_SHIFT 27
330b928af1SViresh Kumar #define SPEAR1340_PLL_CLK_MASK 2
340b928af1SViresh Kumar #define SPEAR1340_PLL3_CLK_SHIFT 24
350b928af1SViresh Kumar #define SPEAR1340_PLL2_CLK_SHIFT 22
360b928af1SViresh Kumar #define SPEAR1340_PLL1_CLK_SHIFT 20
370b928af1SViresh Kumar
38d9909ebeSArnd Bergmann #define SPEAR1340_PLL1_CTR (misc_base + 0x214)
39d9909ebeSArnd Bergmann #define SPEAR1340_PLL1_FRQ (misc_base + 0x218)
40d9909ebeSArnd Bergmann #define SPEAR1340_PLL2_CTR (misc_base + 0x220)
41d9909ebeSArnd Bergmann #define SPEAR1340_PLL2_FRQ (misc_base + 0x224)
42d9909ebeSArnd Bergmann #define SPEAR1340_PLL3_CTR (misc_base + 0x22C)
43d9909ebeSArnd Bergmann #define SPEAR1340_PLL3_FRQ (misc_base + 0x230)
44d9909ebeSArnd Bergmann #define SPEAR1340_PLL4_CTR (misc_base + 0x238)
45d9909ebeSArnd Bergmann #define SPEAR1340_PLL4_FRQ (misc_base + 0x23C)
46d9909ebeSArnd Bergmann #define SPEAR1340_PERIP_CLK_CFG (misc_base + 0x244)
470b928af1SViresh Kumar /* PERIP_CLK_CFG bit values */
480b928af1SViresh Kumar #define SPEAR1340_SPDIF_CLK_MASK 1
490b928af1SViresh Kumar #define SPEAR1340_SPDIF_OUT_CLK_SHIFT 15
500b928af1SViresh Kumar #define SPEAR1340_SPDIF_IN_CLK_SHIFT 14
510b928af1SViresh Kumar #define SPEAR1340_GPT3_CLK_SHIFT 13
520b928af1SViresh Kumar #define SPEAR1340_GPT2_CLK_SHIFT 12
530b928af1SViresh Kumar #define SPEAR1340_GPT_CLK_MASK 1
540b928af1SViresh Kumar #define SPEAR1340_GPT1_CLK_SHIFT 9
550b928af1SViresh Kumar #define SPEAR1340_GPT0_CLK_SHIFT 8
560b928af1SViresh Kumar #define SPEAR1340_UART_CLK_MASK 2
570b928af1SViresh Kumar #define SPEAR1340_UART1_CLK_SHIFT 6
580b928af1SViresh Kumar #define SPEAR1340_UART0_CLK_SHIFT 4
590b928af1SViresh Kumar #define SPEAR1340_CLCD_CLK_MASK 2
600b928af1SViresh Kumar #define SPEAR1340_CLCD_CLK_SHIFT 2
610b928af1SViresh Kumar #define SPEAR1340_C3_CLK_MASK 1
620b928af1SViresh Kumar #define SPEAR1340_C3_CLK_SHIFT 1
630b928af1SViresh Kumar
64d9909ebeSArnd Bergmann #define SPEAR1340_GMAC_CLK_CFG (misc_base + 0x248)
650b928af1SViresh Kumar #define SPEAR1340_GMAC_PHY_CLK_MASK 1
660b928af1SViresh Kumar #define SPEAR1340_GMAC_PHY_CLK_SHIFT 2
670b928af1SViresh Kumar #define SPEAR1340_GMAC_PHY_INPUT_CLK_MASK 2
680b928af1SViresh Kumar #define SPEAR1340_GMAC_PHY_INPUT_CLK_SHIFT 0
690b928af1SViresh Kumar
70d9909ebeSArnd Bergmann #define SPEAR1340_I2S_CLK_CFG (misc_base + 0x24C)
710b928af1SViresh Kumar /* I2S_CLK_CFG register mask */
720b928af1SViresh Kumar #define SPEAR1340_I2S_SCLK_X_MASK 0x1F
730b928af1SViresh Kumar #define SPEAR1340_I2S_SCLK_X_SHIFT 27
740b928af1SViresh Kumar #define SPEAR1340_I2S_SCLK_Y_MASK 0x1F
750b928af1SViresh Kumar #define SPEAR1340_I2S_SCLK_Y_SHIFT 22
760b928af1SViresh Kumar #define SPEAR1340_I2S_SCLK_EQ_SEL_SHIFT 21
770b928af1SViresh Kumar #define SPEAR1340_I2S_SCLK_SYNTH_ENB 20
780b928af1SViresh Kumar #define SPEAR1340_I2S_PRS1_CLK_X_MASK 0xFF
790b928af1SViresh Kumar #define SPEAR1340_I2S_PRS1_CLK_X_SHIFT 12
800b928af1SViresh Kumar #define SPEAR1340_I2S_PRS1_CLK_Y_MASK 0xFF
810b928af1SViresh Kumar #define SPEAR1340_I2S_PRS1_CLK_Y_SHIFT 4
820b928af1SViresh Kumar #define SPEAR1340_I2S_PRS1_EQ_SEL_SHIFT 3
830b928af1SViresh Kumar #define SPEAR1340_I2S_REF_SEL_MASK 1
840b928af1SViresh Kumar #define SPEAR1340_I2S_REF_SHIFT 2
850b928af1SViresh Kumar #define SPEAR1340_I2S_SRC_CLK_MASK 2
860b928af1SViresh Kumar #define SPEAR1340_I2S_SRC_CLK_SHIFT 0
870b928af1SViresh Kumar
88d9909ebeSArnd Bergmann #define SPEAR1340_C3_CLK_SYNT (misc_base + 0x250)
89d9909ebeSArnd Bergmann #define SPEAR1340_UART0_CLK_SYNT (misc_base + 0x254)
90d9909ebeSArnd Bergmann #define SPEAR1340_UART1_CLK_SYNT (misc_base + 0x258)
91d9909ebeSArnd Bergmann #define SPEAR1340_GMAC_CLK_SYNT (misc_base + 0x25C)
92d9909ebeSArnd Bergmann #define SPEAR1340_SDHCI_CLK_SYNT (misc_base + 0x260)
93d9909ebeSArnd Bergmann #define SPEAR1340_CFXD_CLK_SYNT (misc_base + 0x264)
94d9909ebeSArnd Bergmann #define SPEAR1340_ADC_CLK_SYNT (misc_base + 0x270)
95d9909ebeSArnd Bergmann #define SPEAR1340_AMBA_CLK_SYNT (misc_base + 0x274)
96d9909ebeSArnd Bergmann #define SPEAR1340_CLCD_CLK_SYNT (misc_base + 0x27C)
97d9909ebeSArnd Bergmann #define SPEAR1340_SYS_CLK_SYNT (misc_base + 0x284)
98d9909ebeSArnd Bergmann #define SPEAR1340_GEN_CLK_SYNT0 (misc_base + 0x28C)
99d9909ebeSArnd Bergmann #define SPEAR1340_GEN_CLK_SYNT1 (misc_base + 0x294)
100d9909ebeSArnd Bergmann #define SPEAR1340_GEN_CLK_SYNT2 (misc_base + 0x29C)
101d9909ebeSArnd Bergmann #define SPEAR1340_GEN_CLK_SYNT3 (misc_base + 0x304)
102d9909ebeSArnd Bergmann #define SPEAR1340_PERIP1_CLK_ENB (misc_base + 0x30C)
1030b928af1SViresh Kumar #define SPEAR1340_RTC_CLK_ENB 31
1040b928af1SViresh Kumar #define SPEAR1340_ADC_CLK_ENB 30
1050b928af1SViresh Kumar #define SPEAR1340_C3_CLK_ENB 29
1060b928af1SViresh Kumar #define SPEAR1340_CLCD_CLK_ENB 27
1070b928af1SViresh Kumar #define SPEAR1340_DMA_CLK_ENB 25
1080b928af1SViresh Kumar #define SPEAR1340_GPIO1_CLK_ENB 24
1090b928af1SViresh Kumar #define SPEAR1340_GPIO0_CLK_ENB 23
1100b928af1SViresh Kumar #define SPEAR1340_GPT1_CLK_ENB 22
1110b928af1SViresh Kumar #define SPEAR1340_GPT0_CLK_ENB 21
1120b928af1SViresh Kumar #define SPEAR1340_I2S_PLAY_CLK_ENB 20
1130b928af1SViresh Kumar #define SPEAR1340_I2S_REC_CLK_ENB 19
1140b928af1SViresh Kumar #define SPEAR1340_I2C0_CLK_ENB 18
1150b928af1SViresh Kumar #define SPEAR1340_SSP_CLK_ENB 17
1160b928af1SViresh Kumar #define SPEAR1340_UART0_CLK_ENB 15
1170b928af1SViresh Kumar #define SPEAR1340_PCIE_SATA_CLK_ENB 12
1180b928af1SViresh Kumar #define SPEAR1340_UOC_CLK_ENB 11
1190b928af1SViresh Kumar #define SPEAR1340_UHC1_CLK_ENB 10
1200b928af1SViresh Kumar #define SPEAR1340_UHC0_CLK_ENB 9
1210b928af1SViresh Kumar #define SPEAR1340_GMAC_CLK_ENB 8
1220b928af1SViresh Kumar #define SPEAR1340_CFXD_CLK_ENB 7
1230b928af1SViresh Kumar #define SPEAR1340_SDHCI_CLK_ENB 6
1240b928af1SViresh Kumar #define SPEAR1340_SMI_CLK_ENB 5
1250b928af1SViresh Kumar #define SPEAR1340_FSMC_CLK_ENB 4
1260b928af1SViresh Kumar #define SPEAR1340_SYSRAM0_CLK_ENB 3
1270b928af1SViresh Kumar #define SPEAR1340_SYSRAM1_CLK_ENB 2
1280b928af1SViresh Kumar #define SPEAR1340_SYSROM_CLK_ENB 1
1290b928af1SViresh Kumar #define SPEAR1340_BUS_CLK_ENB 0
1300b928af1SViresh Kumar
131d9909ebeSArnd Bergmann #define SPEAR1340_PERIP2_CLK_ENB (misc_base + 0x310)
1320b928af1SViresh Kumar #define SPEAR1340_THSENS_CLK_ENB 8
1330b928af1SViresh Kumar #define SPEAR1340_I2S_REF_PAD_CLK_ENB 7
1340b928af1SViresh Kumar #define SPEAR1340_ACP_CLK_ENB 6
1350b928af1SViresh Kumar #define SPEAR1340_GPT3_CLK_ENB 5
1360b928af1SViresh Kumar #define SPEAR1340_GPT2_CLK_ENB 4
1370b928af1SViresh Kumar #define SPEAR1340_KBD_CLK_ENB 3
1380b928af1SViresh Kumar #define SPEAR1340_CPU_DBG_CLK_ENB 2
1390b928af1SViresh Kumar #define SPEAR1340_DDR_CORE_CLK_ENB 1
1400b928af1SViresh Kumar #define SPEAR1340_DDR_CTRL_CLK_ENB 0
1410b928af1SViresh Kumar
142d9909ebeSArnd Bergmann #define SPEAR1340_PERIP3_CLK_ENB (misc_base + 0x314)
1430b928af1SViresh Kumar #define SPEAR1340_PLGPIO_CLK_ENB 18
1440b928af1SViresh Kumar #define SPEAR1340_VIDEO_DEC_CLK_ENB 16
1450b928af1SViresh Kumar #define SPEAR1340_VIDEO_ENC_CLK_ENB 15
1460b928af1SViresh Kumar #define SPEAR1340_SPDIF_OUT_CLK_ENB 13
1470b928af1SViresh Kumar #define SPEAR1340_SPDIF_IN_CLK_ENB 12
1480b928af1SViresh Kumar #define SPEAR1340_VIDEO_IN_CLK_ENB 11
1490b928af1SViresh Kumar #define SPEAR1340_CAM0_CLK_ENB 10
1500b928af1SViresh Kumar #define SPEAR1340_CAM1_CLK_ENB 9
1510b928af1SViresh Kumar #define SPEAR1340_CAM2_CLK_ENB 8
1520b928af1SViresh Kumar #define SPEAR1340_CAM3_CLK_ENB 7
1530b928af1SViresh Kumar #define SPEAR1340_MALI_CLK_ENB 6
1540b928af1SViresh Kumar #define SPEAR1340_CEC0_CLK_ENB 5
1550b928af1SViresh Kumar #define SPEAR1340_CEC1_CLK_ENB 4
1560b928af1SViresh Kumar #define SPEAR1340_PWM_CLK_ENB 3
1570b928af1SViresh Kumar #define SPEAR1340_I2C1_CLK_ENB 2
1580b928af1SViresh Kumar #define SPEAR1340_UART1_CLK_ENB 1
1590b928af1SViresh Kumar
1600b928af1SViresh Kumar static DEFINE_SPINLOCK(_lock);
1610b928af1SViresh Kumar
1620b928af1SViresh Kumar /* pll rate configuration table, in ascending order of rates */
1630b928af1SViresh Kumar static struct pll_rate_tbl pll_rtbl[] = {
1640b928af1SViresh Kumar /* PCLK 24MHz */
1650b928af1SViresh Kumar {.mode = 0, .m = 0x83, .n = 0x04, .p = 0x5}, /* vco 1572, pll 49.125 MHz */
1660b928af1SViresh Kumar {.mode = 0, .m = 0x7D, .n = 0x06, .p = 0x3}, /* vco 1000, pll 125 MHz */
1670b928af1SViresh Kumar {.mode = 0, .m = 0x64, .n = 0x06, .p = 0x1}, /* vco 800, pll 400 MHz */
1680b928af1SViresh Kumar {.mode = 0, .m = 0x7D, .n = 0x06, .p = 0x1}, /* vco 1000, pll 500 MHz */
1690b928af1SViresh Kumar {.mode = 0, .m = 0xA6, .n = 0x06, .p = 0x1}, /* vco 1328, pll 664 MHz */
1700b928af1SViresh Kumar {.mode = 0, .m = 0xC8, .n = 0x06, .p = 0x1}, /* vco 1600, pll 800 MHz */
1710b928af1SViresh Kumar {.mode = 0, .m = 0x7D, .n = 0x06, .p = 0x0}, /* vco 1, pll 1 GHz */
1720b928af1SViresh Kumar {.mode = 0, .m = 0x96, .n = 0x06, .p = 0x0}, /* vco 1200, pll 1200 MHz */
1730b928af1SViresh Kumar };
1740b928af1SViresh Kumar
1750b928af1SViresh Kumar /* vco-pll4 rate configuration table, in ascending order of rates */
1760b928af1SViresh Kumar static struct pll_rate_tbl pll4_rtbl[] = {
1770b928af1SViresh Kumar {.mode = 0, .m = 0x7D, .n = 0x06, .p = 0x2}, /* vco 1000, pll 250 MHz */
1780b928af1SViresh Kumar {.mode = 0, .m = 0xA6, .n = 0x06, .p = 0x2}, /* vco 1328, pll 332 MHz */
1790b928af1SViresh Kumar {.mode = 0, .m = 0xC8, .n = 0x06, .p = 0x2}, /* vco 1600, pll 400 MHz */
1800b928af1SViresh Kumar {.mode = 0, .m = 0x7D, .n = 0x06, .p = 0x0}, /* vco 1, pll 1 GHz */
1810b928af1SViresh Kumar };
1820b928af1SViresh Kumar
1830b928af1SViresh Kumar /*
1840b928af1SViresh Kumar * All below entries generate 166 MHz for
1850b928af1SViresh Kumar * different values of vco1div2
1860b928af1SViresh Kumar */
1870b928af1SViresh Kumar static struct frac_rate_tbl amba_synth_rtbl[] = {
188ef0fd0a2SDeepak Sikri {.div = 0x073A8}, /* for vco1div2 = 600 MHz */
1890b928af1SViresh Kumar {.div = 0x06062}, /* for vco1div2 = 500 MHz */
1900b928af1SViresh Kumar {.div = 0x04D1B}, /* for vco1div2 = 400 MHz */
1910b928af1SViresh Kumar {.div = 0x04000}, /* for vco1div2 = 332 MHz */
1920b928af1SViresh Kumar {.div = 0x03031}, /* for vco1div2 = 250 MHz */
1930b928af1SViresh Kumar {.div = 0x0268D}, /* for vco1div2 = 200 MHz */
1940b928af1SViresh Kumar };
1950b928af1SViresh Kumar
1960b928af1SViresh Kumar /*
1970b928af1SViresh Kumar * Synthesizer Clock derived from vcodiv2. This clock is one of the
1980b928af1SViresh Kumar * possible clocks to feed cpu directly.
1990b928af1SViresh Kumar * We can program this synthesizer to make cpu run on different clock
2000b928af1SViresh Kumar * frequencies.
2010b928af1SViresh Kumar * Following table provides configuration values to let cpu run on 200,
2020b928af1SViresh Kumar * 250, 332, 400 or 500 MHz considering different possibilites of input
2030b928af1SViresh Kumar * (vco1div2) clock.
2040b928af1SViresh Kumar *
2050b928af1SViresh Kumar * --------------------------------------------------------------------
2060b928af1SViresh Kumar * vco1div2(Mhz) fout(Mhz) cpuclk = fout/2 div
2070b928af1SViresh Kumar * --------------------------------------------------------------------
2080b928af1SViresh Kumar * 400 200 100 0x04000
2090b928af1SViresh Kumar * 400 250 125 0x03333
2100b928af1SViresh Kumar * 400 332 166 0x0268D
2110b928af1SViresh Kumar * 400 400 200 0x02000
2120b928af1SViresh Kumar * --------------------------------------------------------------------
2130b928af1SViresh Kumar * 500 200 100 0x05000
2140b928af1SViresh Kumar * 500 250 125 0x04000
2150b928af1SViresh Kumar * 500 332 166 0x03031
2160b928af1SViresh Kumar * 500 400 200 0x02800
2170b928af1SViresh Kumar * 500 500 250 0x02000
2180b928af1SViresh Kumar * --------------------------------------------------------------------
219ef0fd0a2SDeepak Sikri * 600 200 100 0x06000
220ef0fd0a2SDeepak Sikri * 600 250 125 0x04CCE
221ef0fd0a2SDeepak Sikri * 600 332 166 0x039D5
222ef0fd0a2SDeepak Sikri * 600 400 200 0x03000
223ef0fd0a2SDeepak Sikri * 600 500 250 0x02666
224ef0fd0a2SDeepak Sikri * --------------------------------------------------------------------
2250b928af1SViresh Kumar * 664 200 100 0x06a38
2260b928af1SViresh Kumar * 664 250 125 0x054FD
2270b928af1SViresh Kumar * 664 332 166 0x04000
2280b928af1SViresh Kumar * 664 400 200 0x0351E
2290b928af1SViresh Kumar * 664 500 250 0x02A7E
2300b928af1SViresh Kumar * --------------------------------------------------------------------
2310b928af1SViresh Kumar * 800 200 100 0x08000
2320b928af1SViresh Kumar * 800 250 125 0x06666
2330b928af1SViresh Kumar * 800 332 166 0x04D18
2340b928af1SViresh Kumar * 800 400 200 0x04000
2350b928af1SViresh Kumar * 800 500 250 0x03333
2360b928af1SViresh Kumar * --------------------------------------------------------------------
2370b928af1SViresh Kumar * sys rate configuration table is in descending order of divisor.
2380b928af1SViresh Kumar */
2390b928af1SViresh Kumar static struct frac_rate_tbl sys_synth_rtbl[] = {
2400b928af1SViresh Kumar {.div = 0x08000},
2410b928af1SViresh Kumar {.div = 0x06a38},
2420b928af1SViresh Kumar {.div = 0x06666},
243ef0fd0a2SDeepak Sikri {.div = 0x06000},
2440b928af1SViresh Kumar {.div = 0x054FD},
2450b928af1SViresh Kumar {.div = 0x05000},
2460b928af1SViresh Kumar {.div = 0x04D18},
247ef0fd0a2SDeepak Sikri {.div = 0x04CCE},
2480b928af1SViresh Kumar {.div = 0x04000},
249ef0fd0a2SDeepak Sikri {.div = 0x039D5},
2500b928af1SViresh Kumar {.div = 0x0351E},
2510b928af1SViresh Kumar {.div = 0x03333},
2520b928af1SViresh Kumar {.div = 0x03031},
253ef0fd0a2SDeepak Sikri {.div = 0x03000},
2540b928af1SViresh Kumar {.div = 0x02A7E},
2550b928af1SViresh Kumar {.div = 0x02800},
2560b928af1SViresh Kumar {.div = 0x0268D},
257ef0fd0a2SDeepak Sikri {.div = 0x02666},
2580b928af1SViresh Kumar {.div = 0x02000},
2590b928af1SViresh Kumar };
2600b928af1SViresh Kumar
2610b928af1SViresh Kumar /* aux rate configuration table, in ascending order of rates */
2620b928af1SViresh Kumar static struct aux_rate_tbl aux_rtbl[] = {
263ef0fd0a2SDeepak Sikri /* 12.29MHz for vic1div2=600MHz and 10.24MHz for VCO1div2=500MHz */
264ef0fd0a2SDeepak Sikri {.xscale = 5, .yscale = 122, .eq = 0},
265ef0fd0a2SDeepak Sikri /* 14.70MHz for vic1div2=600MHz and 12.29MHz for VCO1div2=500MHz */
266ef0fd0a2SDeepak Sikri {.xscale = 10, .yscale = 204, .eq = 0},
267ef0fd0a2SDeepak Sikri /* 48MHz for vic1div2=600MHz and 40 MHz for VCO1div2=500MHz */
268ef0fd0a2SDeepak Sikri {.xscale = 4, .yscale = 25, .eq = 0},
269ef0fd0a2SDeepak Sikri /* 57.14MHz for vic1div2=600MHz and 48 MHz for VCO1div2=500MHz */
270ef0fd0a2SDeepak Sikri {.xscale = 4, .yscale = 21, .eq = 0},
271ef0fd0a2SDeepak Sikri /* 83.33MHz for vic1div2=600MHz and 69.44MHz for VCO1div2=500MHz */
272ef0fd0a2SDeepak Sikri {.xscale = 5, .yscale = 18, .eq = 0},
273ef0fd0a2SDeepak Sikri /* 100MHz for vic1div2=600MHz and 83.33 MHz for VCO1div2=500MHz */
274ef0fd0a2SDeepak Sikri {.xscale = 2, .yscale = 6, .eq = 0},
275ef0fd0a2SDeepak Sikri /* 125MHz for vic1div2=600MHz and 104.1MHz for VCO1div2=500MHz */
276ef0fd0a2SDeepak Sikri {.xscale = 5, .yscale = 12, .eq = 0},
277ef0fd0a2SDeepak Sikri /* 150MHz for vic1div2=600MHz and 125MHz for VCO1div2=500MHz */
278ef0fd0a2SDeepak Sikri {.xscale = 2, .yscale = 4, .eq = 0},
279ef0fd0a2SDeepak Sikri /* 166MHz for vic1div2=600MHz and 138.88MHz for VCO1div2=500MHz */
280ef0fd0a2SDeepak Sikri {.xscale = 5, .yscale = 18, .eq = 1},
281ef0fd0a2SDeepak Sikri /* 200MHz for vic1div2=600MHz and 166MHz for VCO1div2=500MHz */
282ef0fd0a2SDeepak Sikri {.xscale = 1, .yscale = 3, .eq = 1},
283ef0fd0a2SDeepak Sikri /* 250MHz for vic1div2=600MHz and 208.33MHz for VCO1div2=500MHz */
284ef0fd0a2SDeepak Sikri {.xscale = 5, .yscale = 12, .eq = 1},
285ef0fd0a2SDeepak Sikri /* 300MHz for vic1div2=600MHz and 250MHz for VCO1div2=500MHz */
286ef0fd0a2SDeepak Sikri {.xscale = 1, .yscale = 2, .eq = 1},
2870b928af1SViresh Kumar };
2880b928af1SViresh Kumar
2890b928af1SViresh Kumar /* gmac rate configuration table, in ascending order of rates */
2900b928af1SViresh Kumar static struct aux_rate_tbl gmac_rtbl[] = {
2910b928af1SViresh Kumar /* For gmac phy input clk */
2920b928af1SViresh Kumar {.xscale = 2, .yscale = 6, .eq = 0}, /* divided by 6 */
2930b928af1SViresh Kumar {.xscale = 2, .yscale = 4, .eq = 0}, /* divided by 4 */
2940b928af1SViresh Kumar {.xscale = 1, .yscale = 3, .eq = 1}, /* divided by 3 */
2950b928af1SViresh Kumar {.xscale = 1, .yscale = 2, .eq = 1}, /* divided by 2 */
2960b928af1SViresh Kumar };
2970b928af1SViresh Kumar
2980b928af1SViresh Kumar /* clcd rate configuration table, in ascending order of rates */
2990b928af1SViresh Kumar static struct frac_rate_tbl clcd_rtbl[] = {
300ef0fd0a2SDeepak Sikri {.div = 0x18000}, /* 25 Mhz , for vc01div4 = 300 MHz*/
301ef0fd0a2SDeepak Sikri {.div = 0x1638E}, /* 27 Mhz , for vc01div4 = 300 MHz*/
3020b928af1SViresh Kumar {.div = 0x14000}, /* 25 Mhz , for vc01div4 = 250 MHz*/
3030b928af1SViresh Kumar {.div = 0x1284B}, /* 27 Mhz , for vc01div4 = 250 MHz*/
3040b928af1SViresh Kumar {.div = 0x0D8D3}, /* 58 Mhz , for vco1div4 = 393 MHz */
3050b928af1SViresh Kumar {.div = 0x0B72C}, /* 58 Mhz , for vco1div4 = 332 MHz */
306ef0fd0a2SDeepak Sikri {.div = 0x0A584}, /* 58 Mhz , for vco1div4 = 300 MHz */
307ef0fd0a2SDeepak Sikri {.div = 0x093B1}, /* 65 Mhz , for vc01div4 = 300 MHz*/
3080b928af1SViresh Kumar {.div = 0x089EE}, /* 58 Mhz , for vc01div4 = 250 MHz*/
309ef0fd0a2SDeepak Sikri {.div = 0x081BA}, /* 74 Mhz , for vc01div4 = 300 MHz*/
3100b928af1SViresh Kumar {.div = 0x07BA0}, /* 65 Mhz , for vc01div4 = 250 MHz*/
3110b928af1SViresh Kumar {.div = 0x06f1C}, /* 72 Mhz , for vc01div4 = 250 MHz*/
3120b928af1SViresh Kumar {.div = 0x06E58}, /* 58 Mhz , for vco1div4 = 200 MHz */
3130b928af1SViresh Kumar {.div = 0x06c1B}, /* 74 Mhz , for vc01div4 = 250 MHz*/
314ef0fd0a2SDeepak Sikri {.div = 0x058E3}, /* 108 Mhz , for vc01div4 = 300 MHz*/
3150b928af1SViresh Kumar {.div = 0x04A12}, /* 108 Mhz , for vc01div4 = 250 MHz*/
316ef0fd0a2SDeepak Sikri {.div = 0x040A5}, /* 148.5 Mhz , for vc01div4 = 300 MHz*/
3170b928af1SViresh Kumar {.div = 0x0378E}, /* 144 Mhz , for vc01div4 = 250 MHz*/
3180b928af1SViresh Kumar {.div = 0x0360D}, /* 148 Mhz , for vc01div4 = 250 MHz*/
3190b928af1SViresh Kumar {.div = 0x035E0}, /* 148.5 MHz, for vc01div4 = 250 MHz*/
3200b928af1SViresh Kumar };
3210b928af1SViresh Kumar
3220b928af1SViresh Kumar /* i2s prescaler1 masks */
32337d2f45dSBhumika Goyal static const struct aux_clk_masks i2s_prs1_masks = {
3240b928af1SViresh Kumar .eq_sel_mask = AUX_EQ_SEL_MASK,
3250b928af1SViresh Kumar .eq_sel_shift = SPEAR1340_I2S_PRS1_EQ_SEL_SHIFT,
3260b928af1SViresh Kumar .eq1_mask = AUX_EQ1_SEL,
3270b928af1SViresh Kumar .eq2_mask = AUX_EQ2_SEL,
3280b928af1SViresh Kumar .xscale_sel_mask = SPEAR1340_I2S_PRS1_CLK_X_MASK,
3290b928af1SViresh Kumar .xscale_sel_shift = SPEAR1340_I2S_PRS1_CLK_X_SHIFT,
3300b928af1SViresh Kumar .yscale_sel_mask = SPEAR1340_I2S_PRS1_CLK_Y_MASK,
3310b928af1SViresh Kumar .yscale_sel_shift = SPEAR1340_I2S_PRS1_CLK_Y_SHIFT,
3320b928af1SViresh Kumar };
3330b928af1SViresh Kumar
3340b928af1SViresh Kumar /* i2s sclk (bit clock) syynthesizers masks */
335f5c009dbSNishka Dasgupta static const struct aux_clk_masks i2s_sclk_masks = {
3360b928af1SViresh Kumar .eq_sel_mask = AUX_EQ_SEL_MASK,
3370b928af1SViresh Kumar .eq_sel_shift = SPEAR1340_I2S_SCLK_EQ_SEL_SHIFT,
3380b928af1SViresh Kumar .eq1_mask = AUX_EQ1_SEL,
3390b928af1SViresh Kumar .eq2_mask = AUX_EQ2_SEL,
3400b928af1SViresh Kumar .xscale_sel_mask = SPEAR1340_I2S_SCLK_X_MASK,
3410b928af1SViresh Kumar .xscale_sel_shift = SPEAR1340_I2S_SCLK_X_SHIFT,
3420b928af1SViresh Kumar .yscale_sel_mask = SPEAR1340_I2S_SCLK_Y_MASK,
3430b928af1SViresh Kumar .yscale_sel_shift = SPEAR1340_I2S_SCLK_Y_SHIFT,
3440b928af1SViresh Kumar .enable_bit = SPEAR1340_I2S_SCLK_SYNTH_ENB,
3450b928af1SViresh Kumar };
3460b928af1SViresh Kumar
3470b928af1SViresh Kumar /* i2s prs1 aux rate configuration table, in ascending order of rates */
3480b928af1SViresh Kumar static struct aux_rate_tbl i2s_prs1_rtbl[] = {
3490b928af1SViresh Kumar /* For parent clk = 49.152 MHz */
3500b928af1SViresh Kumar {.xscale = 1, .yscale = 12, .eq = 0}, /* 2.048 MHz, smp freq = 8Khz */
3510b928af1SViresh Kumar {.xscale = 11, .yscale = 96, .eq = 0}, /* 2.816 MHz, smp freq = 11Khz */
3520b928af1SViresh Kumar {.xscale = 1, .yscale = 6, .eq = 0}, /* 4.096 MHz, smp freq = 16Khz */
3530b928af1SViresh Kumar {.xscale = 11, .yscale = 48, .eq = 0}, /* 5.632 MHz, smp freq = 22Khz */
3540b928af1SViresh Kumar
3550b928af1SViresh Kumar /*
3560b928af1SViresh Kumar * with parent clk = 49.152, freq gen is 8.192 MHz, smp freq = 32Khz
3570b928af1SViresh Kumar * with parent clk = 12.288, freq gen is 2.048 MHz, smp freq = 8Khz
3580b928af1SViresh Kumar */
3590b928af1SViresh Kumar {.xscale = 1, .yscale = 3, .eq = 0},
3600b928af1SViresh Kumar
3610b928af1SViresh Kumar /* For parent clk = 49.152 MHz */
3620b928af1SViresh Kumar {.xscale = 17, .yscale = 37, .eq = 0}, /* 11.289 MHz, smp freq = 44Khz*/
3630b928af1SViresh Kumar {.xscale = 1, .yscale = 2, .eq = 0}, /* 12.288 MHz, smp freq = 48Khz*/
3640b928af1SViresh Kumar };
3650b928af1SViresh Kumar
3660b928af1SViresh Kumar /* i2s sclk aux rate configuration table, in ascending order of rates */
3670b928af1SViresh Kumar static struct aux_rate_tbl i2s_sclk_rtbl[] = {
3680b928af1SViresh Kumar /* For sclk = ref_clk * x/2/y */
3690b928af1SViresh Kumar {.xscale = 1, .yscale = 4, .eq = 0},
3700b928af1SViresh Kumar {.xscale = 1, .yscale = 2, .eq = 0},
3710b928af1SViresh Kumar };
3720b928af1SViresh Kumar
3730b928af1SViresh Kumar /* adc rate configuration table, in ascending order of rates */
3740b928af1SViresh Kumar /* possible adc range is 2.5 MHz to 20 MHz. */
3750b928af1SViresh Kumar static struct aux_rate_tbl adc_rtbl[] = {
3760b928af1SViresh Kumar /* For ahb = 166.67 MHz */
3770b928af1SViresh Kumar {.xscale = 1, .yscale = 31, .eq = 0}, /* 2.68 MHz */
3780b928af1SViresh Kumar {.xscale = 2, .yscale = 21, .eq = 0}, /* 7.94 MHz */
3790b928af1SViresh Kumar {.xscale = 4, .yscale = 21, .eq = 0}, /* 15.87 MHz */
3800b928af1SViresh Kumar {.xscale = 10, .yscale = 42, .eq = 0}, /* 19.84 MHz */
3810b928af1SViresh Kumar };
3820b928af1SViresh Kumar
3830b928af1SViresh Kumar /* General synth rate configuration table, in ascending order of rates */
3840b928af1SViresh Kumar static struct frac_rate_tbl gen_rtbl[] = {
385ef0fd0a2SDeepak Sikri {.div = 0x1A92B}, /* 22.5792 MHz for vco1div4=300 MHz*/
386ef0fd0a2SDeepak Sikri {.div = 0x186A0}, /* 24.576 MHz for vco1div4=300 MHz*/
387ef0fd0a2SDeepak Sikri {.div = 0x18000}, /* 25 MHz for vco1div4=300 MHz*/
388ef0fd0a2SDeepak Sikri {.div = 0x1624E}, /* 22.5792 MHz for vco1div4=250 MHz*/
389ef0fd0a2SDeepak Sikri {.div = 0x14585}, /* 24.576 MHz for vco1div4=250 MHz*/
390ef0fd0a2SDeepak Sikri {.div = 0x14000}, /* 25 MHz for vco1div4=250 MHz*/
391ef0fd0a2SDeepak Sikri {.div = 0x0D495}, /* 45.1584 MHz for vco1div4=300 MHz*/
392ef0fd0a2SDeepak Sikri {.div = 0x0C000}, /* 50 MHz for vco1div4=300 MHz*/
393ef0fd0a2SDeepak Sikri {.div = 0x0B127}, /* 45.1584 MHz for vco1div4=250 MHz*/
394ef0fd0a2SDeepak Sikri {.div = 0x0A000}, /* 50 MHz for vco1div4=250 MHz*/
395ef0fd0a2SDeepak Sikri {.div = 0x07530}, /* 81.92 MHz for vco1div4=300 MHz*/
396ef0fd0a2SDeepak Sikri {.div = 0x061A8}, /* 81.92 MHz for vco1div4=250 MHz*/
397ef0fd0a2SDeepak Sikri {.div = 0x06000}, /* 100 MHz for vco1div4=300 MHz*/
398ef0fd0a2SDeepak Sikri {.div = 0x05000}, /* 100 MHz for vco1div4=250 MHz*/
399ef0fd0a2SDeepak Sikri {.div = 0x03000}, /* 200 MHz for vco1div4=300 MHz*/
400ef0fd0a2SDeepak Sikri {.div = 0x02DB6}, /* 210 MHz for vco1div4=300 MHz*/
401ef0fd0a2SDeepak Sikri {.div = 0x02BA2}, /* 220 MHz for vco1div4=300 MHz*/
402ef0fd0a2SDeepak Sikri {.div = 0x029BD}, /* 230 MHz for vco1div4=300 MHz*/
403ef0fd0a2SDeepak Sikri {.div = 0x02800}, /* 200 MHz for vco1div4=250 MHz*/
404ef0fd0a2SDeepak Sikri {.div = 0x02666}, /* 250 MHz for vco1div4=300 MHz*/
405ef0fd0a2SDeepak Sikri {.div = 0x02620}, /* 210 MHz for vco1div4=250 MHz*/
406ef0fd0a2SDeepak Sikri {.div = 0x02460}, /* 220 MHz for vco1div4=250 MHz*/
407ef0fd0a2SDeepak Sikri {.div = 0x022C0}, /* 230 MHz for vco1div4=250 MHz*/
408ef0fd0a2SDeepak Sikri {.div = 0x02160}, /* 240 MHz for vco1div4=250 MHz*/
409ef0fd0a2SDeepak Sikri {.div = 0x02000}, /* 250 MHz for vco1div4=250 MHz*/
4100b928af1SViresh Kumar };
4110b928af1SViresh Kumar
4120b928af1SViresh Kumar /* clock parents */
4130b928af1SViresh Kumar static const char *vco_parents[] = { "osc_24m_clk", "osc_25m_clk", };
414d4f513ffSVipul Kumar Samar static const char *sys_parents[] = { "pll1_clk", "pll1_clk", "pll1_clk",
415463f9e20SShiraz Hashim "pll1_clk", "sys_syn_clk", "sys_syn_clk", "pll2_clk", "pll3_clk", };
4165cb6a9bcSVipul Kumar Samar static const char *ahb_parents[] = { "cpu_div3_clk", "amba_syn_clk", };
4170b928af1SViresh Kumar static const char *gpt_parents[] = { "osc_24m_clk", "apb_clk", };
4180b928af1SViresh Kumar static const char *uart0_parents[] = { "pll5_clk", "osc_24m_clk",
4195cb6a9bcSVipul Kumar Samar "uart0_syn_gclk", };
4200b928af1SViresh Kumar static const char *uart1_parents[] = { "pll5_clk", "osc_24m_clk",
4215cb6a9bcSVipul Kumar Samar "uart1_syn_gclk", };
4225cb6a9bcSVipul Kumar Samar static const char *c3_parents[] = { "pll5_clk", "c3_syn_gclk", };
4235cb6a9bcSVipul Kumar Samar static const char *gmac_phy_input_parents[] = { "gmii_pad_clk", "pll2_clk",
4240b928af1SViresh Kumar "osc_25m_clk", };
4255cb6a9bcSVipul Kumar Samar static const char *gmac_phy_parents[] = { "phy_input_mclk", "phy_syn_gclk", };
4260b928af1SViresh Kumar static const char *clcd_synth_parents[] = { "vco1div4_clk", "pll2_clk", };
4275cb6a9bcSVipul Kumar Samar static const char *clcd_pixel_parents[] = { "pll5_clk", "clcd_syn_clk", };
4280b928af1SViresh Kumar static const char *i2s_src_parents[] = { "vco1div2_clk", "pll2_clk", "pll3_clk",
4290b928af1SViresh Kumar "i2s_src_pad_clk", };
4305cb6a9bcSVipul Kumar Samar static const char *i2s_ref_parents[] = { "i2s_src_mclk", "i2s_prs1_clk", };
4315cb6a9bcSVipul Kumar Samar static const char *spdif_out_parents[] = { "i2s_src_pad_clk", "gen_syn2_clk", };
4325cb6a9bcSVipul Kumar Samar static const char *spdif_in_parents[] = { "pll2_clk", "gen_syn3_clk", };
4330b928af1SViresh Kumar
4340b928af1SViresh Kumar static const char *gen_synth0_1_parents[] = { "vco1div4_clk", "vco3div2_clk",
4350b928af1SViresh Kumar "pll3_clk", };
436463f9e20SShiraz Hashim static const char *gen_synth2_3_parents[] = { "vco1div4_clk", "vco2div2_clk",
4370b928af1SViresh Kumar "pll2_clk", };
4380b928af1SViresh Kumar
spear1340_clk_init(void __iomem * misc_base)439d9909ebeSArnd Bergmann void __init spear1340_clk_init(void __iomem *misc_base)
4400b928af1SViresh Kumar {
4410b928af1SViresh Kumar struct clk *clk, *clk1;
4420b928af1SViresh Kumar
443afb4bdc9SStephen Boyd clk = clk_register_fixed_rate(NULL, "osc_32k_clk", NULL, 0, 32000);
4440b928af1SViresh Kumar clk_register_clkdev(clk, "osc_32k_clk", NULL);
4450b928af1SViresh Kumar
446afb4bdc9SStephen Boyd clk = clk_register_fixed_rate(NULL, "osc_24m_clk", NULL, 0, 24000000);
4470b928af1SViresh Kumar clk_register_clkdev(clk, "osc_24m_clk", NULL);
4480b928af1SViresh Kumar
449afb4bdc9SStephen Boyd clk = clk_register_fixed_rate(NULL, "osc_25m_clk", NULL, 0, 25000000);
4500b928af1SViresh Kumar clk_register_clkdev(clk, "osc_25m_clk", NULL);
4510b928af1SViresh Kumar
452afb4bdc9SStephen Boyd clk = clk_register_fixed_rate(NULL, "gmii_pad_clk", NULL, 0, 125000000);
4535cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "gmii_pad_clk", NULL);
4540b928af1SViresh Kumar
455afb4bdc9SStephen Boyd clk = clk_register_fixed_rate(NULL, "i2s_src_pad_clk", NULL, 0,
456afb4bdc9SStephen Boyd 12288000);
4570b928af1SViresh Kumar clk_register_clkdev(clk, "i2s_src_pad_clk", NULL);
4580b928af1SViresh Kumar
4590b928af1SViresh Kumar /* clock derived from 32 KHz osc clk */
4600b928af1SViresh Kumar clk = clk_register_gate(NULL, "rtc-spear", "osc_32k_clk", 0,
4610b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_RTC_CLK_ENB, 0,
4620b928af1SViresh Kumar &_lock);
463df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "e0580000.rtc");
4640b928af1SViresh Kumar
4650b928af1SViresh Kumar /* clock derived from 24 or 25 MHz osc clk */
4660b928af1SViresh Kumar /* vco-pll */
4675cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "vco1_mclk", vco_parents,
468819c1de3SJames Hogan ARRAY_SIZE(vco_parents), CLK_SET_RATE_NO_REPARENT,
469819c1de3SJames Hogan SPEAR1340_PLL_CFG, SPEAR1340_PLL1_CLK_SHIFT,
470819c1de3SJames Hogan SPEAR1340_PLL_CLK_MASK, 0, &_lock);
4715cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "vco1_mclk", NULL);
4725cb6a9bcSVipul Kumar Samar clk = clk_register_vco_pll("vco1_clk", "pll1_clk", NULL, "vco1_mclk", 0,
4735cb6a9bcSVipul Kumar Samar SPEAR1340_PLL1_CTR, SPEAR1340_PLL1_FRQ, pll_rtbl,
4740b928af1SViresh Kumar ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL);
4750b928af1SViresh Kumar clk_register_clkdev(clk, "vco1_clk", NULL);
4760b928af1SViresh Kumar clk_register_clkdev(clk1, "pll1_clk", NULL);
4770b928af1SViresh Kumar
4785cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "vco2_mclk", vco_parents,
479819c1de3SJames Hogan ARRAY_SIZE(vco_parents), CLK_SET_RATE_NO_REPARENT,
480819c1de3SJames Hogan SPEAR1340_PLL_CFG, SPEAR1340_PLL2_CLK_SHIFT,
481819c1de3SJames Hogan SPEAR1340_PLL_CLK_MASK, 0, &_lock);
4825cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "vco2_mclk", NULL);
4835cb6a9bcSVipul Kumar Samar clk = clk_register_vco_pll("vco2_clk", "pll2_clk", NULL, "vco2_mclk", 0,
4845cb6a9bcSVipul Kumar Samar SPEAR1340_PLL2_CTR, SPEAR1340_PLL2_FRQ, pll_rtbl,
4850b928af1SViresh Kumar ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL);
4860b928af1SViresh Kumar clk_register_clkdev(clk, "vco2_clk", NULL);
4870b928af1SViresh Kumar clk_register_clkdev(clk1, "pll2_clk", NULL);
4880b928af1SViresh Kumar
4895cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "vco3_mclk", vco_parents,
490819c1de3SJames Hogan ARRAY_SIZE(vco_parents), CLK_SET_RATE_NO_REPARENT,
491819c1de3SJames Hogan SPEAR1340_PLL_CFG, SPEAR1340_PLL3_CLK_SHIFT,
492819c1de3SJames Hogan SPEAR1340_PLL_CLK_MASK, 0, &_lock);
4935cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "vco3_mclk", NULL);
4945cb6a9bcSVipul Kumar Samar clk = clk_register_vco_pll("vco3_clk", "pll3_clk", NULL, "vco3_mclk", 0,
4955cb6a9bcSVipul Kumar Samar SPEAR1340_PLL3_CTR, SPEAR1340_PLL3_FRQ, pll_rtbl,
4960b928af1SViresh Kumar ARRAY_SIZE(pll_rtbl), &_lock, &clk1, NULL);
4970b928af1SViresh Kumar clk_register_clkdev(clk, "vco3_clk", NULL);
4980b928af1SViresh Kumar clk_register_clkdev(clk1, "pll3_clk", NULL);
4990b928af1SViresh Kumar
5000b928af1SViresh Kumar clk = clk_register_vco_pll("vco4_clk", "pll4_clk", NULL, "osc_24m_clk",
5010b928af1SViresh Kumar 0, SPEAR1340_PLL4_CTR, SPEAR1340_PLL4_FRQ, pll4_rtbl,
5020b928af1SViresh Kumar ARRAY_SIZE(pll4_rtbl), &_lock, &clk1, NULL);
5030b928af1SViresh Kumar clk_register_clkdev(clk, "vco4_clk", NULL);
5040b928af1SViresh Kumar clk_register_clkdev(clk1, "pll4_clk", NULL);
5050b928af1SViresh Kumar
5060b928af1SViresh Kumar clk = clk_register_fixed_rate(NULL, "pll5_clk", "osc_24m_clk", 0,
5070b928af1SViresh Kumar 48000000);
5080b928af1SViresh Kumar clk_register_clkdev(clk, "pll5_clk", NULL);
5090b928af1SViresh Kumar
5100b928af1SViresh Kumar clk = clk_register_fixed_rate(NULL, "pll6_clk", "osc_25m_clk", 0,
5110b928af1SViresh Kumar 25000000);
5120b928af1SViresh Kumar clk_register_clkdev(clk, "pll6_clk", NULL);
5130b928af1SViresh Kumar
5140b928af1SViresh Kumar /* vco div n clocks */
5150b928af1SViresh Kumar clk = clk_register_fixed_factor(NULL, "vco1div2_clk", "vco1_clk", 0, 1,
5160b928af1SViresh Kumar 2);
5170b928af1SViresh Kumar clk_register_clkdev(clk, "vco1div2_clk", NULL);
5180b928af1SViresh Kumar
5190b928af1SViresh Kumar clk = clk_register_fixed_factor(NULL, "vco1div4_clk", "vco1_clk", 0, 1,
5200b928af1SViresh Kumar 4);
5210b928af1SViresh Kumar clk_register_clkdev(clk, "vco1div4_clk", NULL);
5220b928af1SViresh Kumar
5230b928af1SViresh Kumar clk = clk_register_fixed_factor(NULL, "vco2div2_clk", "vco2_clk", 0, 1,
5240b928af1SViresh Kumar 2);
5250b928af1SViresh Kumar clk_register_clkdev(clk, "vco2div2_clk", NULL);
5260b928af1SViresh Kumar
5270b928af1SViresh Kumar clk = clk_register_fixed_factor(NULL, "vco3div2_clk", "vco3_clk", 0, 1,
5280b928af1SViresh Kumar 2);
5290b928af1SViresh Kumar clk_register_clkdev(clk, "vco3div2_clk", NULL);
5300b928af1SViresh Kumar
5310b928af1SViresh Kumar /* peripherals */
5320b928af1SViresh Kumar clk_register_fixed_factor(NULL, "thermal_clk", "osc_24m_clk", 0, 1,
5330b928af1SViresh Kumar 128);
5345cb6a9bcSVipul Kumar Samar clk = clk_register_gate(NULL, "thermal_gclk", "thermal_clk", 0,
5350b928af1SViresh Kumar SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_THSENS_CLK_ENB, 0,
5360b928af1SViresh Kumar &_lock);
537df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "e07008c4.thermal");
5380b928af1SViresh Kumar
5390b928af1SViresh Kumar /* clock derived from pll4 clk */
5400b928af1SViresh Kumar clk = clk_register_fixed_factor(NULL, "ddr_clk", "pll4_clk", 0, 1,
5410b928af1SViresh Kumar 1);
5420b928af1SViresh Kumar clk_register_clkdev(clk, "ddr_clk", NULL);
5430b928af1SViresh Kumar
5440b928af1SViresh Kumar /* clock derived from pll1 clk */
5455cb6a9bcSVipul Kumar Samar clk = clk_register_frac("sys_syn_clk", "vco1div2_clk", 0,
5460b928af1SViresh Kumar SPEAR1340_SYS_CLK_SYNT, sys_synth_rtbl,
5470b928af1SViresh Kumar ARRAY_SIZE(sys_synth_rtbl), &_lock);
5485cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "sys_syn_clk", NULL);
5490b928af1SViresh Kumar
5505cb6a9bcSVipul Kumar Samar clk = clk_register_frac("amba_syn_clk", "vco1div2_clk", 0,
5510b928af1SViresh Kumar SPEAR1340_AMBA_CLK_SYNT, amba_synth_rtbl,
5520b928af1SViresh Kumar ARRAY_SIZE(amba_synth_rtbl), &_lock);
5535cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "amba_syn_clk", NULL);
5540b928af1SViresh Kumar
5555cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "sys_mclk", sys_parents,
556819c1de3SJames Hogan ARRAY_SIZE(sys_parents), CLK_SET_RATE_NO_REPARENT,
557819c1de3SJames Hogan SPEAR1340_SYS_CLK_CTRL, SPEAR1340_SCLK_SRC_SEL_SHIFT,
5580b928af1SViresh Kumar SPEAR1340_SCLK_SRC_SEL_MASK, 0, &_lock);
559e0b9c210SShiraz Hashim clk_register_clkdev(clk, "sys_mclk", NULL);
5600b928af1SViresh Kumar
5615cb6a9bcSVipul Kumar Samar clk = clk_register_fixed_factor(NULL, "cpu_clk", "sys_mclk", 0, 1,
5620b928af1SViresh Kumar 2);
5630b928af1SViresh Kumar clk_register_clkdev(clk, "cpu_clk", NULL);
5640b928af1SViresh Kumar
5650b928af1SViresh Kumar clk = clk_register_fixed_factor(NULL, "cpu_div3_clk", "cpu_clk", 0, 1,
5660b928af1SViresh Kumar 3);
5670b928af1SViresh Kumar clk_register_clkdev(clk, "cpu_div3_clk", NULL);
5680b928af1SViresh Kumar
5690b928af1SViresh Kumar clk = clk_register_fixed_factor(NULL, "wdt_clk", "cpu_clk", 0, 1,
5700b928af1SViresh Kumar 2);
5710b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "ec800620.wdt");
5720b928af1SViresh Kumar
573cd4b519aSVipul Kumar Samar clk = clk_register_fixed_factor(NULL, "smp_twd_clk", "cpu_clk", 0, 1,
574cd4b519aSVipul Kumar Samar 2);
575cd4b519aSVipul Kumar Samar clk_register_clkdev(clk, NULL, "smp_twd");
576cd4b519aSVipul Kumar Samar
5770b928af1SViresh Kumar clk = clk_register_mux(NULL, "ahb_clk", ahb_parents,
578819c1de3SJames Hogan ARRAY_SIZE(ahb_parents), CLK_SET_RATE_NO_REPARENT,
579819c1de3SJames Hogan SPEAR1340_SYS_CLK_CTRL, SPEAR1340_HCLK_SRC_SEL_SHIFT,
5800b928af1SViresh Kumar SPEAR1340_HCLK_SRC_SEL_MASK, 0, &_lock);
5810b928af1SViresh Kumar clk_register_clkdev(clk, "ahb_clk", NULL);
5820b928af1SViresh Kumar
5830b928af1SViresh Kumar clk = clk_register_fixed_factor(NULL, "apb_clk", "ahb_clk", 0, 1,
5840b928af1SViresh Kumar 2);
5850b928af1SViresh Kumar clk_register_clkdev(clk, "apb_clk", NULL);
5860b928af1SViresh Kumar
5870b928af1SViresh Kumar /* gpt clocks */
5885cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "gpt0_mclk", gpt_parents,
589819c1de3SJames Hogan ARRAY_SIZE(gpt_parents), CLK_SET_RATE_NO_REPARENT,
590819c1de3SJames Hogan SPEAR1340_PERIP_CLK_CFG, SPEAR1340_GPT0_CLK_SHIFT,
591819c1de3SJames Hogan SPEAR1340_GPT_CLK_MASK, 0, &_lock);
5925cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "gpt0_mclk", NULL);
5935cb6a9bcSVipul Kumar Samar clk = clk_register_gate(NULL, "gpt0_clk", "gpt0_mclk", 0,
5940b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_GPT0_CLK_ENB, 0,
5950b928af1SViresh Kumar &_lock);
5960b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "gpt0");
5970b928af1SViresh Kumar
5985cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "gpt1_mclk", gpt_parents,
599819c1de3SJames Hogan ARRAY_SIZE(gpt_parents), CLK_SET_RATE_NO_REPARENT,
600819c1de3SJames Hogan SPEAR1340_PERIP_CLK_CFG, SPEAR1340_GPT1_CLK_SHIFT,
601819c1de3SJames Hogan SPEAR1340_GPT_CLK_MASK, 0, &_lock);
6025cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "gpt1_mclk", NULL);
6035cb6a9bcSVipul Kumar Samar clk = clk_register_gate(NULL, "gpt1_clk", "gpt1_mclk", 0,
6040b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_GPT1_CLK_ENB, 0,
6050b928af1SViresh Kumar &_lock);
6060b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "gpt1");
6070b928af1SViresh Kumar
6085cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "gpt2_mclk", gpt_parents,
609819c1de3SJames Hogan ARRAY_SIZE(gpt_parents), CLK_SET_RATE_NO_REPARENT,
610819c1de3SJames Hogan SPEAR1340_PERIP_CLK_CFG, SPEAR1340_GPT2_CLK_SHIFT,
611819c1de3SJames Hogan SPEAR1340_GPT_CLK_MASK, 0, &_lock);
6125cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "gpt2_mclk", NULL);
6135cb6a9bcSVipul Kumar Samar clk = clk_register_gate(NULL, "gpt2_clk", "gpt2_mclk", 0,
6140b928af1SViresh Kumar SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_GPT2_CLK_ENB, 0,
6150b928af1SViresh Kumar &_lock);
6160b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "gpt2");
6170b928af1SViresh Kumar
6185cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "gpt3_mclk", gpt_parents,
619819c1de3SJames Hogan ARRAY_SIZE(gpt_parents), CLK_SET_RATE_NO_REPARENT,
620819c1de3SJames Hogan SPEAR1340_PERIP_CLK_CFG, SPEAR1340_GPT3_CLK_SHIFT,
621819c1de3SJames Hogan SPEAR1340_GPT_CLK_MASK, 0, &_lock);
6225cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "gpt3_mclk", NULL);
6235cb6a9bcSVipul Kumar Samar clk = clk_register_gate(NULL, "gpt3_clk", "gpt3_mclk", 0,
6240b928af1SViresh Kumar SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_GPT3_CLK_ENB, 0,
6250b928af1SViresh Kumar &_lock);
6260b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "gpt3");
6270b928af1SViresh Kumar
6280b928af1SViresh Kumar /* others */
6295cb6a9bcSVipul Kumar Samar clk = clk_register_aux("uart0_syn_clk", "uart0_syn_gclk",
6300b928af1SViresh Kumar "vco1div2_clk", 0, SPEAR1340_UART0_CLK_SYNT, NULL,
6310b928af1SViresh Kumar aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
6325cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "uart0_syn_clk", NULL);
6335cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk1, "uart0_syn_gclk", NULL);
6340b928af1SViresh Kumar
6355cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "uart0_mclk", uart0_parents,
636819c1de3SJames Hogan ARRAY_SIZE(uart0_parents),
637819c1de3SJames Hogan CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
63812499792SVipul Kumar Samar SPEAR1340_PERIP_CLK_CFG, SPEAR1340_UART0_CLK_SHIFT,
63912499792SVipul Kumar Samar SPEAR1340_UART_CLK_MASK, 0, &_lock);
6405cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "uart0_mclk", NULL);
6410b928af1SViresh Kumar
64212499792SVipul Kumar Samar clk = clk_register_gate(NULL, "uart0_clk", "uart0_mclk",
64312499792SVipul Kumar Samar CLK_SET_RATE_PARENT, SPEAR1340_PERIP1_CLK_ENB,
64412499792SVipul Kumar Samar SPEAR1340_UART0_CLK_ENB, 0, &_lock);
6450b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "e0000000.serial");
6460b928af1SViresh Kumar
6475cb6a9bcSVipul Kumar Samar clk = clk_register_aux("uart1_syn_clk", "uart1_syn_gclk",
6480b928af1SViresh Kumar "vco1div2_clk", 0, SPEAR1340_UART1_CLK_SYNT, NULL,
6490b928af1SViresh Kumar aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
6505cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "uart1_syn_clk", NULL);
6515cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk1, "uart1_syn_gclk", NULL);
6520b928af1SViresh Kumar
6535cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "uart1_mclk", uart1_parents,
654819c1de3SJames Hogan ARRAY_SIZE(uart1_parents), CLK_SET_RATE_NO_REPARENT,
655819c1de3SJames Hogan SPEAR1340_PERIP_CLK_CFG, SPEAR1340_UART1_CLK_SHIFT,
656819c1de3SJames Hogan SPEAR1340_UART_CLK_MASK, 0, &_lock);
6575cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "uart1_mclk", NULL);
6580b928af1SViresh Kumar
6595cb6a9bcSVipul Kumar Samar clk = clk_register_gate(NULL, "uart1_clk", "uart1_mclk", 0,
660d9ba8db2SVipul Kumar Samar SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_UART1_CLK_ENB, 0,
6610b928af1SViresh Kumar &_lock);
6620b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "b4100000.serial");
6630b928af1SViresh Kumar
6645cb6a9bcSVipul Kumar Samar clk = clk_register_aux("sdhci_syn_clk", "sdhci_syn_gclk",
6650b928af1SViresh Kumar "vco1div2_clk", 0, SPEAR1340_SDHCI_CLK_SYNT, NULL,
6660b928af1SViresh Kumar aux_rtbl, ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
6675cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "sdhci_syn_clk", NULL);
6685cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk1, "sdhci_syn_gclk", NULL);
6690b928af1SViresh Kumar
67012499792SVipul Kumar Samar clk = clk_register_gate(NULL, "sdhci_clk", "sdhci_syn_gclk",
67112499792SVipul Kumar Samar CLK_SET_RATE_PARENT, SPEAR1340_PERIP1_CLK_ENB,
67212499792SVipul Kumar Samar SPEAR1340_SDHCI_CLK_ENB, 0, &_lock);
6730b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "b3000000.sdhci");
6740b928af1SViresh Kumar
6755cb6a9bcSVipul Kumar Samar clk = clk_register_aux("cfxd_syn_clk", "cfxd_syn_gclk", "vco1div2_clk",
6765cb6a9bcSVipul Kumar Samar 0, SPEAR1340_CFXD_CLK_SYNT, NULL, aux_rtbl,
6775cb6a9bcSVipul Kumar Samar ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
6785cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "cfxd_syn_clk", NULL);
6795cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk1, "cfxd_syn_gclk", NULL);
6800b928af1SViresh Kumar
68112499792SVipul Kumar Samar clk = clk_register_gate(NULL, "cfxd_clk", "cfxd_syn_gclk",
68212499792SVipul Kumar Samar CLK_SET_RATE_PARENT, SPEAR1340_PERIP1_CLK_ENB,
68312499792SVipul Kumar Samar SPEAR1340_CFXD_CLK_ENB, 0, &_lock);
6840b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "b2800000.cf");
6850b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "arasan_xd");
6860b928af1SViresh Kumar
6875cb6a9bcSVipul Kumar Samar clk = clk_register_aux("c3_syn_clk", "c3_syn_gclk", "vco1div2_clk", 0,
6885cb6a9bcSVipul Kumar Samar SPEAR1340_C3_CLK_SYNT, NULL, aux_rtbl,
6895cb6a9bcSVipul Kumar Samar ARRAY_SIZE(aux_rtbl), &_lock, &clk1);
6905cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "c3_syn_clk", NULL);
6915cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk1, "c3_syn_gclk", NULL);
6920b928af1SViresh Kumar
6935cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "c3_mclk", c3_parents,
694819c1de3SJames Hogan ARRAY_SIZE(c3_parents),
695819c1de3SJames Hogan CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
69612499792SVipul Kumar Samar SPEAR1340_PERIP_CLK_CFG, SPEAR1340_C3_CLK_SHIFT,
69712499792SVipul Kumar Samar SPEAR1340_C3_CLK_MASK, 0, &_lock);
6985cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "c3_mclk", NULL);
6990b928af1SViresh Kumar
70012499792SVipul Kumar Samar clk = clk_register_gate(NULL, "c3_clk", "c3_mclk", CLK_SET_RATE_PARENT,
7010b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_C3_CLK_ENB, 0,
7020b928af1SViresh Kumar &_lock);
703df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "e1800000.c3");
7040b928af1SViresh Kumar
7050b928af1SViresh Kumar /* gmac */
7065cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "phy_input_mclk", gmac_phy_input_parents,
707819c1de3SJames Hogan ARRAY_SIZE(gmac_phy_input_parents),
708819c1de3SJames Hogan CLK_SET_RATE_NO_REPARENT, SPEAR1340_GMAC_CLK_CFG,
7090b928af1SViresh Kumar SPEAR1340_GMAC_PHY_INPUT_CLK_SHIFT,
7100b928af1SViresh Kumar SPEAR1340_GMAC_PHY_INPUT_CLK_MASK, 0, &_lock);
7115cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "phy_input_mclk", NULL);
7120b928af1SViresh Kumar
7135cb6a9bcSVipul Kumar Samar clk = clk_register_aux("phy_syn_clk", "phy_syn_gclk", "phy_input_mclk",
7145cb6a9bcSVipul Kumar Samar 0, SPEAR1340_GMAC_CLK_SYNT, NULL, gmac_rtbl,
7155cb6a9bcSVipul Kumar Samar ARRAY_SIZE(gmac_rtbl), &_lock, &clk1);
7165cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "phy_syn_clk", NULL);
7175cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk1, "phy_syn_gclk", NULL);
7180b928af1SViresh Kumar
7195cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "phy_mclk", gmac_phy_parents,
720819c1de3SJames Hogan ARRAY_SIZE(gmac_phy_parents), CLK_SET_RATE_NO_REPARENT,
7210b928af1SViresh Kumar SPEAR1340_PERIP_CLK_CFG, SPEAR1340_GMAC_PHY_CLK_SHIFT,
7220b928af1SViresh Kumar SPEAR1340_GMAC_PHY_CLK_MASK, 0, &_lock);
723df2449abSRajeev Kumar clk_register_clkdev(clk, "stmmacphy.0", NULL);
7240b928af1SViresh Kumar
7250b928af1SViresh Kumar /* clcd */
7265cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "clcd_syn_mclk", clcd_synth_parents,
727819c1de3SJames Hogan ARRAY_SIZE(clcd_synth_parents),
728819c1de3SJames Hogan CLK_SET_RATE_NO_REPARENT, SPEAR1340_CLCD_CLK_SYNT,
729819c1de3SJames Hogan SPEAR1340_CLCD_SYNT_CLK_SHIFT,
7300b928af1SViresh Kumar SPEAR1340_CLCD_SYNT_CLK_MASK, 0, &_lock);
7315cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "clcd_syn_mclk", NULL);
7320b928af1SViresh Kumar
7335cb6a9bcSVipul Kumar Samar clk = clk_register_frac("clcd_syn_clk", "clcd_syn_mclk", 0,
7340b928af1SViresh Kumar SPEAR1340_CLCD_CLK_SYNT, clcd_rtbl,
7350b928af1SViresh Kumar ARRAY_SIZE(clcd_rtbl), &_lock);
7365cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "clcd_syn_clk", NULL);
7370b928af1SViresh Kumar
7385cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "clcd_pixel_mclk", clcd_pixel_parents,
739819c1de3SJames Hogan ARRAY_SIZE(clcd_pixel_parents),
740819c1de3SJames Hogan CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
7410b928af1SViresh Kumar SPEAR1340_PERIP_CLK_CFG, SPEAR1340_CLCD_CLK_SHIFT,
7420b928af1SViresh Kumar SPEAR1340_CLCD_CLK_MASK, 0, &_lock);
743e0b9c210SShiraz Hashim clk_register_clkdev(clk, "clcd_pixel_mclk", NULL);
7440b928af1SViresh Kumar
7455cb6a9bcSVipul Kumar Samar clk = clk_register_gate(NULL, "clcd_clk", "clcd_pixel_mclk", 0,
7460b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_CLCD_CLK_ENB, 0,
7470b928af1SViresh Kumar &_lock);
748df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "e1000000.clcd");
7490b928af1SViresh Kumar
7500b928af1SViresh Kumar /* i2s */
7515cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "i2s_src_mclk", i2s_src_parents,
752819c1de3SJames Hogan ARRAY_SIZE(i2s_src_parents), CLK_SET_RATE_NO_REPARENT,
753819c1de3SJames Hogan SPEAR1340_I2S_CLK_CFG, SPEAR1340_I2S_SRC_CLK_SHIFT,
754819c1de3SJames Hogan SPEAR1340_I2S_SRC_CLK_MASK, 0, &_lock);
755e0b9c210SShiraz Hashim clk_register_clkdev(clk, "i2s_src_mclk", NULL);
7560b928af1SViresh Kumar
75712499792SVipul Kumar Samar clk = clk_register_aux("i2s_prs1_clk", NULL, "i2s_src_mclk",
75812499792SVipul Kumar Samar CLK_SET_RATE_PARENT, SPEAR1340_I2S_CLK_CFG,
75912499792SVipul Kumar Samar &i2s_prs1_masks, i2s_prs1_rtbl,
7600b928af1SViresh Kumar ARRAY_SIZE(i2s_prs1_rtbl), &_lock, NULL);
7610b928af1SViresh Kumar clk_register_clkdev(clk, "i2s_prs1_clk", NULL);
7620b928af1SViresh Kumar
7635cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "i2s_ref_mclk", i2s_ref_parents,
764819c1de3SJames Hogan ARRAY_SIZE(i2s_ref_parents),
765819c1de3SJames Hogan CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
76612499792SVipul Kumar Samar SPEAR1340_I2S_CLK_CFG, SPEAR1340_I2S_REF_SHIFT,
76712499792SVipul Kumar Samar SPEAR1340_I2S_REF_SEL_MASK, 0, &_lock);
768e0b9c210SShiraz Hashim clk_register_clkdev(clk, "i2s_ref_mclk", NULL);
7690b928af1SViresh Kumar
7705cb6a9bcSVipul Kumar Samar clk = clk_register_gate(NULL, "i2s_ref_pad_clk", "i2s_ref_mclk", 0,
7710b928af1SViresh Kumar SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_I2S_REF_PAD_CLK_ENB,
7720b928af1SViresh Kumar 0, &_lock);
7730b928af1SViresh Kumar clk_register_clkdev(clk, "i2s_ref_pad_clk", NULL);
7740b928af1SViresh Kumar
7755cb6a9bcSVipul Kumar Samar clk = clk_register_aux("i2s_sclk_clk", "i2s_sclk_gclk", "i2s_ref_mclk",
7765cb6a9bcSVipul Kumar Samar 0, SPEAR1340_I2S_CLK_CFG, &i2s_sclk_masks,
7775cb6a9bcSVipul Kumar Samar i2s_sclk_rtbl, ARRAY_SIZE(i2s_sclk_rtbl), &_lock,
7785cb6a9bcSVipul Kumar Samar &clk1);
7790b928af1SViresh Kumar clk_register_clkdev(clk, "i2s_sclk_clk", NULL);
7805cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk1, "i2s_sclk_gclk", NULL);
7810b928af1SViresh Kumar
7820b928af1SViresh Kumar /* clock derived from ahb clk */
7830b928af1SViresh Kumar clk = clk_register_gate(NULL, "i2c0_clk", "ahb_clk", 0,
7840b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_I2C0_CLK_ENB, 0,
7850b928af1SViresh Kumar &_lock);
7860b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "e0280000.i2c");
7870b928af1SViresh Kumar
7880b928af1SViresh Kumar clk = clk_register_gate(NULL, "i2c1_clk", "ahb_clk", 0,
789d9ba8db2SVipul Kumar Samar SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_I2C1_CLK_ENB, 0,
7900b928af1SViresh Kumar &_lock);
7910b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "b4000000.i2c");
7920b928af1SViresh Kumar
7930b928af1SViresh Kumar clk = clk_register_gate(NULL, "dma_clk", "ahb_clk", 0,
7940b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_DMA_CLK_ENB, 0,
7950b928af1SViresh Kumar &_lock);
7960b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "ea800000.dma");
7970b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "eb000000.dma");
7980b928af1SViresh Kumar
7990b928af1SViresh Kumar clk = clk_register_gate(NULL, "gmac_clk", "ahb_clk", 0,
8000b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_GMAC_CLK_ENB, 0,
8010b928af1SViresh Kumar &_lock);
8020b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "e2000000.eth");
8030b928af1SViresh Kumar
8040b928af1SViresh Kumar clk = clk_register_gate(NULL, "fsmc_clk", "ahb_clk", 0,
8050b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_FSMC_CLK_ENB, 0,
8060b928af1SViresh Kumar &_lock);
8070b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "b0000000.flash");
8080b928af1SViresh Kumar
8090b928af1SViresh Kumar clk = clk_register_gate(NULL, "smi_clk", "ahb_clk", 0,
8100b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_SMI_CLK_ENB, 0,
8110b928af1SViresh Kumar &_lock);
8120b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "ea000000.flash");
8130b928af1SViresh Kumar
8140b928af1SViresh Kumar clk = clk_register_gate(NULL, "usbh0_clk", "ahb_clk", 0,
8150b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_UHC0_CLK_ENB, 0,
8160b928af1SViresh Kumar &_lock);
817df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "e4000000.ohci");
818df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "e4800000.ehci");
8190b928af1SViresh Kumar
8200b928af1SViresh Kumar clk = clk_register_gate(NULL, "usbh1_clk", "ahb_clk", 0,
8210b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_UHC1_CLK_ENB, 0,
8220b928af1SViresh Kumar &_lock);
823df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "e5000000.ohci");
824df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "e5800000.ehci");
8250b928af1SViresh Kumar
8260b928af1SViresh Kumar clk = clk_register_gate(NULL, "uoc_clk", "ahb_clk", 0,
8270b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_UOC_CLK_ENB, 0,
8280b928af1SViresh Kumar &_lock);
829df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "e3800000.otg");
8300b928af1SViresh Kumar
8310b928af1SViresh Kumar clk = clk_register_gate(NULL, "pcie_sata_clk", "ahb_clk", 0,
8320b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_PCIE_SATA_CLK_ENB,
8330b928af1SViresh Kumar 0, &_lock);
83422a69230SPratyush Anand clk_register_clkdev(clk, NULL, "b1000000.pcie");
835df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "b1000000.ahci");
8360b928af1SViresh Kumar
8370b928af1SViresh Kumar clk = clk_register_gate(NULL, "sysram0_clk", "ahb_clk", 0,
8380b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_SYSRAM0_CLK_ENB, 0,
8390b928af1SViresh Kumar &_lock);
8400b928af1SViresh Kumar clk_register_clkdev(clk, "sysram0_clk", NULL);
8410b928af1SViresh Kumar
8420b928af1SViresh Kumar clk = clk_register_gate(NULL, "sysram1_clk", "ahb_clk", 0,
8430b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_SYSRAM1_CLK_ENB, 0,
8440b928af1SViresh Kumar &_lock);
8450b928af1SViresh Kumar clk_register_clkdev(clk, "sysram1_clk", NULL);
8460b928af1SViresh Kumar
8475cb6a9bcSVipul Kumar Samar clk = clk_register_aux("adc_syn_clk", "adc_syn_gclk", "ahb_clk",
8480b928af1SViresh Kumar 0, SPEAR1340_ADC_CLK_SYNT, NULL, adc_rtbl,
8490b928af1SViresh Kumar ARRAY_SIZE(adc_rtbl), &_lock, &clk1);
8505cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "adc_syn_clk", NULL);
8515cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk1, "adc_syn_gclk", NULL);
8520b928af1SViresh Kumar
85312499792SVipul Kumar Samar clk = clk_register_gate(NULL, "adc_clk", "adc_syn_gclk",
85412499792SVipul Kumar Samar CLK_SET_RATE_PARENT, SPEAR1340_PERIP1_CLK_ENB,
85512499792SVipul Kumar Samar SPEAR1340_ADC_CLK_ENB, 0, &_lock);
856df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "e0080000.adc");
8570b928af1SViresh Kumar
8580b928af1SViresh Kumar /* clock derived from apb clk */
8590b928af1SViresh Kumar clk = clk_register_gate(NULL, "ssp_clk", "apb_clk", 0,
8600b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_SSP_CLK_ENB, 0,
8610b928af1SViresh Kumar &_lock);
8620b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "e0100000.spi");
8630b928af1SViresh Kumar
8640b928af1SViresh Kumar clk = clk_register_gate(NULL, "gpio0_clk", "apb_clk", 0,
8650b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_GPIO0_CLK_ENB, 0,
8660b928af1SViresh Kumar &_lock);
8670b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "e0600000.gpio");
8680b928af1SViresh Kumar
8690b928af1SViresh Kumar clk = clk_register_gate(NULL, "gpio1_clk", "apb_clk", 0,
8700b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_GPIO1_CLK_ENB, 0,
8710b928af1SViresh Kumar &_lock);
8720b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "e0680000.gpio");
8730b928af1SViresh Kumar
8740b928af1SViresh Kumar clk = clk_register_gate(NULL, "i2s_play_clk", "apb_clk", 0,
8750b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_I2S_PLAY_CLK_ENB, 0,
8760b928af1SViresh Kumar &_lock);
877df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "b2400000.i2s-play");
8780b928af1SViresh Kumar
8790b928af1SViresh Kumar clk = clk_register_gate(NULL, "i2s_rec_clk", "apb_clk", 0,
8800b928af1SViresh Kumar SPEAR1340_PERIP1_CLK_ENB, SPEAR1340_I2S_REC_CLK_ENB, 0,
8810b928af1SViresh Kumar &_lock);
882df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "b2000000.i2s-rec");
8830b928af1SViresh Kumar
8840b928af1SViresh Kumar clk = clk_register_gate(NULL, "kbd_clk", "apb_clk", 0,
8850b928af1SViresh Kumar SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_KBD_CLK_ENB, 0,
8860b928af1SViresh Kumar &_lock);
8870b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "e0300000.kbd");
8880b928af1SViresh Kumar
8890b928af1SViresh Kumar /* RAS clks */
8905cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "gen_syn0_1_mclk", gen_synth0_1_parents,
891819c1de3SJames Hogan ARRAY_SIZE(gen_synth0_1_parents),
892819c1de3SJames Hogan CLK_SET_RATE_NO_REPARENT, SPEAR1340_PLL_CFG,
8935cb6a9bcSVipul Kumar Samar SPEAR1340_GEN_SYNT0_1_CLK_SHIFT,
8940b928af1SViresh Kumar SPEAR1340_GEN_SYNT_CLK_MASK, 0, &_lock);
895e0b9c210SShiraz Hashim clk_register_clkdev(clk, "gen_syn0_1_mclk", NULL);
8960b928af1SViresh Kumar
8975cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "gen_syn2_3_mclk", gen_synth2_3_parents,
898819c1de3SJames Hogan ARRAY_SIZE(gen_synth2_3_parents),
899819c1de3SJames Hogan CLK_SET_RATE_NO_REPARENT, SPEAR1340_PLL_CFG,
9005cb6a9bcSVipul Kumar Samar SPEAR1340_GEN_SYNT2_3_CLK_SHIFT,
9010b928af1SViresh Kumar SPEAR1340_GEN_SYNT_CLK_MASK, 0, &_lock);
902e0b9c210SShiraz Hashim clk_register_clkdev(clk, "gen_syn2_3_mclk", NULL);
9030b928af1SViresh Kumar
904e0b9c210SShiraz Hashim clk = clk_register_frac("gen_syn0_clk", "gen_syn0_1_mclk", 0,
9050b928af1SViresh Kumar SPEAR1340_GEN_CLK_SYNT0, gen_rtbl, ARRAY_SIZE(gen_rtbl),
9060b928af1SViresh Kumar &_lock);
9075cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "gen_syn0_clk", NULL);
9080b928af1SViresh Kumar
909e0b9c210SShiraz Hashim clk = clk_register_frac("gen_syn1_clk", "gen_syn0_1_mclk", 0,
9100b928af1SViresh Kumar SPEAR1340_GEN_CLK_SYNT1, gen_rtbl, ARRAY_SIZE(gen_rtbl),
9110b928af1SViresh Kumar &_lock);
9125cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "gen_syn1_clk", NULL);
9130b928af1SViresh Kumar
914e0b9c210SShiraz Hashim clk = clk_register_frac("gen_syn2_clk", "gen_syn2_3_mclk", 0,
9150b928af1SViresh Kumar SPEAR1340_GEN_CLK_SYNT2, gen_rtbl, ARRAY_SIZE(gen_rtbl),
9160b928af1SViresh Kumar &_lock);
9175cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "gen_syn2_clk", NULL);
9180b928af1SViresh Kumar
919e0b9c210SShiraz Hashim clk = clk_register_frac("gen_syn3_clk", "gen_syn2_3_mclk", 0,
9200b928af1SViresh Kumar SPEAR1340_GEN_CLK_SYNT3, gen_rtbl, ARRAY_SIZE(gen_rtbl),
9210b928af1SViresh Kumar &_lock);
9225cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "gen_syn3_clk", NULL);
9230b928af1SViresh Kumar
92412499792SVipul Kumar Samar clk = clk_register_gate(NULL, "mali_clk", "gen_syn3_clk",
92512499792SVipul Kumar Samar CLK_SET_RATE_PARENT, SPEAR1340_PERIP3_CLK_ENB,
92612499792SVipul Kumar Samar SPEAR1340_MALI_CLK_ENB, 0, &_lock);
9270b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "mali");
9280b928af1SViresh Kumar
9290b928af1SViresh Kumar clk = clk_register_gate(NULL, "cec0_clk", "ahb_clk", 0,
9300b928af1SViresh Kumar SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CEC0_CLK_ENB, 0,
9310b928af1SViresh Kumar &_lock);
9320b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "spear_cec.0");
9330b928af1SViresh Kumar
9340b928af1SViresh Kumar clk = clk_register_gate(NULL, "cec1_clk", "ahb_clk", 0,
9350b928af1SViresh Kumar SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CEC1_CLK_ENB, 0,
9360b928af1SViresh Kumar &_lock);
9370b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "spear_cec.1");
9380b928af1SViresh Kumar
9395cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "spdif_out_mclk", spdif_out_parents,
940819c1de3SJames Hogan ARRAY_SIZE(spdif_out_parents),
941819c1de3SJames Hogan CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
9420b928af1SViresh Kumar SPEAR1340_PERIP_CLK_CFG, SPEAR1340_SPDIF_OUT_CLK_SHIFT,
9430b928af1SViresh Kumar SPEAR1340_SPDIF_CLK_MASK, 0, &_lock);
9445cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "spdif_out_mclk", NULL);
9450b928af1SViresh Kumar
94612499792SVipul Kumar Samar clk = clk_register_gate(NULL, "spdif_out_clk", "spdif_out_mclk",
94712499792SVipul Kumar Samar CLK_SET_RATE_PARENT, SPEAR1340_PERIP3_CLK_ENB,
94812499792SVipul Kumar Samar SPEAR1340_SPDIF_OUT_CLK_ENB, 0, &_lock);
949df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "d0000000.spdif-out");
9500b928af1SViresh Kumar
9515cb6a9bcSVipul Kumar Samar clk = clk_register_mux(NULL, "spdif_in_mclk", spdif_in_parents,
952819c1de3SJames Hogan ARRAY_SIZE(spdif_in_parents),
953819c1de3SJames Hogan CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
9540b928af1SViresh Kumar SPEAR1340_PERIP_CLK_CFG, SPEAR1340_SPDIF_IN_CLK_SHIFT,
9550b928af1SViresh Kumar SPEAR1340_SPDIF_CLK_MASK, 0, &_lock);
9565cb6a9bcSVipul Kumar Samar clk_register_clkdev(clk, "spdif_in_mclk", NULL);
9570b928af1SViresh Kumar
95812499792SVipul Kumar Samar clk = clk_register_gate(NULL, "spdif_in_clk", "spdif_in_mclk",
95912499792SVipul Kumar Samar CLK_SET_RATE_PARENT, SPEAR1340_PERIP3_CLK_ENB,
96012499792SVipul Kumar Samar SPEAR1340_SPDIF_IN_CLK_ENB, 0, &_lock);
961df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "d0100000.spdif-in");
9620b928af1SViresh Kumar
96304981724SVipul Kumar Samar clk = clk_register_gate(NULL, "acp_clk", "ahb_clk", 0,
9640b928af1SViresh Kumar SPEAR1340_PERIP2_CLK_ENB, SPEAR1340_ACP_CLK_ENB, 0,
9650b928af1SViresh Kumar &_lock);
9660b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "acp_clk");
9670b928af1SViresh Kumar
96804981724SVipul Kumar Samar clk = clk_register_gate(NULL, "plgpio_clk", "ahb_clk", 0,
9690b928af1SViresh Kumar SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_PLGPIO_CLK_ENB, 0,
9700b928af1SViresh Kumar &_lock);
971df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "e2800000.gpio");
9720b928af1SViresh Kumar
97304981724SVipul Kumar Samar clk = clk_register_gate(NULL, "video_dec_clk", "ahb_clk", 0,
9740b928af1SViresh Kumar SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_VIDEO_DEC_CLK_ENB,
9750b928af1SViresh Kumar 0, &_lock);
9760b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "video_dec");
9770b928af1SViresh Kumar
97804981724SVipul Kumar Samar clk = clk_register_gate(NULL, "video_enc_clk", "ahb_clk", 0,
9790b928af1SViresh Kumar SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_VIDEO_ENC_CLK_ENB,
9800b928af1SViresh Kumar 0, &_lock);
9810b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "video_enc");
9820b928af1SViresh Kumar
98304981724SVipul Kumar Samar clk = clk_register_gate(NULL, "video_in_clk", "ahb_clk", 0,
9840b928af1SViresh Kumar SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_VIDEO_IN_CLK_ENB, 0,
9850b928af1SViresh Kumar &_lock);
9860b928af1SViresh Kumar clk_register_clkdev(clk, NULL, "spear_vip");
9870b928af1SViresh Kumar
98804981724SVipul Kumar Samar clk = clk_register_gate(NULL, "cam0_clk", "ahb_clk", 0,
9890b928af1SViresh Kumar SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CAM0_CLK_ENB, 0,
9900b928af1SViresh Kumar &_lock);
991df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "d0200000.cam0");
9920b928af1SViresh Kumar
99304981724SVipul Kumar Samar clk = clk_register_gate(NULL, "cam1_clk", "ahb_clk", 0,
9940b928af1SViresh Kumar SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CAM1_CLK_ENB, 0,
9950b928af1SViresh Kumar &_lock);
996df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "d0300000.cam1");
9970b928af1SViresh Kumar
99804981724SVipul Kumar Samar clk = clk_register_gate(NULL, "cam2_clk", "ahb_clk", 0,
9990b928af1SViresh Kumar SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CAM2_CLK_ENB, 0,
10000b928af1SViresh Kumar &_lock);
1001df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "d0400000.cam2");
10020b928af1SViresh Kumar
100304981724SVipul Kumar Samar clk = clk_register_gate(NULL, "cam3_clk", "ahb_clk", 0,
10040b928af1SViresh Kumar SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_CAM3_CLK_ENB, 0,
10050b928af1SViresh Kumar &_lock);
1006df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "d0500000.cam3");
10070b928af1SViresh Kumar
1008463f9e20SShiraz Hashim clk = clk_register_gate(NULL, "pwm_clk", "ahb_clk", 0,
10090b928af1SViresh Kumar SPEAR1340_PERIP3_CLK_ENB, SPEAR1340_PWM_CLK_ENB, 0,
10100b928af1SViresh Kumar &_lock);
1011df2449abSRajeev Kumar clk_register_clkdev(clk, NULL, "e0180000.pwm");
10120b928af1SViresh Kumar }
1013