blob: b047f87022785477ffafc8336bfd438f27e51ae9 [file] [log] [blame]
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -04001/*
2 * TI DA850/OMAP-L138 chip specific setup
3 *
4 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * Derived from: arch/arm/mach-davinci/da830.c
7 * Original Copyrights follow:
8 *
9 * 2009 (c) MontaVista Software, Inc. This file is licensed under
10 * the terms of the GNU General Public License version 2. This program
11 * is licensed "as is" without any warranty of any kind, whether express
12 * or implied.
13 */
Russell King2f8163b2011-07-26 10:53:52 +010014#include <linux/gpio.h>
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -040015#include <linux/init.h>
16#include <linux/clk.h>
17#include <linux/platform_device.h>
Sekhar Nori683b1e12009-09-22 21:14:01 +053018#include <linux/cpufreq.h>
Sekhar Nori35f9acd2009-09-22 21:14:02 +053019#include <linux/regulator/consumer.h>
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -040020
21#include <asm/mach/map.h>
22
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -040023#include <mach/psc.h>
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -040024#include <mach/irqs.h>
25#include <mach/cputype.h>
26#include <mach/common.h>
27#include <mach/time.h>
28#include <mach/da8xx.h>
Sekhar Nori683b1e12009-09-22 21:14:01 +053029#include <mach/cpufreq.h>
Sekhar Nori044ca012009-12-17 18:29:32 +053030#include <mach/pm.h>
Linus Walleij5f3fcf92011-08-22 08:40:38 +010031#include <mach/gpio-davinci.h>
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -040032
33#include "clock.h"
34#include "mux.h"
35
Sekhar Nori5d36a332009-08-31 15:48:05 +053036/* SoC specific clock flags */
37#define DA850_CLK_ASYNC3 BIT(16)
38
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -040039#define DA850_PLL1_BASE 0x01e1a000
40#define DA850_TIMER64P2_BASE 0x01f0c000
41#define DA850_TIMER64P3_BASE 0x01f0d000
42
43#define DA850_REF_FREQ 24000000
44
Sekhar Nori5d36a332009-08-31 15:48:05 +053045#define CFGCHIP3_ASYNC3_CLKSRC BIT(4)
Sekhar Nori7aad4722009-11-16 17:21:38 +053046#define CFGCHIP3_PLL1_MASTER_LOCK BIT(5)
Sekhar Nori683b1e12009-09-22 21:14:01 +053047#define CFGCHIP0_PLL_MASTER_LOCK BIT(4)
48
49static int da850_set_armrate(struct clk *clk, unsigned long rate);
50static int da850_round_armrate(struct clk *clk, unsigned long rate);
51static int da850_set_pll0rate(struct clk *clk, unsigned long armrate);
Sekhar Nori5d36a332009-08-31 15:48:05 +053052
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -040053static struct pll_data pll0_data = {
54 .num = 1,
55 .phys_base = DA8XX_PLL0_BASE,
56 .flags = PLL_HAS_PREDIV | PLL_HAS_POSTDIV,
57};
58
59static struct clk ref_clk = {
60 .name = "ref_clk",
61 .rate = DA850_REF_FREQ,
Christian Riesch8d542972011-06-28 15:10:51 +000062 .set_rate = davinci_simple_set_rate,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -040063};
64
65static struct clk pll0_clk = {
66 .name = "pll0",
67 .parent = &ref_clk,
68 .pll_data = &pll0_data,
69 .flags = CLK_PLL,
Sekhar Nori683b1e12009-09-22 21:14:01 +053070 .set_rate = da850_set_pll0rate,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -040071};
72
73static struct clk pll0_aux_clk = {
74 .name = "pll0_aux_clk",
75 .parent = &pll0_clk,
76 .flags = CLK_PLL | PRE_PLL,
77};
78
79static struct clk pll0_sysclk2 = {
80 .name = "pll0_sysclk2",
81 .parent = &pll0_clk,
82 .flags = CLK_PLL,
83 .div_reg = PLLDIV2,
84};
85
86static struct clk pll0_sysclk3 = {
87 .name = "pll0_sysclk3",
88 .parent = &pll0_clk,
89 .flags = CLK_PLL,
90 .div_reg = PLLDIV3,
Sekhar Norib987c4b2010-07-20 16:46:51 +053091 .set_rate = davinci_set_sysclk_rate,
92 .maxrate = 100000000,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -040093};
94
95static struct clk pll0_sysclk4 = {
96 .name = "pll0_sysclk4",
97 .parent = &pll0_clk,
98 .flags = CLK_PLL,
99 .div_reg = PLLDIV4,
100};
101
102static struct clk pll0_sysclk5 = {
103 .name = "pll0_sysclk5",
104 .parent = &pll0_clk,
105 .flags = CLK_PLL,
106 .div_reg = PLLDIV5,
107};
108
109static struct clk pll0_sysclk6 = {
110 .name = "pll0_sysclk6",
111 .parent = &pll0_clk,
112 .flags = CLK_PLL,
113 .div_reg = PLLDIV6,
114};
115
116static struct clk pll0_sysclk7 = {
117 .name = "pll0_sysclk7",
118 .parent = &pll0_clk,
119 .flags = CLK_PLL,
120 .div_reg = PLLDIV7,
121};
122
123static struct pll_data pll1_data = {
124 .num = 2,
125 .phys_base = DA850_PLL1_BASE,
126 .flags = PLL_HAS_POSTDIV,
127};
128
129static struct clk pll1_clk = {
130 .name = "pll1",
131 .parent = &ref_clk,
132 .pll_data = &pll1_data,
133 .flags = CLK_PLL,
134};
135
136static struct clk pll1_aux_clk = {
137 .name = "pll1_aux_clk",
138 .parent = &pll1_clk,
139 .flags = CLK_PLL | PRE_PLL,
140};
141
142static struct clk pll1_sysclk2 = {
143 .name = "pll1_sysclk2",
144 .parent = &pll1_clk,
145 .flags = CLK_PLL,
146 .div_reg = PLLDIV2,
147};
148
149static struct clk pll1_sysclk3 = {
150 .name = "pll1_sysclk3",
151 .parent = &pll1_clk,
152 .flags = CLK_PLL,
153 .div_reg = PLLDIV3,
154};
155
156static struct clk pll1_sysclk4 = {
157 .name = "pll1_sysclk4",
158 .parent = &pll1_clk,
159 .flags = CLK_PLL,
160 .div_reg = PLLDIV4,
161};
162
163static struct clk pll1_sysclk5 = {
164 .name = "pll1_sysclk5",
165 .parent = &pll1_clk,
166 .flags = CLK_PLL,
167 .div_reg = PLLDIV5,
168};
169
170static struct clk pll1_sysclk6 = {
171 .name = "pll0_sysclk6",
172 .parent = &pll0_clk,
173 .flags = CLK_PLL,
174 .div_reg = PLLDIV6,
175};
176
177static struct clk pll1_sysclk7 = {
178 .name = "pll1_sysclk7",
179 .parent = &pll1_clk,
180 .flags = CLK_PLL,
181 .div_reg = PLLDIV7,
182};
183
184static struct clk i2c0_clk = {
185 .name = "i2c0",
186 .parent = &pll0_aux_clk,
187};
188
189static struct clk timerp64_0_clk = {
190 .name = "timer0",
191 .parent = &pll0_aux_clk,
192};
193
194static struct clk timerp64_1_clk = {
195 .name = "timer1",
196 .parent = &pll0_aux_clk,
197};
198
199static struct clk arm_rom_clk = {
200 .name = "arm_rom",
201 .parent = &pll0_sysclk2,
202 .lpsc = DA8XX_LPSC0_ARM_RAM_ROM,
203 .flags = ALWAYS_ENABLED,
204};
205
206static struct clk tpcc0_clk = {
207 .name = "tpcc0",
208 .parent = &pll0_sysclk2,
209 .lpsc = DA8XX_LPSC0_TPCC,
210 .flags = ALWAYS_ENABLED | CLK_PSC,
211};
212
213static struct clk tptc0_clk = {
214 .name = "tptc0",
215 .parent = &pll0_sysclk2,
216 .lpsc = DA8XX_LPSC0_TPTC0,
217 .flags = ALWAYS_ENABLED,
218};
219
220static struct clk tptc1_clk = {
221 .name = "tptc1",
222 .parent = &pll0_sysclk2,
223 .lpsc = DA8XX_LPSC0_TPTC1,
224 .flags = ALWAYS_ENABLED,
225};
226
227static struct clk tpcc1_clk = {
228 .name = "tpcc1",
229 .parent = &pll0_sysclk2,
230 .lpsc = DA850_LPSC1_TPCC1,
Sergei Shtylyov789a7852009-09-30 19:48:03 +0400231 .gpsc = 1,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400232 .flags = CLK_PSC | ALWAYS_ENABLED,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400233};
234
235static struct clk tptc2_clk = {
236 .name = "tptc2",
237 .parent = &pll0_sysclk2,
238 .lpsc = DA850_LPSC1_TPTC2,
Sergei Shtylyov789a7852009-09-30 19:48:03 +0400239 .gpsc = 1,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400240 .flags = ALWAYS_ENABLED,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400241};
242
243static struct clk uart0_clk = {
244 .name = "uart0",
245 .parent = &pll0_sysclk2,
246 .lpsc = DA8XX_LPSC0_UART0,
247};
248
249static struct clk uart1_clk = {
250 .name = "uart1",
251 .parent = &pll0_sysclk2,
252 .lpsc = DA8XX_LPSC1_UART1,
Sergei Shtylyov789a7852009-09-30 19:48:03 +0400253 .gpsc = 1,
Sekhar Nori5d36a332009-08-31 15:48:05 +0530254 .flags = DA850_CLK_ASYNC3,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400255};
256
257static struct clk uart2_clk = {
258 .name = "uart2",
259 .parent = &pll0_sysclk2,
260 .lpsc = DA8XX_LPSC1_UART2,
Sergei Shtylyov789a7852009-09-30 19:48:03 +0400261 .gpsc = 1,
Sekhar Nori5d36a332009-08-31 15:48:05 +0530262 .flags = DA850_CLK_ASYNC3,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400263};
264
265static struct clk aintc_clk = {
266 .name = "aintc",
267 .parent = &pll0_sysclk4,
268 .lpsc = DA8XX_LPSC0_AINTC,
269 .flags = ALWAYS_ENABLED,
270};
271
272static struct clk gpio_clk = {
273 .name = "gpio",
274 .parent = &pll0_sysclk4,
275 .lpsc = DA8XX_LPSC1_GPIO,
Sergei Shtylyov789a7852009-09-30 19:48:03 +0400276 .gpsc = 1,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400277};
278
279static struct clk i2c1_clk = {
280 .name = "i2c1",
281 .parent = &pll0_sysclk4,
282 .lpsc = DA8XX_LPSC1_I2C,
Sergei Shtylyov789a7852009-09-30 19:48:03 +0400283 .gpsc = 1,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400284};
285
286static struct clk emif3_clk = {
287 .name = "emif3",
288 .parent = &pll0_sysclk5,
289 .lpsc = DA8XX_LPSC1_EMIF3C,
Sergei Shtylyov789a7852009-09-30 19:48:03 +0400290 .gpsc = 1,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400291 .flags = ALWAYS_ENABLED,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400292};
293
294static struct clk arm_clk = {
295 .name = "arm",
296 .parent = &pll0_sysclk6,
297 .lpsc = DA8XX_LPSC0_ARM,
298 .flags = ALWAYS_ENABLED,
Sekhar Nori683b1e12009-09-22 21:14:01 +0530299 .set_rate = da850_set_armrate,
300 .round_rate = da850_round_armrate,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400301};
302
303static struct clk rmii_clk = {
304 .name = "rmii",
305 .parent = &pll0_sysclk7,
306};
307
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -0400308static struct clk emac_clk = {
309 .name = "emac",
310 .parent = &pll0_sysclk4,
311 .lpsc = DA8XX_LPSC1_CPGMAC,
Sergei Shtylyov789a7852009-09-30 19:48:03 +0400312 .gpsc = 1,
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -0400313};
314
Chaithrika U S491214e2009-08-11 17:03:25 -0400315static struct clk mcasp_clk = {
316 .name = "mcasp",
317 .parent = &pll0_sysclk2,
318 .lpsc = DA8XX_LPSC1_McASP0,
Sergei Shtylyov789a7852009-09-30 19:48:03 +0400319 .gpsc = 1,
Chaithrika U S51157ed2009-10-13 17:32:43 +0530320 .flags = DA850_CLK_ASYNC3,
Chaithrika U S491214e2009-08-11 17:03:25 -0400321};
322
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400323static struct clk lcdc_clk = {
324 .name = "lcdc",
325 .parent = &pll0_sysclk2,
326 .lpsc = DA8XX_LPSC1_LCDC,
Sergei Shtylyov789a7852009-09-30 19:48:03 +0400327 .gpsc = 1,
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400328};
329
Juha Kuikka051a6682010-08-26 12:40:46 -0700330static struct clk mmcsd0_clk = {
331 .name = "mmcsd0",
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400332 .parent = &pll0_sysclk2,
333 .lpsc = DA8XX_LPSC0_MMC_SD,
334};
335
Juha Kuikka051a6682010-08-26 12:40:46 -0700336static struct clk mmcsd1_clk = {
337 .name = "mmcsd1",
338 .parent = &pll0_sysclk2,
339 .lpsc = DA850_LPSC1_MMC_SD1,
340 .gpsc = 1,
341};
342
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400343static struct clk aemif_clk = {
344 .name = "aemif",
345 .parent = &pll0_sysclk3,
346 .lpsc = DA8XX_LPSC0_EMIF25,
347 .flags = ALWAYS_ENABLED,
348};
349
Victor Rodriguez5efe3302010-12-27 16:43:12 -0600350static struct clk usb11_clk = {
351 .name = "usb11",
352 .parent = &pll0_sysclk4,
353 .lpsc = DA8XX_LPSC1_USB11,
354 .gpsc = 1,
355};
356
357static struct clk usb20_clk = {
358 .name = "usb20",
359 .parent = &pll0_sysclk2,
360 .lpsc = DA8XX_LPSC1_USB20,
361 .gpsc = 1,
362};
363
Michael Williamson12d35cf2011-02-22 13:37:00 +0000364static struct clk spi0_clk = {
365 .name = "spi0",
366 .parent = &pll0_sysclk2,
367 .lpsc = DA8XX_LPSC0_SPI0,
368};
369
370static struct clk spi1_clk = {
371 .name = "spi1",
372 .parent = &pll0_sysclk2,
373 .lpsc = DA8XX_LPSC1_SPI1,
374 .gpsc = 1,
375 .flags = DA850_CLK_ASYNC3,
376};
377
Sekhar Noricbb2c962011-07-06 06:01:23 +0000378static struct clk sata_clk = {
379 .name = "sata",
380 .parent = &pll0_sysclk2,
381 .lpsc = DA850_LPSC1_SATA,
382 .gpsc = 1,
383 .flags = PSC_FORCE,
384};
385
Kevin Hilman08aca082010-01-11 08:22:23 -0800386static struct clk_lookup da850_clks[] = {
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400387 CLK(NULL, "ref", &ref_clk),
388 CLK(NULL, "pll0", &pll0_clk),
389 CLK(NULL, "pll0_aux", &pll0_aux_clk),
390 CLK(NULL, "pll0_sysclk2", &pll0_sysclk2),
391 CLK(NULL, "pll0_sysclk3", &pll0_sysclk3),
392 CLK(NULL, "pll0_sysclk4", &pll0_sysclk4),
393 CLK(NULL, "pll0_sysclk5", &pll0_sysclk5),
394 CLK(NULL, "pll0_sysclk6", &pll0_sysclk6),
395 CLK(NULL, "pll0_sysclk7", &pll0_sysclk7),
396 CLK(NULL, "pll1", &pll1_clk),
397 CLK(NULL, "pll1_aux", &pll1_aux_clk),
398 CLK(NULL, "pll1_sysclk2", &pll1_sysclk2),
399 CLK(NULL, "pll1_sysclk3", &pll1_sysclk3),
400 CLK(NULL, "pll1_sysclk4", &pll1_sysclk4),
401 CLK(NULL, "pll1_sysclk5", &pll1_sysclk5),
402 CLK(NULL, "pll1_sysclk6", &pll1_sysclk6),
403 CLK(NULL, "pll1_sysclk7", &pll1_sysclk7),
404 CLK("i2c_davinci.1", NULL, &i2c0_clk),
405 CLK(NULL, "timer0", &timerp64_0_clk),
406 CLK("watchdog", NULL, &timerp64_1_clk),
407 CLK(NULL, "arm_rom", &arm_rom_clk),
408 CLK(NULL, "tpcc0", &tpcc0_clk),
409 CLK(NULL, "tptc0", &tptc0_clk),
410 CLK(NULL, "tptc1", &tptc1_clk),
411 CLK(NULL, "tpcc1", &tpcc1_clk),
412 CLK(NULL, "tptc2", &tptc2_clk),
413 CLK(NULL, "uart0", &uart0_clk),
414 CLK(NULL, "uart1", &uart1_clk),
415 CLK(NULL, "uart2", &uart2_clk),
416 CLK(NULL, "aintc", &aintc_clk),
417 CLK(NULL, "gpio", &gpio_clk),
418 CLK("i2c_davinci.2", NULL, &i2c1_clk),
419 CLK(NULL, "emif3", &emif3_clk),
420 CLK(NULL, "arm", &arm_clk),
421 CLK(NULL, "rmii", &rmii_clk),
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -0400422 CLK("davinci_emac.1", NULL, &emac_clk),
Chaithrika U S491214e2009-08-11 17:03:25 -0400423 CLK("davinci-mcasp.0", NULL, &mcasp_clk),
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400424 CLK("da8xx_lcdc.0", NULL, &lcdc_clk),
Juha Kuikka051a6682010-08-26 12:40:46 -0700425 CLK("davinci_mmc.0", NULL, &mmcsd0_clk),
426 CLK("davinci_mmc.1", NULL, &mmcsd1_clk),
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400427 CLK(NULL, "aemif", &aemif_clk),
Victor Rodriguez5efe3302010-12-27 16:43:12 -0600428 CLK(NULL, "usb11", &usb11_clk),
429 CLK(NULL, "usb20", &usb20_clk),
Michael Williamson12d35cf2011-02-22 13:37:00 +0000430 CLK("spi_davinci.0", NULL, &spi0_clk),
431 CLK("spi_davinci.1", NULL, &spi1_clk),
Sekhar Noricbb2c962011-07-06 06:01:23 +0000432 CLK("ahci", NULL, &sata_clk),
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400433 CLK(NULL, NULL, NULL),
434};
435
436/*
437 * Device specific mux setup
438 *
439 * soc description mux mode mode mux dbg
440 * reg offset mask mode
441 */
442static const struct mux_config da850_pins[] = {
443#ifdef CONFIG_DAVINCI_MUX
444 /* UART0 function */
445 MUX_CFG(DA850, NUART0_CTS, 3, 24, 15, 2, false)
446 MUX_CFG(DA850, NUART0_RTS, 3, 28, 15, 2, false)
447 MUX_CFG(DA850, UART0_RXD, 3, 16, 15, 2, false)
448 MUX_CFG(DA850, UART0_TXD, 3, 20, 15, 2, false)
449 /* UART1 function */
450 MUX_CFG(DA850, UART1_RXD, 4, 24, 15, 2, false)
451 MUX_CFG(DA850, UART1_TXD, 4, 28, 15, 2, false)
452 /* UART2 function */
453 MUX_CFG(DA850, UART2_RXD, 4, 16, 15, 2, false)
454 MUX_CFG(DA850, UART2_TXD, 4, 20, 15, 2, false)
455 /* I2C1 function */
456 MUX_CFG(DA850, I2C1_SCL, 4, 16, 15, 4, false)
457 MUX_CFG(DA850, I2C1_SDA, 4, 20, 15, 4, false)
458 /* I2C0 function */
459 MUX_CFG(DA850, I2C0_SDA, 4, 12, 15, 2, false)
460 MUX_CFG(DA850, I2C0_SCL, 4, 8, 15, 2, false)
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -0400461 /* EMAC function */
462 MUX_CFG(DA850, MII_TXEN, 2, 4, 15, 8, false)
463 MUX_CFG(DA850, MII_TXCLK, 2, 8, 15, 8, false)
464 MUX_CFG(DA850, MII_COL, 2, 12, 15, 8, false)
465 MUX_CFG(DA850, MII_TXD_3, 2, 16, 15, 8, false)
466 MUX_CFG(DA850, MII_TXD_2, 2, 20, 15, 8, false)
467 MUX_CFG(DA850, MII_TXD_1, 2, 24, 15, 8, false)
468 MUX_CFG(DA850, MII_TXD_0, 2, 28, 15, 8, false)
469 MUX_CFG(DA850, MII_RXCLK, 3, 0, 15, 8, false)
470 MUX_CFG(DA850, MII_RXDV, 3, 4, 15, 8, false)
471 MUX_CFG(DA850, MII_RXER, 3, 8, 15, 8, false)
472 MUX_CFG(DA850, MII_CRS, 3, 12, 15, 8, false)
473 MUX_CFG(DA850, MII_RXD_3, 3, 16, 15, 8, false)
474 MUX_CFG(DA850, MII_RXD_2, 3, 20, 15, 8, false)
475 MUX_CFG(DA850, MII_RXD_1, 3, 24, 15, 8, false)
476 MUX_CFG(DA850, MII_RXD_0, 3, 28, 15, 8, false)
Sudhakar Rajashekhara53ca5c92009-08-11 11:10:50 -0400477 MUX_CFG(DA850, MDIO_CLK, 4, 0, 15, 8, false)
478 MUX_CFG(DA850, MDIO_D, 4, 4, 15, 8, false)
Chaithrika U S22067712009-09-30 17:00:53 -0400479 MUX_CFG(DA850, RMII_TXD_0, 14, 12, 15, 8, false)
480 MUX_CFG(DA850, RMII_TXD_1, 14, 8, 15, 8, false)
481 MUX_CFG(DA850, RMII_TXEN, 14, 16, 15, 8, false)
482 MUX_CFG(DA850, RMII_CRS_DV, 15, 4, 15, 8, false)
483 MUX_CFG(DA850, RMII_RXD_0, 14, 24, 15, 8, false)
484 MUX_CFG(DA850, RMII_RXD_1, 14, 20, 15, 8, false)
485 MUX_CFG(DA850, RMII_RXER, 14, 28, 15, 8, false)
486 MUX_CFG(DA850, RMII_MHZ_50_CLK, 15, 0, 15, 0, false)
Chaithrika U S491214e2009-08-11 17:03:25 -0400487 /* McASP function */
488 MUX_CFG(DA850, ACLKR, 0, 0, 15, 1, false)
489 MUX_CFG(DA850, ACLKX, 0, 4, 15, 1, false)
490 MUX_CFG(DA850, AFSR, 0, 8, 15, 1, false)
491 MUX_CFG(DA850, AFSX, 0, 12, 15, 1, false)
492 MUX_CFG(DA850, AHCLKR, 0, 16, 15, 1, false)
493 MUX_CFG(DA850, AHCLKX, 0, 20, 15, 1, false)
494 MUX_CFG(DA850, AMUTE, 0, 24, 15, 1, false)
495 MUX_CFG(DA850, AXR_15, 1, 0, 15, 1, false)
496 MUX_CFG(DA850, AXR_14, 1, 4, 15, 1, false)
497 MUX_CFG(DA850, AXR_13, 1, 8, 15, 1, false)
498 MUX_CFG(DA850, AXR_12, 1, 12, 15, 1, false)
499 MUX_CFG(DA850, AXR_11, 1, 16, 15, 1, false)
500 MUX_CFG(DA850, AXR_10, 1, 20, 15, 1, false)
501 MUX_CFG(DA850, AXR_9, 1, 24, 15, 1, false)
502 MUX_CFG(DA850, AXR_8, 1, 28, 15, 1, false)
503 MUX_CFG(DA850, AXR_7, 2, 0, 15, 1, false)
504 MUX_CFG(DA850, AXR_6, 2, 4, 15, 1, false)
505 MUX_CFG(DA850, AXR_5, 2, 8, 15, 1, false)
506 MUX_CFG(DA850, AXR_4, 2, 12, 15, 1, false)
507 MUX_CFG(DA850, AXR_3, 2, 16, 15, 1, false)
508 MUX_CFG(DA850, AXR_2, 2, 20, 15, 1, false)
509 MUX_CFG(DA850, AXR_1, 2, 24, 15, 1, false)
510 MUX_CFG(DA850, AXR_0, 2, 28, 15, 1, false)
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400511 /* LCD function */
512 MUX_CFG(DA850, LCD_D_7, 16, 8, 15, 2, false)
513 MUX_CFG(DA850, LCD_D_6, 16, 12, 15, 2, false)
514 MUX_CFG(DA850, LCD_D_5, 16, 16, 15, 2, false)
515 MUX_CFG(DA850, LCD_D_4, 16, 20, 15, 2, false)
516 MUX_CFG(DA850, LCD_D_3, 16, 24, 15, 2, false)
517 MUX_CFG(DA850, LCD_D_2, 16, 28, 15, 2, false)
518 MUX_CFG(DA850, LCD_D_1, 17, 0, 15, 2, false)
519 MUX_CFG(DA850, LCD_D_0, 17, 4, 15, 2, false)
520 MUX_CFG(DA850, LCD_D_15, 17, 8, 15, 2, false)
521 MUX_CFG(DA850, LCD_D_14, 17, 12, 15, 2, false)
522 MUX_CFG(DA850, LCD_D_13, 17, 16, 15, 2, false)
523 MUX_CFG(DA850, LCD_D_12, 17, 20, 15, 2, false)
524 MUX_CFG(DA850, LCD_D_11, 17, 24, 15, 2, false)
525 MUX_CFG(DA850, LCD_D_10, 17, 28, 15, 2, false)
526 MUX_CFG(DA850, LCD_D_9, 18, 0, 15, 2, false)
527 MUX_CFG(DA850, LCD_D_8, 18, 4, 15, 2, false)
528 MUX_CFG(DA850, LCD_PCLK, 18, 24, 15, 2, false)
529 MUX_CFG(DA850, LCD_HSYNC, 19, 0, 15, 2, false)
530 MUX_CFG(DA850, LCD_VSYNC, 19, 4, 15, 2, false)
531 MUX_CFG(DA850, NLCD_AC_ENB_CS, 19, 24, 15, 2, false)
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400532 /* MMC/SD0 function */
533 MUX_CFG(DA850, MMCSD0_DAT_0, 10, 8, 15, 2, false)
534 MUX_CFG(DA850, MMCSD0_DAT_1, 10, 12, 15, 2, false)
535 MUX_CFG(DA850, MMCSD0_DAT_2, 10, 16, 15, 2, false)
536 MUX_CFG(DA850, MMCSD0_DAT_3, 10, 20, 15, 2, false)
537 MUX_CFG(DA850, MMCSD0_CLK, 10, 0, 15, 2, false)
538 MUX_CFG(DA850, MMCSD0_CMD, 10, 4, 15, 2, false)
Ido Yariv5c4d11b2011-07-10 16:14:37 +0300539 /* MMC/SD1 function */
540 MUX_CFG(DA850, MMCSD1_DAT_0, 18, 8, 15, 2, false)
541 MUX_CFG(DA850, MMCSD1_DAT_1, 19, 16, 15, 2, false)
542 MUX_CFG(DA850, MMCSD1_DAT_2, 19, 12, 15, 2, false)
543 MUX_CFG(DA850, MMCSD1_DAT_3, 19, 8, 15, 2, false)
544 MUX_CFG(DA850, MMCSD1_CLK, 18, 12, 15, 2, false)
545 MUX_CFG(DA850, MMCSD1_CMD, 18, 16, 15, 2, false)
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400546 /* EMIF2.5/EMIFA function */
547 MUX_CFG(DA850, EMA_D_7, 9, 0, 15, 1, false)
548 MUX_CFG(DA850, EMA_D_6, 9, 4, 15, 1, false)
549 MUX_CFG(DA850, EMA_D_5, 9, 8, 15, 1, false)
550 MUX_CFG(DA850, EMA_D_4, 9, 12, 15, 1, false)
551 MUX_CFG(DA850, EMA_D_3, 9, 16, 15, 1, false)
552 MUX_CFG(DA850, EMA_D_2, 9, 20, 15, 1, false)
553 MUX_CFG(DA850, EMA_D_1, 9, 24, 15, 1, false)
554 MUX_CFG(DA850, EMA_D_0, 9, 28, 15, 1, false)
555 MUX_CFG(DA850, EMA_A_1, 12, 24, 15, 1, false)
556 MUX_CFG(DA850, EMA_A_2, 12, 20, 15, 1, false)
557 MUX_CFG(DA850, NEMA_CS_3, 7, 4, 15, 1, false)
558 MUX_CFG(DA850, NEMA_CS_4, 7, 8, 15, 1, false)
559 MUX_CFG(DA850, NEMA_WE, 7, 16, 15, 1, false)
560 MUX_CFG(DA850, NEMA_OE, 7, 20, 15, 1, false)
Sudhakar Rajashekhara7c5ec602009-08-13 17:36:25 -0400561 MUX_CFG(DA850, EMA_A_0, 12, 28, 15, 1, false)
562 MUX_CFG(DA850, EMA_A_3, 12, 16, 15, 1, false)
563 MUX_CFG(DA850, EMA_A_4, 12, 12, 15, 1, false)
564 MUX_CFG(DA850, EMA_A_5, 12, 8, 15, 1, false)
565 MUX_CFG(DA850, EMA_A_6, 12, 4, 15, 1, false)
566 MUX_CFG(DA850, EMA_A_7, 12, 0, 15, 1, false)
567 MUX_CFG(DA850, EMA_A_8, 11, 28, 15, 1, false)
568 MUX_CFG(DA850, EMA_A_9, 11, 24, 15, 1, false)
569 MUX_CFG(DA850, EMA_A_10, 11, 20, 15, 1, false)
570 MUX_CFG(DA850, EMA_A_11, 11, 16, 15, 1, false)
571 MUX_CFG(DA850, EMA_A_12, 11, 12, 15, 1, false)
572 MUX_CFG(DA850, EMA_A_13, 11, 8, 15, 1, false)
573 MUX_CFG(DA850, EMA_A_14, 11, 4, 15, 1, false)
574 MUX_CFG(DA850, EMA_A_15, 11, 0, 15, 1, false)
575 MUX_CFG(DA850, EMA_A_16, 10, 28, 15, 1, false)
576 MUX_CFG(DA850, EMA_A_17, 10, 24, 15, 1, false)
577 MUX_CFG(DA850, EMA_A_18, 10, 20, 15, 1, false)
578 MUX_CFG(DA850, EMA_A_19, 10, 16, 15, 1, false)
579 MUX_CFG(DA850, EMA_A_20, 10, 12, 15, 1, false)
580 MUX_CFG(DA850, EMA_A_21, 10, 8, 15, 1, false)
581 MUX_CFG(DA850, EMA_A_22, 10, 4, 15, 1, false)
582 MUX_CFG(DA850, EMA_A_23, 10, 0, 15, 1, false)
583 MUX_CFG(DA850, EMA_D_8, 8, 28, 15, 1, false)
584 MUX_CFG(DA850, EMA_D_9, 8, 24, 15, 1, false)
585 MUX_CFG(DA850, EMA_D_10, 8, 20, 15, 1, false)
586 MUX_CFG(DA850, EMA_D_11, 8, 16, 15, 1, false)
587 MUX_CFG(DA850, EMA_D_12, 8, 12, 15, 1, false)
588 MUX_CFG(DA850, EMA_D_13, 8, 8, 15, 1, false)
589 MUX_CFG(DA850, EMA_D_14, 8, 4, 15, 1, false)
590 MUX_CFG(DA850, EMA_D_15, 8, 0, 15, 1, false)
591 MUX_CFG(DA850, EMA_BA_1, 5, 24, 15, 1, false)
592 MUX_CFG(DA850, EMA_CLK, 6, 0, 15, 1, false)
593 MUX_CFG(DA850, EMA_WAIT_1, 6, 24, 15, 1, false)
594 MUX_CFG(DA850, NEMA_CS_2, 7, 0, 15, 1, false)
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400595 /* GPIO function */
Victor Rodriguezfe358d62010-12-27 16:43:10 -0600596 MUX_CFG(DA850, GPIO2_4, 6, 12, 15, 8, false)
Chaithrika U S22067712009-09-30 17:00:53 -0400597 MUX_CFG(DA850, GPIO2_6, 6, 4, 15, 8, false)
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -0400598 MUX_CFG(DA850, GPIO2_8, 5, 28, 15, 8, false)
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400599 MUX_CFG(DA850, GPIO2_15, 5, 0, 15, 8, false)
Victor Rodriguezfe358d62010-12-27 16:43:10 -0600600 MUX_CFG(DA850, GPIO3_12, 7, 12, 15, 8, false)
601 MUX_CFG(DA850, GPIO3_13, 7, 8, 15, 8, false)
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400602 MUX_CFG(DA850, GPIO4_0, 10, 28, 15, 8, false)
603 MUX_CFG(DA850, GPIO4_1, 10, 24, 15, 8, false)
Ido Yariv68369892011-07-10 16:14:38 +0300604 MUX_CFG(DA850, GPIO6_9, 13, 24, 15, 8, false)
605 MUX_CFG(DA850, GPIO6_10, 13, 20, 15, 8, false)
Victor Rodriguezfe358d62010-12-27 16:43:10 -0600606 MUX_CFG(DA850, GPIO6_13, 13, 8, 15, 8, false)
Sekhar Nori044ca012009-12-17 18:29:32 +0530607 MUX_CFG(DA850, RTC_ALARM, 0, 28, 15, 2, false)
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400608#endif
609};
610
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400611const short da850_i2c0_pins[] __initdata = {
612 DA850_I2C0_SDA, DA850_I2C0_SCL,
613 -1
614};
615
616const short da850_i2c1_pins[] __initdata = {
617 DA850_I2C1_SCL, DA850_I2C1_SDA,
618 -1
619};
620
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400621const short da850_lcdcntl_pins[] __initdata = {
Sudhakar Rajashekhara7761ef62009-09-15 17:46:14 -0400622 DA850_LCD_D_0, DA850_LCD_D_1, DA850_LCD_D_2, DA850_LCD_D_3,
623 DA850_LCD_D_4, DA850_LCD_D_5, DA850_LCD_D_6, DA850_LCD_D_7,
624 DA850_LCD_D_8, DA850_LCD_D_9, DA850_LCD_D_10, DA850_LCD_D_11,
625 DA850_LCD_D_12, DA850_LCD_D_13, DA850_LCD_D_14, DA850_LCD_D_15,
626 DA850_LCD_PCLK, DA850_LCD_HSYNC, DA850_LCD_VSYNC, DA850_NLCD_AC_ENB_CS,
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400627 -1
628};
629
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400630/* FIQ are pri 0-1; otherwise 2-7, with 7 lowest priority */
631static u8 da850_default_priorities[DA850_N_CP_INTC_IRQ] = {
632 [IRQ_DA8XX_COMMTX] = 7,
633 [IRQ_DA8XX_COMMRX] = 7,
634 [IRQ_DA8XX_NINT] = 7,
635 [IRQ_DA8XX_EVTOUT0] = 7,
636 [IRQ_DA8XX_EVTOUT1] = 7,
637 [IRQ_DA8XX_EVTOUT2] = 7,
638 [IRQ_DA8XX_EVTOUT3] = 7,
639 [IRQ_DA8XX_EVTOUT4] = 7,
640 [IRQ_DA8XX_EVTOUT5] = 7,
641 [IRQ_DA8XX_EVTOUT6] = 7,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400642 [IRQ_DA8XX_EVTOUT7] = 7,
643 [IRQ_DA8XX_CCINT0] = 7,
644 [IRQ_DA8XX_CCERRINT] = 7,
645 [IRQ_DA8XX_TCERRINT0] = 7,
646 [IRQ_DA8XX_AEMIFINT] = 7,
647 [IRQ_DA8XX_I2CINT0] = 7,
648 [IRQ_DA8XX_MMCSDINT0] = 7,
649 [IRQ_DA8XX_MMCSDINT1] = 7,
650 [IRQ_DA8XX_ALLINT0] = 7,
651 [IRQ_DA8XX_RTC] = 7,
652 [IRQ_DA8XX_SPINT0] = 7,
653 [IRQ_DA8XX_TINT12_0] = 7,
654 [IRQ_DA8XX_TINT34_0] = 7,
655 [IRQ_DA8XX_TINT12_1] = 7,
656 [IRQ_DA8XX_TINT34_1] = 7,
657 [IRQ_DA8XX_UARTINT0] = 7,
658 [IRQ_DA8XX_KEYMGRINT] = 7,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400659 [IRQ_DA850_MPUADDRERR0] = 7,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400660 [IRQ_DA8XX_CHIPINT0] = 7,
661 [IRQ_DA8XX_CHIPINT1] = 7,
662 [IRQ_DA8XX_CHIPINT2] = 7,
663 [IRQ_DA8XX_CHIPINT3] = 7,
664 [IRQ_DA8XX_TCERRINT1] = 7,
665 [IRQ_DA8XX_C0_RX_THRESH_PULSE] = 7,
666 [IRQ_DA8XX_C0_RX_PULSE] = 7,
667 [IRQ_DA8XX_C0_TX_PULSE] = 7,
668 [IRQ_DA8XX_C0_MISC_PULSE] = 7,
669 [IRQ_DA8XX_C1_RX_THRESH_PULSE] = 7,
670 [IRQ_DA8XX_C1_RX_PULSE] = 7,
671 [IRQ_DA8XX_C1_TX_PULSE] = 7,
672 [IRQ_DA8XX_C1_MISC_PULSE] = 7,
673 [IRQ_DA8XX_MEMERR] = 7,
674 [IRQ_DA8XX_GPIO0] = 7,
675 [IRQ_DA8XX_GPIO1] = 7,
676 [IRQ_DA8XX_GPIO2] = 7,
677 [IRQ_DA8XX_GPIO3] = 7,
678 [IRQ_DA8XX_GPIO4] = 7,
679 [IRQ_DA8XX_GPIO5] = 7,
680 [IRQ_DA8XX_GPIO6] = 7,
681 [IRQ_DA8XX_GPIO7] = 7,
682 [IRQ_DA8XX_GPIO8] = 7,
683 [IRQ_DA8XX_I2CINT1] = 7,
684 [IRQ_DA8XX_LCDINT] = 7,
685 [IRQ_DA8XX_UARTINT1] = 7,
686 [IRQ_DA8XX_MCASPINT] = 7,
687 [IRQ_DA8XX_ALLINT1] = 7,
688 [IRQ_DA8XX_SPINT1] = 7,
689 [IRQ_DA8XX_UHPI_INT1] = 7,
690 [IRQ_DA8XX_USB_INT] = 7,
691 [IRQ_DA8XX_IRQN] = 7,
692 [IRQ_DA8XX_RWAKEUP] = 7,
693 [IRQ_DA8XX_UARTINT2] = 7,
694 [IRQ_DA8XX_DFTSSINT] = 7,
695 [IRQ_DA8XX_EHRPWM0] = 7,
696 [IRQ_DA8XX_EHRPWM0TZ] = 7,
697 [IRQ_DA8XX_EHRPWM1] = 7,
698 [IRQ_DA8XX_EHRPWM1TZ] = 7,
699 [IRQ_DA850_SATAINT] = 7,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400700 [IRQ_DA850_TINTALL_2] = 7,
701 [IRQ_DA8XX_ECAP0] = 7,
702 [IRQ_DA8XX_ECAP1] = 7,
703 [IRQ_DA8XX_ECAP2] = 7,
704 [IRQ_DA850_MMCSDINT0_1] = 7,
705 [IRQ_DA850_MMCSDINT1_1] = 7,
706 [IRQ_DA850_T12CMPINT0_2] = 7,
707 [IRQ_DA850_T12CMPINT1_2] = 7,
708 [IRQ_DA850_T12CMPINT2_2] = 7,
709 [IRQ_DA850_T12CMPINT3_2] = 7,
710 [IRQ_DA850_T12CMPINT4_2] = 7,
711 [IRQ_DA850_T12CMPINT5_2] = 7,
712 [IRQ_DA850_T12CMPINT6_2] = 7,
713 [IRQ_DA850_T12CMPINT7_2] = 7,
714 [IRQ_DA850_T12CMPINT0_3] = 7,
715 [IRQ_DA850_T12CMPINT1_3] = 7,
716 [IRQ_DA850_T12CMPINT2_3] = 7,
717 [IRQ_DA850_T12CMPINT3_3] = 7,
718 [IRQ_DA850_T12CMPINT4_3] = 7,
719 [IRQ_DA850_T12CMPINT5_3] = 7,
720 [IRQ_DA850_T12CMPINT6_3] = 7,
721 [IRQ_DA850_T12CMPINT7_3] = 7,
722 [IRQ_DA850_RPIINT] = 7,
723 [IRQ_DA850_VPIFINT] = 7,
724 [IRQ_DA850_CCINT1] = 7,
725 [IRQ_DA850_CCERRINT1] = 7,
726 [IRQ_DA850_TCERRINT2] = 7,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400727 [IRQ_DA850_TINTALL_3] = 7,
728 [IRQ_DA850_MCBSP0RINT] = 7,
729 [IRQ_DA850_MCBSP0XINT] = 7,
730 [IRQ_DA850_MCBSP1RINT] = 7,
731 [IRQ_DA850_MCBSP1XINT] = 7,
732 [IRQ_DA8XX_ARMCLKSTOPREQ] = 7,
733};
734
735static struct map_desc da850_io_desc[] = {
736 {
737 .virtual = IO_VIRT,
738 .pfn = __phys_to_pfn(IO_PHYS),
739 .length = IO_SIZE,
740 .type = MT_DEVICE
741 },
742 {
743 .virtual = DA8XX_CP_INTC_VIRT,
744 .pfn = __phys_to_pfn(DA8XX_CP_INTC_BASE),
745 .length = DA8XX_CP_INTC_SIZE,
746 .type = MT_DEVICE
747 },
Sekhar Nori60cd02e2009-11-16 17:21:39 +0530748 {
749 .virtual = SRAM_VIRT,
750 .pfn = __phys_to_pfn(DA8XX_ARM_RAM_BASE),
751 .length = SZ_8K,
752 .type = MT_DEVICE
753 },
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400754};
755
Cyril Chemparathye4c822c2010-05-07 17:06:36 -0400756static u32 da850_psc_bases[] = { DA8XX_PSC0_BASE, DA8XX_PSC1_BASE };
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400757
758/* Contents of JTAG ID register used to identify exact cpu type */
759static struct davinci_id da850_ids[] = {
760 {
761 .variant = 0x0,
762 .part_no = 0xb7d1,
763 .manufacturer = 0x017, /* 0x02f >> 1 */
764 .cpu_id = DAVINCI_CPU_ID_DA850,
765 .name = "da850/omap-l138",
766 },
Sudhakar Rajashekharacbb691f2011-01-03 08:03:27 -0500767 {
768 .variant = 0x1,
769 .part_no = 0xb7d1,
770 .manufacturer = 0x017, /* 0x02f >> 1 */
771 .cpu_id = DAVINCI_CPU_ID_DA850,
772 .name = "da850/omap-l138/am18x",
773 },
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400774};
775
776static struct davinci_timer_instance da850_timer_instance[4] = {
777 {
Cyril Chemparathy1bcd38a2010-05-07 17:06:35 -0400778 .base = DA8XX_TIMER64P0_BASE,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400779 .bottom_irq = IRQ_DA8XX_TINT12_0,
780 .top_irq = IRQ_DA8XX_TINT34_0,
781 },
782 {
Cyril Chemparathy1bcd38a2010-05-07 17:06:35 -0400783 .base = DA8XX_TIMER64P1_BASE,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400784 .bottom_irq = IRQ_DA8XX_TINT12_1,
785 .top_irq = IRQ_DA8XX_TINT34_1,
786 },
787 {
Cyril Chemparathy1bcd38a2010-05-07 17:06:35 -0400788 .base = DA850_TIMER64P2_BASE,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400789 .bottom_irq = IRQ_DA850_TINT12_2,
790 .top_irq = IRQ_DA850_TINT34_2,
791 },
792 {
Cyril Chemparathy1bcd38a2010-05-07 17:06:35 -0400793 .base = DA850_TIMER64P3_BASE,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -0400794 .bottom_irq = IRQ_DA850_TINT12_3,
795 .top_irq = IRQ_DA850_TINT34_3,
796 },
797};
798
799/*
800 * T0_BOT: Timer 0, bottom : Used for clock_event
801 * T0_TOP: Timer 0, top : Used for clocksource
802 * T1_BOT, T1_TOP: Timer 1, bottom & top: Used for watchdog timer
803 */
804static struct davinci_timer_info da850_timer_info = {
805 .timers = da850_timer_instance,
806 .clockevent_id = T0_BOT,
807 .clocksource_id = T0_TOP,
808};
809
Sekhar Nori5d36a332009-08-31 15:48:05 +0530810static void da850_set_async3_src(int pllnum)
811{
812 struct clk *clk, *newparent = pllnum ? &pll1_sysclk2 : &pll0_sysclk2;
Kevin Hilman08aca082010-01-11 08:22:23 -0800813 struct clk_lookup *c;
Sekhar Nori5d36a332009-08-31 15:48:05 +0530814 unsigned int v;
815 int ret;
816
Kevin Hilman08aca082010-01-11 08:22:23 -0800817 for (c = da850_clks; c->clk; c++) {
818 clk = c->clk;
Sekhar Nori5d36a332009-08-31 15:48:05 +0530819 if (clk->flags & DA850_CLK_ASYNC3) {
820 ret = clk_set_parent(clk, newparent);
821 WARN(ret, "DA850: unable to re-parent clock %s",
822 clk->name);
823 }
824 }
825
Sekhar Norid2de0582009-11-16 17:21:32 +0530826 v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
Sekhar Nori5d36a332009-08-31 15:48:05 +0530827 if (pllnum)
828 v |= CFGCHIP3_ASYNC3_CLKSRC;
829 else
830 v &= ~CFGCHIP3_ASYNC3_CLKSRC;
Sekhar Norid2de0582009-11-16 17:21:32 +0530831 __raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
Sekhar Nori5d36a332009-08-31 15:48:05 +0530832}
833
Sekhar Nori683b1e12009-09-22 21:14:01 +0530834#ifdef CONFIG_CPU_FREQ
835/*
836 * Notes:
837 * According to the TRM, minimum PLLM results in maximum power savings.
838 * The OPP definitions below should keep the PLLM as low as possible.
839 *
Sekhar Nori39e14552010-12-20 21:31:33 +0530840 * The output of the PLLM must be between 300 to 600 MHz.
Sekhar Nori683b1e12009-09-22 21:14:01 +0530841 */
842struct da850_opp {
843 unsigned int freq; /* in KHz */
844 unsigned int prediv;
845 unsigned int mult;
846 unsigned int postdiv;
Sekhar Nori35f9acd2009-09-22 21:14:02 +0530847 unsigned int cvdd_min; /* in uV */
848 unsigned int cvdd_max; /* in uV */
Sekhar Nori683b1e12009-09-22 21:14:01 +0530849};
850
Sekhar Nori39e14552010-12-20 21:31:33 +0530851static const struct da850_opp da850_opp_456 = {
852 .freq = 456000,
853 .prediv = 1,
854 .mult = 19,
855 .postdiv = 1,
856 .cvdd_min = 1300000,
857 .cvdd_max = 1350000,
858};
859
860static const struct da850_opp da850_opp_408 = {
861 .freq = 408000,
862 .prediv = 1,
863 .mult = 17,
864 .postdiv = 1,
865 .cvdd_min = 1300000,
866 .cvdd_max = 1350000,
867};
868
869static const struct da850_opp da850_opp_372 = {
870 .freq = 372000,
871 .prediv = 2,
872 .mult = 31,
873 .postdiv = 1,
874 .cvdd_min = 1200000,
875 .cvdd_max = 1320000,
876};
877
Sekhar Nori683b1e12009-09-22 21:14:01 +0530878static const struct da850_opp da850_opp_300 = {
879 .freq = 300000,
880 .prediv = 1,
881 .mult = 25,
882 .postdiv = 2,
Sekhar Nori6ef62f82010-07-07 14:02:49 +0530883 .cvdd_min = 1200000,
Sekhar Nori35f9acd2009-09-22 21:14:02 +0530884 .cvdd_max = 1320000,
Sekhar Nori683b1e12009-09-22 21:14:01 +0530885};
886
887static const struct da850_opp da850_opp_200 = {
888 .freq = 200000,
889 .prediv = 1,
890 .mult = 25,
891 .postdiv = 3,
Sekhar Nori6ef62f82010-07-07 14:02:49 +0530892 .cvdd_min = 1100000,
Sekhar Nori35f9acd2009-09-22 21:14:02 +0530893 .cvdd_max = 1160000,
Sekhar Nori683b1e12009-09-22 21:14:01 +0530894};
895
896static const struct da850_opp da850_opp_96 = {
897 .freq = 96000,
898 .prediv = 1,
899 .mult = 20,
900 .postdiv = 5,
Sekhar Nori6ef62f82010-07-07 14:02:49 +0530901 .cvdd_min = 1000000,
Sekhar Nori35f9acd2009-09-22 21:14:02 +0530902 .cvdd_max = 1050000,
Sekhar Nori683b1e12009-09-22 21:14:01 +0530903};
904
905#define OPP(freq) \
906 { \
907 .index = (unsigned int) &da850_opp_##freq, \
908 .frequency = freq * 1000, \
909 }
910
911static struct cpufreq_frequency_table da850_freq_table[] = {
Sekhar Nori39e14552010-12-20 21:31:33 +0530912 OPP(456),
913 OPP(408),
914 OPP(372),
Sekhar Nori683b1e12009-09-22 21:14:01 +0530915 OPP(300),
916 OPP(200),
917 OPP(96),
918 {
919 .index = 0,
920 .frequency = CPUFREQ_TABLE_END,
921 },
922};
923
Sekhar Nori13d5e272009-10-22 15:12:16 +0530924#ifdef CONFIG_REGULATOR
Sekhar Nori39e14552010-12-20 21:31:33 +0530925static int da850_set_voltage(unsigned int index);
926static int da850_regulator_init(void);
927#endif
928
929static struct davinci_cpufreq_config cpufreq_info = {
930 .freq_table = da850_freq_table,
931#ifdef CONFIG_REGULATOR
932 .init = da850_regulator_init,
933 .set_voltage = da850_set_voltage,
934#endif
935};
936
937#ifdef CONFIG_REGULATOR
Sekhar Nori13d5e272009-10-22 15:12:16 +0530938static struct regulator *cvdd;
939
940static int da850_set_voltage(unsigned int index)
941{
942 struct da850_opp *opp;
943
944 if (!cvdd)
945 return -ENODEV;
946
Sekhar Nori39e14552010-12-20 21:31:33 +0530947 opp = (struct da850_opp *) cpufreq_info.freq_table[index].index;
Sekhar Nori13d5e272009-10-22 15:12:16 +0530948
949 return regulator_set_voltage(cvdd, opp->cvdd_min, opp->cvdd_max);
950}
951
952static int da850_regulator_init(void)
953{
954 cvdd = regulator_get(NULL, "cvdd");
955 if (WARN(IS_ERR(cvdd), "Unable to obtain voltage regulator for CVDD;"
956 " voltage scaling unsupported\n")) {
957 return PTR_ERR(cvdd);
958 }
959
960 return 0;
961}
962#endif
963
Sekhar Nori683b1e12009-09-22 21:14:01 +0530964static struct platform_device da850_cpufreq_device = {
965 .name = "cpufreq-davinci",
966 .dev = {
967 .platform_data = &cpufreq_info,
968 },
Sekhar Norib987c4b2010-07-20 16:46:51 +0530969 .id = -1,
Sekhar Nori683b1e12009-09-22 21:14:01 +0530970};
971
Sekhar Nori39e14552010-12-20 21:31:33 +0530972unsigned int da850_max_speed = 300000;
973
Sekhar Norib987c4b2010-07-20 16:46:51 +0530974int __init da850_register_cpufreq(char *async_clk)
Sekhar Nori683b1e12009-09-22 21:14:01 +0530975{
Sekhar Nori39e14552010-12-20 21:31:33 +0530976 int i;
977
Sekhar Norib987c4b2010-07-20 16:46:51 +0530978 /* cpufreq driver can help keep an "async" clock constant */
979 if (async_clk)
980 clk_add_alias("async", da850_cpufreq_device.name,
981 async_clk, NULL);
Sekhar Nori39e14552010-12-20 21:31:33 +0530982 for (i = 0; i < ARRAY_SIZE(da850_freq_table); i++) {
983 if (da850_freq_table[i].frequency <= da850_max_speed) {
984 cpufreq_info.freq_table = &da850_freq_table[i];
985 break;
986 }
987 }
Sekhar Norib987c4b2010-07-20 16:46:51 +0530988
Sekhar Nori683b1e12009-09-22 21:14:01 +0530989 return platform_device_register(&da850_cpufreq_device);
990}
991
992static int da850_round_armrate(struct clk *clk, unsigned long rate)
993{
994 int i, ret = 0, diff;
995 unsigned int best = (unsigned int) -1;
Sekhar Nori39e14552010-12-20 21:31:33 +0530996 struct cpufreq_frequency_table *table = cpufreq_info.freq_table;
Sekhar Nori683b1e12009-09-22 21:14:01 +0530997
998 rate /= 1000; /* convert to kHz */
999
Sekhar Nori39e14552010-12-20 21:31:33 +05301000 for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
1001 diff = table[i].frequency - rate;
Sekhar Nori683b1e12009-09-22 21:14:01 +05301002 if (diff < 0)
1003 diff = -diff;
1004
1005 if (diff < best) {
1006 best = diff;
Sekhar Nori39e14552010-12-20 21:31:33 +05301007 ret = table[i].frequency;
Sekhar Nori683b1e12009-09-22 21:14:01 +05301008 }
1009 }
1010
1011 return ret * 1000;
1012}
1013
1014static int da850_set_armrate(struct clk *clk, unsigned long index)
1015{
1016 struct clk *pllclk = &pll0_clk;
1017
1018 return clk_set_rate(pllclk, index);
1019}
1020
1021static int da850_set_pll0rate(struct clk *clk, unsigned long index)
1022{
1023 unsigned int prediv, mult, postdiv;
1024 struct da850_opp *opp;
1025 struct pll_data *pll = clk->pll_data;
Sekhar Nori683b1e12009-09-22 21:14:01 +05301026 int ret;
1027
Sekhar Nori39e14552010-12-20 21:31:33 +05301028 opp = (struct da850_opp *) cpufreq_info.freq_table[index].index;
Sekhar Nori683b1e12009-09-22 21:14:01 +05301029 prediv = opp->prediv;
1030 mult = opp->mult;
1031 postdiv = opp->postdiv;
1032
Sekhar Nori683b1e12009-09-22 21:14:01 +05301033 ret = davinci_set_pllrate(pll, prediv, mult, postdiv);
1034 if (WARN_ON(ret))
1035 return ret;
1036
1037 return 0;
1038}
1039#else
Sekhar Norifca97b32010-07-20 16:46:48 +05301040int __init da850_register_cpufreq(char *async_clk)
Sekhar Nori683b1e12009-09-22 21:14:01 +05301041{
1042 return 0;
1043}
1044
1045static int da850_set_armrate(struct clk *clk, unsigned long rate)
1046{
1047 return -EINVAL;
1048}
1049
1050static int da850_set_pll0rate(struct clk *clk, unsigned long armrate)
1051{
1052 return -EINVAL;
1053}
1054
1055static int da850_round_armrate(struct clk *clk, unsigned long rate)
1056{
1057 return clk->rate;
1058}
1059#endif
1060
Sekhar Nori044ca012009-12-17 18:29:32 +05301061int da850_register_pm(struct platform_device *pdev)
1062{
1063 int ret;
1064 struct davinci_pm_config *pdata = pdev->dev.platform_data;
1065
1066 ret = davinci_cfg_reg(DA850_RTC_ALARM);
1067 if (ret)
1068 return ret;
1069
1070 pdata->ddr2_ctlr_base = da8xx_get_mem_ctlr();
1071 pdata->deepsleep_reg = DA8XX_SYSCFG1_VIRT(DA8XX_DEEPSLEEP_REG);
1072 pdata->ddrpsc_num = DA8XX_LPSC1_EMIF3C;
1073
1074 pdata->cpupll_reg_base = ioremap(DA8XX_PLL0_BASE, SZ_4K);
1075 if (!pdata->cpupll_reg_base)
1076 return -ENOMEM;
1077
Sergei Shtylyove0c199d2011-04-06 17:26:06 +00001078 pdata->ddrpll_reg_base = ioremap(DA850_PLL1_BASE, SZ_4K);
Sekhar Nori044ca012009-12-17 18:29:32 +05301079 if (!pdata->ddrpll_reg_base) {
1080 ret = -ENOMEM;
1081 goto no_ddrpll_mem;
1082 }
1083
1084 pdata->ddrpsc_reg_base = ioremap(DA8XX_PSC1_BASE, SZ_4K);
1085 if (!pdata->ddrpsc_reg_base) {
1086 ret = -ENOMEM;
1087 goto no_ddrpsc_mem;
1088 }
1089
1090 return platform_device_register(pdev);
1091
1092no_ddrpsc_mem:
1093 iounmap(pdata->ddrpll_reg_base);
1094no_ddrpll_mem:
1095 iounmap(pdata->cpupll_reg_base);
1096 return ret;
1097}
Sekhar Nori35f9acd2009-09-22 21:14:02 +05301098
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -04001099static struct davinci_soc_info davinci_soc_info_da850 = {
1100 .io_desc = da850_io_desc,
1101 .io_desc_num = ARRAY_SIZE(da850_io_desc),
Cyril Chemparathy3347db82010-05-07 17:06:34 -04001102 .jtag_id_reg = DA8XX_SYSCFG0_BASE + DA8XX_JTAG_ID_REG,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -04001103 .ids = da850_ids,
1104 .ids_num = ARRAY_SIZE(da850_ids),
1105 .cpu_clks = da850_clks,
1106 .psc_bases = da850_psc_bases,
1107 .psc_bases_num = ARRAY_SIZE(da850_psc_bases),
Cyril Chemparathy779b0d52010-05-07 17:06:38 -04001108 .pinmux_base = DA8XX_SYSCFG0_BASE + 0x120,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -04001109 .pinmux_pins = da850_pins,
1110 .pinmux_pins_num = ARRAY_SIZE(da850_pins),
Cyril Chemparathybd808942010-05-07 17:06:37 -04001111 .intc_base = DA8XX_CP_INTC_BASE,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -04001112 .intc_type = DAVINCI_INTC_TYPE_CP_INTC,
1113 .intc_irq_prios = da850_default_priorities,
1114 .intc_irq_num = DA850_N_CP_INTC_IRQ,
1115 .timer_info = &da850_timer_info,
Cyril Chemparathy686b6342010-05-01 18:37:54 -04001116 .gpio_type = GPIO_TYPE_DAVINCI,
Cyril Chemparathyb8d44292010-05-07 17:06:32 -04001117 .gpio_base = DA8XX_GPIO_BASE,
Sudhakar Rajashekhara5a8d5442009-08-11 16:14:21 -04001118 .gpio_num = 144,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -04001119 .gpio_irq = IRQ_DA8XX_GPIO0,
1120 .serial_dev = &da8xx_serial_device,
1121 .emac_pdata = &da8xx_emac_pdata,
Sekhar Nori60cd02e2009-11-16 17:21:39 +05301122 .sram_dma = DA8XX_ARM_RAM_BASE,
1123 .sram_len = SZ_8K,
Cyril Chemparathyc78a5bc2010-05-01 18:38:28 -04001124 .reset_device = &da8xx_wdt_device,
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -04001125};
1126
1127void __init da850_init(void)
1128{
Sekhar Nori7aad4722009-11-16 17:21:38 +05301129 unsigned int v;
1130
Cyril Chemparathybcd6a1c2010-05-07 17:06:39 -04001131 davinci_common_init(&davinci_soc_info_da850);
1132
Sekhar Norid2de0582009-11-16 17:21:32 +05301133 da8xx_syscfg0_base = ioremap(DA8XX_SYSCFG0_BASE, SZ_4K);
1134 if (WARN(!da8xx_syscfg0_base, "Unable to map syscfg0 module"))
1135 return;
1136
1137 da8xx_syscfg1_base = ioremap(DA8XX_SYSCFG1_BASE, SZ_4K);
1138 if (WARN(!da8xx_syscfg1_base, "Unable to map syscfg1 module"))
Sekhar Nori6a28adef2009-08-31 15:47:59 +05301139 return;
1140
Sekhar Nori5d36a332009-08-31 15:48:05 +05301141 /*
1142 * Move the clock source of Async3 domain to PLL1 SYSCLK2.
1143 * This helps keeping the peripherals on this domain insulated
1144 * from CPU frequency changes caused by DVFS. The firmware sets
1145 * both PLL0 and PLL1 to the same frequency so, there should not
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001146 * be any noticeable change even in non-DVFS use cases.
Sekhar Nori5d36a332009-08-31 15:48:05 +05301147 */
1148 da850_set_async3_src(1);
Sekhar Nori7aad4722009-11-16 17:21:38 +05301149
1150 /* Unlock writing to PLL0 registers */
1151 v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP0_REG));
1152 v &= ~CFGCHIP0_PLL_MASTER_LOCK;
1153 __raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP0_REG));
1154
1155 /* Unlock writing to PLL1 registers */
1156 v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
1157 v &= ~CFGCHIP3_PLL1_MASTER_LOCK;
1158 __raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
Sudhakar Rajashekharae1a8d7e2009-07-16 06:41:54 -04001159}