xref: /rk3399_rockchip-uboot/arch/arm/mach-exynos/include/mach/clk.h (revision 783983f323730540f861413dfbea6802c88afcf8)
1*77b55e8cSThomas Abraham /*
2*77b55e8cSThomas Abraham  * (C) Copyright 2010 Samsung Electronics
3*77b55e8cSThomas Abraham  * Minkyu Kang <mk7.kang@samsung.com>
4*77b55e8cSThomas Abraham  *
5*77b55e8cSThomas Abraham  * SPDX-License-Identifier:	GPL-2.0+
6*77b55e8cSThomas Abraham  */
7*77b55e8cSThomas Abraham 
8*77b55e8cSThomas Abraham #ifndef __ASM_ARM_ARCH_CLK_H_
9*77b55e8cSThomas Abraham #define __ASM_ARM_ARCH_CLK_H_
10*77b55e8cSThomas Abraham 
11*77b55e8cSThomas Abraham #define APLL	0
12*77b55e8cSThomas Abraham #define MPLL	1
13*77b55e8cSThomas Abraham #define EPLL	2
14*77b55e8cSThomas Abraham #define HPLL	3
15*77b55e8cSThomas Abraham #define VPLL	4
16*77b55e8cSThomas Abraham #define BPLL	5
17*77b55e8cSThomas Abraham #define RPLL	6
18*77b55e8cSThomas Abraham #define SPLL	7
19*77b55e8cSThomas Abraham #define CPLL	8
20*77b55e8cSThomas Abraham #define DPLL	9
21*77b55e8cSThomas Abraham #define IPLL	10
22*77b55e8cSThomas Abraham 
23*77b55e8cSThomas Abraham #define MASK_PRE_RATIO(x)	(0xff << ((x << 4) + 8))
24*77b55e8cSThomas Abraham #define MASK_RATIO(x)		(0xf << (x << 4))
25*77b55e8cSThomas Abraham #define SET_PRE_RATIO(x, y)	((y & 0xff) << ((x << 4) + 8))
26*77b55e8cSThomas Abraham #define SET_RATIO(x, y)		((y & 0xf) << (x << 4))
27*77b55e8cSThomas Abraham 
28*77b55e8cSThomas Abraham enum pll_src_bit {
29*77b55e8cSThomas Abraham 	EXYNOS_SRC_MPLL = 6,
30*77b55e8cSThomas Abraham 	EXYNOS_SRC_EPLL,
31*77b55e8cSThomas Abraham 	EXYNOS_SRC_VPLL,
32*77b55e8cSThomas Abraham 	EXYNOS542X_SRC_MPLL = 3,
33*77b55e8cSThomas Abraham 	EXYNOS542X_SRC_SPLL,
34*77b55e8cSThomas Abraham 	EXYNOS542X_SRC_EPLL = 6,
35*77b55e8cSThomas Abraham 	EXYNOS542X_SRC_RPLL,
36*77b55e8cSThomas Abraham };
37*77b55e8cSThomas Abraham 
38*77b55e8cSThomas Abraham unsigned long get_pll_clk(int pllreg);
39*77b55e8cSThomas Abraham unsigned long get_arm_clk(void);
40*77b55e8cSThomas Abraham unsigned long get_i2c_clk(void);
41*77b55e8cSThomas Abraham unsigned long get_pwm_clk(void);
42*77b55e8cSThomas Abraham unsigned long get_uart_clk(int dev_index);
43*77b55e8cSThomas Abraham unsigned long get_mmc_clk(int dev_index);
44*77b55e8cSThomas Abraham void set_mmc_clk(int dev_index, unsigned int div);
45*77b55e8cSThomas Abraham unsigned long get_lcd_clk(void);
46*77b55e8cSThomas Abraham void set_lcd_clk(void);
47*77b55e8cSThomas Abraham void set_mipi_clk(void);
48*77b55e8cSThomas Abraham int set_i2s_clk_source(unsigned int i2s_id);
49*77b55e8cSThomas Abraham int set_i2s_clk_prescaler(unsigned int src_frq, unsigned int dst_frq,
50*77b55e8cSThomas Abraham 				unsigned int i2s_id);
51*77b55e8cSThomas Abraham int set_epll_clk(unsigned long rate);
52*77b55e8cSThomas Abraham int set_spi_clk(int periph_id, unsigned int rate);
53*77b55e8cSThomas Abraham 
54*77b55e8cSThomas Abraham /**
55*77b55e8cSThomas Abraham  * get the clk frequency of the required peripheral
56*77b55e8cSThomas Abraham  *
57*77b55e8cSThomas Abraham  * @param peripheral	Peripheral id
58*77b55e8cSThomas Abraham  *
59*77b55e8cSThomas Abraham  * @return frequency of the peripheral clk
60*77b55e8cSThomas Abraham  */
61*77b55e8cSThomas Abraham unsigned long clock_get_periph_rate(int peripheral);
62*77b55e8cSThomas Abraham 
63*77b55e8cSThomas Abraham #endif
64