diff options
Diffstat (limited to 'arch/arm/mach-mx25/clock.c')
-rw-r--r-- | arch/arm/mach-mx25/clock.c | 70 |
1 files changed, 66 insertions, 4 deletions
diff --git a/arch/arm/mach-mx25/clock.c b/arch/arm/mach-mx25/clock.c index 155014993b13..40c7cc41cee3 100644 --- a/arch/arm/mach-mx25/clock.c +++ b/arch/arm/mach-mx25/clock.c | |||
@@ -109,6 +109,16 @@ static unsigned long get_rate_uart(struct clk *clk) | |||
109 | return get_rate_per(15); | 109 | return get_rate_per(15); |
110 | } | 110 | } |
111 | 111 | ||
112 | static unsigned long get_rate_ssi2(struct clk *clk) | ||
113 | { | ||
114 | return get_rate_per(14); | ||
115 | } | ||
116 | |||
117 | static unsigned long get_rate_ssi1(struct clk *clk) | ||
118 | { | ||
119 | return get_rate_per(13); | ||
120 | } | ||
121 | |||
112 | static unsigned long get_rate_i2c(struct clk *clk) | 122 | static unsigned long get_rate_i2c(struct clk *clk) |
113 | { | 123 | { |
114 | return get_rate_per(6); | 124 | return get_rate_per(6); |
@@ -129,9 +139,17 @@ static unsigned long get_rate_lcdc(struct clk *clk) | |||
129 | return get_rate_per(7); | 139 | return get_rate_per(7); |
130 | } | 140 | } |
131 | 141 | ||
142 | static unsigned long get_rate_csi(struct clk *clk) | ||
143 | { | ||
144 | return get_rate_per(0); | ||
145 | } | ||
146 | |||
132 | static unsigned long get_rate_otg(struct clk *clk) | 147 | static unsigned long get_rate_otg(struct clk *clk) |
133 | { | 148 | { |
134 | return 48000000; /* FIXME */ | 149 | unsigned long cctl = readl(CRM_BASE + CCM_CCTL); |
150 | unsigned long rate = get_rate_upll(); | ||
151 | |||
152 | return (cctl & (1 << 23)) ? 0 : rate / ((0x3F & (cctl >> 16)) + 1); | ||
135 | } | 153 | } |
136 | 154 | ||
137 | static int clk_cgcr_enable(struct clk *clk) | 155 | static int clk_cgcr_enable(struct clk *clk) |
@@ -166,14 +184,40 @@ static void clk_cgcr_disable(struct clk *clk) | |||
166 | .secondary = s, \ | 184 | .secondary = s, \ |
167 | } | 185 | } |
168 | 186 | ||
187 | /* | ||
188 | * Note: the following IPG clock gating bits are wrongly marked "Reserved" in | ||
189 | * the i.MX25 Reference Manual Rev 1, table 15-13. The information below is | ||
190 | * taken from the Freescale released BSP. | ||
191 | * | ||
192 | * bit reg offset clock | ||
193 | * | ||
194 | * 0 CGCR1 0 AUDMUX | ||
195 | * 12 CGCR1 12 ESAI | ||
196 | * 16 CGCR1 16 GPIO1 | ||
197 | * 17 CGCR1 17 GPIO2 | ||
198 | * 18 CGCR1 18 GPIO3 | ||
199 | * 23 CGCR1 23 I2C1 | ||
200 | * 24 CGCR1 24 I2C2 | ||
201 | * 25 CGCR1 25 I2C3 | ||
202 | * 27 CGCR1 27 IOMUXC | ||
203 | * 28 CGCR1 28 KPP | ||
204 | * 30 CGCR1 30 OWIRE | ||
205 | * 36 CGCR2 4 RTIC | ||
206 | * 51 CGCR2 19 WDOG | ||
207 | */ | ||
208 | |||
169 | DEFINE_CLOCK(gpt_clk, 0, CCM_CGCR0, 5, get_rate_gpt, NULL, NULL); | 209 | DEFINE_CLOCK(gpt_clk, 0, CCM_CGCR0, 5, get_rate_gpt, NULL, NULL); |
170 | DEFINE_CLOCK(uart_per_clk, 0, CCM_CGCR0, 15, get_rate_uart, NULL, NULL); | 210 | DEFINE_CLOCK(uart_per_clk, 0, CCM_CGCR0, 15, get_rate_uart, NULL, NULL); |
211 | DEFINE_CLOCK(ssi1_per_clk, 0, CCM_CGCR0, 13, get_rate_ipg, NULL, NULL); | ||
212 | DEFINE_CLOCK(ssi2_per_clk, 0, CCM_CGCR0, 14, get_rate_ipg, NULL, NULL); | ||
171 | DEFINE_CLOCK(cspi1_clk, 0, CCM_CGCR1, 5, get_rate_ipg, NULL, NULL); | 213 | DEFINE_CLOCK(cspi1_clk, 0, CCM_CGCR1, 5, get_rate_ipg, NULL, NULL); |
172 | DEFINE_CLOCK(cspi2_clk, 0, CCM_CGCR1, 6, get_rate_ipg, NULL, NULL); | 214 | DEFINE_CLOCK(cspi2_clk, 0, CCM_CGCR1, 6, get_rate_ipg, NULL, NULL); |
173 | DEFINE_CLOCK(cspi3_clk, 0, CCM_CGCR1, 7, get_rate_ipg, NULL, NULL); | 215 | DEFINE_CLOCK(cspi3_clk, 0, CCM_CGCR1, 7, get_rate_ipg, NULL, NULL); |
174 | DEFINE_CLOCK(fec_ahb_clk, 0, CCM_CGCR0, 23, NULL, NULL, NULL); | 216 | DEFINE_CLOCK(fec_ahb_clk, 0, CCM_CGCR0, 23, NULL, NULL, NULL); |
175 | DEFINE_CLOCK(lcdc_ahb_clk, 0, CCM_CGCR0, 24, NULL, NULL, NULL); | 217 | DEFINE_CLOCK(lcdc_ahb_clk, 0, CCM_CGCR0, 24, NULL, NULL, NULL); |
176 | DEFINE_CLOCK(lcdc_per_clk, 0, CCM_CGCR0, 7, NULL, NULL, &lcdc_ahb_clk); | 218 | DEFINE_CLOCK(lcdc_per_clk, 0, CCM_CGCR0, 7, NULL, NULL, &lcdc_ahb_clk); |
219 | DEFINE_CLOCK(csi_ahb_clk, 0, CCM_CGCR0, 18, get_rate_csi, NULL, NULL); | ||
220 | DEFINE_CLOCK(csi_per_clk, 0, CCM_CGCR0, 0, get_rate_csi, NULL, &csi_ahb_clk); | ||
177 | DEFINE_CLOCK(uart1_clk, 0, CCM_CGCR2, 14, get_rate_uart, NULL, &uart_per_clk); | 221 | DEFINE_CLOCK(uart1_clk, 0, CCM_CGCR2, 14, get_rate_uart, NULL, &uart_per_clk); |
178 | DEFINE_CLOCK(uart2_clk, 0, CCM_CGCR2, 15, get_rate_uart, NULL, &uart_per_clk); | 222 | DEFINE_CLOCK(uart2_clk, 0, CCM_CGCR2, 15, get_rate_uart, NULL, &uart_per_clk); |
179 | DEFINE_CLOCK(uart3_clk, 0, CCM_CGCR2, 16, get_rate_uart, NULL, &uart_per_clk); | 223 | DEFINE_CLOCK(uart3_clk, 0, CCM_CGCR2, 16, get_rate_uart, NULL, &uart_per_clk); |
@@ -191,6 +235,13 @@ DEFINE_CLOCK(i2c_clk, 0, CCM_CGCR0, 6, get_rate_i2c, NULL, NULL); | |||
191 | DEFINE_CLOCK(fec_clk, 0, CCM_CGCR1, 15, get_rate_ipg, NULL, &fec_ahb_clk); | 235 | DEFINE_CLOCK(fec_clk, 0, CCM_CGCR1, 15, get_rate_ipg, NULL, &fec_ahb_clk); |
192 | DEFINE_CLOCK(dryice_clk, 0, CCM_CGCR1, 8, get_rate_ipg, NULL, NULL); | 236 | DEFINE_CLOCK(dryice_clk, 0, CCM_CGCR1, 8, get_rate_ipg, NULL, NULL); |
193 | DEFINE_CLOCK(lcdc_clk, 0, CCM_CGCR1, 29, get_rate_lcdc, NULL, &lcdc_per_clk); | 237 | DEFINE_CLOCK(lcdc_clk, 0, CCM_CGCR1, 29, get_rate_lcdc, NULL, &lcdc_per_clk); |
238 | DEFINE_CLOCK(wdt_clk, 0, CCM_CGCR2, 19, get_rate_ipg, NULL, NULL); | ||
239 | DEFINE_CLOCK(ssi1_clk, 0, CCM_CGCR2, 11, get_rate_ssi1, NULL, &ssi1_per_clk); | ||
240 | DEFINE_CLOCK(ssi2_clk, 1, CCM_CGCR2, 12, get_rate_ssi2, NULL, &ssi2_per_clk); | ||
241 | DEFINE_CLOCK(audmux_clk, 0, CCM_CGCR1, 0, NULL, NULL, NULL); | ||
242 | DEFINE_CLOCK(csi_clk, 0, CCM_CGCR1, 4, get_rate_csi, NULL, &csi_per_clk); | ||
243 | DEFINE_CLOCK(can1_clk, 0, CCM_CGCR1, 2, get_rate_ipg, NULL, NULL); | ||
244 | DEFINE_CLOCK(can2_clk, 0, CCM_CGCR1, 3, get_rate_ipg, NULL, NULL); | ||
194 | 245 | ||
195 | #define _REGISTER_CLOCK(d, n, c) \ | 246 | #define _REGISTER_CLOCK(d, n, c) \ |
196 | { \ | 247 | { \ |
@@ -217,7 +268,7 @@ static struct clk_lookup lookups[] = { | |||
217 | _REGISTER_CLOCK("mxc_pwm.1", NULL, pwm2_clk) | 268 | _REGISTER_CLOCK("mxc_pwm.1", NULL, pwm2_clk) |
218 | _REGISTER_CLOCK("mxc_pwm.2", NULL, pwm3_clk) | 269 | _REGISTER_CLOCK("mxc_pwm.2", NULL, pwm3_clk) |
219 | _REGISTER_CLOCK("mxc_pwm.3", NULL, pwm4_clk) | 270 | _REGISTER_CLOCK("mxc_pwm.3", NULL, pwm4_clk) |
220 | _REGISTER_CLOCK("mxc-keypad", NULL, kpp_clk) | 271 | _REGISTER_CLOCK("imx-keypad", NULL, kpp_clk) |
221 | _REGISTER_CLOCK("mx25-adc", NULL, tsc_clk) | 272 | _REGISTER_CLOCK("mx25-adc", NULL, tsc_clk) |
222 | _REGISTER_CLOCK("imx-i2c.0", NULL, i2c_clk) | 273 | _REGISTER_CLOCK("imx-i2c.0", NULL, i2c_clk) |
223 | _REGISTER_CLOCK("imx-i2c.1", NULL, i2c_clk) | 274 | _REGISTER_CLOCK("imx-i2c.1", NULL, i2c_clk) |
@@ -225,6 +276,13 @@ static struct clk_lookup lookups[] = { | |||
225 | _REGISTER_CLOCK("fec.0", NULL, fec_clk) | 276 | _REGISTER_CLOCK("fec.0", NULL, fec_clk) |
226 | _REGISTER_CLOCK("imxdi_rtc.0", NULL, dryice_clk) | 277 | _REGISTER_CLOCK("imxdi_rtc.0", NULL, dryice_clk) |
227 | _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk) | 278 | _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk) |
279 | _REGISTER_CLOCK("imx-wdt.0", NULL, wdt_clk) | ||
280 | _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) | ||
281 | _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk) | ||
282 | _REGISTER_CLOCK("mx2-camera.0", NULL, csi_clk) | ||
283 | _REGISTER_CLOCK(NULL, "audmux", audmux_clk) | ||
284 | _REGISTER_CLOCK("flexcan.0", NULL, can1_clk) | ||
285 | _REGISTER_CLOCK("flexcan.1", NULL, can2_clk) | ||
228 | }; | 286 | }; |
229 | 287 | ||
230 | int __init mx25_clocks_init(void) | 288 | int __init mx25_clocks_init(void) |
@@ -238,9 +296,13 @@ int __init mx25_clocks_init(void) | |||
238 | __raw_writel((1 << 19), CRM_BASE + CCM_CGCR0); | 296 | __raw_writel((1 << 19), CRM_BASE + CCM_CGCR0); |
239 | __raw_writel((0xf << 16) | (3 << 26), CRM_BASE + CCM_CGCR1); | 297 | __raw_writel((0xf << 16) | (3 << 26), CRM_BASE + CCM_CGCR1); |
240 | __raw_writel((1 << 5), CRM_BASE + CCM_CGCR2); | 298 | __raw_writel((1 << 5), CRM_BASE + CCM_CGCR2); |
299 | #if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC) | ||
300 | clk_enable(&uart1_clk); | ||
301 | #endif | ||
241 | 302 | ||
242 | /* Clock source for lcdc is upll */ | 303 | /* Clock source for lcdc and csi is upll */ |
243 | __raw_writel(__raw_readl(CRM_BASE+0x64) | (1 << 7), CRM_BASE + 0x64); | 304 | __raw_writel(__raw_readl(CRM_BASE+0x64) | (1 << 7) | (1 << 0), |
305 | CRM_BASE + 0x64); | ||
244 | 306 | ||
245 | mxc_timer_init(&gpt_clk, MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), 54); | 307 | mxc_timer_init(&gpt_clk, MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), 54); |
246 | 308 | ||