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/dma-mapping.h>
16 #include <linux/dmaengine.h>
17 #include <linux/init.h>
18 #include <linux/platform_data/edma.h>
19 #include <linux/platform_data/gpio-davinci.h>
20 #include <linux/platform_device.h>
21 #include <linux/serial_8250.h>
23 #include <asm/mach/map.h>
25 #include <mach/common.h>
26 #include <mach/cputype.h>
27 #include <mach/irqs.h>
29 #include <mach/serial.h>
30 #include <mach/time.h>
36 #define DAVINCI_VPIF_BASE (0x01C12000)
38 #define VDD3P3V_VID_MASK (BIT_MASK(3) | BIT_MASK(2) | BIT_MASK(1) |\
40 #define VSCLKDIS_MASK (BIT_MASK(11) | BIT_MASK(10) | BIT_MASK(9) |\
43 #define DM646X_EMAC_BASE 0x01c80000
44 #define DM646X_EMAC_MDIO_BASE (DM646X_EMAC_BASE + 0x4000)
45 #define DM646X_EMAC_CNTRL_OFFSET 0x0000
46 #define DM646X_EMAC_CNTRL_MOD_OFFSET 0x1000
47 #define DM646X_EMAC_CNTRL_RAM_OFFSET 0x2000
48 #define DM646X_EMAC_CNTRL_RAM_SIZE 0x2000
50 static struct emac_platform_data dm646x_emac_pdata = {
51 .ctrl_reg_offset = DM646X_EMAC_CNTRL_OFFSET,
52 .ctrl_mod_reg_offset = DM646X_EMAC_CNTRL_MOD_OFFSET,
53 .ctrl_ram_offset = DM646X_EMAC_CNTRL_RAM_OFFSET,
54 .ctrl_ram_size = DM646X_EMAC_CNTRL_RAM_SIZE,
55 .version = EMAC_VERSION_2,
58 static struct resource dm646x_emac_resources[] = {
60 .start = DM646X_EMAC_BASE,
61 .end = DM646X_EMAC_BASE + SZ_16K - 1,
62 .flags = IORESOURCE_MEM,
65 .start = IRQ_DM646X_EMACRXTHINT,
66 .end = IRQ_DM646X_EMACRXTHINT,
67 .flags = IORESOURCE_IRQ,
70 .start = IRQ_DM646X_EMACRXINT,
71 .end = IRQ_DM646X_EMACRXINT,
72 .flags = IORESOURCE_IRQ,
75 .start = IRQ_DM646X_EMACTXINT,
76 .end = IRQ_DM646X_EMACTXINT,
77 .flags = IORESOURCE_IRQ,
80 .start = IRQ_DM646X_EMACMISCINT,
81 .end = IRQ_DM646X_EMACMISCINT,
82 .flags = IORESOURCE_IRQ,
86 static struct platform_device dm646x_emac_device = {
87 .name = "davinci_emac",
90 .platform_data = &dm646x_emac_pdata,
92 .num_resources = ARRAY_SIZE(dm646x_emac_resources),
93 .resource = dm646x_emac_resources,
96 static struct resource dm646x_mdio_resources[] = {
98 .start = DM646X_EMAC_MDIO_BASE,
99 .end = DM646X_EMAC_MDIO_BASE + SZ_4K - 1,
100 .flags = IORESOURCE_MEM,
104 static struct platform_device dm646x_mdio_device = {
105 .name = "davinci_mdio",
107 .num_resources = ARRAY_SIZE(dm646x_mdio_resources),
108 .resource = dm646x_mdio_resources,
112 * Device specific mux setup
114 * soc description mux mode mode mux dbg
115 * reg offset mask mode
117 static const struct mux_config dm646x_pins[] = {
118 #ifdef CONFIG_DAVINCI_MUX
119 MUX_CFG(DM646X, ATAEN, 0, 0, 5, 1, true)
121 MUX_CFG(DM646X, AUDCK1, 0, 29, 1, 0, false)
123 MUX_CFG(DM646X, AUDCK0, 0, 28, 1, 0, false)
125 MUX_CFG(DM646X, CRGMUX, 0, 24, 7, 5, true)
127 MUX_CFG(DM646X, STSOMUX_DISABLE, 0, 22, 3, 0, true)
129 MUX_CFG(DM646X, STSIMUX_DISABLE, 0, 20, 3, 0, true)
131 MUX_CFG(DM646X, PTSOMUX_DISABLE, 0, 18, 3, 0, true)
133 MUX_CFG(DM646X, PTSIMUX_DISABLE, 0, 16, 3, 0, true)
135 MUX_CFG(DM646X, STSOMUX, 0, 22, 3, 2, true)
137 MUX_CFG(DM646X, STSIMUX, 0, 20, 3, 2, true)
139 MUX_CFG(DM646X, PTSOMUX_PARALLEL, 0, 18, 3, 2, true)
141 MUX_CFG(DM646X, PTSIMUX_PARALLEL, 0, 16, 3, 2, true)
143 MUX_CFG(DM646X, PTSOMUX_SERIAL, 0, 18, 3, 3, true)
145 MUX_CFG(DM646X, PTSIMUX_SERIAL, 0, 16, 3, 3, true)
149 static u8 dm646x_default_priorities[DAVINCI_N_AINTC_IRQ] = {
150 [IRQ_DM646X_VP_VERTINT0] = 7,
151 [IRQ_DM646X_VP_VERTINT1] = 7,
152 [IRQ_DM646X_VP_VERTINT2] = 7,
153 [IRQ_DM646X_VP_VERTINT3] = 7,
154 [IRQ_DM646X_VP_ERRINT] = 7,
155 [IRQ_DM646X_RESERVED_1] = 7,
156 [IRQ_DM646X_RESERVED_2] = 7,
157 [IRQ_DM646X_WDINT] = 7,
158 [IRQ_DM646X_CRGENINT0] = 7,
159 [IRQ_DM646X_CRGENINT1] = 7,
160 [IRQ_DM646X_TSIFINT0] = 7,
161 [IRQ_DM646X_TSIFINT1] = 7,
162 [IRQ_DM646X_VDCEINT] = 7,
163 [IRQ_DM646X_USBINT] = 7,
164 [IRQ_DM646X_USBDMAINT] = 7,
165 [IRQ_DM646X_PCIINT] = 7,
166 [IRQ_CCINT0] = 7, /* dma */
167 [IRQ_CCERRINT] = 7, /* dma */
168 [IRQ_TCERRINT0] = 7, /* dma */
169 [IRQ_TCERRINT] = 7, /* dma */
170 [IRQ_DM646X_TCERRINT2] = 7,
171 [IRQ_DM646X_TCERRINT3] = 7,
172 [IRQ_DM646X_IDE] = 7,
173 [IRQ_DM646X_HPIINT] = 7,
174 [IRQ_DM646X_EMACRXTHINT] = 7,
175 [IRQ_DM646X_EMACRXINT] = 7,
176 [IRQ_DM646X_EMACTXINT] = 7,
177 [IRQ_DM646X_EMACMISCINT] = 7,
178 [IRQ_DM646X_MCASP0TXINT] = 7,
179 [IRQ_DM646X_MCASP0RXINT] = 7,
180 [IRQ_DM646X_RESERVED_3] = 7,
181 [IRQ_DM646X_MCASP1TXINT] = 7,
182 [IRQ_TINT0_TINT12] = 7, /* clockevent */
183 [IRQ_TINT0_TINT34] = 7, /* clocksource */
184 [IRQ_TINT1_TINT12] = 7, /* DSP timer */
185 [IRQ_TINT1_TINT34] = 7, /* system tick */
188 [IRQ_DM646X_VLQINT] = 7,
192 [IRQ_DM646X_UARTINT2] = 7,
193 [IRQ_DM646X_SPINT0] = 7,
194 [IRQ_DM646X_SPINT1] = 7,
195 [IRQ_DM646X_DSP2ARMINT] = 7,
196 [IRQ_DM646X_RESERVED_4] = 7,
197 [IRQ_DM646X_PSCINT] = 7,
198 [IRQ_DM646X_GPIO0] = 7,
199 [IRQ_DM646X_GPIO1] = 7,
200 [IRQ_DM646X_GPIO2] = 7,
201 [IRQ_DM646X_GPIO3] = 7,
202 [IRQ_DM646X_GPIO4] = 7,
203 [IRQ_DM646X_GPIO5] = 7,
204 [IRQ_DM646X_GPIO6] = 7,
205 [IRQ_DM646X_GPIO7] = 7,
206 [IRQ_DM646X_GPIOBNK0] = 7,
207 [IRQ_DM646X_GPIOBNK1] = 7,
208 [IRQ_DM646X_GPIOBNK2] = 7,
209 [IRQ_DM646X_DDRINT] = 7,
210 [IRQ_DM646X_AEMIFINT] = 7,
216 /*----------------------------------------------------------------------*/
218 /* Four Transfer Controllers on DM646x */
219 static s8 dm646x_queue_priority_mapping[][2] = {
220 /* {event queue no, Priority} */
228 static const struct dma_slave_map dm646x_edma_map[] = {
229 { "davinci-mcasp.0", "tx", EDMA_FILTER_PARAM(0, 6) },
230 { "davinci-mcasp.0", "rx", EDMA_FILTER_PARAM(0, 9) },
231 { "davinci-mcasp.1", "tx", EDMA_FILTER_PARAM(0, 12) },
232 { "spi_davinci", "tx", EDMA_FILTER_PARAM(0, 16) },
233 { "spi_davinci", "rx", EDMA_FILTER_PARAM(0, 17) },
236 static struct edma_soc_info dm646x_edma_pdata = {
237 .queue_priority_mapping = dm646x_queue_priority_mapping,
238 .default_queue = EVENTQ_1,
239 .slave_map = dm646x_edma_map,
240 .slavecnt = ARRAY_SIZE(dm646x_edma_map),
243 static struct resource edma_resources[] = {
247 .end = 0x01c00000 + SZ_64K - 1,
248 .flags = IORESOURCE_MEM,
253 .end = 0x01c10000 + SZ_1K - 1,
254 .flags = IORESOURCE_MEM,
259 .end = 0x01c10400 + SZ_1K - 1,
260 .flags = IORESOURCE_MEM,
265 .end = 0x01c10800 + SZ_1K - 1,
266 .flags = IORESOURCE_MEM,
271 .end = 0x01c10c00 + SZ_1K - 1,
272 .flags = IORESOURCE_MEM,
275 .name = "edma3_ccint",
277 .flags = IORESOURCE_IRQ,
280 .name = "edma3_ccerrint",
281 .start = IRQ_CCERRINT,
282 .flags = IORESOURCE_IRQ,
284 /* not using TC*_ERR */
287 static const struct platform_device_info dm646x_edma_device __initconst = {
290 .dma_mask = DMA_BIT_MASK(32),
291 .res = edma_resources,
292 .num_res = ARRAY_SIZE(edma_resources),
293 .data = &dm646x_edma_pdata,
294 .size_data = sizeof(dm646x_edma_pdata),
297 static struct resource dm646x_mcasp0_resources[] = {
300 .start = DAVINCI_DM646X_MCASP0_REG_BASE,
301 .end = DAVINCI_DM646X_MCASP0_REG_BASE + (SZ_1K << 1) - 1,
302 .flags = IORESOURCE_MEM,
306 .start = DAVINCI_DM646X_DMA_MCASP0_AXEVT0,
307 .end = DAVINCI_DM646X_DMA_MCASP0_AXEVT0,
308 .flags = IORESOURCE_DMA,
312 .start = DAVINCI_DM646X_DMA_MCASP0_AREVT0,
313 .end = DAVINCI_DM646X_DMA_MCASP0_AREVT0,
314 .flags = IORESOURCE_DMA,
318 .start = IRQ_DM646X_MCASP0TXINT,
319 .flags = IORESOURCE_IRQ,
323 .start = IRQ_DM646X_MCASP0RXINT,
324 .flags = IORESOURCE_IRQ,
328 /* DIT mode only, rx is not supported */
329 static struct resource dm646x_mcasp1_resources[] = {
332 .start = DAVINCI_DM646X_MCASP1_REG_BASE,
333 .end = DAVINCI_DM646X_MCASP1_REG_BASE + (SZ_1K << 1) - 1,
334 .flags = IORESOURCE_MEM,
338 .start = DAVINCI_DM646X_DMA_MCASP1_AXEVT1,
339 .end = DAVINCI_DM646X_DMA_MCASP1_AXEVT1,
340 .flags = IORESOURCE_DMA,
344 .start = IRQ_DM646X_MCASP1TXINT,
345 .flags = IORESOURCE_IRQ,
349 static struct platform_device dm646x_mcasp0_device = {
350 .name = "davinci-mcasp",
352 .num_resources = ARRAY_SIZE(dm646x_mcasp0_resources),
353 .resource = dm646x_mcasp0_resources,
356 static struct platform_device dm646x_mcasp1_device = {
357 .name = "davinci-mcasp",
359 .num_resources = ARRAY_SIZE(dm646x_mcasp1_resources),
360 .resource = dm646x_mcasp1_resources,
363 static struct platform_device dm646x_dit_device = {
368 static u64 vpif_dma_mask = DMA_BIT_MASK(32);
370 static struct resource vpif_resource[] = {
372 .start = DAVINCI_VPIF_BASE,
373 .end = DAVINCI_VPIF_BASE + 0x03ff,
374 .flags = IORESOURCE_MEM,
378 static struct platform_device vpif_dev = {
382 .dma_mask = &vpif_dma_mask,
383 .coherent_dma_mask = DMA_BIT_MASK(32),
385 .resource = vpif_resource,
386 .num_resources = ARRAY_SIZE(vpif_resource),
389 static struct resource vpif_display_resource[] = {
391 .start = IRQ_DM646X_VP_VERTINT2,
392 .end = IRQ_DM646X_VP_VERTINT2,
393 .flags = IORESOURCE_IRQ,
396 .start = IRQ_DM646X_VP_VERTINT3,
397 .end = IRQ_DM646X_VP_VERTINT3,
398 .flags = IORESOURCE_IRQ,
402 static struct platform_device vpif_display_dev = {
403 .name = "vpif_display",
406 .dma_mask = &vpif_dma_mask,
407 .coherent_dma_mask = DMA_BIT_MASK(32),
409 .resource = vpif_display_resource,
410 .num_resources = ARRAY_SIZE(vpif_display_resource),
413 static struct resource vpif_capture_resource[] = {
415 .start = IRQ_DM646X_VP_VERTINT0,
416 .end = IRQ_DM646X_VP_VERTINT0,
417 .flags = IORESOURCE_IRQ,
420 .start = IRQ_DM646X_VP_VERTINT1,
421 .end = IRQ_DM646X_VP_VERTINT1,
422 .flags = IORESOURCE_IRQ,
426 static struct platform_device vpif_capture_dev = {
427 .name = "vpif_capture",
430 .dma_mask = &vpif_dma_mask,
431 .coherent_dma_mask = DMA_BIT_MASK(32),
433 .resource = vpif_capture_resource,
434 .num_resources = ARRAY_SIZE(vpif_capture_resource),
437 static struct resource dm646x_gpio_resources[] = {
439 .start = DAVINCI_GPIO_BASE,
440 .end = DAVINCI_GPIO_BASE + SZ_4K - 1,
441 .flags = IORESOURCE_MEM,
444 .start = IRQ_DM646X_GPIOBNK0,
445 .end = IRQ_DM646X_GPIOBNK0,
446 .flags = IORESOURCE_IRQ,
449 .start = IRQ_DM646X_GPIOBNK1,
450 .end = IRQ_DM646X_GPIOBNK1,
451 .flags = IORESOURCE_IRQ,
454 .start = IRQ_DM646X_GPIOBNK2,
455 .end = IRQ_DM646X_GPIOBNK2,
456 .flags = IORESOURCE_IRQ,
460 static struct davinci_gpio_platform_data dm646x_gpio_platform_data = {
464 int __init dm646x_gpio_register(void)
466 return davinci_gpio_register(dm646x_gpio_resources,
467 ARRAY_SIZE(dm646x_gpio_resources),
468 &dm646x_gpio_platform_data);
470 /*----------------------------------------------------------------------*/
472 static struct map_desc dm646x_io_desc[] = {
475 .pfn = __phys_to_pfn(IO_PHYS),
481 /* Contents of JTAG ID register used to identify exact cpu type */
482 static struct davinci_id dm646x_ids[] = {
486 .manufacturer = 0x017,
487 .cpu_id = DAVINCI_CPU_ID_DM6467,
488 .name = "dm6467_rev1.x",
493 .manufacturer = 0x017,
494 .cpu_id = DAVINCI_CPU_ID_DM6467,
495 .name = "dm6467_rev3.x",
500 * T0_BOT: Timer 0, bottom: clockevent source for hrtimers
501 * T0_TOP: Timer 0, top : clocksource for generic timekeeping
502 * T1_BOT: Timer 1, bottom: (used by DSP in TI DSPLink code)
503 * T1_TOP: Timer 1, top : <unused>
505 static struct davinci_timer_info dm646x_timer_info = {
506 .timers = davinci_timer_instance,
507 .clockevent_id = T0_BOT,
508 .clocksource_id = T0_TOP,
511 static struct plat_serial8250_port dm646x_serial0_platform_data[] = {
513 .mapbase = DAVINCI_UART0_BASE,
515 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
517 .iotype = UPIO_MEM32,
524 static struct plat_serial8250_port dm646x_serial1_platform_data[] = {
526 .mapbase = DAVINCI_UART1_BASE,
528 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
530 .iotype = UPIO_MEM32,
537 static struct plat_serial8250_port dm646x_serial2_platform_data[] = {
539 .mapbase = DAVINCI_UART2_BASE,
540 .irq = IRQ_DM646X_UARTINT2,
541 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
543 .iotype = UPIO_MEM32,
551 struct platform_device dm646x_serial_device[] = {
553 .name = "serial8250",
554 .id = PLAT8250_DEV_PLATFORM,
556 .platform_data = dm646x_serial0_platform_data,
560 .name = "serial8250",
561 .id = PLAT8250_DEV_PLATFORM1,
563 .platform_data = dm646x_serial1_platform_data,
567 .name = "serial8250",
568 .id = PLAT8250_DEV_PLATFORM2,
570 .platform_data = dm646x_serial2_platform_data,
577 static const struct davinci_soc_info davinci_soc_info_dm646x = {
578 .io_desc = dm646x_io_desc,
579 .io_desc_num = ARRAY_SIZE(dm646x_io_desc),
580 .jtag_id_reg = 0x01c40028,
582 .ids_num = ARRAY_SIZE(dm646x_ids),
583 .pinmux_base = DAVINCI_SYSTEM_MODULE_BASE,
584 .pinmux_pins = dm646x_pins,
585 .pinmux_pins_num = ARRAY_SIZE(dm646x_pins),
586 .intc_base = DAVINCI_ARM_INTC_BASE,
587 .intc_type = DAVINCI_INTC_TYPE_AINTC,
588 .intc_irq_prios = dm646x_default_priorities,
589 .intc_irq_num = DAVINCI_N_AINTC_IRQ,
590 .timer_info = &dm646x_timer_info,
591 .emac_pdata = &dm646x_emac_pdata,
592 .sram_dma = 0x10010000,
596 void __init dm646x_init_mcasp0(struct snd_platform_data *pdata)
598 dm646x_mcasp0_device.dev.platform_data = pdata;
599 platform_device_register(&dm646x_mcasp0_device);
602 void __init dm646x_init_mcasp1(struct snd_platform_data *pdata)
604 dm646x_mcasp1_device.dev.platform_data = pdata;
605 platform_device_register(&dm646x_mcasp1_device);
606 platform_device_register(&dm646x_dit_device);
609 void dm646x_setup_vpif(struct vpif_display_config *display_config,
610 struct vpif_capture_config *capture_config)
614 value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
615 value &= ~VSCLKDIS_MASK;
616 __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
618 value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VDD3P3VPWDN));
619 value &= ~VDD3P3V_VID_MASK;
620 __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VDD3P3VPWDN));
622 davinci_cfg_reg(DM646X_STSOMUX_DISABLE);
623 davinci_cfg_reg(DM646X_STSIMUX_DISABLE);
624 davinci_cfg_reg(DM646X_PTSOMUX_DISABLE);
625 davinci_cfg_reg(DM646X_PTSIMUX_DISABLE);
627 vpif_display_dev.dev.platform_data = display_config;
628 vpif_capture_dev.dev.platform_data = capture_config;
629 platform_device_register(&vpif_dev);
630 platform_device_register(&vpif_display_dev);
631 platform_device_register(&vpif_capture_dev);
634 int __init dm646x_init_edma(struct edma_rsv_info *rsv)
636 struct platform_device *edma_pdev;
638 dm646x_edma_pdata.rsv = rsv;
640 edma_pdev = platform_device_register_full(&dm646x_edma_device);
641 return PTR_ERR_OR_ZERO(edma_pdev);
644 void __init dm646x_init(void)
646 davinci_common_init(&davinci_soc_info_dm646x);
647 davinci_map_sysmod();
650 void __init dm646x_init_time(unsigned long ref_clk_rate,
651 unsigned long aux_clkin_rate)
653 void __iomem *pll1, *psc;
656 clk_register_fixed_rate(NULL, "ref_clk", NULL, 0, ref_clk_rate);
657 clk_register_fixed_rate(NULL, "aux_clkin", NULL, 0, aux_clkin_rate);
659 pll1 = ioremap(DAVINCI_PLL1_BASE, SZ_1K);
660 dm646x_pll1_init(NULL, pll1, NULL);
662 psc = ioremap(DAVINCI_PWR_SLEEP_CNTRL_BASE, SZ_4K);
663 dm646x_psc_init(NULL, psc);
665 clk = clk_get(NULL, "timer0");
667 davinci_timer_init(clk);
670 static struct resource dm646x_pll2_resources[] = {
672 .start = DAVINCI_PLL2_BASE,
673 .end = DAVINCI_PLL2_BASE + SZ_1K - 1,
674 .flags = IORESOURCE_MEM,
678 static struct platform_device dm646x_pll2_device = {
679 .name = "dm646x-pll2",
681 .resource = dm646x_pll2_resources,
682 .num_resources = ARRAY_SIZE(dm646x_pll2_resources),
685 void __init dm646x_register_clocks(void)
687 /* PLL1 and PSC are registered in dm646x_init_time() */
688 platform_device_register(&dm646x_pll2_device);
691 static int __init dm646x_init_devices(void)
695 if (!cpu_is_davinci_dm646x())
698 platform_device_register(&dm646x_mdio_device);
699 platform_device_register(&dm646x_emac_device);
701 ret = davinci_init_wdt();
703 pr_warn("%s: watchdog init failed: %d\n", __func__, ret);
707 postcore_initcall(dm646x_init_devices);