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-mapping.h>
16 #include <linux/serial_8250.h>
17 #include <linux/ahci_platform.h>
18 #include <linux/clk.h>
20 #include <mach/cputype.h>
21 #include <mach/common.h>
22 #include <mach/time.h>
23 #include <mach/da8xx.h>
24 #include <mach/cpuidle.h>
28 #define DA8XX_TPCC_BASE 0x01c00000
29 #define DA8XX_TPTC0_BASE 0x01c08000
30 #define DA8XX_TPTC1_BASE 0x01c08400
31 #define DA8XX_WDOG_BASE 0x01c21000 /* DA8XX_TIMER64P1_BASE */
32 #define DA8XX_I2C0_BASE 0x01c22000
33 #define DA8XX_RTC_BASE 0x01c23000
34 #define DA8XX_MMCSD0_BASE 0x01c40000
35 #define DA8XX_SPI0_BASE 0x01c41000
36 #define DA830_SPI1_BASE 0x01e12000
37 #define DA8XX_LCD_CNTRL_BASE 0x01e13000
38 #define DA850_SATA_BASE 0x01e18000
39 #define DA850_MMCSD1_BASE 0x01e1b000
40 #define DA8XX_EMAC_CPPI_PORT_BASE 0x01e20000
41 #define DA8XX_EMAC_CPGMACSS_BASE 0x01e22000
42 #define DA8XX_EMAC_CPGMAC_BASE 0x01e23000
43 #define DA8XX_EMAC_MDIO_BASE 0x01e24000
44 #define DA8XX_I2C1_BASE 0x01e28000
45 #define DA850_TPCC1_BASE 0x01e30000
46 #define DA850_TPTC2_BASE 0x01e38000
47 #define DA850_SPI1_BASE 0x01f0e000
48 #define DA8XX_DDR2_CTL_BASE 0xb0000000
50 #define DA8XX_EMAC_CTRL_REG_OFFSET 0x3000
51 #define DA8XX_EMAC_MOD_REG_OFFSET 0x2000
52 #define DA8XX_EMAC_RAM_OFFSET 0x0000
53 #define DA8XX_EMAC_CTRL_RAM_SIZE SZ_8K
55 #define DA8XX_DMA_SPI0_RX EDMA_CTLR_CHAN(0, 14)
56 #define DA8XX_DMA_SPI0_TX EDMA_CTLR_CHAN(0, 15)
57 #define DA8XX_DMA_MMCSD0_RX EDMA_CTLR_CHAN(0, 16)
58 #define DA8XX_DMA_MMCSD0_TX EDMA_CTLR_CHAN(0, 17)
59 #define DA8XX_DMA_SPI1_RX EDMA_CTLR_CHAN(0, 18)
60 #define DA8XX_DMA_SPI1_TX EDMA_CTLR_CHAN(0, 19)
61 #define DA850_DMA_MMCSD1_RX EDMA_CTLR_CHAN(1, 28)
62 #define DA850_DMA_MMCSD1_TX EDMA_CTLR_CHAN(1, 29)
64 void __iomem
*da8xx_syscfg0_base
;
65 void __iomem
*da8xx_syscfg1_base
;
67 static struct plat_serial8250_port da8xx_serial_pdata
[] = {
69 .mapbase
= DA8XX_UART0_BASE
,
70 .irq
= IRQ_DA8XX_UARTINT0
,
71 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
|
77 .mapbase
= DA8XX_UART1_BASE
,
78 .irq
= IRQ_DA8XX_UARTINT1
,
79 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
|
85 .mapbase
= DA8XX_UART2_BASE
,
86 .irq
= IRQ_DA8XX_UARTINT2
,
87 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
|
97 struct platform_device da8xx_serial_device
= {
99 .id
= PLAT8250_DEV_PLATFORM
,
101 .platform_data
= da8xx_serial_pdata
,
105 static const s8 da8xx_queue_tc_mapping
[][2] = {
106 /* {event queue no, TC no} */
112 static const s8 da8xx_queue_priority_mapping
[][2] = {
113 /* {event queue no, Priority} */
119 static const s8 da850_queue_tc_mapping
[][2] = {
120 /* {event queue no, TC no} */
125 static const s8 da850_queue_priority_mapping
[][2] = {
126 /* {event queue no, Priority} */
131 static struct edma_soc_info da830_edma_cc0_info
= {
137 .queue_tc_mapping
= da8xx_queue_tc_mapping
,
138 .queue_priority_mapping
= da8xx_queue_priority_mapping
,
139 .default_queue
= EVENTQ_1
,
142 static struct edma_soc_info
*da830_edma_info
[EDMA_MAX_CC
] = {
143 &da830_edma_cc0_info
,
146 static struct edma_soc_info da850_edma_cc_info
[] = {
153 .queue_tc_mapping
= da8xx_queue_tc_mapping
,
154 .queue_priority_mapping
= da8xx_queue_priority_mapping
,
155 .default_queue
= EVENTQ_1
,
163 .queue_tc_mapping
= da850_queue_tc_mapping
,
164 .queue_priority_mapping
= da850_queue_priority_mapping
,
165 .default_queue
= EVENTQ_0
,
169 static struct edma_soc_info
*da850_edma_info
[EDMA_MAX_CC
] = {
170 &da850_edma_cc_info
[0],
171 &da850_edma_cc_info
[1],
174 static struct resource da830_edma_resources
[] = {
177 .start
= DA8XX_TPCC_BASE
,
178 .end
= DA8XX_TPCC_BASE
+ SZ_32K
- 1,
179 .flags
= IORESOURCE_MEM
,
183 .start
= DA8XX_TPTC0_BASE
,
184 .end
= DA8XX_TPTC0_BASE
+ SZ_1K
- 1,
185 .flags
= IORESOURCE_MEM
,
189 .start
= DA8XX_TPTC1_BASE
,
190 .end
= DA8XX_TPTC1_BASE
+ SZ_1K
- 1,
191 .flags
= IORESOURCE_MEM
,
195 .start
= IRQ_DA8XX_CCINT0
,
196 .flags
= IORESOURCE_IRQ
,
200 .start
= IRQ_DA8XX_CCERRINT
,
201 .flags
= IORESOURCE_IRQ
,
205 static struct resource da850_edma_resources
[] = {
208 .start
= DA8XX_TPCC_BASE
,
209 .end
= DA8XX_TPCC_BASE
+ SZ_32K
- 1,
210 .flags
= IORESOURCE_MEM
,
214 .start
= DA8XX_TPTC0_BASE
,
215 .end
= DA8XX_TPTC0_BASE
+ SZ_1K
- 1,
216 .flags
= IORESOURCE_MEM
,
220 .start
= DA8XX_TPTC1_BASE
,
221 .end
= DA8XX_TPTC1_BASE
+ SZ_1K
- 1,
222 .flags
= IORESOURCE_MEM
,
226 .start
= DA850_TPCC1_BASE
,
227 .end
= DA850_TPCC1_BASE
+ SZ_32K
- 1,
228 .flags
= IORESOURCE_MEM
,
232 .start
= DA850_TPTC2_BASE
,
233 .end
= DA850_TPTC2_BASE
+ SZ_1K
- 1,
234 .flags
= IORESOURCE_MEM
,
238 .start
= IRQ_DA8XX_CCINT0
,
239 .flags
= IORESOURCE_IRQ
,
243 .start
= IRQ_DA8XX_CCERRINT
,
244 .flags
= IORESOURCE_IRQ
,
248 .start
= IRQ_DA850_CCINT1
,
249 .flags
= IORESOURCE_IRQ
,
253 .start
= IRQ_DA850_CCERRINT1
,
254 .flags
= IORESOURCE_IRQ
,
258 static struct platform_device da830_edma_device
= {
262 .platform_data
= da830_edma_info
,
264 .num_resources
= ARRAY_SIZE(da830_edma_resources
),
265 .resource
= da830_edma_resources
,
268 static struct platform_device da850_edma_device
= {
272 .platform_data
= da850_edma_info
,
274 .num_resources
= ARRAY_SIZE(da850_edma_resources
),
275 .resource
= da850_edma_resources
,
278 int __init
da830_register_edma(struct edma_rsv_info
*rsv
)
280 da830_edma_cc0_info
.rsv
= rsv
;
282 return platform_device_register(&da830_edma_device
);
285 int __init
da850_register_edma(struct edma_rsv_info
*rsv
[2])
288 da850_edma_cc_info
[0].rsv
= rsv
[0];
289 da850_edma_cc_info
[1].rsv
= rsv
[1];
292 return platform_device_register(&da850_edma_device
);
295 static struct resource da8xx_i2c_resources0
[] = {
297 .start
= DA8XX_I2C0_BASE
,
298 .end
= DA8XX_I2C0_BASE
+ SZ_4K
- 1,
299 .flags
= IORESOURCE_MEM
,
302 .start
= IRQ_DA8XX_I2CINT0
,
303 .end
= IRQ_DA8XX_I2CINT0
,
304 .flags
= IORESOURCE_IRQ
,
308 static struct platform_device da8xx_i2c_device0
= {
309 .name
= "i2c_davinci",
311 .num_resources
= ARRAY_SIZE(da8xx_i2c_resources0
),
312 .resource
= da8xx_i2c_resources0
,
315 static struct resource da8xx_i2c_resources1
[] = {
317 .start
= DA8XX_I2C1_BASE
,
318 .end
= DA8XX_I2C1_BASE
+ SZ_4K
- 1,
319 .flags
= IORESOURCE_MEM
,
322 .start
= IRQ_DA8XX_I2CINT1
,
323 .end
= IRQ_DA8XX_I2CINT1
,
324 .flags
= IORESOURCE_IRQ
,
328 static struct platform_device da8xx_i2c_device1
= {
329 .name
= "i2c_davinci",
331 .num_resources
= ARRAY_SIZE(da8xx_i2c_resources1
),
332 .resource
= da8xx_i2c_resources1
,
335 int __init
da8xx_register_i2c(int instance
,
336 struct davinci_i2c_platform_data
*pdata
)
338 struct platform_device
*pdev
;
341 pdev
= &da8xx_i2c_device0
;
342 else if (instance
== 1)
343 pdev
= &da8xx_i2c_device1
;
347 pdev
->dev
.platform_data
= pdata
;
348 return platform_device_register(pdev
);
351 static struct resource da8xx_watchdog_resources
[] = {
353 .start
= DA8XX_WDOG_BASE
,
354 .end
= DA8XX_WDOG_BASE
+ SZ_4K
- 1,
355 .flags
= IORESOURCE_MEM
,
359 struct platform_device da8xx_wdt_device
= {
362 .num_resources
= ARRAY_SIZE(da8xx_watchdog_resources
),
363 .resource
= da8xx_watchdog_resources
,
366 int __init
da8xx_register_watchdog(void)
368 return platform_device_register(&da8xx_wdt_device
);
371 static struct resource da8xx_emac_resources
[] = {
373 .start
= DA8XX_EMAC_CPPI_PORT_BASE
,
374 .end
= DA8XX_EMAC_CPPI_PORT_BASE
+ SZ_16K
- 1,
375 .flags
= IORESOURCE_MEM
,
378 .start
= IRQ_DA8XX_C0_RX_THRESH_PULSE
,
379 .end
= IRQ_DA8XX_C0_RX_THRESH_PULSE
,
380 .flags
= IORESOURCE_IRQ
,
383 .start
= IRQ_DA8XX_C0_RX_PULSE
,
384 .end
= IRQ_DA8XX_C0_RX_PULSE
,
385 .flags
= IORESOURCE_IRQ
,
388 .start
= IRQ_DA8XX_C0_TX_PULSE
,
389 .end
= IRQ_DA8XX_C0_TX_PULSE
,
390 .flags
= IORESOURCE_IRQ
,
393 .start
= IRQ_DA8XX_C0_MISC_PULSE
,
394 .end
= IRQ_DA8XX_C0_MISC_PULSE
,
395 .flags
= IORESOURCE_IRQ
,
399 struct emac_platform_data da8xx_emac_pdata
= {
400 .ctrl_reg_offset
= DA8XX_EMAC_CTRL_REG_OFFSET
,
401 .ctrl_mod_reg_offset
= DA8XX_EMAC_MOD_REG_OFFSET
,
402 .ctrl_ram_offset
= DA8XX_EMAC_RAM_OFFSET
,
403 .ctrl_ram_size
= DA8XX_EMAC_CTRL_RAM_SIZE
,
404 .version
= EMAC_VERSION_2
,
407 static struct platform_device da8xx_emac_device
= {
408 .name
= "davinci_emac",
411 .platform_data
= &da8xx_emac_pdata
,
413 .num_resources
= ARRAY_SIZE(da8xx_emac_resources
),
414 .resource
= da8xx_emac_resources
,
417 static struct resource da8xx_mdio_resources
[] = {
419 .start
= DA8XX_EMAC_MDIO_BASE
,
420 .end
= DA8XX_EMAC_MDIO_BASE
+ SZ_4K
- 1,
421 .flags
= IORESOURCE_MEM
,
425 static struct platform_device da8xx_mdio_device
= {
426 .name
= "davinci_mdio",
428 .num_resources
= ARRAY_SIZE(da8xx_mdio_resources
),
429 .resource
= da8xx_mdio_resources
,
432 int __init
da8xx_register_emac(void)
436 ret
= platform_device_register(&da8xx_mdio_device
);
439 ret
= platform_device_register(&da8xx_emac_device
);
442 ret
= clk_add_alias(NULL
, dev_name(&da8xx_mdio_device
.dev
),
443 NULL
, &da8xx_emac_device
.dev
);
447 static struct resource da830_mcasp1_resources
[] = {
450 .start
= DAVINCI_DA830_MCASP1_REG_BASE
,
451 .end
= DAVINCI_DA830_MCASP1_REG_BASE
+ (SZ_1K
* 12) - 1,
452 .flags
= IORESOURCE_MEM
,
456 .start
= DAVINCI_DA830_DMA_MCASP1_AXEVT
,
457 .end
= DAVINCI_DA830_DMA_MCASP1_AXEVT
,
458 .flags
= IORESOURCE_DMA
,
462 .start
= DAVINCI_DA830_DMA_MCASP1_AREVT
,
463 .end
= DAVINCI_DA830_DMA_MCASP1_AREVT
,
464 .flags
= IORESOURCE_DMA
,
468 static struct platform_device da830_mcasp1_device
= {
469 .name
= "davinci-mcasp",
471 .num_resources
= ARRAY_SIZE(da830_mcasp1_resources
),
472 .resource
= da830_mcasp1_resources
,
475 static struct resource da850_mcasp_resources
[] = {
478 .start
= DAVINCI_DA8XX_MCASP0_REG_BASE
,
479 .end
= DAVINCI_DA8XX_MCASP0_REG_BASE
+ (SZ_1K
* 12) - 1,
480 .flags
= IORESOURCE_MEM
,
484 .start
= DAVINCI_DA8XX_DMA_MCASP0_AXEVT
,
485 .end
= DAVINCI_DA8XX_DMA_MCASP0_AXEVT
,
486 .flags
= IORESOURCE_DMA
,
490 .start
= DAVINCI_DA8XX_DMA_MCASP0_AREVT
,
491 .end
= DAVINCI_DA8XX_DMA_MCASP0_AREVT
,
492 .flags
= IORESOURCE_DMA
,
496 static struct platform_device da850_mcasp_device
= {
497 .name
= "davinci-mcasp",
499 .num_resources
= ARRAY_SIZE(da850_mcasp_resources
),
500 .resource
= da850_mcasp_resources
,
503 static struct platform_device davinci_pcm_device
= {
504 .name
= "davinci-pcm-audio",
508 void __init
da8xx_register_mcasp(int id
, struct snd_platform_data
*pdata
)
510 platform_device_register(&davinci_pcm_device
);
512 /* DA830/OMAP-L137 has 3 instances of McASP */
513 if (cpu_is_davinci_da830() && id
== 1) {
514 da830_mcasp1_device
.dev
.platform_data
= pdata
;
515 platform_device_register(&da830_mcasp1_device
);
516 } else if (cpu_is_davinci_da850()) {
517 da850_mcasp_device
.dev
.platform_data
= pdata
;
518 platform_device_register(&da850_mcasp_device
);
522 static const struct display_panel disp_panel
= {
529 static struct lcd_ctrl_config lcd_cfg
= {
539 .invert_line_clock
= 1,
540 .invert_frm_clock
= 1,
546 struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata
= {
547 .manu_name
= "sharp",
548 .controller_data
= &lcd_cfg
,
549 .type
= "Sharp_LCD035Q3DG01",
552 struct da8xx_lcdc_platform_data sharp_lk043t1dg01_pdata
= {
553 .manu_name
= "sharp",
554 .controller_data
= &lcd_cfg
,
555 .type
= "Sharp_LK043T1DG01",
558 static struct resource da8xx_lcdc_resources
[] = {
559 [0] = { /* registers */
560 .start
= DA8XX_LCD_CNTRL_BASE
,
561 .end
= DA8XX_LCD_CNTRL_BASE
+ SZ_4K
- 1,
562 .flags
= IORESOURCE_MEM
,
564 [1] = { /* interrupt */
565 .start
= IRQ_DA8XX_LCDINT
,
566 .end
= IRQ_DA8XX_LCDINT
,
567 .flags
= IORESOURCE_IRQ
,
571 static struct platform_device da8xx_lcdc_device
= {
572 .name
= "da8xx_lcdc",
574 .num_resources
= ARRAY_SIZE(da8xx_lcdc_resources
),
575 .resource
= da8xx_lcdc_resources
,
578 int __init
da8xx_register_lcdc(struct da8xx_lcdc_platform_data
*pdata
)
580 da8xx_lcdc_device
.dev
.platform_data
= pdata
;
581 return platform_device_register(&da8xx_lcdc_device
);
584 static struct resource da8xx_mmcsd0_resources
[] = {
586 .start
= DA8XX_MMCSD0_BASE
,
587 .end
= DA8XX_MMCSD0_BASE
+ SZ_4K
- 1,
588 .flags
= IORESOURCE_MEM
,
591 .start
= IRQ_DA8XX_MMCSDINT0
,
592 .end
= IRQ_DA8XX_MMCSDINT0
,
593 .flags
= IORESOURCE_IRQ
,
596 .start
= DA8XX_DMA_MMCSD0_RX
,
597 .end
= DA8XX_DMA_MMCSD0_RX
,
598 .flags
= IORESOURCE_DMA
,
601 .start
= DA8XX_DMA_MMCSD0_TX
,
602 .end
= DA8XX_DMA_MMCSD0_TX
,
603 .flags
= IORESOURCE_DMA
,
607 static struct platform_device da8xx_mmcsd0_device
= {
608 .name
= "davinci_mmc",
610 .num_resources
= ARRAY_SIZE(da8xx_mmcsd0_resources
),
611 .resource
= da8xx_mmcsd0_resources
,
614 int __init
da8xx_register_mmcsd0(struct davinci_mmc_config
*config
)
616 da8xx_mmcsd0_device
.dev
.platform_data
= config
;
617 return platform_device_register(&da8xx_mmcsd0_device
);
620 #ifdef CONFIG_ARCH_DAVINCI_DA850
621 static struct resource da850_mmcsd1_resources
[] = {
623 .start
= DA850_MMCSD1_BASE
,
624 .end
= DA850_MMCSD1_BASE
+ SZ_4K
- 1,
625 .flags
= IORESOURCE_MEM
,
628 .start
= IRQ_DA850_MMCSDINT0_1
,
629 .end
= IRQ_DA850_MMCSDINT0_1
,
630 .flags
= IORESOURCE_IRQ
,
633 .start
= DA850_DMA_MMCSD1_RX
,
634 .end
= DA850_DMA_MMCSD1_RX
,
635 .flags
= IORESOURCE_DMA
,
638 .start
= DA850_DMA_MMCSD1_TX
,
639 .end
= DA850_DMA_MMCSD1_TX
,
640 .flags
= IORESOURCE_DMA
,
644 static struct platform_device da850_mmcsd1_device
= {
645 .name
= "davinci_mmc",
647 .num_resources
= ARRAY_SIZE(da850_mmcsd1_resources
),
648 .resource
= da850_mmcsd1_resources
,
651 int __init
da850_register_mmcsd1(struct davinci_mmc_config
*config
)
653 da850_mmcsd1_device
.dev
.platform_data
= config
;
654 return platform_device_register(&da850_mmcsd1_device
);
658 static struct resource da8xx_rtc_resources
[] = {
660 .start
= DA8XX_RTC_BASE
,
661 .end
= DA8XX_RTC_BASE
+ SZ_4K
- 1,
662 .flags
= IORESOURCE_MEM
,
665 .start
= IRQ_DA8XX_RTC
,
666 .end
= IRQ_DA8XX_RTC
,
667 .flags
= IORESOURCE_IRQ
,
670 .start
= IRQ_DA8XX_RTC
,
671 .end
= IRQ_DA8XX_RTC
,
672 .flags
= IORESOURCE_IRQ
,
676 static struct platform_device da8xx_rtc_device
= {
679 .num_resources
= ARRAY_SIZE(da8xx_rtc_resources
),
680 .resource
= da8xx_rtc_resources
,
683 int da8xx_register_rtc(void)
688 base
= ioremap(DA8XX_RTC_BASE
, SZ_4K
);
692 /* Unlock the rtc's registers */
693 __raw_writel(0x83e70b13, base
+ 0x6c);
694 __raw_writel(0x95a4f1e0, base
+ 0x70);
698 ret
= platform_device_register(&da8xx_rtc_device
);
700 /* Atleast on DA850, RTC is a wakeup source */
701 device_init_wakeup(&da8xx_rtc_device
.dev
, true);
706 static void __iomem
*da8xx_ddr2_ctlr_base
;
707 void __iomem
* __init
da8xx_get_mem_ctlr(void)
709 if (da8xx_ddr2_ctlr_base
)
710 return da8xx_ddr2_ctlr_base
;
712 da8xx_ddr2_ctlr_base
= ioremap(DA8XX_DDR2_CTL_BASE
, SZ_32K
);
713 if (!da8xx_ddr2_ctlr_base
)
714 pr_warning("%s: Unable to map DDR2 controller", __func__
);
716 return da8xx_ddr2_ctlr_base
;
719 static struct resource da8xx_cpuidle_resources
[] = {
721 .start
= DA8XX_DDR2_CTL_BASE
,
722 .end
= DA8XX_DDR2_CTL_BASE
+ SZ_32K
- 1,
723 .flags
= IORESOURCE_MEM
,
727 /* DA8XX devices support DDR2 power down */
728 static struct davinci_cpuidle_config da8xx_cpuidle_pdata
= {
733 static struct platform_device da8xx_cpuidle_device
= {
734 .name
= "cpuidle-davinci",
735 .num_resources
= ARRAY_SIZE(da8xx_cpuidle_resources
),
736 .resource
= da8xx_cpuidle_resources
,
738 .platform_data
= &da8xx_cpuidle_pdata
,
742 int __init
da8xx_register_cpuidle(void)
744 da8xx_cpuidle_pdata
.ddr2_ctlr_base
= da8xx_get_mem_ctlr();
746 return platform_device_register(&da8xx_cpuidle_device
);
749 static struct resource da8xx_spi0_resources
[] = {
751 .start
= DA8XX_SPI0_BASE
,
752 .end
= DA8XX_SPI0_BASE
+ SZ_4K
- 1,
753 .flags
= IORESOURCE_MEM
,
756 .start
= IRQ_DA8XX_SPINT0
,
757 .end
= IRQ_DA8XX_SPINT0
,
758 .flags
= IORESOURCE_IRQ
,
761 .start
= DA8XX_DMA_SPI0_RX
,
762 .end
= DA8XX_DMA_SPI0_RX
,
763 .flags
= IORESOURCE_DMA
,
766 .start
= DA8XX_DMA_SPI0_TX
,
767 .end
= DA8XX_DMA_SPI0_TX
,
768 .flags
= IORESOURCE_DMA
,
772 static struct resource da8xx_spi1_resources
[] = {
774 .start
= DA830_SPI1_BASE
,
775 .end
= DA830_SPI1_BASE
+ SZ_4K
- 1,
776 .flags
= IORESOURCE_MEM
,
779 .start
= IRQ_DA8XX_SPINT1
,
780 .end
= IRQ_DA8XX_SPINT1
,
781 .flags
= IORESOURCE_IRQ
,
784 .start
= DA8XX_DMA_SPI1_RX
,
785 .end
= DA8XX_DMA_SPI1_RX
,
786 .flags
= IORESOURCE_DMA
,
789 .start
= DA8XX_DMA_SPI1_TX
,
790 .end
= DA8XX_DMA_SPI1_TX
,
791 .flags
= IORESOURCE_DMA
,
795 struct davinci_spi_platform_data da8xx_spi_pdata
[] = {
797 .version
= SPI_VERSION_2
,
799 .dma_event_q
= EVENTQ_0
,
802 .version
= SPI_VERSION_2
,
804 .dma_event_q
= EVENTQ_0
,
808 static struct platform_device da8xx_spi_device
[] = {
810 .name
= "spi_davinci",
812 .num_resources
= ARRAY_SIZE(da8xx_spi0_resources
),
813 .resource
= da8xx_spi0_resources
,
815 .platform_data
= &da8xx_spi_pdata
[0],
819 .name
= "spi_davinci",
821 .num_resources
= ARRAY_SIZE(da8xx_spi1_resources
),
822 .resource
= da8xx_spi1_resources
,
824 .platform_data
= &da8xx_spi_pdata
[1],
829 int __init
da8xx_register_spi(int instance
, struct spi_board_info
*info
,
834 if (instance
< 0 || instance
> 1)
837 ret
= spi_register_board_info(info
, len
);
839 pr_warning("%s: failed to register board info for spi %d :"
840 " %d\n", __func__
, instance
, ret
);
842 da8xx_spi_pdata
[instance
].num_chipselect
= len
;
844 if (instance
== 1 && cpu_is_davinci_da850()) {
845 da8xx_spi1_resources
[0].start
= DA850_SPI1_BASE
;
846 da8xx_spi1_resources
[0].end
= DA850_SPI1_BASE
+ SZ_4K
- 1;
849 return platform_device_register(&da8xx_spi_device
[instance
]);
852 #ifdef CONFIG_ARCH_DAVINCI_DA850
854 static struct resource da850_sata_resources
[] = {
856 .start
= DA850_SATA_BASE
,
857 .end
= DA850_SATA_BASE
+ 0x1fff,
858 .flags
= IORESOURCE_MEM
,
861 .start
= IRQ_DA850_SATAINT
,
862 .flags
= IORESOURCE_IRQ
,
866 /* SATA PHY Control Register offset from AHCI base */
867 #define SATA_P0PHYCR_REG 0x178
869 #define SATA_PHY_MPY(x) ((x) << 0)
870 #define SATA_PHY_LOS(x) ((x) << 6)
871 #define SATA_PHY_RXCDR(x) ((x) << 10)
872 #define SATA_PHY_RXEQ(x) ((x) << 13)
873 #define SATA_PHY_TXSWING(x) ((x) << 19)
874 #define SATA_PHY_ENPLL(x) ((x) << 31)
876 static struct clk
*da850_sata_clk
;
877 static unsigned long da850_sata_refclkpn
;
879 /* Supported DA850 SATA crystal frequencies */
880 #define KHZ_TO_HZ(freq) ((freq) * 1000)
881 static unsigned long da850_sata_xtal
[] = {
894 static int da850_sata_init(struct device
*dev
, void __iomem
*addr
)
899 da850_sata_clk
= clk_get(dev
, NULL
);
900 if (IS_ERR(da850_sata_clk
))
901 return PTR_ERR(da850_sata_clk
);
903 ret
= clk_enable(da850_sata_clk
);
907 /* Enable SATA clock receiver */
908 val
= __raw_readl(DA8XX_SYSCFG1_VIRT(DA8XX_PWRDN_REG
));
910 __raw_writel(val
, DA8XX_SYSCFG1_VIRT(DA8XX_PWRDN_REG
));
912 /* Get the multiplier needed for 1.5GHz PLL output */
913 for (i
= 0; i
< ARRAY_SIZE(da850_sata_xtal
); i
++)
914 if (da850_sata_xtal
[i
] == da850_sata_refclkpn
)
917 if (i
== ARRAY_SIZE(da850_sata_xtal
)) {
922 val
= SATA_PHY_MPY(i
+ 1) |
926 SATA_PHY_TXSWING(3) |
929 __raw_writel(val
, addr
+ SATA_P0PHYCR_REG
);
934 clk_disable(da850_sata_clk
);
936 clk_put(da850_sata_clk
);
940 static void da850_sata_exit(struct device
*dev
)
942 clk_disable(da850_sata_clk
);
943 clk_put(da850_sata_clk
);
946 static struct ahci_platform_data da850_sata_pdata
= {
947 .init
= da850_sata_init
,
948 .exit
= da850_sata_exit
,
951 static u64 da850_sata_dmamask
= DMA_BIT_MASK(32);
953 static struct platform_device da850_sata_device
= {
957 .platform_data
= &da850_sata_pdata
,
958 .dma_mask
= &da850_sata_dmamask
,
959 .coherent_dma_mask
= DMA_BIT_MASK(32),
961 .num_resources
= ARRAY_SIZE(da850_sata_resources
),
962 .resource
= da850_sata_resources
,
965 int __init
da850_register_sata(unsigned long refclkpn
)
967 da850_sata_refclkpn
= refclkpn
;
968 if (!da850_sata_refclkpn
)
971 return platform_device_register(&da850_sata_device
);