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/dm644x.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>
36 * Device specific clocks
38 #define DM644X_REF_FREQ 27000000
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
= DM644X_REF_FREQ
,
55 static struct clk pll1_clk
= {
58 .pll_data
= &pll1_data
,
62 static struct clk pll1_sysclk1
= {
63 .name
= "pll1_sysclk1",
69 static struct clk pll1_sysclk2
= {
70 .name
= "pll1_sysclk2",
76 static struct clk pll1_sysclk3
= {
77 .name
= "pll1_sysclk3",
83 static struct clk pll1_sysclk5
= {
84 .name
= "pll1_sysclk5",
90 static struct clk pll1_aux_clk
= {
91 .name
= "pll1_aux_clk",
93 .flags
= CLK_PLL
| PRE_PLL
,
96 static struct clk pll1_sysclkbp
= {
97 .name
= "pll1_sysclkbp",
99 .flags
= CLK_PLL
| PRE_PLL
,
103 static struct clk pll2_clk
= {
106 .pll_data
= &pll2_data
,
110 static struct clk pll2_sysclk1
= {
111 .name
= "pll2_sysclk1",
117 static struct clk pll2_sysclk2
= {
118 .name
= "pll2_sysclk2",
124 static struct clk pll2_sysclkbp
= {
125 .name
= "pll2_sysclkbp",
127 .flags
= CLK_PLL
| PRE_PLL
,
131 static struct clk dsp_clk
= {
133 .parent
= &pll1_sysclk1
,
134 .lpsc
= DAVINCI_LPSC_GEM
,
136 .usecount
= 1, /* REVISIT how to disable? */
139 static struct clk arm_clk
= {
141 .parent
= &pll1_sysclk2
,
142 .lpsc
= DAVINCI_LPSC_ARM
,
143 .flags
= ALWAYS_ENABLED
,
146 static struct clk vicp_clk
= {
148 .parent
= &pll1_sysclk2
,
149 .lpsc
= DAVINCI_LPSC_IMCOP
,
151 .usecount
= 1, /* REVISIT how to disable? */
154 static struct clk vpss_master_clk
= {
155 .name
= "vpss_master",
156 .parent
= &pll1_sysclk3
,
157 .lpsc
= DAVINCI_LPSC_VPSSMSTR
,
161 static struct clk vpss_slave_clk
= {
162 .name
= "vpss_slave",
163 .parent
= &pll1_sysclk3
,
164 .lpsc
= DAVINCI_LPSC_VPSSSLV
,
167 static struct clk uart0_clk
= {
169 .parent
= &pll1_aux_clk
,
170 .lpsc
= DAVINCI_LPSC_UART0
,
173 static struct clk uart1_clk
= {
175 .parent
= &pll1_aux_clk
,
176 .lpsc
= DAVINCI_LPSC_UART1
,
179 static struct clk uart2_clk
= {
181 .parent
= &pll1_aux_clk
,
182 .lpsc
= DAVINCI_LPSC_UART2
,
185 static struct clk emac_clk
= {
187 .parent
= &pll1_sysclk5
,
188 .lpsc
= DAVINCI_LPSC_EMAC_WRAPPER
,
191 static struct clk i2c_clk
= {
193 .parent
= &pll1_aux_clk
,
194 .lpsc
= DAVINCI_LPSC_I2C
,
197 static struct clk ide_clk
= {
199 .parent
= &pll1_sysclk5
,
200 .lpsc
= DAVINCI_LPSC_ATA
,
203 static struct clk asp_clk
= {
205 .parent
= &pll1_sysclk5
,
206 .lpsc
= DAVINCI_LPSC_McBSP
,
209 static struct clk mmcsd_clk
= {
211 .parent
= &pll1_sysclk5
,
212 .lpsc
= DAVINCI_LPSC_MMC_SD
,
215 static struct clk spi_clk
= {
217 .parent
= &pll1_sysclk5
,
218 .lpsc
= DAVINCI_LPSC_SPI
,
221 static struct clk gpio_clk
= {
223 .parent
= &pll1_sysclk5
,
224 .lpsc
= DAVINCI_LPSC_GPIO
,
227 static struct clk usb_clk
= {
229 .parent
= &pll1_sysclk5
,
230 .lpsc
= DAVINCI_LPSC_USB
,
233 static struct clk vlynq_clk
= {
235 .parent
= &pll1_sysclk5
,
236 .lpsc
= DAVINCI_LPSC_VLYNQ
,
239 static struct clk aemif_clk
= {
241 .parent
= &pll1_sysclk5
,
242 .lpsc
= DAVINCI_LPSC_AEMIF
,
245 static struct clk pwm0_clk
= {
247 .parent
= &pll1_aux_clk
,
248 .lpsc
= DAVINCI_LPSC_PWM0
,
251 static struct clk pwm1_clk
= {
253 .parent
= &pll1_aux_clk
,
254 .lpsc
= DAVINCI_LPSC_PWM1
,
257 static struct clk pwm2_clk
= {
259 .parent
= &pll1_aux_clk
,
260 .lpsc
= DAVINCI_LPSC_PWM2
,
263 static struct clk timer0_clk
= {
265 .parent
= &pll1_aux_clk
,
266 .lpsc
= DAVINCI_LPSC_TIMER0
,
269 static struct clk timer1_clk
= {
271 .parent
= &pll1_aux_clk
,
272 .lpsc
= DAVINCI_LPSC_TIMER1
,
275 static struct clk timer2_clk
= {
277 .parent
= &pll1_aux_clk
,
278 .lpsc
= DAVINCI_LPSC_TIMER2
,
279 .usecount
= 1, /* REVISIT: why cant' this be disabled? */
282 struct davinci_clk dm644x_clks
[] = {
283 CLK(NULL
, "ref", &ref_clk
),
284 CLK(NULL
, "pll1", &pll1_clk
),
285 CLK(NULL
, "pll1_sysclk1", &pll1_sysclk1
),
286 CLK(NULL
, "pll1_sysclk2", &pll1_sysclk2
),
287 CLK(NULL
, "pll1_sysclk3", &pll1_sysclk3
),
288 CLK(NULL
, "pll1_sysclk5", &pll1_sysclk5
),
289 CLK(NULL
, "pll1_aux", &pll1_aux_clk
),
290 CLK(NULL
, "pll1_sysclkbp", &pll1_sysclkbp
),
291 CLK(NULL
, "pll2", &pll2_clk
),
292 CLK(NULL
, "pll2_sysclk1", &pll2_sysclk1
),
293 CLK(NULL
, "pll2_sysclk2", &pll2_sysclk2
),
294 CLK(NULL
, "pll2_sysclkbp", &pll2_sysclkbp
),
295 CLK(NULL
, "dsp", &dsp_clk
),
296 CLK(NULL
, "arm", &arm_clk
),
297 CLK(NULL
, "vicp", &vicp_clk
),
298 CLK(NULL
, "vpss_master", &vpss_master_clk
),
299 CLK(NULL
, "vpss_slave", &vpss_slave_clk
),
300 CLK(NULL
, "arm", &arm_clk
),
301 CLK(NULL
, "uart0", &uart0_clk
),
302 CLK(NULL
, "uart1", &uart1_clk
),
303 CLK(NULL
, "uart2", &uart2_clk
),
304 CLK("davinci_emac.1", NULL
, &emac_clk
),
305 CLK("i2c_davinci.1", NULL
, &i2c_clk
),
306 CLK("palm_bk3710", NULL
, &ide_clk
),
307 CLK("davinci-asp", NULL
, &asp_clk
),
308 CLK("davinci_mmc.0", NULL
, &mmcsd_clk
),
309 CLK(NULL
, "spi", &spi_clk
),
310 CLK(NULL
, "gpio", &gpio_clk
),
311 CLK(NULL
, "usb", &usb_clk
),
312 CLK(NULL
, "vlynq", &vlynq_clk
),
313 CLK(NULL
, "aemif", &aemif_clk
),
314 CLK(NULL
, "pwm0", &pwm0_clk
),
315 CLK(NULL
, "pwm1", &pwm1_clk
),
316 CLK(NULL
, "pwm2", &pwm2_clk
),
317 CLK(NULL
, "timer0", &timer0_clk
),
318 CLK(NULL
, "timer1", &timer1_clk
),
319 CLK("watchdog", NULL
, &timer2_clk
),
320 CLK(NULL
, NULL
, NULL
),
323 static struct emac_platform_data dm644x_emac_pdata
= {
324 .ctrl_reg_offset
= DM644X_EMAC_CNTRL_OFFSET
,
325 .ctrl_mod_reg_offset
= DM644X_EMAC_CNTRL_MOD_OFFSET
,
326 .ctrl_ram_offset
= DM644X_EMAC_CNTRL_RAM_OFFSET
,
327 .mdio_reg_offset
= DM644X_EMAC_MDIO_OFFSET
,
328 .ctrl_ram_size
= DM644X_EMAC_CNTRL_RAM_SIZE
,
329 .version
= EMAC_VERSION_1
,
332 static struct resource dm644x_emac_resources
[] = {
334 .start
= DM644X_EMAC_BASE
,
335 .end
= DM644X_EMAC_BASE
+ 0x47ff,
336 .flags
= IORESOURCE_MEM
,
339 .start
= IRQ_EMACINT
,
341 .flags
= IORESOURCE_IRQ
,
345 static struct platform_device dm644x_emac_device
= {
346 .name
= "davinci_emac",
349 .platform_data
= &dm644x_emac_pdata
,
351 .num_resources
= ARRAY_SIZE(dm644x_emac_resources
),
352 .resource
= dm644x_emac_resources
,
359 * Device specific mux setup
361 * soc description mux mode mode mux dbg
362 * reg offset mask mode
364 static const struct mux_config dm644x_pins
[] = {
365 #ifdef CONFIG_DAVINCI_MUX
366 MUX_CFG(DM644X
, HDIREN
, 0, 16, 1, 1, true)
367 MUX_CFG(DM644X
, ATAEN
, 0, 17, 1, 1, true)
368 MUX_CFG(DM644X
, ATAEN_DISABLE
, 0, 17, 1, 0, true)
370 MUX_CFG(DM644X
, HPIEN_DISABLE
, 0, 29, 1, 0, true)
372 MUX_CFG(DM644X
, AEAW
, 0, 0, 31, 31, true)
374 MUX_CFG(DM644X
, MSTK
, 1, 9, 1, 0, false)
376 MUX_CFG(DM644X
, I2C
, 1, 7, 1, 1, false)
378 MUX_CFG(DM644X
, MCBSP
, 1, 10, 1, 1, false)
380 MUX_CFG(DM644X
, UART1
, 1, 1, 1, 1, true)
381 MUX_CFG(DM644X
, UART2
, 1, 2, 1, 1, true)
383 MUX_CFG(DM644X
, PWM0
, 1, 4, 1, 1, false)
385 MUX_CFG(DM644X
, PWM1
, 1, 5, 1, 1, false)
387 MUX_CFG(DM644X
, PWM2
, 1, 6, 1, 1, false)
389 MUX_CFG(DM644X
, VLYNQEN
, 0, 15, 1, 1, false)
390 MUX_CFG(DM644X
, VLSCREN
, 0, 14, 1, 1, false)
391 MUX_CFG(DM644X
, VLYNQWD
, 0, 12, 3, 3, false)
393 MUX_CFG(DM644X
, EMACEN
, 0, 31, 1, 1, true)
395 MUX_CFG(DM644X
, GPIO3V
, 0, 31, 1, 0, true)
397 MUX_CFG(DM644X
, GPIO0
, 0, 24, 1, 0, true)
398 MUX_CFG(DM644X
, GPIO3
, 0, 25, 1, 0, false)
399 MUX_CFG(DM644X
, GPIO43_44
, 1, 7, 1, 0, false)
400 MUX_CFG(DM644X
, GPIO46_47
, 0, 22, 1, 0, true)
402 MUX_CFG(DM644X
, RGB666
, 0, 22, 1, 1, true)
404 MUX_CFG(DM644X
, LOEEN
, 0, 24, 1, 1, true)
405 MUX_CFG(DM644X
, LFLDEN
, 0, 25, 1, 1, false)
409 /* FIQ are pri 0-1; otherwise 2-7, with 7 lowest priority */
410 static u8 dm644x_default_priorities
[DAVINCI_N_AINTC_IRQ
] = {
427 [IRQ_CCINT0
] = 5, /* dma */
428 [IRQ_CCERRINT
] = 5, /* dma */
429 [IRQ_TCERRINT0
] = 5, /* dma */
430 [IRQ_TCERRINT
] = 5, /* dma */
443 [IRQ_TINT0_TINT12
] = 2, /* clockevent */
444 [IRQ_TINT0_TINT34
] = 2, /* clocksource */
445 [IRQ_TINT1_TINT12
] = 7, /* DSP timer */
446 [IRQ_TINT1_TINT34
] = 7, /* system tick */
477 /*----------------------------------------------------------------------*/
479 static const s8 dma_chan_dm644x_no_event
[] = {
489 queue_tc_mapping
[][2] = {
490 /* {event queue no, TC no} */
497 queue_priority_mapping
[][2] = {
498 /* {event queue no, Priority} */
504 static struct edma_soc_info dm644x_edma_info
[] = {
511 .noevent
= dma_chan_dm644x_no_event
,
512 .queue_tc_mapping
= queue_tc_mapping
,
513 .queue_priority_mapping
= queue_priority_mapping
,
517 static struct resource edma_resources
[] = {
521 .end
= 0x01c00000 + SZ_64K
- 1,
522 .flags
= IORESOURCE_MEM
,
527 .end
= 0x01c10000 + SZ_1K
- 1,
528 .flags
= IORESOURCE_MEM
,
533 .end
= 0x01c10400 + SZ_1K
- 1,
534 .flags
= IORESOURCE_MEM
,
539 .flags
= IORESOURCE_IRQ
,
543 .start
= IRQ_CCERRINT
,
544 .flags
= IORESOURCE_IRQ
,
546 /* not using TC*_ERR */
549 static struct platform_device dm644x_edma_device
= {
552 .dev
.platform_data
= dm644x_edma_info
,
553 .num_resources
= ARRAY_SIZE(edma_resources
),
554 .resource
= edma_resources
,
557 /* DM6446 EVM uses ASP0; line-out is a pair of RCA jacks */
558 static struct resource dm644x_asp_resources
[] = {
560 .start
= DAVINCI_ASP0_BASE
,
561 .end
= DAVINCI_ASP0_BASE
+ SZ_8K
- 1,
562 .flags
= IORESOURCE_MEM
,
565 .start
= DAVINCI_DMA_ASP0_TX
,
566 .end
= DAVINCI_DMA_ASP0_TX
,
567 .flags
= IORESOURCE_DMA
,
570 .start
= DAVINCI_DMA_ASP0_RX
,
571 .end
= DAVINCI_DMA_ASP0_RX
,
572 .flags
= IORESOURCE_DMA
,
576 static struct platform_device dm644x_asp_device
= {
577 .name
= "davinci-asp",
579 .num_resources
= ARRAY_SIZE(dm644x_asp_resources
),
580 .resource
= dm644x_asp_resources
,
583 static struct resource dm644x_vpss_resources
[] = {
585 /* VPSS Base address */
588 .end
= 0x01c73400 + 0xff,
589 .flags
= IORESOURCE_MEM
,
593 static struct platform_device dm644x_vpss_device
= {
596 .dev
.platform_data
= "dm644x_vpss",
597 .num_resources
= ARRAY_SIZE(dm644x_vpss_resources
),
598 .resource
= dm644x_vpss_resources
,
601 static struct resource vpfe_resources
[] = {
605 .flags
= IORESOURCE_IRQ
,
610 .flags
= IORESOURCE_IRQ
,
614 .end
= 0x01c70400 + 0xff,
615 .flags
= IORESOURCE_MEM
,
619 static u64 vpfe_capture_dma_mask
= DMA_BIT_MASK(32);
620 static struct platform_device vpfe_capture_dev
= {
621 .name
= CAPTURE_DRV_NAME
,
623 .num_resources
= ARRAY_SIZE(vpfe_resources
),
624 .resource
= vpfe_resources
,
626 .dma_mask
= &vpfe_capture_dma_mask
,
627 .coherent_dma_mask
= DMA_BIT_MASK(32),
631 void dm644x_set_vpfe_config(struct vpfe_config
*cfg
)
633 vpfe_capture_dev
.dev
.platform_data
= cfg
;
636 /*----------------------------------------------------------------------*/
638 static struct map_desc dm644x_io_desc
[] = {
641 .pfn
= __phys_to_pfn(IO_PHYS
),
646 .virtual = SRAM_VIRT
,
647 .pfn
= __phys_to_pfn(0x00008000),
649 /* MT_MEMORY_NONCACHED requires supersection alignment */
654 /* Contents of JTAG ID register used to identify exact cpu type */
655 static struct davinci_id dm644x_ids
[] = {
659 .manufacturer
= 0x017,
660 .cpu_id
= DAVINCI_CPU_ID_DM6446
,
666 .manufacturer
= 0x017,
667 .cpu_id
= DAVINCI_CPU_ID_DM6446
,
672 static void __iomem
*dm644x_psc_bases
[] = {
673 IO_ADDRESS(DAVINCI_PWR_SLEEP_CNTRL_BASE
),
677 * T0_BOT: Timer 0, bottom: clockevent source for hrtimers
678 * T0_TOP: Timer 0, top : clocksource for generic timekeeping
679 * T1_BOT: Timer 1, bottom: (used by DSP in TI DSPLink code)
680 * T1_TOP: Timer 1, top : <unused>
682 struct davinci_timer_info dm644x_timer_info
= {
683 .timers
= davinci_timer_instance
,
684 .clockevent_id
= T0_BOT
,
685 .clocksource_id
= T0_TOP
,
688 static struct plat_serial8250_port dm644x_serial_platform_data
[] = {
690 .mapbase
= DAVINCI_UART0_BASE
,
692 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
|
698 .mapbase
= DAVINCI_UART1_BASE
,
700 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
|
706 .mapbase
= DAVINCI_UART2_BASE
,
708 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
|
718 static struct platform_device dm644x_serial_device
= {
719 .name
= "serial8250",
720 .id
= PLAT8250_DEV_PLATFORM
,
722 .platform_data
= dm644x_serial_platform_data
,
726 static struct davinci_soc_info davinci_soc_info_dm644x
= {
727 .io_desc
= dm644x_io_desc
,
728 .io_desc_num
= ARRAY_SIZE(dm644x_io_desc
),
729 .jtag_id_base
= IO_ADDRESS(0x01c40028),
731 .ids_num
= ARRAY_SIZE(dm644x_ids
),
732 .cpu_clks
= dm644x_clks
,
733 .psc_bases
= dm644x_psc_bases
,
734 .psc_bases_num
= ARRAY_SIZE(dm644x_psc_bases
),
735 .pinmux_base
= IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE
),
736 .pinmux_pins
= dm644x_pins
,
737 .pinmux_pins_num
= ARRAY_SIZE(dm644x_pins
),
738 .intc_base
= IO_ADDRESS(DAVINCI_ARM_INTC_BASE
),
739 .intc_type
= DAVINCI_INTC_TYPE_AINTC
,
740 .intc_irq_prios
= dm644x_default_priorities
,
741 .intc_irq_num
= DAVINCI_N_AINTC_IRQ
,
742 .timer_info
= &dm644x_timer_info
,
743 .gpio_base
= IO_ADDRESS(DAVINCI_GPIO_BASE
),
745 .gpio_irq
= IRQ_GPIOBNK0
,
746 .serial_dev
= &dm644x_serial_device
,
747 .emac_pdata
= &dm644x_emac_pdata
,
748 .sram_dma
= 0x00008000,
752 void __init
dm644x_init_asp(struct snd_platform_data
*pdata
)
754 davinci_cfg_reg(DM644X_MCBSP
);
755 dm644x_asp_device
.dev
.platform_data
= pdata
;
756 platform_device_register(&dm644x_asp_device
);
759 void __init
dm644x_init(void)
761 davinci_common_init(&davinci_soc_info_dm644x
);
764 static int __init
dm644x_init_devices(void)
766 if (!cpu_is_davinci_dm644x())
769 platform_device_register(&dm644x_edma_device
);
770 platform_device_register(&dm644x_emac_device
);
771 platform_device_register(&dm644x_vpss_device
);
772 platform_device_register(&vpfe_capture_dev
);
776 postcore_initcall(dm644x_init_devices
);