2 * DA8XX/OMAP L1XX platform device data
4 * Copyright (c) 2007-2009, MontaVista Software, Inc. <source@mvista.com>
5 * Derived from code that was:
6 * Copyright (C) 2006 Komal Shah <komal_shah802003@yahoo.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/dma-contiguous.h>
16 #include <linux/serial_8250.h>
17 #include <linux/ahci_platform.h>
18 #include <linux/clk.h>
19 #include <linux/reboot.h>
21 #include <mach/cputype.h>
22 #include <mach/common.h>
23 #include <mach/time.h>
24 #include <mach/da8xx.h>
25 #include <mach/cpuidle.h>
26 #include <mach/sram.h>
31 #define DA8XX_TPCC_BASE 0x01c00000
32 #define DA8XX_TPTC0_BASE 0x01c08000
33 #define DA8XX_TPTC1_BASE 0x01c08400
34 #define DA8XX_WDOG_BASE 0x01c21000 /* DA8XX_TIMER64P1_BASE */
35 #define DA8XX_I2C0_BASE 0x01c22000
36 #define DA8XX_RTC_BASE 0x01c23000
37 #define DA8XX_PRUSS_MEM_BASE 0x01c30000
38 #define DA8XX_MMCSD0_BASE 0x01c40000
39 #define DA8XX_SPI0_BASE 0x01c41000
40 #define DA830_SPI1_BASE 0x01e12000
41 #define DA8XX_LCD_CNTRL_BASE 0x01e13000
42 #define DA850_SATA_BASE 0x01e18000
43 #define DA850_MMCSD1_BASE 0x01e1b000
44 #define DA8XX_EMAC_CPPI_PORT_BASE 0x01e20000
45 #define DA8XX_EMAC_CPGMACSS_BASE 0x01e22000
46 #define DA8XX_EMAC_CPGMAC_BASE 0x01e23000
47 #define DA8XX_EMAC_MDIO_BASE 0x01e24000
48 #define DA8XX_I2C1_BASE 0x01e28000
49 #define DA850_TPCC1_BASE 0x01e30000
50 #define DA850_TPTC2_BASE 0x01e38000
51 #define DA850_SPI1_BASE 0x01f0e000
52 #define DA8XX_DDR2_CTL_BASE 0xb0000000
54 #define DA8XX_EMAC_CTRL_REG_OFFSET 0x3000
55 #define DA8XX_EMAC_MOD_REG_OFFSET 0x2000
56 #define DA8XX_EMAC_RAM_OFFSET 0x0000
57 #define DA8XX_EMAC_CTRL_RAM_SIZE SZ_8K
59 #define DA8XX_DMA_SPI0_RX EDMA_CTLR_CHAN(0, 14)
60 #define DA8XX_DMA_SPI0_TX EDMA_CTLR_CHAN(0, 15)
61 #define DA8XX_DMA_MMCSD0_RX EDMA_CTLR_CHAN(0, 16)
62 #define DA8XX_DMA_MMCSD0_TX EDMA_CTLR_CHAN(0, 17)
63 #define DA8XX_DMA_SPI1_RX EDMA_CTLR_CHAN(0, 18)
64 #define DA8XX_DMA_SPI1_TX EDMA_CTLR_CHAN(0, 19)
65 #define DA850_DMA_MMCSD1_RX EDMA_CTLR_CHAN(1, 28)
66 #define DA850_DMA_MMCSD1_TX EDMA_CTLR_CHAN(1, 29)
68 void __iomem
*da8xx_syscfg0_base
;
69 void __iomem
*da8xx_syscfg1_base
;
71 static struct plat_serial8250_port da8xx_serial0_pdata
[] = {
73 .mapbase
= DA8XX_UART0_BASE
,
74 .irq
= IRQ_DA8XX_UARTINT0
,
75 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
|
84 static struct plat_serial8250_port da8xx_serial1_pdata
[] = {
86 .mapbase
= DA8XX_UART1_BASE
,
87 .irq
= IRQ_DA8XX_UARTINT1
,
88 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
|
97 static struct plat_serial8250_port da8xx_serial2_pdata
[] = {
99 .mapbase
= DA8XX_UART2_BASE
,
100 .irq
= IRQ_DA8XX_UARTINT2
,
101 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
|
111 struct platform_device da8xx_serial_device
[] = {
113 .name
= "serial8250",
114 .id
= PLAT8250_DEV_PLATFORM
,
116 .platform_data
= da8xx_serial0_pdata
,
120 .name
= "serial8250",
121 .id
= PLAT8250_DEV_PLATFORM1
,
123 .platform_data
= da8xx_serial1_pdata
,
127 .name
= "serial8250",
128 .id
= PLAT8250_DEV_PLATFORM2
,
130 .platform_data
= da8xx_serial2_pdata
,
137 static s8 da8xx_queue_tc_mapping
[][2] = {
138 /* {event queue no, TC no} */
144 static s8 da8xx_queue_priority_mapping
[][2] = {
145 /* {event queue no, Priority} */
151 static s8 da850_queue_tc_mapping
[][2] = {
152 /* {event queue no, TC no} */
157 static s8 da850_queue_priority_mapping
[][2] = {
158 /* {event queue no, Priority} */
163 static struct edma_soc_info da830_edma_cc0_info
= {
169 .queue_tc_mapping
= da8xx_queue_tc_mapping
,
170 .queue_priority_mapping
= da8xx_queue_priority_mapping
,
171 .default_queue
= EVENTQ_1
,
174 static struct edma_soc_info
*da830_edma_info
[EDMA_MAX_CC
] = {
175 &da830_edma_cc0_info
,
178 static struct edma_soc_info da850_edma_cc_info
[] = {
185 .queue_tc_mapping
= da8xx_queue_tc_mapping
,
186 .queue_priority_mapping
= da8xx_queue_priority_mapping
,
187 .default_queue
= EVENTQ_1
,
195 .queue_tc_mapping
= da850_queue_tc_mapping
,
196 .queue_priority_mapping
= da850_queue_priority_mapping
,
197 .default_queue
= EVENTQ_0
,
201 static struct edma_soc_info
*da850_edma_info
[EDMA_MAX_CC
] = {
202 &da850_edma_cc_info
[0],
203 &da850_edma_cc_info
[1],
206 static struct resource da830_edma_resources
[] = {
209 .start
= DA8XX_TPCC_BASE
,
210 .end
= DA8XX_TPCC_BASE
+ SZ_32K
- 1,
211 .flags
= IORESOURCE_MEM
,
215 .start
= DA8XX_TPTC0_BASE
,
216 .end
= DA8XX_TPTC0_BASE
+ SZ_1K
- 1,
217 .flags
= IORESOURCE_MEM
,
221 .start
= DA8XX_TPTC1_BASE
,
222 .end
= DA8XX_TPTC1_BASE
+ SZ_1K
- 1,
223 .flags
= IORESOURCE_MEM
,
227 .start
= IRQ_DA8XX_CCINT0
,
228 .flags
= IORESOURCE_IRQ
,
232 .start
= IRQ_DA8XX_CCERRINT
,
233 .flags
= IORESOURCE_IRQ
,
237 static struct resource da850_edma_resources
[] = {
240 .start
= DA8XX_TPCC_BASE
,
241 .end
= DA8XX_TPCC_BASE
+ SZ_32K
- 1,
242 .flags
= IORESOURCE_MEM
,
246 .start
= DA8XX_TPTC0_BASE
,
247 .end
= DA8XX_TPTC0_BASE
+ SZ_1K
- 1,
248 .flags
= IORESOURCE_MEM
,
252 .start
= DA8XX_TPTC1_BASE
,
253 .end
= DA8XX_TPTC1_BASE
+ SZ_1K
- 1,
254 .flags
= IORESOURCE_MEM
,
258 .start
= DA850_TPCC1_BASE
,
259 .end
= DA850_TPCC1_BASE
+ SZ_32K
- 1,
260 .flags
= IORESOURCE_MEM
,
264 .start
= DA850_TPTC2_BASE
,
265 .end
= DA850_TPTC2_BASE
+ SZ_1K
- 1,
266 .flags
= IORESOURCE_MEM
,
270 .start
= IRQ_DA8XX_CCINT0
,
271 .flags
= IORESOURCE_IRQ
,
275 .start
= IRQ_DA8XX_CCERRINT
,
276 .flags
= IORESOURCE_IRQ
,
280 .start
= IRQ_DA850_CCINT1
,
281 .flags
= IORESOURCE_IRQ
,
285 .start
= IRQ_DA850_CCERRINT1
,
286 .flags
= IORESOURCE_IRQ
,
290 static struct platform_device da830_edma_device
= {
294 .platform_data
= da830_edma_info
,
296 .num_resources
= ARRAY_SIZE(da830_edma_resources
),
297 .resource
= da830_edma_resources
,
300 static struct platform_device da850_edma_device
= {
304 .platform_data
= da850_edma_info
,
306 .num_resources
= ARRAY_SIZE(da850_edma_resources
),
307 .resource
= da850_edma_resources
,
310 int __init
da830_register_edma(struct edma_rsv_info
*rsv
)
312 da830_edma_cc0_info
.rsv
= rsv
;
314 return platform_device_register(&da830_edma_device
);
317 int __init
da850_register_edma(struct edma_rsv_info
*rsv
[2])
320 da850_edma_cc_info
[0].rsv
= rsv
[0];
321 da850_edma_cc_info
[1].rsv
= rsv
[1];
324 return platform_device_register(&da850_edma_device
);
327 static struct resource da8xx_i2c_resources0
[] = {
329 .start
= DA8XX_I2C0_BASE
,
330 .end
= DA8XX_I2C0_BASE
+ SZ_4K
- 1,
331 .flags
= IORESOURCE_MEM
,
334 .start
= IRQ_DA8XX_I2CINT0
,
335 .end
= IRQ_DA8XX_I2CINT0
,
336 .flags
= IORESOURCE_IRQ
,
340 static struct platform_device da8xx_i2c_device0
= {
341 .name
= "i2c_davinci",
343 .num_resources
= ARRAY_SIZE(da8xx_i2c_resources0
),
344 .resource
= da8xx_i2c_resources0
,
347 static struct resource da8xx_i2c_resources1
[] = {
349 .start
= DA8XX_I2C1_BASE
,
350 .end
= DA8XX_I2C1_BASE
+ SZ_4K
- 1,
351 .flags
= IORESOURCE_MEM
,
354 .start
= IRQ_DA8XX_I2CINT1
,
355 .end
= IRQ_DA8XX_I2CINT1
,
356 .flags
= IORESOURCE_IRQ
,
360 static struct platform_device da8xx_i2c_device1
= {
361 .name
= "i2c_davinci",
363 .num_resources
= ARRAY_SIZE(da8xx_i2c_resources1
),
364 .resource
= da8xx_i2c_resources1
,
367 int __init
da8xx_register_i2c(int instance
,
368 struct davinci_i2c_platform_data
*pdata
)
370 struct platform_device
*pdev
;
373 pdev
= &da8xx_i2c_device0
;
374 else if (instance
== 1)
375 pdev
= &da8xx_i2c_device1
;
379 pdev
->dev
.platform_data
= pdata
;
380 return platform_device_register(pdev
);
383 static struct resource da8xx_watchdog_resources
[] = {
385 .start
= DA8XX_WDOG_BASE
,
386 .end
= DA8XX_WDOG_BASE
+ SZ_4K
- 1,
387 .flags
= IORESOURCE_MEM
,
391 static struct platform_device da8xx_wdt_device
= {
394 .num_resources
= ARRAY_SIZE(da8xx_watchdog_resources
),
395 .resource
= da8xx_watchdog_resources
,
398 void da8xx_restart(enum reboot_mode mode
, const char *cmd
)
402 dev
= bus_find_device_by_name(&platform_bus_type
, NULL
, "watchdog");
404 pr_err("%s: failed to find watchdog device\n", __func__
);
408 davinci_watchdog_reset(to_platform_device(dev
));
411 int __init
da8xx_register_watchdog(void)
413 return platform_device_register(&da8xx_wdt_device
);
416 static struct resource da8xx_emac_resources
[] = {
418 .start
= DA8XX_EMAC_CPPI_PORT_BASE
,
419 .end
= DA8XX_EMAC_CPPI_PORT_BASE
+ SZ_16K
- 1,
420 .flags
= IORESOURCE_MEM
,
423 .start
= IRQ_DA8XX_C0_RX_THRESH_PULSE
,
424 .end
= IRQ_DA8XX_C0_RX_THRESH_PULSE
,
425 .flags
= IORESOURCE_IRQ
,
428 .start
= IRQ_DA8XX_C0_RX_PULSE
,
429 .end
= IRQ_DA8XX_C0_RX_PULSE
,
430 .flags
= IORESOURCE_IRQ
,
433 .start
= IRQ_DA8XX_C0_TX_PULSE
,
434 .end
= IRQ_DA8XX_C0_TX_PULSE
,
435 .flags
= IORESOURCE_IRQ
,
438 .start
= IRQ_DA8XX_C0_MISC_PULSE
,
439 .end
= IRQ_DA8XX_C0_MISC_PULSE
,
440 .flags
= IORESOURCE_IRQ
,
444 struct emac_platform_data da8xx_emac_pdata
= {
445 .ctrl_reg_offset
= DA8XX_EMAC_CTRL_REG_OFFSET
,
446 .ctrl_mod_reg_offset
= DA8XX_EMAC_MOD_REG_OFFSET
,
447 .ctrl_ram_offset
= DA8XX_EMAC_RAM_OFFSET
,
448 .ctrl_ram_size
= DA8XX_EMAC_CTRL_RAM_SIZE
,
449 .version
= EMAC_VERSION_2
,
452 static struct platform_device da8xx_emac_device
= {
453 .name
= "davinci_emac",
456 .platform_data
= &da8xx_emac_pdata
,
458 .num_resources
= ARRAY_SIZE(da8xx_emac_resources
),
459 .resource
= da8xx_emac_resources
,
462 static struct resource da8xx_mdio_resources
[] = {
464 .start
= DA8XX_EMAC_MDIO_BASE
,
465 .end
= DA8XX_EMAC_MDIO_BASE
+ SZ_4K
- 1,
466 .flags
= IORESOURCE_MEM
,
470 static struct platform_device da8xx_mdio_device
= {
471 .name
= "davinci_mdio",
473 .num_resources
= ARRAY_SIZE(da8xx_mdio_resources
),
474 .resource
= da8xx_mdio_resources
,
477 int __init
da8xx_register_emac(void)
481 ret
= platform_device_register(&da8xx_mdio_device
);
485 return platform_device_register(&da8xx_emac_device
);
488 static struct resource da830_mcasp1_resources
[] = {
491 .start
= DAVINCI_DA830_MCASP1_REG_BASE
,
492 .end
= DAVINCI_DA830_MCASP1_REG_BASE
+ (SZ_1K
* 12) - 1,
493 .flags
= IORESOURCE_MEM
,
497 .start
= DAVINCI_DA830_DMA_MCASP1_AXEVT
,
498 .end
= DAVINCI_DA830_DMA_MCASP1_AXEVT
,
499 .flags
= IORESOURCE_DMA
,
503 .start
= DAVINCI_DA830_DMA_MCASP1_AREVT
,
504 .end
= DAVINCI_DA830_DMA_MCASP1_AREVT
,
505 .flags
= IORESOURCE_DMA
,
509 static struct platform_device da830_mcasp1_device
= {
510 .name
= "davinci-mcasp",
512 .num_resources
= ARRAY_SIZE(da830_mcasp1_resources
),
513 .resource
= da830_mcasp1_resources
,
516 static struct resource da850_mcasp_resources
[] = {
519 .start
= DAVINCI_DA8XX_MCASP0_REG_BASE
,
520 .end
= DAVINCI_DA8XX_MCASP0_REG_BASE
+ (SZ_1K
* 12) - 1,
521 .flags
= IORESOURCE_MEM
,
525 .start
= DAVINCI_DA8XX_DMA_MCASP0_AXEVT
,
526 .end
= DAVINCI_DA8XX_DMA_MCASP0_AXEVT
,
527 .flags
= IORESOURCE_DMA
,
531 .start
= DAVINCI_DA8XX_DMA_MCASP0_AREVT
,
532 .end
= DAVINCI_DA8XX_DMA_MCASP0_AREVT
,
533 .flags
= IORESOURCE_DMA
,
537 static struct platform_device da850_mcasp_device
= {
538 .name
= "davinci-mcasp",
540 .num_resources
= ARRAY_SIZE(da850_mcasp_resources
),
541 .resource
= da850_mcasp_resources
,
544 void __init
da8xx_register_mcasp(int id
, struct snd_platform_data
*pdata
)
546 /* DA830/OMAP-L137 has 3 instances of McASP */
547 if (cpu_is_davinci_da830() && id
== 1) {
548 da830_mcasp1_device
.dev
.platform_data
= pdata
;
549 platform_device_register(&da830_mcasp1_device
);
550 } else if (cpu_is_davinci_da850()) {
551 da850_mcasp_device
.dev
.platform_data
= pdata
;
552 platform_device_register(&da850_mcasp_device
);
556 static struct resource da8xx_pruss_resources
[] = {
558 .start
= DA8XX_PRUSS_MEM_BASE
,
559 .end
= DA8XX_PRUSS_MEM_BASE
+ 0xFFFF,
560 .flags
= IORESOURCE_MEM
,
563 .start
= IRQ_DA8XX_EVTOUT0
,
564 .end
= IRQ_DA8XX_EVTOUT0
,
565 .flags
= IORESOURCE_IRQ
,
568 .start
= IRQ_DA8XX_EVTOUT1
,
569 .end
= IRQ_DA8XX_EVTOUT1
,
570 .flags
= IORESOURCE_IRQ
,
573 .start
= IRQ_DA8XX_EVTOUT2
,
574 .end
= IRQ_DA8XX_EVTOUT2
,
575 .flags
= IORESOURCE_IRQ
,
578 .start
= IRQ_DA8XX_EVTOUT3
,
579 .end
= IRQ_DA8XX_EVTOUT3
,
580 .flags
= IORESOURCE_IRQ
,
583 .start
= IRQ_DA8XX_EVTOUT4
,
584 .end
= IRQ_DA8XX_EVTOUT4
,
585 .flags
= IORESOURCE_IRQ
,
588 .start
= IRQ_DA8XX_EVTOUT5
,
589 .end
= IRQ_DA8XX_EVTOUT5
,
590 .flags
= IORESOURCE_IRQ
,
593 .start
= IRQ_DA8XX_EVTOUT6
,
594 .end
= IRQ_DA8XX_EVTOUT6
,
595 .flags
= IORESOURCE_IRQ
,
598 .start
= IRQ_DA8XX_EVTOUT7
,
599 .end
= IRQ_DA8XX_EVTOUT7
,
600 .flags
= IORESOURCE_IRQ
,
604 static struct uio_pruss_pdata da8xx_uio_pruss_pdata
= {
605 .pintc_base
= 0x4000,
608 static struct platform_device da8xx_uio_pruss_dev
= {
611 .num_resources
= ARRAY_SIZE(da8xx_pruss_resources
),
612 .resource
= da8xx_pruss_resources
,
614 .coherent_dma_mask
= DMA_BIT_MASK(32),
615 .platform_data
= &da8xx_uio_pruss_pdata
,
619 int __init
da8xx_register_uio_pruss(void)
621 da8xx_uio_pruss_pdata
.sram_pool
= sram_get_gen_pool();
622 return platform_device_register(&da8xx_uio_pruss_dev
);
625 static struct lcd_ctrl_config lcd_cfg
= {
626 .panel_shade
= COLOR_ACTIVE
,
630 struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata
= {
631 .manu_name
= "sharp",
632 .controller_data
= &lcd_cfg
,
633 .type
= "Sharp_LCD035Q3DG01",
636 struct da8xx_lcdc_platform_data sharp_lk043t1dg01_pdata
= {
637 .manu_name
= "sharp",
638 .controller_data
= &lcd_cfg
,
639 .type
= "Sharp_LK043T1DG01",
642 static struct resource da8xx_lcdc_resources
[] = {
643 [0] = { /* registers */
644 .start
= DA8XX_LCD_CNTRL_BASE
,
645 .end
= DA8XX_LCD_CNTRL_BASE
+ SZ_4K
- 1,
646 .flags
= IORESOURCE_MEM
,
648 [1] = { /* interrupt */
649 .start
= IRQ_DA8XX_LCDINT
,
650 .end
= IRQ_DA8XX_LCDINT
,
651 .flags
= IORESOURCE_IRQ
,
655 static struct platform_device da8xx_lcdc_device
= {
656 .name
= "da8xx_lcdc",
658 .num_resources
= ARRAY_SIZE(da8xx_lcdc_resources
),
659 .resource
= da8xx_lcdc_resources
,
662 int __init
da8xx_register_lcdc(struct da8xx_lcdc_platform_data
*pdata
)
664 da8xx_lcdc_device
.dev
.platform_data
= pdata
;
665 return platform_device_register(&da8xx_lcdc_device
);
668 static struct resource da8xx_mmcsd0_resources
[] = {
670 .start
= DA8XX_MMCSD0_BASE
,
671 .end
= DA8XX_MMCSD0_BASE
+ SZ_4K
- 1,
672 .flags
= IORESOURCE_MEM
,
675 .start
= IRQ_DA8XX_MMCSDINT0
,
676 .end
= IRQ_DA8XX_MMCSDINT0
,
677 .flags
= IORESOURCE_IRQ
,
680 .start
= DA8XX_DMA_MMCSD0_RX
,
681 .end
= DA8XX_DMA_MMCSD0_RX
,
682 .flags
= IORESOURCE_DMA
,
685 .start
= DA8XX_DMA_MMCSD0_TX
,
686 .end
= DA8XX_DMA_MMCSD0_TX
,
687 .flags
= IORESOURCE_DMA
,
691 static struct platform_device da8xx_mmcsd0_device
= {
694 .num_resources
= ARRAY_SIZE(da8xx_mmcsd0_resources
),
695 .resource
= da8xx_mmcsd0_resources
,
698 int __init
da8xx_register_mmcsd0(struct davinci_mmc_config
*config
)
700 da8xx_mmcsd0_device
.dev
.platform_data
= config
;
701 return platform_device_register(&da8xx_mmcsd0_device
);
704 #ifdef CONFIG_ARCH_DAVINCI_DA850
705 static struct resource da850_mmcsd1_resources
[] = {
707 .start
= DA850_MMCSD1_BASE
,
708 .end
= DA850_MMCSD1_BASE
+ SZ_4K
- 1,
709 .flags
= IORESOURCE_MEM
,
712 .start
= IRQ_DA850_MMCSDINT0_1
,
713 .end
= IRQ_DA850_MMCSDINT0_1
,
714 .flags
= IORESOURCE_IRQ
,
717 .start
= DA850_DMA_MMCSD1_RX
,
718 .end
= DA850_DMA_MMCSD1_RX
,
719 .flags
= IORESOURCE_DMA
,
722 .start
= DA850_DMA_MMCSD1_TX
,
723 .end
= DA850_DMA_MMCSD1_TX
,
724 .flags
= IORESOURCE_DMA
,
728 static struct platform_device da850_mmcsd1_device
= {
731 .num_resources
= ARRAY_SIZE(da850_mmcsd1_resources
),
732 .resource
= da850_mmcsd1_resources
,
735 int __init
da850_register_mmcsd1(struct davinci_mmc_config
*config
)
737 da850_mmcsd1_device
.dev
.platform_data
= config
;
738 return platform_device_register(&da850_mmcsd1_device
);
742 static struct resource da8xx_rproc_resources
[] = {
743 { /* DSP boot address */
744 .start
= DA8XX_SYSCFG0_BASE
+ DA8XX_HOST1CFG_REG
,
745 .end
= DA8XX_SYSCFG0_BASE
+ DA8XX_HOST1CFG_REG
+ 3,
746 .flags
= IORESOURCE_MEM
,
748 { /* DSP interrupt registers */
749 .start
= DA8XX_SYSCFG0_BASE
+ DA8XX_CHIPSIG_REG
,
750 .end
= DA8XX_SYSCFG0_BASE
+ DA8XX_CHIPSIG_REG
+ 7,
751 .flags
= IORESOURCE_MEM
,
754 .start
= IRQ_DA8XX_CHIPINT0
,
755 .end
= IRQ_DA8XX_CHIPINT0
,
756 .flags
= IORESOURCE_IRQ
,
760 static struct platform_device da8xx_dsp
= {
761 .name
= "davinci-rproc",
763 .coherent_dma_mask
= DMA_BIT_MASK(32),
765 .num_resources
= ARRAY_SIZE(da8xx_rproc_resources
),
766 .resource
= da8xx_rproc_resources
,
769 #if IS_ENABLED(CONFIG_DA8XX_REMOTEPROC)
771 static phys_addr_t rproc_base __initdata
;
772 static unsigned long rproc_size __initdata
;
774 static int __init
early_rproc_mem(char *p
)
781 rproc_size
= memparse(p
, &endp
);
783 rproc_base
= memparse(endp
+ 1, NULL
);
787 early_param("rproc_mem", early_rproc_mem
);
789 void __init
da8xx_rproc_reserve_cma(void)
793 if (!rproc_base
|| !rproc_size
) {
794 pr_err("%s: 'rproc_mem=nn@address' badly specified\n"
795 " 'nn' and 'address' must both be non-zero\n",
801 pr_info("%s: reserving 0x%lx @ 0x%lx...\n",
802 __func__
, rproc_size
, (unsigned long)rproc_base
);
804 ret
= dma_declare_contiguous(&da8xx_dsp
.dev
, rproc_size
, rproc_base
, 0);
806 pr_err("%s: dma_declare_contiguous failed %d\n", __func__
, ret
);
811 void __init
da8xx_rproc_reserve_cma(void)
817 int __init
da8xx_register_rproc(void)
821 ret
= platform_device_register(&da8xx_dsp
);
823 pr_err("%s: can't register DSP device: %d\n", __func__
, ret
);
828 static struct resource da8xx_rtc_resources
[] = {
830 .start
= DA8XX_RTC_BASE
,
831 .end
= DA8XX_RTC_BASE
+ SZ_4K
- 1,
832 .flags
= IORESOURCE_MEM
,
835 .start
= IRQ_DA8XX_RTC
,
836 .end
= IRQ_DA8XX_RTC
,
837 .flags
= IORESOURCE_IRQ
,
840 .start
= IRQ_DA8XX_RTC
,
841 .end
= IRQ_DA8XX_RTC
,
842 .flags
= IORESOURCE_IRQ
,
846 static struct platform_device da8xx_rtc_device
= {
849 .num_resources
= ARRAY_SIZE(da8xx_rtc_resources
),
850 .resource
= da8xx_rtc_resources
,
853 int da8xx_register_rtc(void)
855 return platform_device_register(&da8xx_rtc_device
);
858 static void __iomem
*da8xx_ddr2_ctlr_base
;
859 void __iomem
* __init
da8xx_get_mem_ctlr(void)
861 if (da8xx_ddr2_ctlr_base
)
862 return da8xx_ddr2_ctlr_base
;
864 da8xx_ddr2_ctlr_base
= ioremap(DA8XX_DDR2_CTL_BASE
, SZ_32K
);
865 if (!da8xx_ddr2_ctlr_base
)
866 pr_warn("%s: Unable to map DDR2 controller", __func__
);
868 return da8xx_ddr2_ctlr_base
;
871 static struct resource da8xx_cpuidle_resources
[] = {
873 .start
= DA8XX_DDR2_CTL_BASE
,
874 .end
= DA8XX_DDR2_CTL_BASE
+ SZ_32K
- 1,
875 .flags
= IORESOURCE_MEM
,
879 /* DA8XX devices support DDR2 power down */
880 static struct davinci_cpuidle_config da8xx_cpuidle_pdata
= {
885 static struct platform_device da8xx_cpuidle_device
= {
886 .name
= "cpuidle-davinci",
887 .num_resources
= ARRAY_SIZE(da8xx_cpuidle_resources
),
888 .resource
= da8xx_cpuidle_resources
,
890 .platform_data
= &da8xx_cpuidle_pdata
,
894 int __init
da8xx_register_cpuidle(void)
896 da8xx_cpuidle_pdata
.ddr2_ctlr_base
= da8xx_get_mem_ctlr();
898 return platform_device_register(&da8xx_cpuidle_device
);
901 static struct resource da8xx_spi0_resources
[] = {
903 .start
= DA8XX_SPI0_BASE
,
904 .end
= DA8XX_SPI0_BASE
+ SZ_4K
- 1,
905 .flags
= IORESOURCE_MEM
,
908 .start
= IRQ_DA8XX_SPINT0
,
909 .end
= IRQ_DA8XX_SPINT0
,
910 .flags
= IORESOURCE_IRQ
,
913 .start
= DA8XX_DMA_SPI0_RX
,
914 .end
= DA8XX_DMA_SPI0_RX
,
915 .flags
= IORESOURCE_DMA
,
918 .start
= DA8XX_DMA_SPI0_TX
,
919 .end
= DA8XX_DMA_SPI0_TX
,
920 .flags
= IORESOURCE_DMA
,
924 static struct resource da8xx_spi1_resources
[] = {
926 .start
= DA830_SPI1_BASE
,
927 .end
= DA830_SPI1_BASE
+ SZ_4K
- 1,
928 .flags
= IORESOURCE_MEM
,
931 .start
= IRQ_DA8XX_SPINT1
,
932 .end
= IRQ_DA8XX_SPINT1
,
933 .flags
= IORESOURCE_IRQ
,
936 .start
= DA8XX_DMA_SPI1_RX
,
937 .end
= DA8XX_DMA_SPI1_RX
,
938 .flags
= IORESOURCE_DMA
,
941 .start
= DA8XX_DMA_SPI1_TX
,
942 .end
= DA8XX_DMA_SPI1_TX
,
943 .flags
= IORESOURCE_DMA
,
947 static struct davinci_spi_platform_data da8xx_spi_pdata
[] = {
949 .version
= SPI_VERSION_2
,
951 .dma_event_q
= EVENTQ_0
,
954 .version
= SPI_VERSION_2
,
956 .dma_event_q
= EVENTQ_0
,
960 static struct platform_device da8xx_spi_device
[] = {
962 .name
= "spi_davinci",
964 .num_resources
= ARRAY_SIZE(da8xx_spi0_resources
),
965 .resource
= da8xx_spi0_resources
,
967 .platform_data
= &da8xx_spi_pdata
[0],
971 .name
= "spi_davinci",
973 .num_resources
= ARRAY_SIZE(da8xx_spi1_resources
),
974 .resource
= da8xx_spi1_resources
,
976 .platform_data
= &da8xx_spi_pdata
[1],
981 int __init
da8xx_register_spi_bus(int instance
, unsigned num_chipselect
)
983 if (instance
< 0 || instance
> 1)
986 da8xx_spi_pdata
[instance
].num_chipselect
= num_chipselect
;
988 if (instance
== 1 && cpu_is_davinci_da850()) {
989 da8xx_spi1_resources
[0].start
= DA850_SPI1_BASE
;
990 da8xx_spi1_resources
[0].end
= DA850_SPI1_BASE
+ SZ_4K
- 1;
993 return platform_device_register(&da8xx_spi_device
[instance
]);
996 #ifdef CONFIG_ARCH_DAVINCI_DA850
998 static struct resource da850_sata_resources
[] = {
1000 .start
= DA850_SATA_BASE
,
1001 .end
= DA850_SATA_BASE
+ 0x1fff,
1002 .flags
= IORESOURCE_MEM
,
1005 .start
= IRQ_DA850_SATAINT
,
1006 .flags
= IORESOURCE_IRQ
,
1010 /* SATA PHY Control Register offset from AHCI base */
1011 #define SATA_P0PHYCR_REG 0x178
1013 #define SATA_PHY_MPY(x) ((x) << 0)
1014 #define SATA_PHY_LOS(x) ((x) << 6)
1015 #define SATA_PHY_RXCDR(x) ((x) << 10)
1016 #define SATA_PHY_RXEQ(x) ((x) << 13)
1017 #define SATA_PHY_TXSWING(x) ((x) << 19)
1018 #define SATA_PHY_ENPLL(x) ((x) << 31)
1020 static struct clk
*da850_sata_clk
;
1021 static unsigned long da850_sata_refclkpn
;
1023 /* Supported DA850 SATA crystal frequencies */
1024 #define KHZ_TO_HZ(freq) ((freq) * 1000)
1025 static unsigned long da850_sata_xtal
[] = {
1038 static int da850_sata_init(struct device
*dev
, void __iomem
*addr
)
1043 da850_sata_clk
= clk_get(dev
, NULL
);
1044 if (IS_ERR(da850_sata_clk
))
1045 return PTR_ERR(da850_sata_clk
);
1047 ret
= clk_prepare_enable(da850_sata_clk
);
1051 /* Enable SATA clock receiver */
1052 val
= __raw_readl(DA8XX_SYSCFG1_VIRT(DA8XX_PWRDN_REG
));
1054 __raw_writel(val
, DA8XX_SYSCFG1_VIRT(DA8XX_PWRDN_REG
));
1056 /* Get the multiplier needed for 1.5GHz PLL output */
1057 for (i
= 0; i
< ARRAY_SIZE(da850_sata_xtal
); i
++)
1058 if (da850_sata_xtal
[i
] == da850_sata_refclkpn
)
1061 if (i
== ARRAY_SIZE(da850_sata_xtal
)) {
1066 val
= SATA_PHY_MPY(i
+ 1) |
1070 SATA_PHY_TXSWING(3) |
1073 __raw_writel(val
, addr
+ SATA_P0PHYCR_REG
);
1078 clk_disable_unprepare(da850_sata_clk
);
1080 clk_put(da850_sata_clk
);
1084 static void da850_sata_exit(struct device
*dev
)
1086 clk_disable_unprepare(da850_sata_clk
);
1087 clk_put(da850_sata_clk
);
1090 static struct ahci_platform_data da850_sata_pdata
= {
1091 .init
= da850_sata_init
,
1092 .exit
= da850_sata_exit
,
1095 static u64 da850_sata_dmamask
= DMA_BIT_MASK(32);
1097 static struct platform_device da850_sata_device
= {
1101 .platform_data
= &da850_sata_pdata
,
1102 .dma_mask
= &da850_sata_dmamask
,
1103 .coherent_dma_mask
= DMA_BIT_MASK(32),
1105 .num_resources
= ARRAY_SIZE(da850_sata_resources
),
1106 .resource
= da850_sata_resources
,
1109 int __init
da850_register_sata(unsigned long refclkpn
)
1111 da850_sata_refclkpn
= refclkpn
;
1112 if (!da850_sata_refclkpn
)
1115 return platform_device_register(&da850_sata_device
);