]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/include/asm/arch-tegra2/clock.h
tegra2: Rename CLOCK_PLL_ID to CLOCK_ID
[karo-tx-uboot.git] / arch / arm / include / asm / arch-tegra2 / clock.h
1 /*
2  * Copyright (c) 2011 The Chromium OS Authors.
3  * See file CREDITS for list of people who contributed to this
4  * project.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19  * MA 02111-1307 USA
20  */
21
22 /* Tegra2 clock control functions */
23
24 #ifndef _CLOCK_H
25 #define _CLOCK_H
26
27 /* Set of oscillator frequencies supported in the internal API. */
28 enum clock_osc_freq {
29         /* All in MHz, so 13_0 is 13.0MHz */
30         CLOCK_OSC_FREQ_13_0,
31         CLOCK_OSC_FREQ_19_2,
32         CLOCK_OSC_FREQ_12_0,
33         CLOCK_OSC_FREQ_26_0,
34
35         CLOCK_OSC_FREQ_COUNT,
36 };
37
38 /* The PLLs supported by the hardware */
39 enum clock_id {
40         CLOCK_ID_FIRST,
41         CLOCK_ID_CGENERAL = CLOCK_ID_FIRST,
42         CLOCK_ID_MEMORY,
43         CLOCK_ID_PERIPH,
44         CLOCK_ID_AUDIO,
45         CLOCK_ID_USB,
46         CLOCK_ID_DISPLAY,
47
48         /* now the simple ones */
49         CLOCK_ID_FIRST_SIMPLE,
50         CLOCK_ID_XCPU = CLOCK_ID_FIRST_SIMPLE,
51         CLOCK_ID_EPCI,
52         CLOCK_ID_SFROM32KHZ,
53
54         CLOCK_ID_COUNT,
55 };
56
57 /* The clocks supported by the hardware */
58 enum periph_id {
59         PERIPH_ID_FIRST,
60
61         /* Low word: 31:0 */
62         PERIPH_ID_CPU = PERIPH_ID_FIRST,
63         PERIPH_ID_RESERVED1,
64         PERIPH_ID_RESERVED2,
65         PERIPH_ID_AC97,
66         PERIPH_ID_RTC,
67         PERIPH_ID_TMR,
68         PERIPH_ID_UART1,
69         PERIPH_ID_UART2,
70
71         /* 8 */
72         PERIPH_ID_GPIO,
73         PERIPH_ID_SDMMC2,
74         PERIPH_ID_SPDIF,
75         PERIPH_ID_I2S1,
76         PERIPH_ID_I2C1,
77         PERIPH_ID_NDFLASH,
78         PERIPH_ID_SDMMC1,
79         PERIPH_ID_SDMMC4,
80
81         /* 16 */
82         PERIPH_ID_TWC,
83         PERIPH_ID_PWM,
84         PERIPH_ID_I2S2,
85         PERIPH_ID_EPP,
86         PERIPH_ID_VI,
87         PERIPH_ID_2D,
88         PERIPH_ID_USBD,
89         PERIPH_ID_ISP,
90
91         /* 24 */
92         PERIPH_ID_3D,
93         PERIPH_ID_IDE,
94         PERIPH_ID_DISP2,
95         PERIPH_ID_DISP1,
96         PERIPH_ID_HOST1X,
97         PERIPH_ID_VCP,
98         PERIPH_ID_RESERVED30,
99         PERIPH_ID_CACHE2,
100
101         /* Middle word: 63:32 */
102         PERIPH_ID_MEM,
103         PERIPH_ID_AHBDMA,
104         PERIPH_ID_APBDMA,
105         PERIPH_ID_RESERVED35,
106         PERIPH_ID_KBC,
107         PERIPH_ID_STAT_MON,
108         PERIPH_ID_PMC,
109         PERIPH_ID_FUSE,
110
111         /* 40 */
112         PERIPH_ID_KFUSE,
113         PERIPH_ID_SBC1,
114         PERIPH_ID_SNOR,
115         PERIPH_ID_SPI1,
116         PERIPH_ID_SBC2,
117         PERIPH_ID_XIO,
118         PERIPH_ID_SBC3,
119         PERIPH_ID_DVC_I2C,
120
121         /* 48 */
122         PERIPH_ID_DSI,
123         PERIPH_ID_TVO,
124         PERIPH_ID_MIPI,
125         PERIPH_ID_HDMI,
126         PERIPH_ID_CSI,
127         PERIPH_ID_TVDAC,
128         PERIPH_ID_I2C2,
129         PERIPH_ID_UART3,
130
131         /* 56 */
132         PERIPH_ID_RESERVED56,
133         PERIPH_ID_EMC,
134         PERIPH_ID_USB2,
135         PERIPH_ID_USB3,
136         PERIPH_ID_MPE,
137         PERIPH_ID_VDE,
138         PERIPH_ID_BSEA,
139         PERIPH_ID_BSEV,
140
141         /* Upper word 95:64 */
142         PERIPH_ID_SPEEDO,
143         PERIPH_ID_UART4,
144         PERIPH_ID_UART5,
145         PERIPH_ID_I2C3,
146         PERIPH_ID_SBC4,
147         PERIPH_ID_SDMMC3,
148         PERIPH_ID_PCIE,
149         PERIPH_ID_OWR,
150
151         /* 72 */
152         PERIPH_ID_AFI,
153         PERIPH_ID_CORESIGHT,
154         PERIPH_ID_RESERVED74,
155         PERIPH_ID_AVPUCQ,
156         PERIPH_ID_RESERVED76,
157         PERIPH_ID_RESERVED77,
158         PERIPH_ID_RESERVED78,
159         PERIPH_ID_RESERVED79,
160
161         /* 80 */
162         PERIPH_ID_RESERVED80,
163         PERIPH_ID_RESERVED81,
164         PERIPH_ID_RESERVED82,
165         PERIPH_ID_RESERVED83,
166         PERIPH_ID_IRAMA,
167         PERIPH_ID_IRAMB,
168         PERIPH_ID_IRAMC,
169         PERIPH_ID_IRAMD,
170
171         /* 88 */
172         PERIPH_ID_CRAM2,
173
174         PERIPH_ID_COUNT,
175 };
176
177 /* Converts a clock number to a clock register: 0=L, 1=H, 2=U */
178 #define PERIPH_REG(id) ((id) >> 5)
179
180 /* Mask value for a clock (within PERIPH_REG(id)) */
181 #define PERIPH_MASK(id) (1 << ((id) & 0x1f))
182
183 /* return 1 if a PLL ID is in range */
184 #define clock_id_isvalid(id) ((id) >= CLOCK_ID_FIRST && (id) < CLOCK_ID_COUNT)
185
186 /* return 1 if a peripheral ID is in range */
187 #define clock_periph_id_isvalid(id) ((id) >= PERIPH_ID_FIRST && \
188                 (id) < PERIPH_ID_COUNT)
189
190 /* PLL stabilization delay in usec */
191 #define CLOCK_PLL_STABLE_DELAY_US 300
192
193 /* return the current oscillator clock frequency */
194 enum clock_osc_freq clock_get_osc_freq(void);
195
196 /**
197  * Start PLL using the provided configuration parameters.
198  *
199  * @param id    clock id
200  * @param divm  input divider
201  * @param divn  feedback divider
202  * @param divp  post divider 2^n
203  * @param cpcon charge pump setup control
204  * @param lfcon loop filter setup control
205  *
206  * @returns monotonic time in us that the PLL will be stable
207  */
208 unsigned long clock_start_pll(enum clock_id id, u32 divm, u32 divn,
209                 u32 divp, u32 cpcon, u32 lfcon);
210
211 /*
212  * Enable a clock
213  *
214  * @param id    clock id
215  */
216 void clock_enable(enum periph_id clkid);
217
218 /*
219  * Set whether a clock is enabled or disabled.
220  *
221  * @param id            clock id
222  * @param enable        1 to enable, 0 to disable
223  */
224 void clock_set_enable(enum periph_id clkid, int enable);
225
226 /**
227  * Reset a peripheral. This puts it in reset, waits for a delay, then takes
228  * it out of reset and waits for th delay again.
229  *
230  * @param periph_id     peripheral to reset
231  * @param us_delay      time to delay in microseconds
232  */
233 void reset_periph(enum periph_id periph_id, int us_delay);
234
235 /**
236  * Put a peripheral into or out of reset.
237  *
238  * @param periph_id     peripheral to reset
239  * @param enable        1 to put into reset, 0 to take out of reset
240  */
241 void reset_set_enable(enum periph_id periph_id, int enable);
242
243
244 /* CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET/CLR_0 */
245 enum crc_reset_id {
246         /* Things we can hold in reset for each CPU */
247         crc_rst_cpu = 1,
248         crc_rst_de = 1 << 2,    /* What is de? */
249         crc_rst_watchdog = 1 << 3,
250         crc_rst_debug = 1 << 4,
251 };
252
253 /**
254  * Put parts of the CPU complex into or out of reset.\
255  *
256  * @param cpu           cpu number (0 or 1 on Tegra2)
257  * @param which         which parts of the complex to affect (OR of crc_reset_id)
258  * @param reset         1 to assert reset, 0 to de-assert
259  */
260 void reset_cmplx_set_enable(int cpu, int which, int reset);
261
262 #endif