aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-s5p/include
diff options
context:
space:
mode:
authorKukjin Kim <kgene.kim@samsung.com>2010-01-13 18:13:37 -0500
committerBen Dooks <ben-linux@fluff.org>2010-01-15 05:16:16 -0500
commit1a0e8a52ad56075663d8e120e2468fc96fb6fa6c (patch)
tree1ff1246f8bfc638e6fc2fab1c3d25b1aba6bb8c1 /arch/arm/plat-s5p/include
parent209fecd1b8e65b8046efbbc8314d449e53c4c6b6 (diff)
ARM: S5P6440: Add Clock and PLL support
This patch adds clock and pll support for S5P6440. This patch are based on Harald Welte's patches and Ben's plat-samsung. Signed-off-by: Thomas Abraham <thomas.ab@samsung.com> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/plat-s5p/include')
-rw-r--r--arch/arm/plat-s5p/include/plat/pll.h83
-rw-r--r--arch/arm/plat-s5p/include/plat/s5p-clock.h38
2 files changed, 121 insertions, 0 deletions
diff --git a/arch/arm/plat-s5p/include/plat/pll.h b/arch/arm/plat-s5p/include/plat/pll.h
new file mode 100644
index 000000000000..d48325bb29e2
--- /dev/null
+++ b/arch/arm/plat-s5p/include/plat/pll.h
@@ -0,0 +1,83 @@
1/* arch/arm/plat-s5p/include/plat/pll.h
2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5P PLL code
7 *
8 * Based on arch/arm/plat-s3c64xx/include/plat/pll.h
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13*/
14
15#define PLL45XX_MDIV_MASK (0x3FF)
16#define PLL45XX_PDIV_MASK (0x3F)
17#define PLL45XX_SDIV_MASK (0x7)
18#define PLL45XX_MDIV_SHIFT (16)
19#define PLL45XX_PDIV_SHIFT (8)
20#define PLL45XX_SDIV_SHIFT (0)
21
22#include <asm/div64.h>
23
24enum pll45xx_type_t {
25 pll_4500,
26 pll_4502,
27 pll_4508
28};
29
30static inline unsigned long s5p_get_pll45xx(unsigned long baseclk, u32 pll_con,
31 enum pll45xx_type_t pll_type)
32{
33 u32 mdiv, pdiv, sdiv;
34 u64 fvco = baseclk;
35
36 mdiv = (pll_con >> PLL45XX_MDIV_SHIFT) & PLL45XX_MDIV_MASK;
37 pdiv = (pll_con >> PLL45XX_PDIV_SHIFT) & PLL45XX_PDIV_MASK;
38 sdiv = (pll_con >> PLL45XX_SDIV_SHIFT) & PLL45XX_SDIV_MASK;
39
40 if (pll_type == pll_4508)
41 sdiv = sdiv - 1;
42
43 fvco *= mdiv;
44 do_div(fvco, (pdiv << sdiv));
45
46 return (unsigned long)fvco;
47}
48
49#define PLL90XX_MDIV_MASK (0xFF)
50#define PLL90XX_PDIV_MASK (0x3F)
51#define PLL90XX_SDIV_MASK (0x7)
52#define PLL90XX_KDIV_MASK (0xffff)
53#define PLL90XX_MDIV_SHIFT (16)
54#define PLL90XX_PDIV_SHIFT (8)
55#define PLL90XX_SDIV_SHIFT (0)
56#define PLL90XX_KDIV_SHIFT (0)
57
58static inline unsigned long s5p_get_pll90xx(unsigned long baseclk,
59 u32 pll_con, u32 pll_conk)
60{
61 unsigned long result;
62 u32 mdiv, pdiv, sdiv, kdiv;
63 u64 tmp;
64
65 mdiv = (pll_con >> PLL90XX_MDIV_SHIFT) & PLL90XX_MDIV_MASK;
66 pdiv = (pll_con >> PLL90XX_PDIV_SHIFT) & PLL90XX_PDIV_MASK;
67 sdiv = (pll_con >> PLL90XX_SDIV_SHIFT) & PLL90XX_SDIV_MASK;
68 kdiv = pll_conk & PLL90XX_KDIV_MASK;
69
70 /* We need to multiple baseclk by mdiv (the integer part) and kdiv
71 * which is in 2^16ths, so shift mdiv up (does not overflow) and
72 * add kdiv before multiplying. The use of tmp is to avoid any
73 * overflows before shifting bac down into result when multipling
74 * by the mdiv and kdiv pair.
75 */
76
77 tmp = baseclk;
78 tmp *= (mdiv << 16) + kdiv;
79 do_div(tmp, (pdiv << sdiv));
80 result = tmp >> 16;
81
82 return result;
83}
diff --git a/arch/arm/plat-s5p/include/plat/s5p-clock.h b/arch/arm/plat-s5p/include/plat/s5p-clock.h
new file mode 100644
index 000000000000..e1a7444b8829
--- /dev/null
+++ b/arch/arm/plat-s5p/include/plat/s5p-clock.h
@@ -0,0 +1,38 @@
1/* linux/arch/arm/plat-s5p/include/plat/s5p-clock.h
2 *
3 * Copyright 2009 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * Header file for s5p clock support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_PLAT_S5P_CLOCK_H
14#define __ASM_PLAT_S5P_CLOCK_H __FILE__
15
16#include <linux/clk.h>
17
18#define GET_DIV(clk, field) ((((clk) & field##_MASK) >> field##_SHIFT) + 1)
19
20#define clk_fin_apll clk_ext_xtal_mux
21#define clk_fin_mpll clk_ext_xtal_mux
22#define clk_fin_epll clk_ext_xtal_mux
23
24extern struct clk clk_ext_xtal_mux;
25extern struct clk clk_48m;
26extern struct clk clk_fout_apll;
27extern struct clk clk_fout_mpll;
28extern struct clk clk_fout_epll;
29extern struct clk clk_arm;
30
31extern struct clksrc_sources clk_src_apll;
32extern struct clksrc_sources clk_src_mpll;
33extern struct clksrc_sources clk_src_epll;
34
35extern int s5p6440_clk48m_ctrl(struct clk *clk, int enable);
36extern int s5p_gatectrl(void __iomem *reg, struct clk *clk, int enable);
37
38#endif /* __ASM_PLAT_S5P_CLOCK_H */