2 * TI DaVinci DM644x chip specific setup
4 * Author: Kevin Hilman, Deep Root Systems, LLC
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
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/clk.h>
14 #include <linux/serial_8250.h>
15 #include <linux/platform_device.h>
16 #include <linux/gpio.h>
18 #include <asm/mach/map.h>
20 #include <mach/dm646x.h>
21 #include <mach/clock.h>
22 #include <mach/cputype.h>
23 #include <mach/edma.h>
24 #include <mach/irqs.h>
27 #include <mach/time.h>
28 #include <mach/serial.h>
29 #include <mach/common.h>
35 * Device specific clocks
37 #define DM646X_REF_FREQ 27000000
38 #define DM646X_AUX_FREQ 24000000
40 static struct pll_data pll1_data
= {
42 .phys_base
= DAVINCI_PLL1_BASE
,
45 static struct pll_data pll2_data
= {
47 .phys_base
= DAVINCI_PLL2_BASE
,
50 static struct clk ref_clk
= {
52 .rate
= DM646X_REF_FREQ
,
55 static struct clk aux_clkin
= {
57 .rate
= DM646X_AUX_FREQ
,
60 static struct clk pll1_clk
= {
63 .pll_data
= &pll1_data
,
67 static struct clk pll1_sysclk1
= {
68 .name
= "pll1_sysclk1",
74 static struct clk pll1_sysclk2
= {
75 .name
= "pll1_sysclk2",
81 static struct clk pll1_sysclk3
= {
82 .name
= "pll1_sysclk3",
88 static struct clk pll1_sysclk4
= {
89 .name
= "pll1_sysclk4",
95 static struct clk pll1_sysclk5
= {
96 .name
= "pll1_sysclk5",
102 static struct clk pll1_sysclk6
= {
103 .name
= "pll1_sysclk6",
109 static struct clk pll1_sysclk8
= {
110 .name
= "pll1_sysclk8",
116 static struct clk pll1_sysclk9
= {
117 .name
= "pll1_sysclk9",
123 static struct clk pll1_sysclkbp
= {
124 .name
= "pll1_sysclkbp",
126 .flags
= CLK_PLL
| PRE_PLL
,
130 static struct clk pll1_aux_clk
= {
131 .name
= "pll1_aux_clk",
133 .flags
= CLK_PLL
| PRE_PLL
,
136 static struct clk pll2_clk
= {
139 .pll_data
= &pll2_data
,
143 static struct clk pll2_sysclk1
= {
144 .name
= "pll2_sysclk1",
150 static struct clk dsp_clk
= {
152 .parent
= &pll1_sysclk1
,
153 .lpsc
= DM646X_LPSC_C64X_CPU
,
155 .usecount
= 1, /* REVISIT how to disable? */
158 static struct clk arm_clk
= {
160 .parent
= &pll1_sysclk2
,
161 .lpsc
= DM646X_LPSC_ARM
,
162 .flags
= ALWAYS_ENABLED
,
165 static struct clk uart0_clk
= {
167 .parent
= &aux_clkin
,
168 .lpsc
= DM646X_LPSC_UART0
,
171 static struct clk uart1_clk
= {
173 .parent
= &aux_clkin
,
174 .lpsc
= DM646X_LPSC_UART1
,
177 static struct clk uart2_clk
= {
179 .parent
= &aux_clkin
,
180 .lpsc
= DM646X_LPSC_UART2
,
183 static struct clk i2c_clk
= {
185 .parent
= &pll1_sysclk3
,
186 .lpsc
= DM646X_LPSC_I2C
,
189 static struct clk gpio_clk
= {
191 .parent
= &pll1_sysclk3
,
192 .lpsc
= DM646X_LPSC_GPIO
,
195 static struct clk aemif_clk
= {
197 .parent
= &pll1_sysclk3
,
198 .lpsc
= DM646X_LPSC_AEMIF
,
199 .flags
= ALWAYS_ENABLED
,
202 static struct clk emac_clk
= {
204 .parent
= &pll1_sysclk3
,
205 .lpsc
= DM646X_LPSC_EMAC
,
208 static struct clk pwm0_clk
= {
210 .parent
= &pll1_sysclk3
,
211 .lpsc
= DM646X_LPSC_PWM0
,
212 .usecount
= 1, /* REVIST: disabling hangs system */
215 static struct clk pwm1_clk
= {
217 .parent
= &pll1_sysclk3
,
218 .lpsc
= DM646X_LPSC_PWM1
,
219 .usecount
= 1, /* REVIST: disabling hangs system */
222 static struct clk timer0_clk
= {
224 .parent
= &pll1_sysclk3
,
225 .lpsc
= DM646X_LPSC_TIMER0
,
228 static struct clk timer1_clk
= {
230 .parent
= &pll1_sysclk3
,
231 .lpsc
= DM646X_LPSC_TIMER1
,
234 static struct clk timer2_clk
= {
236 .parent
= &pll1_sysclk3
,
237 .flags
= ALWAYS_ENABLED
, /* no LPSC, always enabled; c.f. spruep9a */
240 static struct clk vpif0_clk
= {
243 .lpsc
= DM646X_LPSC_VPSSMSTR
,
244 .flags
= ALWAYS_ENABLED
,
247 static struct clk vpif1_clk
= {
250 .lpsc
= DM646X_LPSC_VPSSSLV
,
251 .flags
= ALWAYS_ENABLED
,
254 struct davinci_clk dm646x_clks
[] = {
255 CLK(NULL
, "ref", &ref_clk
),
256 CLK(NULL
, "aux", &aux_clkin
),
257 CLK(NULL
, "pll1", &pll1_clk
),
258 CLK(NULL
, "pll1_sysclk", &pll1_sysclk1
),
259 CLK(NULL
, "pll1_sysclk", &pll1_sysclk2
),
260 CLK(NULL
, "pll1_sysclk", &pll1_sysclk3
),
261 CLK(NULL
, "pll1_sysclk", &pll1_sysclk4
),
262 CLK(NULL
, "pll1_sysclk", &pll1_sysclk5
),
263 CLK(NULL
, "pll1_sysclk", &pll1_sysclk6
),
264 CLK(NULL
, "pll1_sysclk", &pll1_sysclk8
),
265 CLK(NULL
, "pll1_sysclk", &pll1_sysclk9
),
266 CLK(NULL
, "pll1_sysclk", &pll1_sysclkbp
),
267 CLK(NULL
, "pll1_aux", &pll1_aux_clk
),
268 CLK(NULL
, "pll2", &pll2_clk
),
269 CLK(NULL
, "pll2_sysclk1", &pll2_sysclk1
),
270 CLK(NULL
, "dsp", &dsp_clk
),
271 CLK(NULL
, "arm", &arm_clk
),
272 CLK(NULL
, "uart0", &uart0_clk
),
273 CLK(NULL
, "uart1", &uart1_clk
),
274 CLK(NULL
, "uart2", &uart2_clk
),
275 CLK("i2c_davinci.1", NULL
, &i2c_clk
),
276 CLK(NULL
, "gpio", &gpio_clk
),
277 CLK(NULL
, "aemif", &aemif_clk
),
278 CLK("davinci_emac.1", NULL
, &emac_clk
),
279 CLK(NULL
, "pwm0", &pwm0_clk
),
280 CLK(NULL
, "pwm1", &pwm1_clk
),
281 CLK(NULL
, "timer0", &timer0_clk
),
282 CLK(NULL
, "timer1", &timer1_clk
),
283 CLK("watchdog", NULL
, &timer2_clk
),
284 CLK(NULL
, "vpif0", &vpif0_clk
),
285 CLK(NULL
, "vpif1", &vpif1_clk
),
286 CLK(NULL
, NULL
, NULL
),
289 static struct emac_platform_data dm646x_emac_pdata
= {
290 .ctrl_reg_offset
= DM646X_EMAC_CNTRL_OFFSET
,
291 .ctrl_mod_reg_offset
= DM646X_EMAC_CNTRL_MOD_OFFSET
,
292 .ctrl_ram_offset
= DM646X_EMAC_CNTRL_RAM_OFFSET
,
293 .mdio_reg_offset
= DM646X_EMAC_MDIO_OFFSET
,
294 .ctrl_ram_size
= DM646X_EMAC_CNTRL_RAM_SIZE
,
295 .version
= EMAC_VERSION_2
,
298 static struct resource dm646x_emac_resources
[] = {
300 .start
= DM646X_EMAC_BASE
,
301 .end
= DM646X_EMAC_BASE
+ 0x47ff,
302 .flags
= IORESOURCE_MEM
,
305 .start
= IRQ_DM646X_EMACRXTHINT
,
306 .end
= IRQ_DM646X_EMACRXTHINT
,
307 .flags
= IORESOURCE_IRQ
,
310 .start
= IRQ_DM646X_EMACRXINT
,
311 .end
= IRQ_DM646X_EMACRXINT
,
312 .flags
= IORESOURCE_IRQ
,
315 .start
= IRQ_DM646X_EMACTXINT
,
316 .end
= IRQ_DM646X_EMACTXINT
,
317 .flags
= IORESOURCE_IRQ
,
320 .start
= IRQ_DM646X_EMACMISCINT
,
321 .end
= IRQ_DM646X_EMACMISCINT
,
322 .flags
= IORESOURCE_IRQ
,
326 static struct platform_device dm646x_emac_device
= {
327 .name
= "davinci_emac",
330 .platform_data
= &dm646x_emac_pdata
,
332 .num_resources
= ARRAY_SIZE(dm646x_emac_resources
),
333 .resource
= dm646x_emac_resources
,
340 * Device specific mux setup
342 * soc description mux mode mode mux dbg
343 * reg offset mask mode
345 static const struct mux_config dm646x_pins
[] = {
346 #ifdef CONFIG_DAVINCI_MUX
347 MUX_CFG(DM646X
, ATAEN
, 0, 0, 1, 1, true)
349 MUX_CFG(DM646X
, AUDCK1
, 0, 29, 1, 0, false)
351 MUX_CFG(DM646X
, AUDCK0
, 0, 28, 1, 0, false)
353 MUX_CFG(DM646X
, CRGMUX
, 0, 24, 7, 5, true)
355 MUX_CFG(DM646X
, STSOMUX_DISABLE
, 0, 22, 3, 0, true)
357 MUX_CFG(DM646X
, STSIMUX_DISABLE
, 0, 20, 3, 0, true)
359 MUX_CFG(DM646X
, PTSOMUX_DISABLE
, 0, 18, 3, 0, true)
361 MUX_CFG(DM646X
, PTSIMUX_DISABLE
, 0, 16, 3, 0, true)
363 MUX_CFG(DM646X
, STSOMUX
, 0, 22, 3, 2, true)
365 MUX_CFG(DM646X
, STSIMUX
, 0, 20, 3, 2, true)
367 MUX_CFG(DM646X
, PTSOMUX_PARALLEL
, 0, 18, 3, 2, true)
369 MUX_CFG(DM646X
, PTSIMUX_PARALLEL
, 0, 16, 3, 2, true)
371 MUX_CFG(DM646X
, PTSOMUX_SERIAL
, 0, 18, 3, 3, true)
373 MUX_CFG(DM646X
, PTSIMUX_SERIAL
, 0, 16, 3, 3, true)
377 static u8 dm646x_default_priorities
[DAVINCI_N_AINTC_IRQ
] = {
378 [IRQ_DM646X_VP_VERTINT0
] = 7,
379 [IRQ_DM646X_VP_VERTINT1
] = 7,
380 [IRQ_DM646X_VP_VERTINT2
] = 7,
381 [IRQ_DM646X_VP_VERTINT3
] = 7,
382 [IRQ_DM646X_VP_ERRINT
] = 7,
383 [IRQ_DM646X_RESERVED_1
] = 7,
384 [IRQ_DM646X_RESERVED_2
] = 7,
385 [IRQ_DM646X_WDINT
] = 7,
386 [IRQ_DM646X_CRGENINT0
] = 7,
387 [IRQ_DM646X_CRGENINT1
] = 7,
388 [IRQ_DM646X_TSIFINT0
] = 7,
389 [IRQ_DM646X_TSIFINT1
] = 7,
390 [IRQ_DM646X_VDCEINT
] = 7,
391 [IRQ_DM646X_USBINT
] = 7,
392 [IRQ_DM646X_USBDMAINT
] = 7,
393 [IRQ_DM646X_PCIINT
] = 7,
394 [IRQ_CCINT0
] = 7, /* dma */
395 [IRQ_CCERRINT
] = 7, /* dma */
396 [IRQ_TCERRINT0
] = 7, /* dma */
397 [IRQ_TCERRINT
] = 7, /* dma */
398 [IRQ_DM646X_TCERRINT2
] = 7,
399 [IRQ_DM646X_TCERRINT3
] = 7,
400 [IRQ_DM646X_IDE
] = 7,
401 [IRQ_DM646X_HPIINT
] = 7,
402 [IRQ_DM646X_EMACRXTHINT
] = 7,
403 [IRQ_DM646X_EMACRXINT
] = 7,
404 [IRQ_DM646X_EMACTXINT
] = 7,
405 [IRQ_DM646X_EMACMISCINT
] = 7,
406 [IRQ_DM646X_MCASP0TXINT
] = 7,
407 [IRQ_DM646X_MCASP0RXINT
] = 7,
409 [IRQ_DM646X_RESERVED_3
] = 7,
410 [IRQ_DM646X_MCASP1TXINT
] = 7, /* clockevent */
411 [IRQ_TINT0_TINT34
] = 7, /* clocksource */
412 [IRQ_TINT1_TINT12
] = 7, /* DSP timer */
413 [IRQ_TINT1_TINT34
] = 7, /* system tick */
416 [IRQ_DM646X_VLQINT
] = 7,
420 [IRQ_DM646X_UARTINT2
] = 7,
421 [IRQ_DM646X_SPINT0
] = 7,
422 [IRQ_DM646X_SPINT1
] = 7,
423 [IRQ_DM646X_DSP2ARMINT
] = 7,
424 [IRQ_DM646X_RESERVED_4
] = 7,
425 [IRQ_DM646X_PSCINT
] = 7,
426 [IRQ_DM646X_GPIO0
] = 7,
427 [IRQ_DM646X_GPIO1
] = 7,
428 [IRQ_DM646X_GPIO2
] = 7,
429 [IRQ_DM646X_GPIO3
] = 7,
430 [IRQ_DM646X_GPIO4
] = 7,
431 [IRQ_DM646X_GPIO5
] = 7,
432 [IRQ_DM646X_GPIO6
] = 7,
433 [IRQ_DM646X_GPIO7
] = 7,
434 [IRQ_DM646X_GPIOBNK0
] = 7,
435 [IRQ_DM646X_GPIOBNK1
] = 7,
436 [IRQ_DM646X_GPIOBNK2
] = 7,
437 [IRQ_DM646X_DDRINT
] = 7,
438 [IRQ_DM646X_AEMIFINT
] = 7,
444 /*----------------------------------------------------------------------*/
446 static const s8 dma_chan_dm646x_no_event
[] = {
454 static struct edma_soc_info dm646x_edma_info
= {
456 .n_region
= 6, /* 0-1, 4-7 */
459 .noevent
= dma_chan_dm646x_no_event
,
462 static struct resource edma_resources
[] = {
466 .end
= 0x01c00000 + SZ_64K
- 1,
467 .flags
= IORESOURCE_MEM
,
472 .end
= 0x01c10000 + SZ_1K
- 1,
473 .flags
= IORESOURCE_MEM
,
478 .end
= 0x01c10400 + SZ_1K
- 1,
479 .flags
= IORESOURCE_MEM
,
484 .end
= 0x01c10800 + SZ_1K
- 1,
485 .flags
= IORESOURCE_MEM
,
490 .end
= 0x01c10c00 + SZ_1K
- 1,
491 .flags
= IORESOURCE_MEM
,
495 .flags
= IORESOURCE_IRQ
,
498 .start
= IRQ_CCERRINT
,
499 .flags
= IORESOURCE_IRQ
,
501 /* not using TC*_ERR */
504 static struct platform_device dm646x_edma_device
= {
507 .dev
.platform_data
= &dm646x_edma_info
,
508 .num_resources
= ARRAY_SIZE(edma_resources
),
509 .resource
= edma_resources
,
512 /*----------------------------------------------------------------------*/
514 static struct map_desc dm646x_io_desc
[] = {
517 .pfn
= __phys_to_pfn(IO_PHYS
),
522 .virtual = SRAM_VIRT
,
523 .pfn
= __phys_to_pfn(0x00010000),
525 /* MT_MEMORY_NONCACHED requires supersection alignment */
530 /* Contents of JTAG ID register used to identify exact cpu type */
531 static struct davinci_id dm646x_ids
[] = {
535 .manufacturer
= 0x017,
536 .cpu_id
= DAVINCI_CPU_ID_DM6467
,
541 static void __iomem
*dm646x_psc_bases
[] = {
542 IO_ADDRESS(DAVINCI_PWR_SLEEP_CNTRL_BASE
),
546 * T0_BOT: Timer 0, bottom: clockevent source for hrtimers
547 * T0_TOP: Timer 0, top : clocksource for generic timekeeping
548 * T1_BOT: Timer 1, bottom: (used by DSP in TI DSPLink code)
549 * T1_TOP: Timer 1, top : <unused>
551 struct davinci_timer_info dm646x_timer_info
= {
552 .timers
= davinci_timer_instance
,
553 .clockevent_id
= T0_BOT
,
554 .clocksource_id
= T0_TOP
,
557 static struct plat_serial8250_port dm646x_serial_platform_data
[] = {
559 .mapbase
= DAVINCI_UART0_BASE
,
561 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
|
563 .iotype
= UPIO_MEM32
,
567 .mapbase
= DAVINCI_UART1_BASE
,
569 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
|
571 .iotype
= UPIO_MEM32
,
575 .mapbase
= DAVINCI_UART2_BASE
,
576 .irq
= IRQ_DM646X_UARTINT2
,
577 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
|
579 .iotype
= UPIO_MEM32
,
587 static struct platform_device dm646x_serial_device
= {
588 .name
= "serial8250",
589 .id
= PLAT8250_DEV_PLATFORM
,
591 .platform_data
= dm646x_serial_platform_data
,
595 static struct davinci_soc_info davinci_soc_info_dm646x
= {
596 .io_desc
= dm646x_io_desc
,
597 .io_desc_num
= ARRAY_SIZE(dm646x_io_desc
),
598 .jtag_id_base
= IO_ADDRESS(0x01c40028),
600 .ids_num
= ARRAY_SIZE(dm646x_ids
),
601 .cpu_clks
= dm646x_clks
,
602 .psc_bases
= dm646x_psc_bases
,
603 .psc_bases_num
= ARRAY_SIZE(dm646x_psc_bases
),
604 .pinmux_base
= IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE
),
605 .pinmux_pins
= dm646x_pins
,
606 .pinmux_pins_num
= ARRAY_SIZE(dm646x_pins
),
607 .intc_base
= IO_ADDRESS(DAVINCI_ARM_INTC_BASE
),
608 .intc_type
= DAVINCI_INTC_TYPE_AINTC
,
609 .intc_irq_prios
= dm646x_default_priorities
,
610 .intc_irq_num
= DAVINCI_N_AINTC_IRQ
,
611 .timer_info
= &dm646x_timer_info
,
612 .wdt_base
= IO_ADDRESS(DAVINCI_WDOG_BASE
),
613 .gpio_base
= IO_ADDRESS(DAVINCI_GPIO_BASE
),
614 .gpio_num
= 43, /* Only 33 usable */
615 .gpio_irq
= IRQ_DM646X_GPIOBNK0
,
616 .serial_dev
= &dm646x_serial_device
,
617 .emac_pdata
= &dm646x_emac_pdata
,
618 .sram_dma
= 0x10010000,
622 void __init
dm646x_init(void)
624 davinci_common_init(&davinci_soc_info_dm646x
);
627 static int __init
dm646x_init_devices(void)
629 if (!cpu_is_davinci_dm646x())
632 platform_device_register(&dm646x_edma_device
);
633 platform_device_register(&dm646x_emac_device
);
636 postcore_initcall(dm646x_init_devices
);