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
12 #include <linux/clk-provider.h>
13 #include <linux/clk/davinci.h>
14 #include <linux/clkdev.h>
15 #include <linux/dmaengine.h>
16 #include <linux/init.h>
17 #include <linux/platform_data/edma.h>
18 #include <linux/platform_data/gpio-davinci.h>
19 #include <linux/platform_device.h>
20 #include <linux/serial_8250.h>
22 #include <asm/mach/map.h>
24 #include <mach/common.h>
25 #include <mach/cputype.h>
26 #include <mach/irqs.h>
28 #include <mach/serial.h>
29 #include <mach/time.h>
36 * Device specific clocks
38 #define DM644X_REF_FREQ 27000000
40 #define DM644X_EMAC_BASE 0x01c80000
41 #define DM644X_EMAC_MDIO_BASE (DM644X_EMAC_BASE + 0x4000)
42 #define DM644X_EMAC_CNTRL_OFFSET 0x0000
43 #define DM644X_EMAC_CNTRL_MOD_OFFSET 0x1000
44 #define DM644X_EMAC_CNTRL_RAM_OFFSET 0x2000
45 #define DM644X_EMAC_CNTRL_RAM_SIZE 0x2000
47 static struct emac_platform_data dm644x_emac_pdata = {
48 .ctrl_reg_offset = DM644X_EMAC_CNTRL_OFFSET,
49 .ctrl_mod_reg_offset = DM644X_EMAC_CNTRL_MOD_OFFSET,
50 .ctrl_ram_offset = DM644X_EMAC_CNTRL_RAM_OFFSET,
51 .ctrl_ram_size = DM644X_EMAC_CNTRL_RAM_SIZE,
52 .version = EMAC_VERSION_1,
55 static struct resource dm644x_emac_resources[] = {
57 .start = DM644X_EMAC_BASE,
58 .end = DM644X_EMAC_BASE + SZ_16K - 1,
59 .flags = IORESOURCE_MEM,
64 .flags = IORESOURCE_IRQ,
68 static struct platform_device dm644x_emac_device = {
69 .name = "davinci_emac",
72 .platform_data = &dm644x_emac_pdata,
74 .num_resources = ARRAY_SIZE(dm644x_emac_resources),
75 .resource = dm644x_emac_resources,
78 static struct resource dm644x_mdio_resources[] = {
80 .start = DM644X_EMAC_MDIO_BASE,
81 .end = DM644X_EMAC_MDIO_BASE + SZ_4K - 1,
82 .flags = IORESOURCE_MEM,
86 static struct platform_device dm644x_mdio_device = {
87 .name = "davinci_mdio",
89 .num_resources = ARRAY_SIZE(dm644x_mdio_resources),
90 .resource = dm644x_mdio_resources,
94 * Device specific mux setup
96 * soc description mux mode mode mux dbg
97 * reg offset mask mode
99 static const struct mux_config dm644x_pins[] = {
100 #ifdef CONFIG_DAVINCI_MUX
101 MUX_CFG(DM644X, HDIREN, 0, 16, 1, 1, true)
102 MUX_CFG(DM644X, ATAEN, 0, 17, 1, 1, true)
103 MUX_CFG(DM644X, ATAEN_DISABLE, 0, 17, 1, 0, true)
105 MUX_CFG(DM644X, HPIEN_DISABLE, 0, 29, 1, 0, true)
107 MUX_CFG(DM644X, AEAW, 0, 0, 31, 31, true)
108 MUX_CFG(DM644X, AEAW0, 0, 0, 1, 0, true)
109 MUX_CFG(DM644X, AEAW1, 0, 1, 1, 0, true)
110 MUX_CFG(DM644X, AEAW2, 0, 2, 1, 0, true)
111 MUX_CFG(DM644X, AEAW3, 0, 3, 1, 0, true)
112 MUX_CFG(DM644X, AEAW4, 0, 4, 1, 0, true)
114 MUX_CFG(DM644X, MSTK, 1, 9, 1, 0, false)
116 MUX_CFG(DM644X, I2C, 1, 7, 1, 1, false)
118 MUX_CFG(DM644X, MCBSP, 1, 10, 1, 1, false)
120 MUX_CFG(DM644X, UART1, 1, 1, 1, 1, true)
121 MUX_CFG(DM644X, UART2, 1, 2, 1, 1, true)
123 MUX_CFG(DM644X, PWM0, 1, 4, 1, 1, false)
125 MUX_CFG(DM644X, PWM1, 1, 5, 1, 1, false)
127 MUX_CFG(DM644X, PWM2, 1, 6, 1, 1, false)
129 MUX_CFG(DM644X, VLYNQEN, 0, 15, 1, 1, false)
130 MUX_CFG(DM644X, VLSCREN, 0, 14, 1, 1, false)
131 MUX_CFG(DM644X, VLYNQWD, 0, 12, 3, 3, false)
133 MUX_CFG(DM644X, EMACEN, 0, 31, 1, 1, true)
135 MUX_CFG(DM644X, GPIO3V, 0, 31, 1, 0, true)
137 MUX_CFG(DM644X, GPIO0, 0, 24, 1, 0, true)
138 MUX_CFG(DM644X, GPIO3, 0, 25, 1, 0, false)
139 MUX_CFG(DM644X, GPIO43_44, 1, 7, 1, 0, false)
140 MUX_CFG(DM644X, GPIO46_47, 0, 22, 1, 0, true)
142 MUX_CFG(DM644X, RGB666, 0, 22, 1, 1, true)
144 MUX_CFG(DM644X, LOEEN, 0, 24, 1, 1, true)
145 MUX_CFG(DM644X, LFLDEN, 0, 25, 1, 1, false)
149 /* FIQ are pri 0-1; otherwise 2-7, with 7 lowest priority */
150 static u8 dm644x_default_priorities[DAVINCI_N_AINTC_IRQ] = {
167 [IRQ_CCINT0] = 5, /* dma */
168 [IRQ_CCERRINT] = 5, /* dma */
169 [IRQ_TCERRINT0] = 5, /* dma */
170 [IRQ_TCERRINT] = 5, /* dma */
183 [IRQ_TINT0_TINT12] = 2, /* clockevent */
184 [IRQ_TINT0_TINT34] = 2, /* clocksource */
185 [IRQ_TINT1_TINT12] = 7, /* DSP timer */
186 [IRQ_TINT1_TINT34] = 7, /* system tick */
217 /*----------------------------------------------------------------------*/
219 static s8 queue_priority_mapping[][2] = {
220 /* {event queue no, Priority} */
226 static const struct dma_slave_map dm644x_edma_map[] = {
227 { "davinci-mcbsp", "tx", EDMA_FILTER_PARAM(0, 2) },
228 { "davinci-mcbsp", "rx", EDMA_FILTER_PARAM(0, 3) },
229 { "spi_davinci", "tx", EDMA_FILTER_PARAM(0, 16) },
230 { "spi_davinci", "rx", EDMA_FILTER_PARAM(0, 17) },
231 { "dm6441-mmc.0", "rx", EDMA_FILTER_PARAM(0, 26) },
232 { "dm6441-mmc.0", "tx", EDMA_FILTER_PARAM(0, 27) },
235 static struct edma_soc_info dm644x_edma_pdata = {
236 .queue_priority_mapping = queue_priority_mapping,
237 .default_queue = EVENTQ_1,
238 .slave_map = dm644x_edma_map,
239 .slavecnt = ARRAY_SIZE(dm644x_edma_map),
242 static struct resource edma_resources[] = {
246 .end = 0x01c00000 + SZ_64K - 1,
247 .flags = IORESOURCE_MEM,
252 .end = 0x01c10000 + SZ_1K - 1,
253 .flags = IORESOURCE_MEM,
258 .end = 0x01c10400 + SZ_1K - 1,
259 .flags = IORESOURCE_MEM,
262 .name = "edma3_ccint",
264 .flags = IORESOURCE_IRQ,
267 .name = "edma3_ccerrint",
268 .start = IRQ_CCERRINT,
269 .flags = IORESOURCE_IRQ,
271 /* not using TC*_ERR */
274 static const struct platform_device_info dm644x_edma_device __initconst = {
277 .dma_mask = DMA_BIT_MASK(32),
278 .res = edma_resources,
279 .num_res = ARRAY_SIZE(edma_resources),
280 .data = &dm644x_edma_pdata,
281 .size_data = sizeof(dm644x_edma_pdata),
284 /* DM6446 EVM uses ASP0; line-out is a pair of RCA jacks */
285 static struct resource dm644x_asp_resources[] = {
288 .start = DAVINCI_ASP0_BASE,
289 .end = DAVINCI_ASP0_BASE + SZ_8K - 1,
290 .flags = IORESOURCE_MEM,
293 .start = DAVINCI_DMA_ASP0_TX,
294 .end = DAVINCI_DMA_ASP0_TX,
295 .flags = IORESOURCE_DMA,
298 .start = DAVINCI_DMA_ASP0_RX,
299 .end = DAVINCI_DMA_ASP0_RX,
300 .flags = IORESOURCE_DMA,
304 static struct platform_device dm644x_asp_device = {
305 .name = "davinci-mcbsp",
307 .num_resources = ARRAY_SIZE(dm644x_asp_resources),
308 .resource = dm644x_asp_resources,
311 #define DM644X_VPSS_BASE 0x01c73400
313 static struct resource dm644x_vpss_resources[] = {
315 /* VPSS Base address */
317 .start = DM644X_VPSS_BASE,
318 .end = DM644X_VPSS_BASE + 0xff,
319 .flags = IORESOURCE_MEM,
323 static struct platform_device dm644x_vpss_device = {
326 .dev.platform_data = "dm644x_vpss",
327 .num_resources = ARRAY_SIZE(dm644x_vpss_resources),
328 .resource = dm644x_vpss_resources,
331 static struct resource dm644x_vpfe_resources[] = {
335 .flags = IORESOURCE_IRQ,
340 .flags = IORESOURCE_IRQ,
344 static u64 dm644x_video_dma_mask = DMA_BIT_MASK(32);
345 static struct resource dm644x_ccdc_resource[] = {
346 /* CCDC Base address */
349 .end = 0x01c70400 + 0xff,
350 .flags = IORESOURCE_MEM,
354 static struct platform_device dm644x_ccdc_dev = {
355 .name = "dm644x_ccdc",
357 .num_resources = ARRAY_SIZE(dm644x_ccdc_resource),
358 .resource = dm644x_ccdc_resource,
360 .dma_mask = &dm644x_video_dma_mask,
361 .coherent_dma_mask = DMA_BIT_MASK(32),
365 static struct platform_device dm644x_vpfe_dev = {
366 .name = CAPTURE_DRV_NAME,
368 .num_resources = ARRAY_SIZE(dm644x_vpfe_resources),
369 .resource = dm644x_vpfe_resources,
371 .dma_mask = &dm644x_video_dma_mask,
372 .coherent_dma_mask = DMA_BIT_MASK(32),
376 #define DM644X_OSD_BASE 0x01c72600
378 static struct resource dm644x_osd_resources[] = {
380 .start = DM644X_OSD_BASE,
381 .end = DM644X_OSD_BASE + 0x1ff,
382 .flags = IORESOURCE_MEM,
386 static struct platform_device dm644x_osd_dev = {
387 .name = DM644X_VPBE_OSD_SUBDEV_NAME,
389 .num_resources = ARRAY_SIZE(dm644x_osd_resources),
390 .resource = dm644x_osd_resources,
392 .dma_mask = &dm644x_video_dma_mask,
393 .coherent_dma_mask = DMA_BIT_MASK(32),
397 #define DM644X_VENC_BASE 0x01c72400
399 static struct resource dm644x_venc_resources[] = {
401 .start = DM644X_VENC_BASE,
402 .end = DM644X_VENC_BASE + 0x17f,
403 .flags = IORESOURCE_MEM,
407 #define DM644X_VPSS_MUXSEL_PLL2_MODE BIT(0)
408 #define DM644X_VPSS_MUXSEL_VPBECLK_MODE BIT(1)
409 #define DM644X_VPSS_VENCLKEN BIT(3)
410 #define DM644X_VPSS_DACCLKEN BIT(4)
412 static int dm644x_venc_setup_clock(enum vpbe_enc_timings_type type,
416 u32 v = DM644X_VPSS_VENCLKEN;
420 v |= DM644X_VPSS_DACCLKEN;
421 writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
423 case VPBE_ENC_DV_TIMINGS:
424 if (pclock <= 27000000) {
425 v |= DM644X_VPSS_DACCLKEN;
426 writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
429 * For HD, use external clock source since
430 * HD requires higher clock rate
432 v |= DM644X_VPSS_MUXSEL_VPBECLK_MODE;
433 writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
443 static struct resource dm644x_v4l2_disp_resources[] = {
445 .start = IRQ_VENCINT,
447 .flags = IORESOURCE_IRQ,
451 static struct platform_device dm644x_vpbe_display = {
454 .num_resources = ARRAY_SIZE(dm644x_v4l2_disp_resources),
455 .resource = dm644x_v4l2_disp_resources,
457 .dma_mask = &dm644x_video_dma_mask,
458 .coherent_dma_mask = DMA_BIT_MASK(32),
462 static struct venc_platform_data dm644x_venc_pdata = {
463 .setup_clock = dm644x_venc_setup_clock,
466 static struct platform_device dm644x_venc_dev = {
467 .name = DM644X_VPBE_VENC_SUBDEV_NAME,
469 .num_resources = ARRAY_SIZE(dm644x_venc_resources),
470 .resource = dm644x_venc_resources,
472 .dma_mask = &dm644x_video_dma_mask,
473 .coherent_dma_mask = DMA_BIT_MASK(32),
474 .platform_data = &dm644x_venc_pdata,
478 static struct platform_device dm644x_vpbe_dev = {
479 .name = "vpbe_controller",
482 .dma_mask = &dm644x_video_dma_mask,
483 .coherent_dma_mask = DMA_BIT_MASK(32),
487 static struct resource dm644_gpio_resources[] = {
489 .start = DAVINCI_GPIO_BASE,
490 .end = DAVINCI_GPIO_BASE + SZ_4K - 1,
491 .flags = IORESOURCE_MEM,
494 .start = IRQ_GPIOBNK0,
496 .flags = IORESOURCE_IRQ,
499 .start = IRQ_GPIOBNK1,
501 .flags = IORESOURCE_IRQ,
504 .start = IRQ_GPIOBNK2,
506 .flags = IORESOURCE_IRQ,
509 .start = IRQ_GPIOBNK3,
511 .flags = IORESOURCE_IRQ,
514 .start = IRQ_GPIOBNK4,
516 .flags = IORESOURCE_IRQ,
520 static struct davinci_gpio_platform_data dm644_gpio_platform_data = {
524 int __init dm644x_gpio_register(void)
526 return davinci_gpio_register(dm644_gpio_resources,
527 ARRAY_SIZE(dm644_gpio_resources),
528 &dm644_gpio_platform_data);
530 /*----------------------------------------------------------------------*/
532 static struct map_desc dm644x_io_desc[] = {
535 .pfn = __phys_to_pfn(IO_PHYS),
541 /* Contents of JTAG ID register used to identify exact cpu type */
542 static struct davinci_id dm644x_ids[] = {
546 .manufacturer = 0x017,
547 .cpu_id = DAVINCI_CPU_ID_DM6446,
553 .manufacturer = 0x017,
554 .cpu_id = DAVINCI_CPU_ID_DM6446,
560 * T0_BOT: Timer 0, bottom: clockevent source for hrtimers
561 * T0_TOP: Timer 0, top : clocksource for generic timekeeping
562 * T1_BOT: Timer 1, bottom: (used by DSP in TI DSPLink code)
563 * T1_TOP: Timer 1, top : <unused>
565 static struct davinci_timer_info dm644x_timer_info = {
566 .timers = davinci_timer_instance,
567 .clockevent_id = T0_BOT,
568 .clocksource_id = T0_TOP,
571 static struct plat_serial8250_port dm644x_serial0_platform_data[] = {
573 .mapbase = DAVINCI_UART0_BASE,
575 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
584 static struct plat_serial8250_port dm644x_serial1_platform_data[] = {
586 .mapbase = DAVINCI_UART1_BASE,
588 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
597 static struct plat_serial8250_port dm644x_serial2_platform_data[] = {
599 .mapbase = DAVINCI_UART2_BASE,
601 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
611 struct platform_device dm644x_serial_device[] = {
613 .name = "serial8250",
614 .id = PLAT8250_DEV_PLATFORM,
616 .platform_data = dm644x_serial0_platform_data,
620 .name = "serial8250",
621 .id = PLAT8250_DEV_PLATFORM1,
623 .platform_data = dm644x_serial1_platform_data,
627 .name = "serial8250",
628 .id = PLAT8250_DEV_PLATFORM2,
630 .platform_data = dm644x_serial2_platform_data,
637 static const struct davinci_soc_info davinci_soc_info_dm644x = {
638 .io_desc = dm644x_io_desc,
639 .io_desc_num = ARRAY_SIZE(dm644x_io_desc),
640 .jtag_id_reg = 0x01c40028,
642 .ids_num = ARRAY_SIZE(dm644x_ids),
643 .pinmux_base = DAVINCI_SYSTEM_MODULE_BASE,
644 .pinmux_pins = dm644x_pins,
645 .pinmux_pins_num = ARRAY_SIZE(dm644x_pins),
646 .intc_base = DAVINCI_ARM_INTC_BASE,
647 .intc_type = DAVINCI_INTC_TYPE_AINTC,
648 .intc_irq_prios = dm644x_default_priorities,
649 .intc_irq_num = DAVINCI_N_AINTC_IRQ,
650 .timer_info = &dm644x_timer_info,
651 .emac_pdata = &dm644x_emac_pdata,
652 .sram_dma = 0x00008000,
656 void __init dm644x_init_asp(void)
658 davinci_cfg_reg(DM644X_MCBSP);
659 platform_device_register(&dm644x_asp_device);
662 void __init dm644x_init(void)
664 davinci_common_init(&davinci_soc_info_dm644x);
665 davinci_map_sysmod();
668 void __init dm644x_init_time(void)
670 void __iomem *pll1, *psc;
673 clk_register_fixed_rate(NULL, "ref_clk", NULL, 0, DM644X_REF_FREQ);
675 pll1 = ioremap(DAVINCI_PLL1_BASE, SZ_1K);
676 dm644x_pll1_init(NULL, pll1, NULL);
678 psc = ioremap(DAVINCI_PWR_SLEEP_CNTRL_BASE, SZ_4K);
679 dm644x_psc_init(NULL, psc);
681 clk = clk_get(NULL, "timer0");
683 davinci_timer_init(clk);
686 static struct resource dm644x_pll2_resources[] = {
688 .start = DAVINCI_PLL2_BASE,
689 .end = DAVINCI_PLL2_BASE + SZ_1K - 1,
690 .flags = IORESOURCE_MEM,
694 static struct platform_device dm644x_pll2_device = {
695 .name = "dm644x-pll2",
697 .resource = dm644x_pll2_resources,
698 .num_resources = ARRAY_SIZE(dm644x_pll2_resources),
701 void __init dm644x_register_clocks(void)
703 /* PLL1 and PSC are registered in dm644x_init_time() */
704 platform_device_register(&dm644x_pll2_device);
707 int __init dm644x_init_video(struct vpfe_config *vpfe_cfg,
708 struct vpbe_config *vpbe_cfg)
710 if (vpfe_cfg || vpbe_cfg)
711 platform_device_register(&dm644x_vpss_device);
714 dm644x_vpfe_dev.dev.platform_data = vpfe_cfg;
715 platform_device_register(&dm644x_ccdc_dev);
716 platform_device_register(&dm644x_vpfe_dev);
720 dm644x_vpbe_dev.dev.platform_data = vpbe_cfg;
721 platform_device_register(&dm644x_osd_dev);
722 platform_device_register(&dm644x_venc_dev);
723 platform_device_register(&dm644x_vpbe_dev);
724 platform_device_register(&dm644x_vpbe_display);
730 void __init dm644x_init_devices(void)
732 struct platform_device *edma_pdev;
735 edma_pdev = platform_device_register_full(&dm644x_edma_device);
736 if (IS_ERR(edma_pdev))
737 pr_warn("%s: Failed to register eDMA\n", __func__);
739 platform_device_register(&dm644x_mdio_device);
740 platform_device_register(&dm644x_emac_device);
742 ret = davinci_init_wdt();
744 pr_warn("%s: watchdog init failed: %d\n", __func__, ret);