blob: 5c3e0be95ef3d283b653d5842001386527ab2979 [file] [log] [blame]
Kevin Hilmand0e47fb2009-04-14 11:30:11 -05001/*
2 * TI DaVinci DM644x chip specific setup
3 *
4 * Author: Kevin Hilman, Deep Root Systems, LLC
5 *
6 * 2007 (c) Deep Root Systems, LLC. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050011#include <linux/init.h>
12#include <linux/clk.h>
Mark A. Greer65e866a2009-03-18 12:36:08 -050013#include <linux/serial_8250.h>
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050014#include <linux/platform_device.h>
Matt Porter3ad7a422013-03-06 11:15:31 -050015#include <linux/platform_data/edma.h>
Philip Avinash9cc15152013-08-18 10:49:00 +053016#include <linux/platform_data/gpio-davinci.h>
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050017
Mark A. Greer79c3c0b2009-04-15 12:38:58 -070018#include <asm/mach/map.h>
19
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050020#include <mach/cputype.h>
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050021#include <mach/irqs.h>
22#include <mach/psc.h>
23#include <mach/mux.h>
Mark A. Greerf64691b2009-04-15 12:40:11 -070024#include <mach/time.h>
Mark A. Greer65e866a2009-03-18 12:36:08 -050025#include <mach/serial.h>
Mark A. Greer79c3c0b2009-04-15 12:38:58 -070026#include <mach/common.h>
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050027
Manjunath Hadli39c6d2d2011-12-21 19:13:35 +053028#include "davinci.h"
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050029#include "clock.h"
30#include "mux.h"
Hebbar, Gururaja896f66b2012-08-27 18:56:41 +053031#include "asp.h"
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050032
33/*
34 * Device specific clocks
35 */
36#define DM644X_REF_FREQ 27000000
37
Manjunath Hadli887b8a92011-12-15 17:41:51 +053038#define DM644X_EMAC_BASE 0x01c80000
39#define DM644X_EMAC_MDIO_BASE (DM644X_EMAC_BASE + 0x4000)
40#define DM644X_EMAC_CNTRL_OFFSET 0x0000
41#define DM644X_EMAC_CNTRL_MOD_OFFSET 0x1000
42#define DM644X_EMAC_CNTRL_RAM_OFFSET 0x2000
43#define DM644X_EMAC_CNTRL_RAM_SIZE 0x2000
44
Kevin Hilmand0e47fb2009-04-14 11:30:11 -050045static struct pll_data pll1_data = {
46 .num = 1,
47 .phys_base = DAVINCI_PLL1_BASE,
48};
49
50static struct pll_data pll2_data = {
51 .num = 2,
52 .phys_base = DAVINCI_PLL2_BASE,
53};
54
55static struct clk ref_clk = {
56 .name = "ref_clk",
57 .rate = DM644X_REF_FREQ,
58};
59
60static struct clk pll1_clk = {
61 .name = "pll1",
62 .parent = &ref_clk,
63 .pll_data = &pll1_data,
64 .flags = CLK_PLL,
65};
66
67static struct clk pll1_sysclk1 = {
68 .name = "pll1_sysclk1",
69 .parent = &pll1_clk,
70 .flags = CLK_PLL,
71 .div_reg = PLLDIV1,
72};
73
74static struct clk pll1_sysclk2 = {
75 .name = "pll1_sysclk2",
76 .parent = &pll1_clk,
77 .flags = CLK_PLL,
78 .div_reg = PLLDIV2,
79};
80
81static struct clk pll1_sysclk3 = {
82 .name = "pll1_sysclk3",
83 .parent = &pll1_clk,
84 .flags = CLK_PLL,
85 .div_reg = PLLDIV3,
86};
87
88static struct clk pll1_sysclk5 = {
89 .name = "pll1_sysclk5",
90 .parent = &pll1_clk,
91 .flags = CLK_PLL,
92 .div_reg = PLLDIV5,
93};
94
95static struct clk pll1_aux_clk = {
96 .name = "pll1_aux_clk",
97 .parent = &pll1_clk,
98 .flags = CLK_PLL | PRE_PLL,
99};
100
101static struct clk pll1_sysclkbp = {
102 .name = "pll1_sysclkbp",
103 .parent = &pll1_clk,
104 .flags = CLK_PLL | PRE_PLL,
105 .div_reg = BPDIV
106};
107
108static struct clk pll2_clk = {
109 .name = "pll2",
110 .parent = &ref_clk,
111 .pll_data = &pll2_data,
112 .flags = CLK_PLL,
113};
114
115static struct clk pll2_sysclk1 = {
116 .name = "pll2_sysclk1",
117 .parent = &pll2_clk,
118 .flags = CLK_PLL,
119 .div_reg = PLLDIV1,
120};
121
122static struct clk pll2_sysclk2 = {
123 .name = "pll2_sysclk2",
124 .parent = &pll2_clk,
125 .flags = CLK_PLL,
126 .div_reg = PLLDIV2,
127};
128
129static struct clk pll2_sysclkbp = {
130 .name = "pll2_sysclkbp",
131 .parent = &pll2_clk,
132 .flags = CLK_PLL | PRE_PLL,
133 .div_reg = BPDIV
134};
135
136static struct clk dsp_clk = {
137 .name = "dsp",
138 .parent = &pll1_sysclk1,
139 .lpsc = DAVINCI_LPSC_GEM,
Murali Karicheri12221d42011-11-15 01:42:09 +0530140 .domain = DAVINCI_GPSC_DSPDOMAIN,
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500141 .usecount = 1, /* REVISIT how to disable? */
142};
143
144static struct clk arm_clk = {
145 .name = "arm",
146 .parent = &pll1_sysclk2,
147 .lpsc = DAVINCI_LPSC_ARM,
148 .flags = ALWAYS_ENABLED,
149};
150
151static struct clk vicp_clk = {
152 .name = "vicp",
153 .parent = &pll1_sysclk2,
154 .lpsc = DAVINCI_LPSC_IMCOP,
Murali Karicheri12221d42011-11-15 01:42:09 +0530155 .domain = DAVINCI_GPSC_DSPDOMAIN,
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500156 .usecount = 1, /* REVISIT how to disable? */
157};
158
159static struct clk vpss_master_clk = {
160 .name = "vpss_master",
161 .parent = &pll1_sysclk3,
162 .lpsc = DAVINCI_LPSC_VPSSMSTR,
163 .flags = CLK_PSC,
164};
165
166static struct clk vpss_slave_clk = {
167 .name = "vpss_slave",
168 .parent = &pll1_sysclk3,
169 .lpsc = DAVINCI_LPSC_VPSSSLV,
170};
171
172static struct clk uart0_clk = {
173 .name = "uart0",
174 .parent = &pll1_aux_clk,
175 .lpsc = DAVINCI_LPSC_UART0,
176};
177
178static struct clk uart1_clk = {
179 .name = "uart1",
180 .parent = &pll1_aux_clk,
181 .lpsc = DAVINCI_LPSC_UART1,
182};
183
184static struct clk uart2_clk = {
185 .name = "uart2",
186 .parent = &pll1_aux_clk,
187 .lpsc = DAVINCI_LPSC_UART2,
188};
189
190static struct clk emac_clk = {
191 .name = "emac",
192 .parent = &pll1_sysclk5,
193 .lpsc = DAVINCI_LPSC_EMAC_WRAPPER,
194};
195
196static struct clk i2c_clk = {
197 .name = "i2c",
198 .parent = &pll1_aux_clk,
199 .lpsc = DAVINCI_LPSC_I2C,
200};
201
202static struct clk ide_clk = {
203 .name = "ide",
204 .parent = &pll1_sysclk5,
205 .lpsc = DAVINCI_LPSC_ATA,
206};
207
208static struct clk asp_clk = {
209 .name = "asp0",
210 .parent = &pll1_sysclk5,
211 .lpsc = DAVINCI_LPSC_McBSP,
212};
213
214static struct clk mmcsd_clk = {
215 .name = "mmcsd",
216 .parent = &pll1_sysclk5,
217 .lpsc = DAVINCI_LPSC_MMC_SD,
218};
219
220static struct clk spi_clk = {
221 .name = "spi",
222 .parent = &pll1_sysclk5,
223 .lpsc = DAVINCI_LPSC_SPI,
224};
225
226static struct clk gpio_clk = {
227 .name = "gpio",
228 .parent = &pll1_sysclk5,
229 .lpsc = DAVINCI_LPSC_GPIO,
230};
231
232static struct clk usb_clk = {
233 .name = "usb",
234 .parent = &pll1_sysclk5,
235 .lpsc = DAVINCI_LPSC_USB,
236};
237
238static struct clk vlynq_clk = {
239 .name = "vlynq",
240 .parent = &pll1_sysclk5,
241 .lpsc = DAVINCI_LPSC_VLYNQ,
242};
243
244static struct clk aemif_clk = {
245 .name = "aemif",
246 .parent = &pll1_sysclk5,
247 .lpsc = DAVINCI_LPSC_AEMIF,
248};
249
250static struct clk pwm0_clk = {
251 .name = "pwm0",
252 .parent = &pll1_aux_clk,
253 .lpsc = DAVINCI_LPSC_PWM0,
254};
255
256static struct clk pwm1_clk = {
257 .name = "pwm1",
258 .parent = &pll1_aux_clk,
259 .lpsc = DAVINCI_LPSC_PWM1,
260};
261
262static struct clk pwm2_clk = {
263 .name = "pwm2",
264 .parent = &pll1_aux_clk,
265 .lpsc = DAVINCI_LPSC_PWM2,
266};
267
268static struct clk timer0_clk = {
269 .name = "timer0",
270 .parent = &pll1_aux_clk,
271 .lpsc = DAVINCI_LPSC_TIMER0,
272};
273
274static struct clk timer1_clk = {
275 .name = "timer1",
276 .parent = &pll1_aux_clk,
277 .lpsc = DAVINCI_LPSC_TIMER1,
278};
279
280static struct clk timer2_clk = {
281 .name = "timer2",
282 .parent = &pll1_aux_clk,
283 .lpsc = DAVINCI_LPSC_TIMER2,
Lucas De Marchie9c54992011-04-26 23:28:26 -0700284 .usecount = 1, /* REVISIT: why can't this be disabled? */
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500285};
286
Kevin Hilman28552c22010-02-25 15:36:38 -0800287static struct clk_lookup dm644x_clks[] = {
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500288 CLK(NULL, "ref", &ref_clk),
289 CLK(NULL, "pll1", &pll1_clk),
290 CLK(NULL, "pll1_sysclk1", &pll1_sysclk1),
291 CLK(NULL, "pll1_sysclk2", &pll1_sysclk2),
292 CLK(NULL, "pll1_sysclk3", &pll1_sysclk3),
293 CLK(NULL, "pll1_sysclk5", &pll1_sysclk5),
294 CLK(NULL, "pll1_aux", &pll1_aux_clk),
295 CLK(NULL, "pll1_sysclkbp", &pll1_sysclkbp),
296 CLK(NULL, "pll2", &pll2_clk),
297 CLK(NULL, "pll2_sysclk1", &pll2_sysclk1),
298 CLK(NULL, "pll2_sysclk2", &pll2_sysclk2),
299 CLK(NULL, "pll2_sysclkbp", &pll2_sysclkbp),
300 CLK(NULL, "dsp", &dsp_clk),
301 CLK(NULL, "arm", &arm_clk),
302 CLK(NULL, "vicp", &vicp_clk),
Lad, Prabhakar9a3e89b2013-03-22 04:53:12 -0300303 CLK("vpss", "master", &vpss_master_clk),
304 CLK("vpss", "slave", &vpss_slave_clk),
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500305 CLK(NULL, "arm", &arm_clk),
Manjunathappa, Prakash19955c32013-06-19 14:45:38 +0530306 CLK("serial8250.0", NULL, &uart0_clk),
307 CLK("serial8250.1", NULL, &uart1_clk),
308 CLK("serial8250.2", NULL, &uart2_clk),
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500309 CLK("davinci_emac.1", NULL, &emac_clk),
Lad, Prabhakar46c18332013-08-15 11:31:33 +0530310 CLK("davinci_mdio.0", "fck", &emac_clk),
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500311 CLK("i2c_davinci.1", NULL, &i2c_clk),
312 CLK("palm_bk3710", NULL, &ide_clk),
Chris Paulson-Ellisbedad0c2010-11-16 12:27:09 +0000313 CLK("davinci-mcbsp", NULL, &asp_clk),
Manjunathappa, Prakashd7ca4c72013-03-28 18:41:59 +0530314 CLK("dm6441-mmc.0", NULL, &mmcsd_clk),
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500315 CLK(NULL, "spi", &spi_clk),
316 CLK(NULL, "gpio", &gpio_clk),
317 CLK(NULL, "usb", &usb_clk),
318 CLK(NULL, "vlynq", &vlynq_clk),
319 CLK(NULL, "aemif", &aemif_clk),
320 CLK(NULL, "pwm0", &pwm0_clk),
321 CLK(NULL, "pwm1", &pwm1_clk),
322 CLK(NULL, "pwm2", &pwm2_clk),
323 CLK(NULL, "timer0", &timer0_clk),
324 CLK(NULL, "timer1", &timer1_clk),
Ivan Khoronzhuk84374812013-11-27 15:31:53 +0200325 CLK("davinci-wdt", NULL, &timer2_clk),
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500326 CLK(NULL, NULL, NULL),
327};
328
Mark A. Greer972412b2009-04-15 12:40:56 -0700329static struct emac_platform_data dm644x_emac_pdata = {
330 .ctrl_reg_offset = DM644X_EMAC_CNTRL_OFFSET,
331 .ctrl_mod_reg_offset = DM644X_EMAC_CNTRL_MOD_OFFSET,
332 .ctrl_ram_offset = DM644X_EMAC_CNTRL_RAM_OFFSET,
Mark A. Greer972412b2009-04-15 12:40:56 -0700333 .ctrl_ram_size = DM644X_EMAC_CNTRL_RAM_SIZE,
334 .version = EMAC_VERSION_1,
335};
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500336
337static struct resource dm644x_emac_resources[] = {
338 {
339 .start = DM644X_EMAC_BASE,
Cyril Chemparathyd22960c2010-09-15 10:11:22 -0400340 .end = DM644X_EMAC_BASE + SZ_16K - 1,
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500341 .flags = IORESOURCE_MEM,
342 },
343 {
344 .start = IRQ_EMACINT,
345 .end = IRQ_EMACINT,
346 .flags = IORESOURCE_IRQ,
347 },
348};
349
350static struct platform_device dm644x_emac_device = {
351 .name = "davinci_emac",
352 .id = 1,
Mark A. Greer972412b2009-04-15 12:40:56 -0700353 .dev = {
354 .platform_data = &dm644x_emac_pdata,
355 },
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500356 .num_resources = ARRAY_SIZE(dm644x_emac_resources),
357 .resource = dm644x_emac_resources,
358};
359
Cyril Chemparathyd22960c2010-09-15 10:11:22 -0400360static struct resource dm644x_mdio_resources[] = {
361 {
362 .start = DM644X_EMAC_MDIO_BASE,
363 .end = DM644X_EMAC_MDIO_BASE + SZ_4K - 1,
364 .flags = IORESOURCE_MEM,
365 },
366};
367
368static struct platform_device dm644x_mdio_device = {
369 .name = "davinci_mdio",
370 .id = 0,
371 .num_resources = ARRAY_SIZE(dm644x_mdio_resources),
372 .resource = dm644x_mdio_resources,
373};
374
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500375/*
376 * Device specific mux setup
377 *
378 * soc description mux mode mode mux dbg
379 * reg offset mask mode
380 */
381static const struct mux_config dm644x_pins[] = {
Mark A. Greer0e585952009-04-15 12:39:48 -0700382#ifdef CONFIG_DAVINCI_MUX
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500383MUX_CFG(DM644X, HDIREN, 0, 16, 1, 1, true)
384MUX_CFG(DM644X, ATAEN, 0, 17, 1, 1, true)
385MUX_CFG(DM644X, ATAEN_DISABLE, 0, 17, 1, 0, true)
386
387MUX_CFG(DM644X, HPIEN_DISABLE, 0, 29, 1, 0, true)
388
389MUX_CFG(DM644X, AEAW, 0, 0, 31, 31, true)
Andrey Porodkoc16fe262009-11-13 19:16:51 +0500390MUX_CFG(DM644X, AEAW0, 0, 0, 1, 0, true)
391MUX_CFG(DM644X, AEAW1, 0, 1, 1, 0, true)
392MUX_CFG(DM644X, AEAW2, 0, 2, 1, 0, true)
393MUX_CFG(DM644X, AEAW3, 0, 3, 1, 0, true)
394MUX_CFG(DM644X, AEAW4, 0, 4, 1, 0, true)
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500395
396MUX_CFG(DM644X, MSTK, 1, 9, 1, 0, false)
397
398MUX_CFG(DM644X, I2C, 1, 7, 1, 1, false)
399
400MUX_CFG(DM644X, MCBSP, 1, 10, 1, 1, false)
401
402MUX_CFG(DM644X, UART1, 1, 1, 1, 1, true)
403MUX_CFG(DM644X, UART2, 1, 2, 1, 1, true)
404
405MUX_CFG(DM644X, PWM0, 1, 4, 1, 1, false)
406
407MUX_CFG(DM644X, PWM1, 1, 5, 1, 1, false)
408
409MUX_CFG(DM644X, PWM2, 1, 6, 1, 1, false)
410
411MUX_CFG(DM644X, VLYNQEN, 0, 15, 1, 1, false)
412MUX_CFG(DM644X, VLSCREN, 0, 14, 1, 1, false)
413MUX_CFG(DM644X, VLYNQWD, 0, 12, 3, 3, false)
414
415MUX_CFG(DM644X, EMACEN, 0, 31, 1, 1, true)
416
417MUX_CFG(DM644X, GPIO3V, 0, 31, 1, 0, true)
418
419MUX_CFG(DM644X, GPIO0, 0, 24, 1, 0, true)
420MUX_CFG(DM644X, GPIO3, 0, 25, 1, 0, false)
421MUX_CFG(DM644X, GPIO43_44, 1, 7, 1, 0, false)
422MUX_CFG(DM644X, GPIO46_47, 0, 22, 1, 0, true)
423
424MUX_CFG(DM644X, RGB666, 0, 22, 1, 1, true)
425
426MUX_CFG(DM644X, LOEEN, 0, 24, 1, 1, true)
427MUX_CFG(DM644X, LFLDEN, 0, 25, 1, 1, false)
Mark A. Greer0e585952009-04-15 12:39:48 -0700428#endif
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500429};
430
Mark A. Greer673dd362009-04-15 12:40:00 -0700431/* FIQ are pri 0-1; otherwise 2-7, with 7 lowest priority */
432static u8 dm644x_default_priorities[DAVINCI_N_AINTC_IRQ] = {
433 [IRQ_VDINT0] = 2,
434 [IRQ_VDINT1] = 6,
435 [IRQ_VDINT2] = 6,
436 [IRQ_HISTINT] = 6,
437 [IRQ_H3AINT] = 6,
438 [IRQ_PRVUINT] = 6,
439 [IRQ_RSZINT] = 6,
440 [7] = 7,
441 [IRQ_VENCINT] = 6,
442 [IRQ_ASQINT] = 6,
443 [IRQ_IMXINT] = 6,
444 [IRQ_VLCDINT] = 6,
445 [IRQ_USBINT] = 4,
446 [IRQ_EMACINT] = 4,
447 [14] = 7,
448 [15] = 7,
449 [IRQ_CCINT0] = 5, /* dma */
450 [IRQ_CCERRINT] = 5, /* dma */
451 [IRQ_TCERRINT0] = 5, /* dma */
452 [IRQ_TCERRINT] = 5, /* dma */
453 [IRQ_PSCIN] = 7,
454 [21] = 7,
455 [IRQ_IDE] = 4,
456 [23] = 7,
457 [IRQ_MBXINT] = 7,
458 [IRQ_MBRINT] = 7,
459 [IRQ_MMCINT] = 7,
460 [IRQ_SDIOINT] = 7,
461 [28] = 7,
462 [IRQ_DDRINT] = 7,
463 [IRQ_AEMIFINT] = 7,
464 [IRQ_VLQINT] = 4,
465 [IRQ_TINT0_TINT12] = 2, /* clockevent */
466 [IRQ_TINT0_TINT34] = 2, /* clocksource */
467 [IRQ_TINT1_TINT12] = 7, /* DSP timer */
468 [IRQ_TINT1_TINT34] = 7, /* system tick */
469 [IRQ_PWMINT0] = 7,
470 [IRQ_PWMINT1] = 7,
471 [IRQ_PWMINT2] = 7,
472 [IRQ_I2C] = 3,
473 [IRQ_UARTINT0] = 3,
474 [IRQ_UARTINT1] = 3,
475 [IRQ_UARTINT2] = 3,
476 [IRQ_SPINT0] = 3,
477 [IRQ_SPINT1] = 3,
478 [45] = 7,
479 [IRQ_DSP2ARM0] = 4,
480 [IRQ_DSP2ARM1] = 4,
481 [IRQ_GPIO0] = 7,
482 [IRQ_GPIO1] = 7,
483 [IRQ_GPIO2] = 7,
484 [IRQ_GPIO3] = 7,
485 [IRQ_GPIO4] = 7,
486 [IRQ_GPIO5] = 7,
487 [IRQ_GPIO6] = 7,
488 [IRQ_GPIO7] = 7,
489 [IRQ_GPIOBNK0] = 7,
490 [IRQ_GPIOBNK1] = 7,
491 [IRQ_GPIOBNK2] = 7,
492 [IRQ_GPIOBNK3] = 7,
493 [IRQ_GPIOBNK4] = 7,
494 [IRQ_COMMTX] = 7,
495 [IRQ_COMMRX] = 7,
496 [IRQ_EMUINT] = 7,
497};
498
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500499/*----------------------------------------------------------------------*/
500
Matt Porter6cba4352013-06-20 16:06:38 -0500501static s8
Sudhakar Rajashekhara60902a22009-05-21 07:41:35 -0400502queue_tc_mapping[][2] = {
503 /* {event queue no, TC no} */
504 {0, 0},
505 {1, 1},
506 {-1, -1},
507};
508
Matt Porter6cba4352013-06-20 16:06:38 -0500509static s8
Sudhakar Rajashekhara60902a22009-05-21 07:41:35 -0400510queue_priority_mapping[][2] = {
511 /* {event queue no, Priority} */
512 {0, 3},
513 {1, 7},
514 {-1, -1},
515};
516
Sekhar Noribc3ac9f2010-06-29 11:35:12 +0530517static struct edma_soc_info edma_cc0_info = {
518 .n_channel = 64,
519 .n_region = 4,
520 .n_slot = 128,
521 .n_tc = 2,
522 .n_cc = 1,
523 .queue_tc_mapping = queue_tc_mapping,
524 .queue_priority_mapping = queue_priority_mapping,
Ido Yarivf23fe852011-07-10 16:14:35 +0300525 .default_queue = EVENTQ_1,
Sekhar Noribc3ac9f2010-06-29 11:35:12 +0530526};
527
528static struct edma_soc_info *dm644x_edma_info[EDMA_MAX_CC] = {
529 &edma_cc0_info,
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500530};
531
532static struct resource edma_resources[] = {
533 {
Sudhakar Rajashekhara60902a22009-05-21 07:41:35 -0400534 .name = "edma_cc0",
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500535 .start = 0x01c00000,
536 .end = 0x01c00000 + SZ_64K - 1,
537 .flags = IORESOURCE_MEM,
538 },
539 {
540 .name = "edma_tc0",
541 .start = 0x01c10000,
542 .end = 0x01c10000 + SZ_1K - 1,
543 .flags = IORESOURCE_MEM,
544 },
545 {
546 .name = "edma_tc1",
547 .start = 0x01c10400,
548 .end = 0x01c10400 + SZ_1K - 1,
549 .flags = IORESOURCE_MEM,
550 },
551 {
Sudhakar Rajashekhara60902a22009-05-21 07:41:35 -0400552 .name = "edma0",
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500553 .start = IRQ_CCINT0,
554 .flags = IORESOURCE_IRQ,
555 },
556 {
Sudhakar Rajashekhara60902a22009-05-21 07:41:35 -0400557 .name = "edma0_err",
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500558 .start = IRQ_CCERRINT,
559 .flags = IORESOURCE_IRQ,
560 },
561 /* not using TC*_ERR */
562};
563
564static struct platform_device dm644x_edma_device = {
565 .name = "edma",
Sudhakar Rajashekhara60902a22009-05-21 07:41:35 -0400566 .id = 0,
567 .dev.platform_data = dm644x_edma_info,
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500568 .num_resources = ARRAY_SIZE(edma_resources),
569 .resource = edma_resources,
570};
571
Chaithrika U S25acf552009-06-05 06:28:08 -0400572/* DM6446 EVM uses ASP0; line-out is a pair of RCA jacks */
573static struct resource dm644x_asp_resources[] = {
574 {
Peter Ujfalusiee880db2013-11-13 16:48:17 +0200575 .name = "mpu",
Chaithrika U S25acf552009-06-05 06:28:08 -0400576 .start = DAVINCI_ASP0_BASE,
577 .end = DAVINCI_ASP0_BASE + SZ_8K - 1,
578 .flags = IORESOURCE_MEM,
579 },
580 {
581 .start = DAVINCI_DMA_ASP0_TX,
582 .end = DAVINCI_DMA_ASP0_TX,
583 .flags = IORESOURCE_DMA,
584 },
585 {
586 .start = DAVINCI_DMA_ASP0_RX,
587 .end = DAVINCI_DMA_ASP0_RX,
588 .flags = IORESOURCE_DMA,
589 },
590};
591
592static struct platform_device dm644x_asp_device = {
Chris Paulson-Ellisbedad0c2010-11-16 12:27:09 +0000593 .name = "davinci-mcbsp",
Chaithrika U S25acf552009-06-05 06:28:08 -0400594 .id = -1,
595 .num_resources = ARRAY_SIZE(dm644x_asp_resources),
596 .resource = dm644x_asp_resources,
597};
598
Manjunath Hadli51f31cb2011-12-21 19:13:37 +0530599#define DM644X_VPSS_BASE 0x01c73400
600
Muralidharan Karicheriab8e8df2009-09-16 11:53:18 -0400601static struct resource dm644x_vpss_resources[] = {
602 {
603 /* VPSS Base address */
604 .name = "vpss",
Manjunath Hadli51f31cb2011-12-21 19:13:37 +0530605 .start = DM644X_VPSS_BASE,
606 .end = DM644X_VPSS_BASE + 0xff,
607 .flags = IORESOURCE_MEM,
Muralidharan Karicheriab8e8df2009-09-16 11:53:18 -0400608 },
609};
610
611static struct platform_device dm644x_vpss_device = {
612 .name = "vpss",
613 .id = -1,
614 .dev.platform_data = "dm644x_vpss",
615 .num_resources = ARRAY_SIZE(dm644x_vpss_resources),
616 .resource = dm644x_vpss_resources,
617};
618
Manjunath Hadli314d7382011-12-21 19:13:38 +0530619static struct resource dm644x_vpfe_resources[] = {
Muralidharan Karicheriab8e8df2009-09-16 11:53:18 -0400620 {
621 .start = IRQ_VDINT0,
622 .end = IRQ_VDINT0,
623 .flags = IORESOURCE_IRQ,
624 },
625 {
626 .start = IRQ_VDINT1,
627 .end = IRQ_VDINT1,
628 .flags = IORESOURCE_IRQ,
629 },
Muralidharan Karicheri77c8b5f2010-01-13 20:27:08 -0300630};
631
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530632static u64 dm644x_video_dma_mask = DMA_BIT_MASK(32);
Muralidharan Karicheri77c8b5f2010-01-13 20:27:08 -0300633static struct resource dm644x_ccdc_resource[] = {
634 /* CCDC Base address */
Muralidharan Karicheriab8e8df2009-09-16 11:53:18 -0400635 {
636 .start = 0x01c70400,
637 .end = 0x01c70400 + 0xff,
638 .flags = IORESOURCE_MEM,
639 },
640};
641
Muralidharan Karicheri77c8b5f2010-01-13 20:27:08 -0300642static struct platform_device dm644x_ccdc_dev = {
643 .name = "dm644x_ccdc",
644 .id = -1,
645 .num_resources = ARRAY_SIZE(dm644x_ccdc_resource),
646 .resource = dm644x_ccdc_resource,
647 .dev = {
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530648 .dma_mask = &dm644x_video_dma_mask,
Muralidharan Karicheri77c8b5f2010-01-13 20:27:08 -0300649 .coherent_dma_mask = DMA_BIT_MASK(32),
650 },
651};
652
Manjunath Hadli314d7382011-12-21 19:13:38 +0530653static struct platform_device dm644x_vpfe_dev = {
Muralidharan Karicheriab8e8df2009-09-16 11:53:18 -0400654 .name = CAPTURE_DRV_NAME,
655 .id = -1,
Manjunath Hadli314d7382011-12-21 19:13:38 +0530656 .num_resources = ARRAY_SIZE(dm644x_vpfe_resources),
657 .resource = dm644x_vpfe_resources,
Muralidharan Karicheriab8e8df2009-09-16 11:53:18 -0400658 .dev = {
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530659 .dma_mask = &dm644x_video_dma_mask,
660 .coherent_dma_mask = DMA_BIT_MASK(32),
661 },
662};
663
664#define DM644X_OSD_BASE 0x01c72600
665
666static struct resource dm644x_osd_resources[] = {
667 {
668 .start = DM644X_OSD_BASE,
669 .end = DM644X_OSD_BASE + 0x1ff,
670 .flags = IORESOURCE_MEM,
671 },
672};
673
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530674static struct platform_device dm644x_osd_dev = {
Lad, Prabhakarcaff80c2012-11-20 07:30:36 -0300675 .name = DM644X_VPBE_OSD_SUBDEV_NAME,
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530676 .id = -1,
677 .num_resources = ARRAY_SIZE(dm644x_osd_resources),
678 .resource = dm644x_osd_resources,
679 .dev = {
680 .dma_mask = &dm644x_video_dma_mask,
681 .coherent_dma_mask = DMA_BIT_MASK(32),
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530682 },
683};
684
685#define DM644X_VENC_BASE 0x01c72400
686
687static struct resource dm644x_venc_resources[] = {
688 {
689 .start = DM644X_VENC_BASE,
690 .end = DM644X_VENC_BASE + 0x17f,
691 .flags = IORESOURCE_MEM,
692 },
693};
694
695#define DM644X_VPSS_MUXSEL_PLL2_MODE BIT(0)
696#define DM644X_VPSS_MUXSEL_VPBECLK_MODE BIT(1)
697#define DM644X_VPSS_VENCLKEN BIT(3)
698#define DM644X_VPSS_DACCLKEN BIT(4)
699
700static int dm644x_venc_setup_clock(enum vpbe_enc_timings_type type,
Hans Verkuil36864082012-10-01 11:39:46 -0300701 unsigned int pclock)
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530702{
703 int ret = 0;
704 u32 v = DM644X_VPSS_VENCLKEN;
705
706 switch (type) {
707 case VPBE_ENC_STD:
708 v |= DM644X_VPSS_DACCLKEN;
709 writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
710 break;
Hans Verkuilef2d41b2013-02-15 15:06:28 -0300711 case VPBE_ENC_DV_TIMINGS:
Hans Verkuil36864082012-10-01 11:39:46 -0300712 if (pclock <= 27000000) {
Lad, Prabhakare37212a2012-10-03 12:05:00 +0530713 v |= DM644X_VPSS_DACCLKEN;
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530714 writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
Hans Verkuil36864082012-10-01 11:39:46 -0300715 } else {
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530716 /*
717 * For HD, use external clock source since
718 * HD requires higher clock rate
719 */
720 v |= DM644X_VPSS_MUXSEL_VPBECLK_MODE;
721 writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530722 }
723 break;
724 default:
725 ret = -EINVAL;
726 }
727
728 return ret;
729}
730
731static struct resource dm644x_v4l2_disp_resources[] = {
732 {
733 .start = IRQ_VENCINT,
734 .end = IRQ_VENCINT,
735 .flags = IORESOURCE_IRQ,
736 },
737};
738
739static struct platform_device dm644x_vpbe_display = {
740 .name = "vpbe-v4l2",
741 .id = -1,
742 .num_resources = ARRAY_SIZE(dm644x_v4l2_disp_resources),
743 .resource = dm644x_v4l2_disp_resources,
744 .dev = {
745 .dma_mask = &dm644x_video_dma_mask,
746 .coherent_dma_mask = DMA_BIT_MASK(32),
747 },
748};
749
750static struct venc_platform_data dm644x_venc_pdata = {
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530751 .setup_clock = dm644x_venc_setup_clock,
752};
753
754static struct platform_device dm644x_venc_dev = {
Lad, Prabhakarcaff80c2012-11-20 07:30:36 -0300755 .name = DM644X_VPBE_VENC_SUBDEV_NAME,
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530756 .id = -1,
757 .num_resources = ARRAY_SIZE(dm644x_venc_resources),
758 .resource = dm644x_venc_resources,
759 .dev = {
760 .dma_mask = &dm644x_video_dma_mask,
761 .coherent_dma_mask = DMA_BIT_MASK(32),
762 .platform_data = &dm644x_venc_pdata,
763 },
764};
765
766static struct platform_device dm644x_vpbe_dev = {
767 .name = "vpbe_controller",
768 .id = -1,
769 .dev = {
770 .dma_mask = &dm644x_video_dma_mask,
Muralidharan Karicheriab8e8df2009-09-16 11:53:18 -0400771 .coherent_dma_mask = DMA_BIT_MASK(32),
772 },
773};
774
Philip Avinash9cc15152013-08-18 10:49:00 +0530775static struct resource dm644_gpio_resources[] = {
776 { /* registers */
777 .start = DAVINCI_GPIO_BASE,
778 .end = DAVINCI_GPIO_BASE + SZ_4K - 1,
779 .flags = IORESOURCE_MEM,
780 },
781 { /* interrupt */
782 .start = IRQ_GPIOBNK0,
783 .end = IRQ_GPIOBNK4,
784 .flags = IORESOURCE_IRQ,
785 },
786};
787
788static struct davinci_gpio_platform_data dm644_gpio_platform_data = {
789 .ngpio = 71,
Philip Avinash9cc15152013-08-18 10:49:00 +0530790};
791
792int __init dm644x_gpio_register(void)
793{
794 return davinci_gpio_register(dm644_gpio_resources,
Lad, Prabhakare462f1f2013-11-08 12:15:56 +0530795 ARRAY_SIZE(dm644_gpio_resources),
Philip Avinash9cc15152013-08-18 10:49:00 +0530796 &dm644_gpio_platform_data);
797}
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500798/*----------------------------------------------------------------------*/
Kevin Hilmanac7b75b2009-05-07 06:19:40 -0700799
Mark A. Greer79c3c0b2009-04-15 12:38:58 -0700800static struct map_desc dm644x_io_desc[] = {
801 {
802 .virtual = IO_VIRT,
803 .pfn = __phys_to_pfn(IO_PHYS),
804 .length = IO_SIZE,
805 .type = MT_DEVICE
806 },
807};
808
Mark A. Greerb9ab1272009-04-15 12:39:09 -0700809/* Contents of JTAG ID register used to identify exact cpu type */
810static struct davinci_id dm644x_ids[] = {
811 {
812 .variant = 0x0,
813 .part_no = 0xb700,
814 .manufacturer = 0x017,
815 .cpu_id = DAVINCI_CPU_ID_DM6446,
816 .name = "dm6446",
817 },
Rajashekhara, Sudhakar98d0e9f2009-06-02 06:48:43 -0400818 {
819 .variant = 0x1,
820 .part_no = 0xb700,
821 .manufacturer = 0x017,
822 .cpu_id = DAVINCI_CPU_ID_DM6446,
823 .name = "dm6446a",
824 },
Mark A. Greerb9ab1272009-04-15 12:39:09 -0700825};
826
Cyril Chemparathye4c822c2010-05-07 17:06:36 -0400827static u32 dm644x_psc_bases[] = { DAVINCI_PWR_SLEEP_CNTRL_BASE };
Mark A. Greerd81d1882009-04-15 12:39:33 -0700828
Mark A. Greerf64691b2009-04-15 12:40:11 -0700829/*
830 * T0_BOT: Timer 0, bottom: clockevent source for hrtimers
831 * T0_TOP: Timer 0, top : clocksource for generic timekeeping
832 * T1_BOT: Timer 1, bottom: (used by DSP in TI DSPLink code)
833 * T1_TOP: Timer 1, top : <unused>
834 */
Kevin Hilman28552c22010-02-25 15:36:38 -0800835static struct davinci_timer_info dm644x_timer_info = {
Mark A. Greerf64691b2009-04-15 12:40:11 -0700836 .timers = davinci_timer_instance,
837 .clockevent_id = T0_BOT,
838 .clocksource_id = T0_TOP,
839};
840
Manjunathappa, Prakash19955c32013-06-19 14:45:38 +0530841static struct plat_serial8250_port dm644x_serial0_platform_data[] = {
Mark A. Greer65e866a2009-03-18 12:36:08 -0500842 {
843 .mapbase = DAVINCI_UART0_BASE,
844 .irq = IRQ_UARTINT0,
845 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
846 UPF_IOREMAP,
847 .iotype = UPIO_MEM,
848 .regshift = 2,
849 },
850 {
Manjunathappa, Prakash19955c32013-06-19 14:45:38 +0530851 .flags = 0,
852 }
853};
854static struct plat_serial8250_port dm644x_serial1_platform_data[] = {
855 {
Mark A. Greer65e866a2009-03-18 12:36:08 -0500856 .mapbase = DAVINCI_UART1_BASE,
857 .irq = IRQ_UARTINT1,
858 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
859 UPF_IOREMAP,
860 .iotype = UPIO_MEM,
861 .regshift = 2,
862 },
863 {
Manjunathappa, Prakash19955c32013-06-19 14:45:38 +0530864 .flags = 0,
865 }
866};
867static struct plat_serial8250_port dm644x_serial2_platform_data[] = {
868 {
Mark A. Greer65e866a2009-03-18 12:36:08 -0500869 .mapbase = DAVINCI_UART2_BASE,
870 .irq = IRQ_UARTINT2,
871 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
872 UPF_IOREMAP,
873 .iotype = UPIO_MEM,
874 .regshift = 2,
875 },
876 {
Manjunathappa, Prakash19955c32013-06-19 14:45:38 +0530877 .flags = 0,
878 }
Mark A. Greer65e866a2009-03-18 12:36:08 -0500879};
880
Manjunathappa, Prakashfcf71572013-06-19 14:45:42 +0530881struct platform_device dm644x_serial_device[] = {
Manjunathappa, Prakash19955c32013-06-19 14:45:38 +0530882 {
883 .name = "serial8250",
884 .id = PLAT8250_DEV_PLATFORM,
885 .dev = {
886 .platform_data = dm644x_serial0_platform_data,
887 }
Mark A. Greer65e866a2009-03-18 12:36:08 -0500888 },
Manjunathappa, Prakash19955c32013-06-19 14:45:38 +0530889 {
890 .name = "serial8250",
891 .id = PLAT8250_DEV_PLATFORM1,
892 .dev = {
893 .platform_data = dm644x_serial1_platform_data,
894 }
895 },
896 {
897 .name = "serial8250",
898 .id = PLAT8250_DEV_PLATFORM2,
899 .dev = {
900 .platform_data = dm644x_serial2_platform_data,
901 }
902 },
903 {
904 }
Mark A. Greer65e866a2009-03-18 12:36:08 -0500905};
906
Mark A. Greer79c3c0b2009-04-15 12:38:58 -0700907static struct davinci_soc_info davinci_soc_info_dm644x = {
908 .io_desc = dm644x_io_desc,
909 .io_desc_num = ARRAY_SIZE(dm644x_io_desc),
Cyril Chemparathy3347db82010-05-07 17:06:34 -0400910 .jtag_id_reg = 0x01c40028,
Mark A. Greerb9ab1272009-04-15 12:39:09 -0700911 .ids = dm644x_ids,
912 .ids_num = ARRAY_SIZE(dm644x_ids),
Mark A. Greer66e0c392009-04-15 12:39:23 -0700913 .cpu_clks = dm644x_clks,
Mark A. Greerd81d1882009-04-15 12:39:33 -0700914 .psc_bases = dm644x_psc_bases,
915 .psc_bases_num = ARRAY_SIZE(dm644x_psc_bases),
Cyril Chemparathy779b0d52010-05-07 17:06:38 -0400916 .pinmux_base = DAVINCI_SYSTEM_MODULE_BASE,
Mark A. Greer0e585952009-04-15 12:39:48 -0700917 .pinmux_pins = dm644x_pins,
918 .pinmux_pins_num = ARRAY_SIZE(dm644x_pins),
Cyril Chemparathybd808942010-05-07 17:06:37 -0400919 .intc_base = DAVINCI_ARM_INTC_BASE,
Mark A. Greer673dd362009-04-15 12:40:00 -0700920 .intc_type = DAVINCI_INTC_TYPE_AINTC,
921 .intc_irq_prios = dm644x_default_priorities,
922 .intc_irq_num = DAVINCI_N_AINTC_IRQ,
Mark A. Greerf64691b2009-04-15 12:40:11 -0700923 .timer_info = &dm644x_timer_info,
Mark A. Greer972412b2009-04-15 12:40:56 -0700924 .emac_pdata = &dm644x_emac_pdata,
David Brownell0d04eb42009-04-30 17:35:48 -0700925 .sram_dma = 0x00008000,
926 .sram_len = SZ_16K,
Mark A. Greer79c3c0b2009-04-15 12:38:58 -0700927};
928
Chaithrika U S25acf552009-06-05 06:28:08 -0400929void __init dm644x_init_asp(struct snd_platform_data *pdata)
930{
931 davinci_cfg_reg(DM644X_MCBSP);
932 dm644x_asp_device.dev.platform_data = pdata;
933 platform_device_register(&dm644x_asp_device);
934}
935
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500936void __init dm644x_init(void)
937{
Mark A. Greer79c3c0b2009-04-15 12:38:58 -0700938 davinci_common_init(&davinci_soc_info_dm644x);
Manjunath Hadli5cfb19a2011-12-21 19:13:36 +0530939 davinci_map_sysmod();
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500940}
941
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530942int __init dm644x_init_video(struct vpfe_config *vpfe_cfg,
943 struct vpbe_config *vpbe_cfg)
Manjunath Hadli12db9582011-12-21 19:13:39 +0530944{
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530945 if (vpfe_cfg || vpbe_cfg)
946 platform_device_register(&dm644x_vpss_device);
Manjunath Hadli12db9582011-12-21 19:13:39 +0530947
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530948 if (vpfe_cfg) {
949 dm644x_vpfe_dev.dev.platform_data = vpfe_cfg;
950 platform_device_register(&dm644x_ccdc_dev);
951 platform_device_register(&dm644x_vpfe_dev);
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530952 }
Manjunath Hadli12db9582011-12-21 19:13:39 +0530953
Manjunath Hadliaf946f22012-02-23 15:17:45 +0530954 if (vpbe_cfg) {
955 dm644x_vpbe_dev.dev.platform_data = vpbe_cfg;
956 platform_device_register(&dm644x_osd_dev);
957 platform_device_register(&dm644x_venc_dev);
958 platform_device_register(&dm644x_vpbe_dev);
959 platform_device_register(&dm644x_vpbe_display);
960 }
Manjunath Hadli12db9582011-12-21 19:13:39 +0530961
962 return 0;
963}
964
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500965static int __init dm644x_init_devices(void)
966{
967 if (!cpu_is_davinci_dm644x())
968 return 0;
969
970 platform_device_register(&dm644x_edma_device);
Cyril Chemparathyd22960c2010-09-15 10:11:22 -0400971
972 platform_device_register(&dm644x_mdio_device);
Mark A. Greer972412b2009-04-15 12:40:56 -0700973 platform_device_register(&dm644x_emac_device);
Cyril Chemparathyd22960c2010-09-15 10:11:22 -0400974
Kevin Hilmand0e47fb2009-04-14 11:30:11 -0500975 return 0;
976}
977postcore_initcall(dm644x_init_devices);