Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/tglx/linux...
[platform/adaptation/renesas_rcar/renesas_kernel.git] / arch / arm / mach-davinci / dm365.c
1 /*
2  * TI DaVinci DM365 chip specific setup
3  *
4  * Copyright (C) 2009 Texas Instruments
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 version 2.
9  *
10  * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11  * kind, whether express or implied; without even the implied warranty
12  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  */
15 #include <linux/init.h>
16 #include <linux/clk.h>
17 #include <linux/serial_8250.h>
18 #include <linux/platform_device.h>
19 #include <linux/dma-mapping.h>
20 #include <linux/gpio.h>
21 #include <linux/spi/spi.h>
22
23 #include <asm/mach/map.h>
24
25 #include <mach/dm365.h>
26 #include <mach/cputype.h>
27 #include <mach/edma.h>
28 #include <mach/psc.h>
29 #include <mach/mux.h>
30 #include <mach/irqs.h>
31 #include <mach/time.h>
32 #include <mach/serial.h>
33 #include <mach/common.h>
34 #include <mach/asp.h>
35 #include <mach/keyscan.h>
36 #include <mach/spi.h>
37
38
39 #include "clock.h"
40 #include "mux.h"
41
42 #define DM365_REF_FREQ          24000000        /* 24 MHz on the DM365 EVM */
43
44 static struct pll_data pll1_data = {
45         .num            = 1,
46         .phys_base      = DAVINCI_PLL1_BASE,
47         .flags          = PLL_HAS_POSTDIV | PLL_HAS_PREDIV,
48 };
49
50 static struct pll_data pll2_data = {
51         .num            = 2,
52         .phys_base      = DAVINCI_PLL2_BASE,
53         .flags          = PLL_HAS_POSTDIV | PLL_HAS_PREDIV,
54 };
55
56 static struct clk ref_clk = {
57         .name           = "ref_clk",
58         .rate           = DM365_REF_FREQ,
59 };
60
61 static struct clk pll1_clk = {
62         .name           = "pll1",
63         .parent         = &ref_clk,
64         .flags          = CLK_PLL,
65         .pll_data       = &pll1_data,
66 };
67
68 static struct clk pll1_aux_clk = {
69         .name           = "pll1_aux_clk",
70         .parent         = &pll1_clk,
71         .flags          = CLK_PLL | PRE_PLL,
72 };
73
74 static struct clk pll1_sysclkbp = {
75         .name           = "pll1_sysclkbp",
76         .parent         = &pll1_clk,
77         .flags          = CLK_PLL | PRE_PLL,
78         .div_reg        = BPDIV
79 };
80
81 static struct clk clkout0_clk = {
82         .name           = "clkout0",
83         .parent         = &pll1_clk,
84         .flags          = CLK_PLL | PRE_PLL,
85 };
86
87 static struct clk pll1_sysclk1 = {
88         .name           = "pll1_sysclk1",
89         .parent         = &pll1_clk,
90         .flags          = CLK_PLL,
91         .div_reg        = PLLDIV1,
92 };
93
94 static struct clk pll1_sysclk2 = {
95         .name           = "pll1_sysclk2",
96         .parent         = &pll1_clk,
97         .flags          = CLK_PLL,
98         .div_reg        = PLLDIV2,
99 };
100
101 static struct clk pll1_sysclk3 = {
102         .name           = "pll1_sysclk3",
103         .parent         = &pll1_clk,
104         .flags          = CLK_PLL,
105         .div_reg        = PLLDIV3,
106 };
107
108 static struct clk pll1_sysclk4 = {
109         .name           = "pll1_sysclk4",
110         .parent         = &pll1_clk,
111         .flags          = CLK_PLL,
112         .div_reg        = PLLDIV4,
113 };
114
115 static struct clk pll1_sysclk5 = {
116         .name           = "pll1_sysclk5",
117         .parent         = &pll1_clk,
118         .flags          = CLK_PLL,
119         .div_reg        = PLLDIV5,
120 };
121
122 static struct clk pll1_sysclk6 = {
123         .name           = "pll1_sysclk6",
124         .parent         = &pll1_clk,
125         .flags          = CLK_PLL,
126         .div_reg        = PLLDIV6,
127 };
128
129 static struct clk pll1_sysclk7 = {
130         .name           = "pll1_sysclk7",
131         .parent         = &pll1_clk,
132         .flags          = CLK_PLL,
133         .div_reg        = PLLDIV7,
134 };
135
136 static struct clk pll1_sysclk8 = {
137         .name           = "pll1_sysclk8",
138         .parent         = &pll1_clk,
139         .flags          = CLK_PLL,
140         .div_reg        = PLLDIV8,
141 };
142
143 static struct clk pll1_sysclk9 = {
144         .name           = "pll1_sysclk9",
145         .parent         = &pll1_clk,
146         .flags          = CLK_PLL,
147         .div_reg        = PLLDIV9,
148 };
149
150 static struct clk pll2_clk = {
151         .name           = "pll2",
152         .parent         = &ref_clk,
153         .flags          = CLK_PLL,
154         .pll_data       = &pll2_data,
155 };
156
157 static struct clk pll2_aux_clk = {
158         .name           = "pll2_aux_clk",
159         .parent         = &pll2_clk,
160         .flags          = CLK_PLL | PRE_PLL,
161 };
162
163 static struct clk clkout1_clk = {
164         .name           = "clkout1",
165         .parent         = &pll2_clk,
166         .flags          = CLK_PLL | PRE_PLL,
167 };
168
169 static struct clk pll2_sysclk1 = {
170         .name           = "pll2_sysclk1",
171         .parent         = &pll2_clk,
172         .flags          = CLK_PLL,
173         .div_reg        = PLLDIV1,
174 };
175
176 static struct clk pll2_sysclk2 = {
177         .name           = "pll2_sysclk2",
178         .parent         = &pll2_clk,
179         .flags          = CLK_PLL,
180         .div_reg        = PLLDIV2,
181 };
182
183 static struct clk pll2_sysclk3 = {
184         .name           = "pll2_sysclk3",
185         .parent         = &pll2_clk,
186         .flags          = CLK_PLL,
187         .div_reg        = PLLDIV3,
188 };
189
190 static struct clk pll2_sysclk4 = {
191         .name           = "pll2_sysclk4",
192         .parent         = &pll2_clk,
193         .flags          = CLK_PLL,
194         .div_reg        = PLLDIV4,
195 };
196
197 static struct clk pll2_sysclk5 = {
198         .name           = "pll2_sysclk5",
199         .parent         = &pll2_clk,
200         .flags          = CLK_PLL,
201         .div_reg        = PLLDIV5,
202 };
203
204 static struct clk pll2_sysclk6 = {
205         .name           = "pll2_sysclk6",
206         .parent         = &pll2_clk,
207         .flags          = CLK_PLL,
208         .div_reg        = PLLDIV6,
209 };
210
211 static struct clk pll2_sysclk7 = {
212         .name           = "pll2_sysclk7",
213         .parent         = &pll2_clk,
214         .flags          = CLK_PLL,
215         .div_reg        = PLLDIV7,
216 };
217
218 static struct clk pll2_sysclk8 = {
219         .name           = "pll2_sysclk8",
220         .parent         = &pll2_clk,
221         .flags          = CLK_PLL,
222         .div_reg        = PLLDIV8,
223 };
224
225 static struct clk pll2_sysclk9 = {
226         .name           = "pll2_sysclk9",
227         .parent         = &pll2_clk,
228         .flags          = CLK_PLL,
229         .div_reg        = PLLDIV9,
230 };
231
232 static struct clk vpss_dac_clk = {
233         .name           = "vpss_dac",
234         .parent         = &pll1_sysclk3,
235         .lpsc           = DM365_LPSC_DAC_CLK,
236 };
237
238 static struct clk vpss_master_clk = {
239         .name           = "vpss_master",
240         .parent         = &pll1_sysclk5,
241         .lpsc           = DM365_LPSC_VPSSMSTR,
242         .flags          = CLK_PSC,
243 };
244
245 static struct clk arm_clk = {
246         .name           = "arm_clk",
247         .parent         = &pll2_sysclk2,
248         .lpsc           = DAVINCI_LPSC_ARM,
249         .flags          = ALWAYS_ENABLED,
250 };
251
252 static struct clk uart0_clk = {
253         .name           = "uart0",
254         .parent         = &pll1_aux_clk,
255         .lpsc           = DAVINCI_LPSC_UART0,
256 };
257
258 static struct clk uart1_clk = {
259         .name           = "uart1",
260         .parent         = &pll1_sysclk4,
261         .lpsc           = DAVINCI_LPSC_UART1,
262 };
263
264 static struct clk i2c_clk = {
265         .name           = "i2c",
266         .parent         = &pll1_aux_clk,
267         .lpsc           = DAVINCI_LPSC_I2C,
268 };
269
270 static struct clk mmcsd0_clk = {
271         .name           = "mmcsd0",
272         .parent         = &pll1_sysclk8,
273         .lpsc           = DAVINCI_LPSC_MMC_SD,
274 };
275
276 static struct clk mmcsd1_clk = {
277         .name           = "mmcsd1",
278         .parent         = &pll1_sysclk4,
279         .lpsc           = DM365_LPSC_MMC_SD1,
280 };
281
282 static struct clk spi0_clk = {
283         .name           = "spi0",
284         .parent         = &pll1_sysclk4,
285         .lpsc           = DAVINCI_LPSC_SPI,
286 };
287
288 static struct clk spi1_clk = {
289         .name           = "spi1",
290         .parent         = &pll1_sysclk4,
291         .lpsc           = DM365_LPSC_SPI1,
292 };
293
294 static struct clk spi2_clk = {
295         .name           = "spi2",
296         .parent         = &pll1_sysclk4,
297         .lpsc           = DM365_LPSC_SPI2,
298 };
299
300 static struct clk spi3_clk = {
301         .name           = "spi3",
302         .parent         = &pll1_sysclk4,
303         .lpsc           = DM365_LPSC_SPI3,
304 };
305
306 static struct clk spi4_clk = {
307         .name           = "spi4",
308         .parent         = &pll1_aux_clk,
309         .lpsc           = DM365_LPSC_SPI4,
310 };
311
312 static struct clk gpio_clk = {
313         .name           = "gpio",
314         .parent         = &pll1_sysclk4,
315         .lpsc           = DAVINCI_LPSC_GPIO,
316 };
317
318 static struct clk aemif_clk = {
319         .name           = "aemif",
320         .parent         = &pll1_sysclk4,
321         .lpsc           = DAVINCI_LPSC_AEMIF,
322 };
323
324 static struct clk pwm0_clk = {
325         .name           = "pwm0",
326         .parent         = &pll1_aux_clk,
327         .lpsc           = DAVINCI_LPSC_PWM0,
328 };
329
330 static struct clk pwm1_clk = {
331         .name           = "pwm1",
332         .parent         = &pll1_aux_clk,
333         .lpsc           = DAVINCI_LPSC_PWM1,
334 };
335
336 static struct clk pwm2_clk = {
337         .name           = "pwm2",
338         .parent         = &pll1_aux_clk,
339         .lpsc           = DAVINCI_LPSC_PWM2,
340 };
341
342 static struct clk pwm3_clk = {
343         .name           = "pwm3",
344         .parent         = &ref_clk,
345         .lpsc           = DM365_LPSC_PWM3,
346 };
347
348 static struct clk timer0_clk = {
349         .name           = "timer0",
350         .parent         = &pll1_aux_clk,
351         .lpsc           = DAVINCI_LPSC_TIMER0,
352 };
353
354 static struct clk timer1_clk = {
355         .name           = "timer1",
356         .parent         = &pll1_aux_clk,
357         .lpsc           = DAVINCI_LPSC_TIMER1,
358 };
359
360 static struct clk timer2_clk = {
361         .name           = "timer2",
362         .parent         = &pll1_aux_clk,
363         .lpsc           = DAVINCI_LPSC_TIMER2,
364         .usecount       = 1,
365 };
366
367 static struct clk timer3_clk = {
368         .name           = "timer3",
369         .parent         = &pll1_aux_clk,
370         .lpsc           = DM365_LPSC_TIMER3,
371 };
372
373 static struct clk usb_clk = {
374         .name           = "usb",
375         .parent         = &pll1_aux_clk,
376         .lpsc           = DAVINCI_LPSC_USB,
377 };
378
379 static struct clk emac_clk = {
380         .name           = "emac",
381         .parent         = &pll1_sysclk4,
382         .lpsc           = DM365_LPSC_EMAC,
383 };
384
385 static struct clk voicecodec_clk = {
386         .name           = "voice_codec",
387         .parent         = &pll2_sysclk4,
388         .lpsc           = DM365_LPSC_VOICE_CODEC,
389 };
390
391 static struct clk asp0_clk = {
392         .name           = "asp0",
393         .parent         = &pll1_sysclk4,
394         .lpsc           = DM365_LPSC_McBSP1,
395 };
396
397 static struct clk rto_clk = {
398         .name           = "rto",
399         .parent         = &pll1_sysclk4,
400         .lpsc           = DM365_LPSC_RTO,
401 };
402
403 static struct clk mjcp_clk = {
404         .name           = "mjcp",
405         .parent         = &pll1_sysclk3,
406         .lpsc           = DM365_LPSC_MJCP,
407 };
408
409 static struct clk_lookup dm365_clks[] = {
410         CLK(NULL, "ref", &ref_clk),
411         CLK(NULL, "pll1", &pll1_clk),
412         CLK(NULL, "pll1_aux", &pll1_aux_clk),
413         CLK(NULL, "pll1_sysclkbp", &pll1_sysclkbp),
414         CLK(NULL, "clkout0", &clkout0_clk),
415         CLK(NULL, "pll1_sysclk1", &pll1_sysclk1),
416         CLK(NULL, "pll1_sysclk2", &pll1_sysclk2),
417         CLK(NULL, "pll1_sysclk3", &pll1_sysclk3),
418         CLK(NULL, "pll1_sysclk4", &pll1_sysclk4),
419         CLK(NULL, "pll1_sysclk5", &pll1_sysclk5),
420         CLK(NULL, "pll1_sysclk6", &pll1_sysclk6),
421         CLK(NULL, "pll1_sysclk7", &pll1_sysclk7),
422         CLK(NULL, "pll1_sysclk8", &pll1_sysclk8),
423         CLK(NULL, "pll1_sysclk9", &pll1_sysclk9),
424         CLK(NULL, "pll2", &pll2_clk),
425         CLK(NULL, "pll2_aux", &pll2_aux_clk),
426         CLK(NULL, "clkout1", &clkout1_clk),
427         CLK(NULL, "pll2_sysclk1", &pll2_sysclk1),
428         CLK(NULL, "pll2_sysclk2", &pll2_sysclk2),
429         CLK(NULL, "pll2_sysclk3", &pll2_sysclk3),
430         CLK(NULL, "pll2_sysclk4", &pll2_sysclk4),
431         CLK(NULL, "pll2_sysclk5", &pll2_sysclk5),
432         CLK(NULL, "pll2_sysclk6", &pll2_sysclk6),
433         CLK(NULL, "pll2_sysclk7", &pll2_sysclk7),
434         CLK(NULL, "pll2_sysclk8", &pll2_sysclk8),
435         CLK(NULL, "pll2_sysclk9", &pll2_sysclk9),
436         CLK(NULL, "vpss_dac", &vpss_dac_clk),
437         CLK(NULL, "vpss_master", &vpss_master_clk),
438         CLK(NULL, "arm", &arm_clk),
439         CLK(NULL, "uart0", &uart0_clk),
440         CLK(NULL, "uart1", &uart1_clk),
441         CLK("i2c_davinci.1", NULL, &i2c_clk),
442         CLK("davinci_mmc.0", NULL, &mmcsd0_clk),
443         CLK("davinci_mmc.1", NULL, &mmcsd1_clk),
444         CLK("spi_davinci.0", NULL, &spi0_clk),
445         CLK("spi_davinci.1", NULL, &spi1_clk),
446         CLK("spi_davinci.2", NULL, &spi2_clk),
447         CLK("spi_davinci.3", NULL, &spi3_clk),
448         CLK("spi_davinci.4", NULL, &spi4_clk),
449         CLK(NULL, "gpio", &gpio_clk),
450         CLK(NULL, "aemif", &aemif_clk),
451         CLK(NULL, "pwm0", &pwm0_clk),
452         CLK(NULL, "pwm1", &pwm1_clk),
453         CLK(NULL, "pwm2", &pwm2_clk),
454         CLK(NULL, "pwm3", &pwm3_clk),
455         CLK(NULL, "timer0", &timer0_clk),
456         CLK(NULL, "timer1", &timer1_clk),
457         CLK("watchdog", NULL, &timer2_clk),
458         CLK(NULL, "timer3", &timer3_clk),
459         CLK(NULL, "usb", &usb_clk),
460         CLK("davinci_emac.1", NULL, &emac_clk),
461         CLK("davinci_voicecodec", NULL, &voicecodec_clk),
462         CLK("davinci-mcbsp", NULL, &asp0_clk),
463         CLK(NULL, "rto", &rto_clk),
464         CLK(NULL, "mjcp", &mjcp_clk),
465         CLK(NULL, NULL, NULL),
466 };
467
468 /*----------------------------------------------------------------------*/
469
470 #define INTMUX          0x18
471 #define EVTMUX          0x1c
472
473
474 static const struct mux_config dm365_pins[] = {
475 #ifdef CONFIG_DAVINCI_MUX
476 MUX_CFG(DM365,  MMCSD0,         0,   24,     1,   0,     false)
477
478 MUX_CFG(DM365,  SD1_CLK,        0,   16,    3,    1,     false)
479 MUX_CFG(DM365,  SD1_CMD,        4,   30,    3,    1,     false)
480 MUX_CFG(DM365,  SD1_DATA3,      4,   28,    3,    1,     false)
481 MUX_CFG(DM365,  SD1_DATA2,      4,   26,    3,    1,     false)
482 MUX_CFG(DM365,  SD1_DATA1,      4,   24,    3,    1,     false)
483 MUX_CFG(DM365,  SD1_DATA0,      4,   22,    3,    1,     false)
484
485 MUX_CFG(DM365,  I2C_SDA,        3,   23,    3,    2,     false)
486 MUX_CFG(DM365,  I2C_SCL,        3,   21,    3,    2,     false)
487
488 MUX_CFG(DM365,  AEMIF_AR_A14,   2,   0,     3,    1,     false)
489 MUX_CFG(DM365,  AEMIF_AR_BA0,   2,   0,     3,    2,     false)
490 MUX_CFG(DM365,  AEMIF_A3,       2,   2,     3,    1,     false)
491 MUX_CFG(DM365,  AEMIF_A7,       2,   4,     3,    1,     false)
492 MUX_CFG(DM365,  AEMIF_D15_8,    2,   6,     1,    1,     false)
493 MUX_CFG(DM365,  AEMIF_CE0,      2,   7,     1,    0,     false)
494 MUX_CFG(DM365,  AEMIF_CE1,      2,   8,     1,    0,     false)
495 MUX_CFG(DM365,  AEMIF_WE_OE,    2,   9,     1,    0,     false)
496
497 MUX_CFG(DM365,  MCBSP0_BDX,     0,   23,    1,    1,     false)
498 MUX_CFG(DM365,  MCBSP0_X,       0,   22,    1,    1,     false)
499 MUX_CFG(DM365,  MCBSP0_BFSX,    0,   21,    1,    1,     false)
500 MUX_CFG(DM365,  MCBSP0_BDR,     0,   20,    1,    1,     false)
501 MUX_CFG(DM365,  MCBSP0_R,       0,   19,    1,    1,     false)
502 MUX_CFG(DM365,  MCBSP0_BFSR,    0,   18,    1,    1,     false)
503
504 MUX_CFG(DM365,  SPI0_SCLK,      3,   28,    1,    1,     false)
505 MUX_CFG(DM365,  SPI0_SDI,       3,   26,    3,    1,     false)
506 MUX_CFG(DM365,  SPI0_SDO,       3,   25,    1,    1,     false)
507 MUX_CFG(DM365,  SPI0_SDENA0,    3,   29,    3,    1,     false)
508 MUX_CFG(DM365,  SPI0_SDENA1,    3,   26,    3,    2,     false)
509
510 MUX_CFG(DM365,  UART0_RXD,      3,   20,    1,    1,     false)
511 MUX_CFG(DM365,  UART0_TXD,      3,   19,    1,    1,     false)
512 MUX_CFG(DM365,  UART1_RXD,      3,   17,    3,    2,     false)
513 MUX_CFG(DM365,  UART1_TXD,      3,   15,    3,    2,     false)
514 MUX_CFG(DM365,  UART1_RTS,      3,   23,    3,    1,     false)
515 MUX_CFG(DM365,  UART1_CTS,      3,   21,    3,    1,     false)
516
517 MUX_CFG(DM365,  EMAC_TX_EN,     3,   17,    3,    1,     false)
518 MUX_CFG(DM365,  EMAC_TX_CLK,    3,   15,    3,    1,     false)
519 MUX_CFG(DM365,  EMAC_COL,       3,   14,    1,    1,     false)
520 MUX_CFG(DM365,  EMAC_TXD3,      3,   13,    1,    1,     false)
521 MUX_CFG(DM365,  EMAC_TXD2,      3,   12,    1,    1,     false)
522 MUX_CFG(DM365,  EMAC_TXD1,      3,   11,    1,    1,     false)
523 MUX_CFG(DM365,  EMAC_TXD0,      3,   10,    1,    1,     false)
524 MUX_CFG(DM365,  EMAC_RXD3,      3,   9,     1,    1,     false)
525 MUX_CFG(DM365,  EMAC_RXD2,      3,   8,     1,    1,     false)
526 MUX_CFG(DM365,  EMAC_RXD1,      3,   7,     1,    1,     false)
527 MUX_CFG(DM365,  EMAC_RXD0,      3,   6,     1,    1,     false)
528 MUX_CFG(DM365,  EMAC_RX_CLK,    3,   5,     1,    1,     false)
529 MUX_CFG(DM365,  EMAC_RX_DV,     3,   4,     1,    1,     false)
530 MUX_CFG(DM365,  EMAC_RX_ER,     3,   3,     1,    1,     false)
531 MUX_CFG(DM365,  EMAC_CRS,       3,   2,     1,    1,     false)
532 MUX_CFG(DM365,  EMAC_MDIO,      3,   1,     1,    1,     false)
533 MUX_CFG(DM365,  EMAC_MDCLK,     3,   0,     1,    1,     false)
534
535 MUX_CFG(DM365,  KEYSCAN,        2,   0,     0x3f, 0x3f,  false)
536
537 MUX_CFG(DM365,  PWM0,           1,   0,     3,    2,     false)
538 MUX_CFG(DM365,  PWM0_G23,       3,   26,    3,    3,     false)
539 MUX_CFG(DM365,  PWM1,           1,   2,     3,    2,     false)
540 MUX_CFG(DM365,  PWM1_G25,       3,   29,    3,    2,     false)
541 MUX_CFG(DM365,  PWM2_G87,       1,   10,    3,    2,     false)
542 MUX_CFG(DM365,  PWM2_G88,       1,   8,     3,    2,     false)
543 MUX_CFG(DM365,  PWM2_G89,       1,   6,     3,    2,     false)
544 MUX_CFG(DM365,  PWM2_G90,       1,   4,     3,    2,     false)
545 MUX_CFG(DM365,  PWM3_G80,       1,   20,    3,    3,     false)
546 MUX_CFG(DM365,  PWM3_G81,       1,   18,    3,    3,     false)
547 MUX_CFG(DM365,  PWM3_G85,       1,   14,    3,    2,     false)
548 MUX_CFG(DM365,  PWM3_G86,       1,   12,    3,    2,     false)
549
550 MUX_CFG(DM365,  SPI1_SCLK,      4,   2,     3,    1,     false)
551 MUX_CFG(DM365,  SPI1_SDI,       3,   31,    1,    1,     false)
552 MUX_CFG(DM365,  SPI1_SDO,       4,   0,     3,    1,     false)
553 MUX_CFG(DM365,  SPI1_SDENA0,    4,   4,     3,    1,     false)
554 MUX_CFG(DM365,  SPI1_SDENA1,    4,   0,     3,    2,     false)
555
556 MUX_CFG(DM365,  SPI2_SCLK,      4,   10,    3,    1,     false)
557 MUX_CFG(DM365,  SPI2_SDI,       4,   6,     3,    1,     false)
558 MUX_CFG(DM365,  SPI2_SDO,       4,   8,     3,    1,     false)
559 MUX_CFG(DM365,  SPI2_SDENA0,    4,   12,    3,    1,     false)
560 MUX_CFG(DM365,  SPI2_SDENA1,    4,   8,     3,    2,     false)
561
562 MUX_CFG(DM365,  SPI3_SCLK,      0,   0,     3,    2,     false)
563 MUX_CFG(DM365,  SPI3_SDI,       0,   2,     3,    2,     false)
564 MUX_CFG(DM365,  SPI3_SDO,       0,   6,     3,    2,     false)
565 MUX_CFG(DM365,  SPI3_SDENA0,    0,   4,     3,    2,     false)
566 MUX_CFG(DM365,  SPI3_SDENA1,    0,   6,     3,    3,     false)
567
568 MUX_CFG(DM365,  SPI4_SCLK,      4,   18,    3,    1,     false)
569 MUX_CFG(DM365,  SPI4_SDI,       4,   14,    3,    1,     false)
570 MUX_CFG(DM365,  SPI4_SDO,       4,   16,    3,    1,     false)
571 MUX_CFG(DM365,  SPI4_SDENA0,    4,   20,    3,    1,     false)
572 MUX_CFG(DM365,  SPI4_SDENA1,    4,   16,    3,    2,     false)
573
574 MUX_CFG(DM365,  CLKOUT0,        4,   20,    3,    3,     false)
575 MUX_CFG(DM365,  CLKOUT1,        4,   16,    3,    3,     false)
576 MUX_CFG(DM365,  CLKOUT2,        4,   8,     3,    3,     false)
577
578 MUX_CFG(DM365,  GPIO20,         3,   21,    3,    0,     false)
579 MUX_CFG(DM365,  GPIO30,         4,   6,     3,    0,     false)
580 MUX_CFG(DM365,  GPIO31,         4,   8,     3,    0,     false)
581 MUX_CFG(DM365,  GPIO32,         4,   10,    3,    0,     false)
582 MUX_CFG(DM365,  GPIO33,         4,   12,    3,    0,     false)
583 MUX_CFG(DM365,  GPIO40,         4,   26,    3,    0,     false)
584 MUX_CFG(DM365,  GPIO64_57,      2,   6,     1,    0,     false)
585
586 MUX_CFG(DM365,  VOUT_FIELD,     1,   18,    3,    1,     false)
587 MUX_CFG(DM365,  VOUT_FIELD_G81, 1,   18,    3,    0,     false)
588 MUX_CFG(DM365,  VOUT_HVSYNC,    1,   16,    1,    0,     false)
589 MUX_CFG(DM365,  VOUT_COUTL_EN,  1,   0,     0xff, 0x55,  false)
590 MUX_CFG(DM365,  VOUT_COUTH_EN,  1,   8,     0xff, 0x55,  false)
591 MUX_CFG(DM365,  VIN_CAM_WEN,    0,   14,    3,    0,     false)
592 MUX_CFG(DM365,  VIN_CAM_VD,     0,   13,    1,    0,     false)
593 MUX_CFG(DM365,  VIN_CAM_HD,     0,   12,    1,    0,     false)
594 MUX_CFG(DM365,  VIN_YIN4_7_EN,  0,   0,     0xff, 0,     false)
595 MUX_CFG(DM365,  VIN_YIN0_3_EN,  0,   8,     0xf,  0,     false)
596
597 INT_CFG(DM365,  INT_EDMA_CC,         2,     1,    1,     false)
598 INT_CFG(DM365,  INT_EDMA_TC0_ERR,    3,     1,    1,     false)
599 INT_CFG(DM365,  INT_EDMA_TC1_ERR,    4,     1,    1,     false)
600 INT_CFG(DM365,  INT_EDMA_TC2_ERR,    22,    1,    1,     false)
601 INT_CFG(DM365,  INT_EDMA_TC3_ERR,    23,    1,    1,     false)
602 INT_CFG(DM365,  INT_PRTCSS,          10,    1,    1,     false)
603 INT_CFG(DM365,  INT_EMAC_RXTHRESH,   14,    1,    1,     false)
604 INT_CFG(DM365,  INT_EMAC_RXPULSE,    15,    1,    1,     false)
605 INT_CFG(DM365,  INT_EMAC_TXPULSE,    16,    1,    1,     false)
606 INT_CFG(DM365,  INT_EMAC_MISCPULSE,  17,    1,    1,     false)
607 INT_CFG(DM365,  INT_IMX0_ENABLE,     0,     1,    0,     false)
608 INT_CFG(DM365,  INT_IMX0_DISABLE,    0,     1,    1,     false)
609 INT_CFG(DM365,  INT_HDVICP_ENABLE,   0,     1,    1,     false)
610 INT_CFG(DM365,  INT_HDVICP_DISABLE,  0,     1,    0,     false)
611 INT_CFG(DM365,  INT_IMX1_ENABLE,     24,    1,    1,     false)
612 INT_CFG(DM365,  INT_IMX1_DISABLE,    24,    1,    0,     false)
613 INT_CFG(DM365,  INT_NSF_ENABLE,      25,    1,    1,     false)
614 INT_CFG(DM365,  INT_NSF_DISABLE,     25,    1,    0,     false)
615
616 EVT_CFG(DM365,  EVT2_ASP_TX,         0,     1,    0,     false)
617 EVT_CFG(DM365,  EVT3_ASP_RX,         1,     1,    0,     false)
618 EVT_CFG(DM365,  EVT2_VC_TX,          0,     1,    1,     false)
619 EVT_CFG(DM365,  EVT3_VC_RX,          1,     1,    1,     false)
620 #endif
621 };
622
623 static u64 dm365_spi0_dma_mask = DMA_BIT_MASK(32);
624
625 static struct davinci_spi_platform_data dm365_spi0_pdata = {
626         .version        = SPI_VERSION_1,
627         .num_chipselect = 2,
628 };
629
630 static struct resource dm365_spi0_resources[] = {
631         {
632                 .start = 0x01c66000,
633                 .end   = 0x01c667ff,
634                 .flags = IORESOURCE_MEM,
635         },
636         {
637                 .start = IRQ_DM365_SPIINT0_0,
638                 .flags = IORESOURCE_IRQ,
639         },
640         {
641                 .start = 17,
642                 .flags = IORESOURCE_DMA,
643         },
644         {
645                 .start = 16,
646                 .flags = IORESOURCE_DMA,
647         },
648         {
649                 .start = EVENTQ_3,
650                 .flags = IORESOURCE_DMA,
651         },
652 };
653
654 static struct platform_device dm365_spi0_device = {
655         .name = "spi_davinci",
656         .id = 0,
657         .dev = {
658                 .dma_mask = &dm365_spi0_dma_mask,
659                 .coherent_dma_mask = DMA_BIT_MASK(32),
660                 .platform_data = &dm365_spi0_pdata,
661         },
662         .num_resources = ARRAY_SIZE(dm365_spi0_resources),
663         .resource = dm365_spi0_resources,
664 };
665
666 void __init dm365_init_spi0(unsigned chipselect_mask,
667                 struct spi_board_info *info, unsigned len)
668 {
669         davinci_cfg_reg(DM365_SPI0_SCLK);
670         davinci_cfg_reg(DM365_SPI0_SDI);
671         davinci_cfg_reg(DM365_SPI0_SDO);
672
673         /* not all slaves will be wired up */
674         if (chipselect_mask & BIT(0))
675                 davinci_cfg_reg(DM365_SPI0_SDENA0);
676         if (chipselect_mask & BIT(1))
677                 davinci_cfg_reg(DM365_SPI0_SDENA1);
678
679         spi_register_board_info(info, len);
680
681         platform_device_register(&dm365_spi0_device);
682 }
683
684 static struct emac_platform_data dm365_emac_pdata = {
685         .ctrl_reg_offset        = DM365_EMAC_CNTRL_OFFSET,
686         .ctrl_mod_reg_offset    = DM365_EMAC_CNTRL_MOD_OFFSET,
687         .ctrl_ram_offset        = DM365_EMAC_CNTRL_RAM_OFFSET,
688         .ctrl_ram_size          = DM365_EMAC_CNTRL_RAM_SIZE,
689         .version                = EMAC_VERSION_2,
690 };
691
692 static struct resource dm365_emac_resources[] = {
693         {
694                 .start  = DM365_EMAC_BASE,
695                 .end    = DM365_EMAC_BASE + SZ_16K - 1,
696                 .flags  = IORESOURCE_MEM,
697         },
698         {
699                 .start  = IRQ_DM365_EMAC_RXTHRESH,
700                 .end    = IRQ_DM365_EMAC_RXTHRESH,
701                 .flags  = IORESOURCE_IRQ,
702         },
703         {
704                 .start  = IRQ_DM365_EMAC_RXPULSE,
705                 .end    = IRQ_DM365_EMAC_RXPULSE,
706                 .flags  = IORESOURCE_IRQ,
707         },
708         {
709                 .start  = IRQ_DM365_EMAC_TXPULSE,
710                 .end    = IRQ_DM365_EMAC_TXPULSE,
711                 .flags  = IORESOURCE_IRQ,
712         },
713         {
714                 .start  = IRQ_DM365_EMAC_MISCPULSE,
715                 .end    = IRQ_DM365_EMAC_MISCPULSE,
716                 .flags  = IORESOURCE_IRQ,
717         },
718 };
719
720 static struct platform_device dm365_emac_device = {
721         .name           = "davinci_emac",
722         .id             = 1,
723         .dev = {
724                 .platform_data  = &dm365_emac_pdata,
725         },
726         .num_resources  = ARRAY_SIZE(dm365_emac_resources),
727         .resource       = dm365_emac_resources,
728 };
729
730 static struct resource dm365_mdio_resources[] = {
731         {
732                 .start  = DM365_EMAC_MDIO_BASE,
733                 .end    = DM365_EMAC_MDIO_BASE + SZ_4K - 1,
734                 .flags  = IORESOURCE_MEM,
735         },
736 };
737
738 static struct platform_device dm365_mdio_device = {
739         .name           = "davinci_mdio",
740         .id             = 0,
741         .num_resources  = ARRAY_SIZE(dm365_mdio_resources),
742         .resource       = dm365_mdio_resources,
743 };
744
745 static u8 dm365_default_priorities[DAVINCI_N_AINTC_IRQ] = {
746         [IRQ_VDINT0]                    = 2,
747         [IRQ_VDINT1]                    = 6,
748         [IRQ_VDINT2]                    = 6,
749         [IRQ_HISTINT]                   = 6,
750         [IRQ_H3AINT]                    = 6,
751         [IRQ_PRVUINT]                   = 6,
752         [IRQ_RSZINT]                    = 6,
753         [IRQ_DM365_INSFINT]             = 7,
754         [IRQ_VENCINT]                   = 6,
755         [IRQ_ASQINT]                    = 6,
756         [IRQ_IMXINT]                    = 6,
757         [IRQ_DM365_IMCOPINT]            = 4,
758         [IRQ_USBINT]                    = 4,
759         [IRQ_DM365_RTOINT]              = 7,
760         [IRQ_DM365_TINT5]               = 7,
761         [IRQ_DM365_TINT6]               = 5,
762         [IRQ_CCINT0]                    = 5,
763         [IRQ_CCERRINT]                  = 5,
764         [IRQ_TCERRINT0]                 = 5,
765         [IRQ_TCERRINT]                  = 7,
766         [IRQ_PSCIN]                     = 4,
767         [IRQ_DM365_SPINT2_1]            = 7,
768         [IRQ_DM365_TINT7]               = 7,
769         [IRQ_DM365_SDIOINT0]            = 7,
770         [IRQ_MBXINT]                    = 7,
771         [IRQ_MBRINT]                    = 7,
772         [IRQ_MMCINT]                    = 7,
773         [IRQ_DM365_MMCINT1]             = 7,
774         [IRQ_DM365_PWMINT3]             = 7,
775         [IRQ_AEMIFINT]                  = 2,
776         [IRQ_DM365_SDIOINT1]            = 2,
777         [IRQ_TINT0_TINT12]              = 7,
778         [IRQ_TINT0_TINT34]              = 7,
779         [IRQ_TINT1_TINT12]              = 7,
780         [IRQ_TINT1_TINT34]              = 7,
781         [IRQ_PWMINT0]                   = 7,
782         [IRQ_PWMINT1]                   = 3,
783         [IRQ_PWMINT2]                   = 3,
784         [IRQ_I2C]                       = 3,
785         [IRQ_UARTINT0]                  = 3,
786         [IRQ_UARTINT1]                  = 3,
787         [IRQ_DM365_RTCINT]              = 3,
788         [IRQ_DM365_SPIINT0_0]           = 3,
789         [IRQ_DM365_SPIINT3_0]           = 3,
790         [IRQ_DM365_GPIO0]               = 3,
791         [IRQ_DM365_GPIO1]               = 7,
792         [IRQ_DM365_GPIO2]               = 4,
793         [IRQ_DM365_GPIO3]               = 4,
794         [IRQ_DM365_GPIO4]               = 7,
795         [IRQ_DM365_GPIO5]               = 7,
796         [IRQ_DM365_GPIO6]               = 7,
797         [IRQ_DM365_GPIO7]               = 7,
798         [IRQ_DM365_EMAC_RXTHRESH]       = 7,
799         [IRQ_DM365_EMAC_RXPULSE]        = 7,
800         [IRQ_DM365_EMAC_TXPULSE]        = 7,
801         [IRQ_DM365_EMAC_MISCPULSE]      = 7,
802         [IRQ_DM365_GPIO12]              = 7,
803         [IRQ_DM365_GPIO13]              = 7,
804         [IRQ_DM365_GPIO14]              = 7,
805         [IRQ_DM365_GPIO15]              = 7,
806         [IRQ_DM365_KEYINT]              = 7,
807         [IRQ_DM365_TCERRINT2]           = 7,
808         [IRQ_DM365_TCERRINT3]           = 7,
809         [IRQ_DM365_EMUINT]              = 7,
810 };
811
812 /* Four Transfer Controllers on DM365 */
813 static const s8
814 dm365_queue_tc_mapping[][2] = {
815         /* {event queue no, TC no} */
816         {0, 0},
817         {1, 1},
818         {2, 2},
819         {3, 3},
820         {-1, -1},
821 };
822
823 static const s8
824 dm365_queue_priority_mapping[][2] = {
825         /* {event queue no, Priority} */
826         {0, 7},
827         {1, 7},
828         {2, 7},
829         {3, 0},
830         {-1, -1},
831 };
832
833 static struct edma_soc_info edma_cc0_info = {
834         .n_channel              = 64,
835         .n_region               = 4,
836         .n_slot                 = 256,
837         .n_tc                   = 4,
838         .n_cc                   = 1,
839         .queue_tc_mapping       = dm365_queue_tc_mapping,
840         .queue_priority_mapping = dm365_queue_priority_mapping,
841         .default_queue          = EVENTQ_3,
842 };
843
844 static struct edma_soc_info *dm365_edma_info[EDMA_MAX_CC] = {
845         &edma_cc0_info,
846 };
847
848 static struct resource edma_resources[] = {
849         {
850                 .name   = "edma_cc0",
851                 .start  = 0x01c00000,
852                 .end    = 0x01c00000 + SZ_64K - 1,
853                 .flags  = IORESOURCE_MEM,
854         },
855         {
856                 .name   = "edma_tc0",
857                 .start  = 0x01c10000,
858                 .end    = 0x01c10000 + SZ_1K - 1,
859                 .flags  = IORESOURCE_MEM,
860         },
861         {
862                 .name   = "edma_tc1",
863                 .start  = 0x01c10400,
864                 .end    = 0x01c10400 + SZ_1K - 1,
865                 .flags  = IORESOURCE_MEM,
866         },
867         {
868                 .name   = "edma_tc2",
869                 .start  = 0x01c10800,
870                 .end    = 0x01c10800 + SZ_1K - 1,
871                 .flags  = IORESOURCE_MEM,
872         },
873         {
874                 .name   = "edma_tc3",
875                 .start  = 0x01c10c00,
876                 .end    = 0x01c10c00 + SZ_1K - 1,
877                 .flags  = IORESOURCE_MEM,
878         },
879         {
880                 .name   = "edma0",
881                 .start  = IRQ_CCINT0,
882                 .flags  = IORESOURCE_IRQ,
883         },
884         {
885                 .name   = "edma0_err",
886                 .start  = IRQ_CCERRINT,
887                 .flags  = IORESOURCE_IRQ,
888         },
889         /* not using TC*_ERR */
890 };
891
892 static struct platform_device dm365_edma_device = {
893         .name                   = "edma",
894         .id                     = 0,
895         .dev.platform_data      = dm365_edma_info,
896         .num_resources          = ARRAY_SIZE(edma_resources),
897         .resource               = edma_resources,
898 };
899
900 static struct resource dm365_asp_resources[] = {
901         {
902                 .start  = DAVINCI_DM365_ASP0_BASE,
903                 .end    = DAVINCI_DM365_ASP0_BASE + SZ_8K - 1,
904                 .flags  = IORESOURCE_MEM,
905         },
906         {
907                 .start  = DAVINCI_DMA_ASP0_TX,
908                 .end    = DAVINCI_DMA_ASP0_TX,
909                 .flags  = IORESOURCE_DMA,
910         },
911         {
912                 .start  = DAVINCI_DMA_ASP0_RX,
913                 .end    = DAVINCI_DMA_ASP0_RX,
914                 .flags  = IORESOURCE_DMA,
915         },
916 };
917
918 static struct platform_device dm365_asp_device = {
919         .name           = "davinci-mcbsp",
920         .id             = -1,
921         .num_resources  = ARRAY_SIZE(dm365_asp_resources),
922         .resource       = dm365_asp_resources,
923 };
924
925 static struct resource dm365_vc_resources[] = {
926         {
927                 .start  = DAVINCI_DM365_VC_BASE,
928                 .end    = DAVINCI_DM365_VC_BASE + SZ_1K - 1,
929                 .flags  = IORESOURCE_MEM,
930         },
931         {
932                 .start  = DAVINCI_DMA_VC_TX,
933                 .end    = DAVINCI_DMA_VC_TX,
934                 .flags  = IORESOURCE_DMA,
935         },
936         {
937                 .start  = DAVINCI_DMA_VC_RX,
938                 .end    = DAVINCI_DMA_VC_RX,
939                 .flags  = IORESOURCE_DMA,
940         },
941 };
942
943 static struct platform_device dm365_vc_device = {
944         .name           = "davinci_voicecodec",
945         .id             = -1,
946         .num_resources  = ARRAY_SIZE(dm365_vc_resources),
947         .resource       = dm365_vc_resources,
948 };
949
950 static struct resource dm365_rtc_resources[] = {
951         {
952                 .start = DM365_RTC_BASE,
953                 .end = DM365_RTC_BASE + SZ_1K - 1,
954                 .flags = IORESOURCE_MEM,
955         },
956         {
957                 .start = IRQ_DM365_RTCINT,
958                 .flags = IORESOURCE_IRQ,
959         },
960 };
961
962 static struct platform_device dm365_rtc_device = {
963         .name = "rtc_davinci",
964         .id = 0,
965         .num_resources = ARRAY_SIZE(dm365_rtc_resources),
966         .resource = dm365_rtc_resources,
967 };
968
969 static struct map_desc dm365_io_desc[] = {
970         {
971                 .virtual        = IO_VIRT,
972                 .pfn            = __phys_to_pfn(IO_PHYS),
973                 .length         = IO_SIZE,
974                 .type           = MT_DEVICE
975         },
976         {
977                 .virtual        = SRAM_VIRT,
978                 .pfn            = __phys_to_pfn(0x00010000),
979                 .length         = SZ_32K,
980                 .type           = MT_MEMORY_NONCACHED,
981         },
982 };
983
984 static struct resource dm365_ks_resources[] = {
985         {
986                 /* registers */
987                 .start = DM365_KEYSCAN_BASE,
988                 .end = DM365_KEYSCAN_BASE + SZ_1K - 1,
989                 .flags = IORESOURCE_MEM,
990         },
991         {
992                 /* interrupt */
993                 .start = IRQ_DM365_KEYINT,
994                 .end = IRQ_DM365_KEYINT,
995                 .flags = IORESOURCE_IRQ,
996         },
997 };
998
999 static struct platform_device dm365_ks_device = {
1000         .name           = "davinci_keyscan",
1001         .id             = 0,
1002         .num_resources  = ARRAY_SIZE(dm365_ks_resources),
1003         .resource       = dm365_ks_resources,
1004 };
1005
1006 /* Contents of JTAG ID register used to identify exact cpu type */
1007 static struct davinci_id dm365_ids[] = {
1008         {
1009                 .variant        = 0x0,
1010                 .part_no        = 0xb83e,
1011                 .manufacturer   = 0x017,
1012                 .cpu_id         = DAVINCI_CPU_ID_DM365,
1013                 .name           = "dm365_rev1.1",
1014         },
1015         {
1016                 .variant        = 0x8,
1017                 .part_no        = 0xb83e,
1018                 .manufacturer   = 0x017,
1019                 .cpu_id         = DAVINCI_CPU_ID_DM365,
1020                 .name           = "dm365_rev1.2",
1021         },
1022 };
1023
1024 static u32 dm365_psc_bases[] = { DAVINCI_PWR_SLEEP_CNTRL_BASE };
1025
1026 static struct davinci_timer_info dm365_timer_info = {
1027         .timers         = davinci_timer_instance,
1028         .clockevent_id  = T0_BOT,
1029         .clocksource_id = T0_TOP,
1030 };
1031
1032 #define DM365_UART1_BASE        (IO_PHYS + 0x106000)
1033
1034 static struct plat_serial8250_port dm365_serial_platform_data[] = {
1035         {
1036                 .mapbase        = DAVINCI_UART0_BASE,
1037                 .irq            = IRQ_UARTINT0,
1038                 .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
1039                                   UPF_IOREMAP,
1040                 .iotype         = UPIO_MEM,
1041                 .regshift       = 2,
1042         },
1043         {
1044                 .mapbase        = DM365_UART1_BASE,
1045                 .irq            = IRQ_UARTINT1,
1046                 .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
1047                                   UPF_IOREMAP,
1048                 .iotype         = UPIO_MEM,
1049                 .regshift       = 2,
1050         },
1051         {
1052                 .flags          = 0
1053         },
1054 };
1055
1056 static struct platform_device dm365_serial_device = {
1057         .name                   = "serial8250",
1058         .id                     = PLAT8250_DEV_PLATFORM,
1059         .dev                    = {
1060                 .platform_data  = dm365_serial_platform_data,
1061         },
1062 };
1063
1064 static struct davinci_soc_info davinci_soc_info_dm365 = {
1065         .io_desc                = dm365_io_desc,
1066         .io_desc_num            = ARRAY_SIZE(dm365_io_desc),
1067         .jtag_id_reg            = 0x01c40028,
1068         .ids                    = dm365_ids,
1069         .ids_num                = ARRAY_SIZE(dm365_ids),
1070         .cpu_clks               = dm365_clks,
1071         .psc_bases              = dm365_psc_bases,
1072         .psc_bases_num          = ARRAY_SIZE(dm365_psc_bases),
1073         .pinmux_base            = DAVINCI_SYSTEM_MODULE_BASE,
1074         .pinmux_pins            = dm365_pins,
1075         .pinmux_pins_num        = ARRAY_SIZE(dm365_pins),
1076         .intc_base              = DAVINCI_ARM_INTC_BASE,
1077         .intc_type              = DAVINCI_INTC_TYPE_AINTC,
1078         .intc_irq_prios         = dm365_default_priorities,
1079         .intc_irq_num           = DAVINCI_N_AINTC_IRQ,
1080         .timer_info             = &dm365_timer_info,
1081         .gpio_type              = GPIO_TYPE_DAVINCI,
1082         .gpio_base              = DAVINCI_GPIO_BASE,
1083         .gpio_num               = 104,
1084         .gpio_irq               = IRQ_DM365_GPIO0,
1085         .gpio_unbanked          = 8,    /* really 16 ... skip muxed GPIOs */
1086         .serial_dev             = &dm365_serial_device,
1087         .emac_pdata             = &dm365_emac_pdata,
1088         .sram_dma               = 0x00010000,
1089         .sram_len               = SZ_32K,
1090         .reset_device           = &davinci_wdt_device,
1091 };
1092
1093 void __init dm365_init_asp(struct snd_platform_data *pdata)
1094 {
1095         davinci_cfg_reg(DM365_MCBSP0_BDX);
1096         davinci_cfg_reg(DM365_MCBSP0_X);
1097         davinci_cfg_reg(DM365_MCBSP0_BFSX);
1098         davinci_cfg_reg(DM365_MCBSP0_BDR);
1099         davinci_cfg_reg(DM365_MCBSP0_R);
1100         davinci_cfg_reg(DM365_MCBSP0_BFSR);
1101         davinci_cfg_reg(DM365_EVT2_ASP_TX);
1102         davinci_cfg_reg(DM365_EVT3_ASP_RX);
1103         dm365_asp_device.dev.platform_data = pdata;
1104         platform_device_register(&dm365_asp_device);
1105 }
1106
1107 void __init dm365_init_vc(struct snd_platform_data *pdata)
1108 {
1109         davinci_cfg_reg(DM365_EVT2_VC_TX);
1110         davinci_cfg_reg(DM365_EVT3_VC_RX);
1111         dm365_vc_device.dev.platform_data = pdata;
1112         platform_device_register(&dm365_vc_device);
1113 }
1114
1115 void __init dm365_init_ks(struct davinci_ks_platform_data *pdata)
1116 {
1117         dm365_ks_device.dev.platform_data = pdata;
1118         platform_device_register(&dm365_ks_device);
1119 }
1120
1121 void __init dm365_init_rtc(void)
1122 {
1123         davinci_cfg_reg(DM365_INT_PRTCSS);
1124         platform_device_register(&dm365_rtc_device);
1125 }
1126
1127 void __init dm365_init(void)
1128 {
1129         davinci_common_init(&davinci_soc_info_dm365);
1130 }
1131
1132 static struct resource dm365_vpss_resources[] = {
1133         {
1134                 /* VPSS ISP5 Base address */
1135                 .name           = "isp5",
1136                 .start          = 0x01c70000,
1137                 .end            = 0x01c70000 + 0xff,
1138                 .flags          = IORESOURCE_MEM,
1139         },
1140         {
1141                 /* VPSS CLK Base address */
1142                 .name           = "vpss",
1143                 .start          = 0x01c70200,
1144                 .end            = 0x01c70200 + 0xff,
1145                 .flags          = IORESOURCE_MEM,
1146         },
1147 };
1148
1149 static struct platform_device dm365_vpss_device = {
1150        .name                   = "vpss",
1151        .id                     = -1,
1152        .dev.platform_data      = "dm365_vpss",
1153        .num_resources          = ARRAY_SIZE(dm365_vpss_resources),
1154        .resource               = dm365_vpss_resources,
1155 };
1156
1157 static struct resource vpfe_resources[] = {
1158         {
1159                 .start          = IRQ_VDINT0,
1160                 .end            = IRQ_VDINT0,
1161                 .flags          = IORESOURCE_IRQ,
1162         },
1163         {
1164                 .start          = IRQ_VDINT1,
1165                 .end            = IRQ_VDINT1,
1166                 .flags          = IORESOURCE_IRQ,
1167         },
1168 };
1169
1170 static u64 vpfe_capture_dma_mask = DMA_BIT_MASK(32);
1171 static struct platform_device vpfe_capture_dev = {
1172         .name           = CAPTURE_DRV_NAME,
1173         .id             = -1,
1174         .num_resources  = ARRAY_SIZE(vpfe_resources),
1175         .resource       = vpfe_resources,
1176         .dev = {
1177                 .dma_mask               = &vpfe_capture_dma_mask,
1178                 .coherent_dma_mask      = DMA_BIT_MASK(32),
1179         },
1180 };
1181
1182 static void dm365_isif_setup_pinmux(void)
1183 {
1184         davinci_cfg_reg(DM365_VIN_CAM_WEN);
1185         davinci_cfg_reg(DM365_VIN_CAM_VD);
1186         davinci_cfg_reg(DM365_VIN_CAM_HD);
1187         davinci_cfg_reg(DM365_VIN_YIN4_7_EN);
1188         davinci_cfg_reg(DM365_VIN_YIN0_3_EN);
1189 }
1190
1191 static struct resource isif_resource[] = {
1192         /* ISIF Base address */
1193         {
1194                 .start          = 0x01c71000,
1195                 .end            = 0x01c71000 + 0x1ff,
1196                 .flags          = IORESOURCE_MEM,
1197         },
1198         /* ISIF Linearization table 0 */
1199         {
1200                 .start          = 0x1C7C000,
1201                 .end            = 0x1C7C000 + 0x2ff,
1202                 .flags          = IORESOURCE_MEM,
1203         },
1204         /* ISIF Linearization table 1 */
1205         {
1206                 .start          = 0x1C7C400,
1207                 .end            = 0x1C7C400 + 0x2ff,
1208                 .flags          = IORESOURCE_MEM,
1209         },
1210 };
1211 static struct platform_device dm365_isif_dev = {
1212         .name           = "isif",
1213         .id             = -1,
1214         .num_resources  = ARRAY_SIZE(isif_resource),
1215         .resource       = isif_resource,
1216         .dev = {
1217                 .dma_mask               = &vpfe_capture_dma_mask,
1218                 .coherent_dma_mask      = DMA_BIT_MASK(32),
1219                 .platform_data          = dm365_isif_setup_pinmux,
1220         },
1221 };
1222
1223 static int __init dm365_init_devices(void)
1224 {
1225         if (!cpu_is_davinci_dm365())
1226                 return 0;
1227
1228         davinci_cfg_reg(DM365_INT_EDMA_CC);
1229         platform_device_register(&dm365_edma_device);
1230
1231         platform_device_register(&dm365_mdio_device);
1232         platform_device_register(&dm365_emac_device);
1233         clk_add_alias(NULL, dev_name(&dm365_mdio_device.dev),
1234                       NULL, &dm365_emac_device.dev);
1235
1236         /* Add isif clock alias */
1237         clk_add_alias("master", dm365_isif_dev.name, "vpss_master", NULL);
1238         platform_device_register(&dm365_vpss_device);
1239         platform_device_register(&dm365_isif_dev);
1240         platform_device_register(&vpfe_capture_dev);
1241         return 0;
1242 }
1243 postcore_initcall(dm365_init_devices);
1244
1245 void dm365_set_vpfe_config(struct vpfe_config *cfg)
1246 {
1247        vpfe_capture_dev.dev.platform_data = cfg;
1248 }