1 /* linux/include/asm/arch-s3c2410/regs-clock.h
3 * Copyright (c) 2003,2004,2005,2006 Simtec Electronics <linux@simtec.co.uk>
4 * http://armlinux.simtec.co.uk/
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * S3C2410 clock register definitions
13 * 18-Aug-2004 Ben Dooks Added 2440 definitions
14 * 08-Aug-2004 Herbert Pƶtzl Added CLKCON definitions
15 * 19-06-2003 Ben Dooks Created file
16 * 12-03-2004 Ben Dooks Updated include protection
17 * 29-Sep-2004 Ben Dooks Fixed usage for assembly inclusion
18 * 10-Feb-2005 Ben Dooks Fixed CAMDIVN address (Guillaume Gourat)
19 * 10-Mar-2005 Lucas Villa Real Changed S3C2410_VA to S3C24XX_VA
20 * 27-Aug-2005 Ben Dooks Add clock-slow info
21 * 20-Oct-2005 Ben Dooks Fixed overflow in PLL (Guillaume Gourat)
22 * 20-Oct-2005 Ben Dooks Add masks for DCLK (Guillaume Gourat)
25 #ifndef __ASM_ARM_REGS_CLOCK
26 #define __ASM_ARM_REGS_CLOCK "$Id: clock.h,v 1.4 2003/04/30 14:50:51 ben Exp $"
28 #define S3C2410_CLKREG(x) ((x) + S3C24XX_VA_CLKPWR)
30 #define S3C2410_PLLVAL(_m,_p,_s) ((_m) << 12 | ((_p) << 4) | ((_s)))
32 #define S3C2410_LOCKTIME S3C2410_CLKREG(0x00)
33 #define S3C2410_MPLLCON S3C2410_CLKREG(0x04)
34 #define S3C2410_UPLLCON S3C2410_CLKREG(0x08)
35 #define S3C2410_CLKCON S3C2410_CLKREG(0x0C)
36 #define S3C2410_CLKSLOW S3C2410_CLKREG(0x10)
37 #define S3C2410_CLKDIVN S3C2410_CLKREG(0x14)
39 #define S3C2410_CLKCON_IDLE (1<<2)
40 #define S3C2410_CLKCON_POWER (1<<3)
41 #define S3C2410_CLKCON_NAND (1<<4)
42 #define S3C2410_CLKCON_LCDC (1<<5)
43 #define S3C2410_CLKCON_USBH (1<<6)
44 #define S3C2410_CLKCON_USBD (1<<7)
45 #define S3C2410_CLKCON_PWMT (1<<8)
46 #define S3C2410_CLKCON_SDI (1<<9)
47 #define S3C2410_CLKCON_UART0 (1<<10)
48 #define S3C2410_CLKCON_UART1 (1<<11)
49 #define S3C2410_CLKCON_UART2 (1<<12)
50 #define S3C2410_CLKCON_GPIO (1<<13)
51 #define S3C2410_CLKCON_RTC (1<<14)
52 #define S3C2410_CLKCON_ADC (1<<15)
53 #define S3C2410_CLKCON_IIC (1<<16)
54 #define S3C2410_CLKCON_IIS (1<<17)
55 #define S3C2410_CLKCON_SPI (1<<18)
57 #define S3C2410_PLLCON_MDIVSHIFT 12
58 #define S3C2410_PLLCON_PDIVSHIFT 4
59 #define S3C2410_PLLCON_SDIVSHIFT 0
60 #define S3C2410_PLLCON_MDIVMASK ((1<<(1+(19-12)))-1)
61 #define S3C2410_PLLCON_PDIVMASK ((1<<5)-1)
62 #define S3C2410_PLLCON_SDIVMASK 3
64 /* DCLKCON register addresses in gpio.h */
66 #define S3C2410_DCLKCON_DCLK0EN (1<<0)
67 #define S3C2410_DCLKCON_DCLK0_PCLK (0<<1)
68 #define S3C2410_DCLKCON_DCLK0_UCLK (1<<1)
69 #define S3C2410_DCLKCON_DCLK0_DIV(x) (((x) - 1 )<<4)
70 #define S3C2410_DCLKCON_DCLK0_CMP(x) (((x) - 1 )<<8)
71 #define S3C2410_DCLKCON_DCLK0_DIV_MASK ((0xf)<<4)
72 #define S3C2410_DCLKCON_DCLK0_CMP_MASK ((0xf)<<8)
74 #define S3C2410_DCLKCON_DCLK1EN (1<<16)
75 #define S3C2410_DCLKCON_DCLK1_PCLK (0<<17)
76 #define S3C2410_DCLKCON_DCLK1_UCLK (1<<17)
77 #define S3C2410_DCLKCON_DCLK1_DIV(x) (((x) - 1) <<20)
78 #define S3C2410_DCLKCON_DCLK1_CMP(x) (((x) - 1) <<24)
79 #define S3C2410_DCLKCON_DCLK1_DIV_MASK ((0xf) <<20)
80 #define S3C2410_DCLKCON_DCLK1_CMP_MASK ((0xf) <<24)
82 #define S3C2410_CLKDIVN_PDIVN (1<<0)
83 #define S3C2410_CLKDIVN_HDIVN (1<<1)
85 #define S3C2410_CLKSLOW_UCLK_OFF (1<<7)
86 #define S3C2410_CLKSLOW_MPLL_OFF (1<<5)
87 #define S3C2410_CLKSLOW_SLOW (1<<4)
88 #define S3C2410_CLKSLOW_SLOWVAL(x) (x)
89 #define S3C2410_CLKSLOW_GET_SLOWVAL(x) ((x) & 7)
93 #include <asm/div64.h>
95 static inline unsigned int
96 s3c2410_get_pll(unsigned int pllval, unsigned int baseclk)
98 unsigned int mdiv, pdiv, sdiv;
101 mdiv = pllval >> S3C2410_PLLCON_MDIVSHIFT;
102 pdiv = pllval >> S3C2410_PLLCON_PDIVSHIFT;
103 sdiv = pllval >> S3C2410_PLLCON_SDIVSHIFT;
105 mdiv &= S3C2410_PLLCON_MDIVMASK;
106 pdiv &= S3C2410_PLLCON_PDIVMASK;
107 sdiv &= S3C2410_PLLCON_SDIVMASK;
109 fvco = (uint64_t)baseclk * (mdiv + 8);
110 do_div(fvco, (pdiv + 2) << sdiv);
112 return (unsigned int)fvco;
115 #endif /* __ASSEMBLY__ */
117 #if defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2442)
119 /* extra registers */
120 #define S3C2440_CAMDIVN S3C2410_CLKREG(0x18)
122 #define S3C2440_CLKCON_CAMERA (1<<19)
123 #define S3C2440_CLKCON_AC97 (1<<20)
125 #define S3C2440_CLKDIVN_PDIVN (1<<0)
126 #define S3C2440_CLKDIVN_HDIVN_MASK (3<<1)
127 #define S3C2440_CLKDIVN_HDIVN_1 (0<<1)
128 #define S3C2440_CLKDIVN_HDIVN_2 (1<<1)
129 #define S3C2440_CLKDIVN_HDIVN_4_8 (2<<1)
130 #define S3C2440_CLKDIVN_HDIVN_3_6 (3<<1)
131 #define S3C2440_CLKDIVN_UCLK (1<<3)
133 #define S3C2440_CAMDIVN_CAMCLK_MASK (0xf<<0)
134 #define S3C2440_CAMDIVN_CAMCLK_SEL (1<<4)
135 #define S3C2440_CAMDIVN_HCLK3_HALF (1<<8)
136 #define S3C2440_CAMDIVN_HCLK4_HALF (1<<9)
137 #define S3C2440_CAMDIVN_DVSEN (1<<12)
139 #define S3C2442_CAMDIVN_CAMCLK_DIV3 (1<<5)
141 #endif /* CONFIG_CPU_S3C2440 or CONFIG_CPU_S3C2442 */
143 #if defined(CONFIG_CPU_S3C2412) || defined(CONFIG_CPU_S3C2413)
145 #define S3C2412_OSCSET S3C2410_CLKREG(0x18)
146 #define S3C2412_CLKSRC S3C2410_CLKREG(0x1C)
148 #define S3C2412_PLLCON_OFF (1<<20)
150 #define S3C2412_CLKDIVN_PDIVN (1<<2)
151 #define S3C2412_CLKDIVN_HDIVN_MASK (3<<0)
152 #define S3C2421_CLKDIVN_ARMDIVN (1<<3)
153 #define S3C2412_CLKDIVN_USB48DIV (1<<6)
154 #define S3C2412_CLKDIVN_UARTDIV_MASK (15<<8)
155 #define S3C2412_CLKDIVN_UARTDIV_SHIFT (8)
156 #define S3C2412_CLKDIVN_I2SDIV_MASK (15<<12)
157 #define S3C2412_CLKDIVN_I2SDIV_SHIFT (12)
158 #define S3C2412_CLKDIVN_CAMDIV_MASK (15<<16)
159 #define S3C2412_CLKDIVN_CAMDIV_SHIFT (16)
161 #define S3C2412_CLKCON_WDT (1<<28)
162 #define S3C2412_CLKCON_SPI (1<<27)
163 #define S3C2412_CLKCON_IIS (1<<26)
164 #define S3C2412_CLKCON_IIC (1<<25)
165 #define S3C2412_CLKCON_ADC (1<<24)
166 #define S3C2412_CLKCON_RTC (1<<23)
167 #define S3C2412_CLKCON_GPIO (1<<22)
168 #define S3C2412_CLKCON_UART2 (1<<21)
169 #define S3C2412_CLKCON_UART1 (1<<20)
170 #define S3C2412_CLKCON_UART0 (1<<19)
171 #define S3C2412_CLKCON_SDI (1<<18)
172 #define S3C2412_CLKCON_PWMT (1<<17)
173 #define S3C2412_CLKCON_USBD (1<<16)
174 #define S3C2412_CLKCON_CAMCLK (1<<15)
175 #define S3C2412_CLKCON_UARTCLK (1<<14)
177 #define S3C2412_CLKCON_USB_HOST48 (1<<12)
178 #define S3C2412_CLKCON_USB_DEV48 (1<<11)
179 #define S3C2412_CLKCON_HCLKdiv2 (1<<10)
180 #define S3C2412_CLKCON_HCLKx2 (1<<9)
181 #define S3C2412_CLKCON_SDRAM (1<<8)
183 #define S3C2412_CLKCON_USBH S3C2410_CLKCON_USBH
184 #define S3C2412_CLKCON_LCDC S3C2410_CLKCON_LCDC
185 #define S3C2412_CLKCON_NAND S3C2410_CLKCON_NAND
186 #define S3C2412_CLKCON_DMA3 (1<<3)
187 #define S3C2412_CLKCON_DMA2 (1<<2)
188 #define S3C2412_CLKCON_DMA1 (1<<1)
189 #define S3C2412_CLKCON_DMA0 (1<<0)
191 /* clock sourec controls */
193 #define S3C2412_CLKSRC_EXTCLKDIV_MASK (7 << 0)
194 #define S3C2412_CLKSRC_EXTCLKDIV_SHIFT (0)
195 #define S3C2412_CLKSRC_MDIVCLK_EXTCLKDIV (1<<3)
196 #define S3C2412_CLKSRC_MSYSCLK_MPLL (1<<4)
197 #define S3C2412_CLKSRC_USYSCLK_UPLL (1<<5)
198 #define S3C2412_CLKSRC_UARTCLK_MPLL (1<<8)
199 #define S3C2412_CLKSRC_I2SCLK_MPLL (1<<9)
200 #define S3C2412_CLKSRC_USBCLK_HCLK (1<<10)
201 #define S3C2412_CLKSRC_CAMCLK_HCLK (1<<11)
203 #endif /* CONFIG_CPU_S3C2412 | CONFIG_CPU_S3C2413 */
205 #endif /* __ASM_ARM_REGS_CLOCK */