mm: make wait_on_page_writeback() wait for multiple pending writebacks
[linux/fpc-iii.git] / arch / arm / mach-davinci / devices-da8xx.c
blobbb368938fc49214faae7be0ed62dbc02196a2786
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * DA8XX/OMAP L1XX platform device data
5 * Copyright (c) 2007-2009, MontaVista Software, Inc. <source@mvista.com>
6 * Derived from code that was:
7 * Copyright (C) 2006 Komal Shah <komal_shah802003@yahoo.com>
8 */
9 #include <linux/ahci_platform.h>
10 #include <linux/clk-provider.h>
11 #include <linux/clk.h>
12 #include <linux/clkdev.h>
13 #include <linux/dma-map-ops.h>
14 #include <linux/dmaengine.h>
15 #include <linux/init.h>
16 #include <linux/io.h>
17 #include <linux/platform_device.h>
18 #include <linux/reboot.h>
19 #include <linux/serial_8250.h>
21 #include <mach/common.h>
22 #include <mach/cputype.h>
23 #include <mach/da8xx.h>
25 #include "asp.h"
26 #include "cpuidle.h"
27 #include "irqs.h"
28 #include "sram.h"
30 #define DA8XX_TPCC_BASE 0x01c00000
31 #define DA8XX_TPTC0_BASE 0x01c08000
32 #define DA8XX_TPTC1_BASE 0x01c08400
33 #define DA8XX_WDOG_BASE 0x01c21000 /* DA8XX_TIMER64P1_BASE */
34 #define DA8XX_I2C0_BASE 0x01c22000
35 #define DA8XX_RTC_BASE 0x01c23000
36 #define DA8XX_PRUSS_MEM_BASE 0x01c30000
37 #define DA8XX_MMCSD0_BASE 0x01c40000
38 #define DA8XX_SPI0_BASE 0x01c41000
39 #define DA830_SPI1_BASE 0x01e12000
40 #define DA8XX_LCD_CNTRL_BASE 0x01e13000
41 #define DA850_SATA_BASE 0x01e18000
42 #define DA850_MMCSD1_BASE 0x01e1b000
43 #define DA8XX_EMAC_CPPI_PORT_BASE 0x01e20000
44 #define DA8XX_EMAC_CPGMACSS_BASE 0x01e22000
45 #define DA8XX_EMAC_CPGMAC_BASE 0x01e23000
46 #define DA8XX_EMAC_MDIO_BASE 0x01e24000
47 #define DA8XX_I2C1_BASE 0x01e28000
48 #define DA850_TPCC1_BASE 0x01e30000
49 #define DA850_TPTC2_BASE 0x01e38000
50 #define DA850_SPI1_BASE 0x01f0e000
51 #define DA8XX_DDR2_CTL_BASE 0xb0000000
53 #define DA8XX_EMAC_CTRL_REG_OFFSET 0x3000
54 #define DA8XX_EMAC_MOD_REG_OFFSET 0x2000
55 #define DA8XX_EMAC_RAM_OFFSET 0x0000
56 #define DA8XX_EMAC_CTRL_RAM_SIZE SZ_8K
58 void __iomem *da8xx_syscfg0_base;
59 void __iomem *da8xx_syscfg1_base;
61 static struct plat_serial8250_port da8xx_serial0_pdata[] = {
63 .mapbase = DA8XX_UART0_BASE,
64 .irq = DAVINCI_INTC_IRQ(IRQ_DA8XX_UARTINT0),
65 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
66 UPF_IOREMAP,
67 .iotype = UPIO_MEM,
68 .regshift = 2,
71 .flags = 0,
74 static struct plat_serial8250_port da8xx_serial1_pdata[] = {
76 .mapbase = DA8XX_UART1_BASE,
77 .irq = DAVINCI_INTC_IRQ(IRQ_DA8XX_UARTINT1),
78 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
79 UPF_IOREMAP,
80 .iotype = UPIO_MEM,
81 .regshift = 2,
84 .flags = 0,
87 static struct plat_serial8250_port da8xx_serial2_pdata[] = {
89 .mapbase = DA8XX_UART2_BASE,
90 .irq = DAVINCI_INTC_IRQ(IRQ_DA8XX_UARTINT2),
91 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
92 UPF_IOREMAP,
93 .iotype = UPIO_MEM,
94 .regshift = 2,
97 .flags = 0,
101 struct platform_device da8xx_serial_device[] = {
103 .name = "serial8250",
104 .id = PLAT8250_DEV_PLATFORM,
105 .dev = {
106 .platform_data = da8xx_serial0_pdata,
110 .name = "serial8250",
111 .id = PLAT8250_DEV_PLATFORM1,
112 .dev = {
113 .platform_data = da8xx_serial1_pdata,
117 .name = "serial8250",
118 .id = PLAT8250_DEV_PLATFORM2,
119 .dev = {
120 .platform_data = da8xx_serial2_pdata,
127 static s8 da8xx_queue_priority_mapping[][2] = {
128 /* {event queue no, Priority} */
129 {0, 3},
130 {1, 7},
131 {-1, -1}
134 static s8 da850_queue_priority_mapping[][2] = {
135 /* {event queue no, Priority} */
136 {0, 3},
137 {-1, -1}
140 static struct edma_soc_info da8xx_edma0_pdata = {
141 .queue_priority_mapping = da8xx_queue_priority_mapping,
142 .default_queue = EVENTQ_1,
145 static struct edma_soc_info da850_edma1_pdata = {
146 .queue_priority_mapping = da850_queue_priority_mapping,
147 .default_queue = EVENTQ_0,
150 static struct resource da8xx_edma0_resources[] = {
152 .name = "edma3_cc",
153 .start = DA8XX_TPCC_BASE,
154 .end = DA8XX_TPCC_BASE + SZ_32K - 1,
155 .flags = IORESOURCE_MEM,
158 .name = "edma3_tc0",
159 .start = DA8XX_TPTC0_BASE,
160 .end = DA8XX_TPTC0_BASE + SZ_1K - 1,
161 .flags = IORESOURCE_MEM,
164 .name = "edma3_tc1",
165 .start = DA8XX_TPTC1_BASE,
166 .end = DA8XX_TPTC1_BASE + SZ_1K - 1,
167 .flags = IORESOURCE_MEM,
170 .name = "edma3_ccint",
171 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_CCINT0),
172 .flags = IORESOURCE_IRQ,
175 .name = "edma3_ccerrint",
176 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_CCERRINT),
177 .flags = IORESOURCE_IRQ,
181 static struct resource da850_edma1_resources[] = {
183 .name = "edma3_cc",
184 .start = DA850_TPCC1_BASE,
185 .end = DA850_TPCC1_BASE + SZ_32K - 1,
186 .flags = IORESOURCE_MEM,
189 .name = "edma3_tc0",
190 .start = DA850_TPTC2_BASE,
191 .end = DA850_TPTC2_BASE + SZ_1K - 1,
192 .flags = IORESOURCE_MEM,
195 .name = "edma3_ccint",
196 .start = DAVINCI_INTC_IRQ(IRQ_DA850_CCINT1),
197 .flags = IORESOURCE_IRQ,
200 .name = "edma3_ccerrint",
201 .start = DAVINCI_INTC_IRQ(IRQ_DA850_CCERRINT1),
202 .flags = IORESOURCE_IRQ,
206 static const struct platform_device_info da8xx_edma0_device __initconst = {
207 .name = "edma",
208 .id = 0,
209 .dma_mask = DMA_BIT_MASK(32),
210 .res = da8xx_edma0_resources,
211 .num_res = ARRAY_SIZE(da8xx_edma0_resources),
212 .data = &da8xx_edma0_pdata,
213 .size_data = sizeof(da8xx_edma0_pdata),
216 static const struct platform_device_info da850_edma1_device __initconst = {
217 .name = "edma",
218 .id = 1,
219 .dma_mask = DMA_BIT_MASK(32),
220 .res = da850_edma1_resources,
221 .num_res = ARRAY_SIZE(da850_edma1_resources),
222 .data = &da850_edma1_pdata,
223 .size_data = sizeof(da850_edma1_pdata),
226 static const struct dma_slave_map da830_edma_map[] = {
227 { "davinci-mcasp.0", "rx", EDMA_FILTER_PARAM(0, 0) },
228 { "davinci-mcasp.0", "tx", EDMA_FILTER_PARAM(0, 1) },
229 { "davinci-mcasp.1", "rx", EDMA_FILTER_PARAM(0, 2) },
230 { "davinci-mcasp.1", "tx", EDMA_FILTER_PARAM(0, 3) },
231 { "davinci-mcasp.2", "rx", EDMA_FILTER_PARAM(0, 4) },
232 { "davinci-mcasp.2", "tx", EDMA_FILTER_PARAM(0, 5) },
233 { "spi_davinci.0", "rx", EDMA_FILTER_PARAM(0, 14) },
234 { "spi_davinci.0", "tx", EDMA_FILTER_PARAM(0, 15) },
235 { "da830-mmc.0", "rx", EDMA_FILTER_PARAM(0, 16) },
236 { "da830-mmc.0", "tx", EDMA_FILTER_PARAM(0, 17) },
237 { "spi_davinci.1", "rx", EDMA_FILTER_PARAM(0, 18) },
238 { "spi_davinci.1", "tx", EDMA_FILTER_PARAM(0, 19) },
241 int __init da830_register_edma(struct edma_rsv_info *rsv)
243 struct platform_device *edma_pdev;
245 da8xx_edma0_pdata.rsv = rsv;
247 da8xx_edma0_pdata.slave_map = da830_edma_map;
248 da8xx_edma0_pdata.slavecnt = ARRAY_SIZE(da830_edma_map);
250 edma_pdev = platform_device_register_full(&da8xx_edma0_device);
251 return PTR_ERR_OR_ZERO(edma_pdev);
254 static const struct dma_slave_map da850_edma0_map[] = {
255 { "davinci-mcasp.0", "rx", EDMA_FILTER_PARAM(0, 0) },
256 { "davinci-mcasp.0", "tx", EDMA_FILTER_PARAM(0, 1) },
257 { "davinci-mcbsp.0", "rx", EDMA_FILTER_PARAM(0, 2) },
258 { "davinci-mcbsp.0", "tx", EDMA_FILTER_PARAM(0, 3) },
259 { "davinci-mcbsp.1", "rx", EDMA_FILTER_PARAM(0, 4) },
260 { "davinci-mcbsp.1", "tx", EDMA_FILTER_PARAM(0, 5) },
261 { "spi_davinci.0", "rx", EDMA_FILTER_PARAM(0, 14) },
262 { "spi_davinci.0", "tx", EDMA_FILTER_PARAM(0, 15) },
263 { "da830-mmc.0", "rx", EDMA_FILTER_PARAM(0, 16) },
264 { "da830-mmc.0", "tx", EDMA_FILTER_PARAM(0, 17) },
265 { "spi_davinci.1", "rx", EDMA_FILTER_PARAM(0, 18) },
266 { "spi_davinci.1", "tx", EDMA_FILTER_PARAM(0, 19) },
269 static const struct dma_slave_map da850_edma1_map[] = {
270 { "da830-mmc.1", "rx", EDMA_FILTER_PARAM(1, 28) },
271 { "da830-mmc.1", "tx", EDMA_FILTER_PARAM(1, 29) },
274 int __init da850_register_edma(struct edma_rsv_info *rsv[2])
276 struct platform_device *edma_pdev;
278 if (rsv) {
279 da8xx_edma0_pdata.rsv = rsv[0];
280 da850_edma1_pdata.rsv = rsv[1];
283 da8xx_edma0_pdata.slave_map = da850_edma0_map;
284 da8xx_edma0_pdata.slavecnt = ARRAY_SIZE(da850_edma0_map);
286 edma_pdev = platform_device_register_full(&da8xx_edma0_device);
287 if (IS_ERR(edma_pdev)) {
288 pr_warn("%s: Failed to register eDMA0\n", __func__);
289 return PTR_ERR(edma_pdev);
292 da850_edma1_pdata.slave_map = da850_edma1_map;
293 da850_edma1_pdata.slavecnt = ARRAY_SIZE(da850_edma1_map);
295 edma_pdev = platform_device_register_full(&da850_edma1_device);
296 return PTR_ERR_OR_ZERO(edma_pdev);
299 static struct resource da8xx_i2c_resources0[] = {
301 .start = DA8XX_I2C0_BASE,
302 .end = DA8XX_I2C0_BASE + SZ_4K - 1,
303 .flags = IORESOURCE_MEM,
306 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_I2CINT0),
307 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_I2CINT0),
308 .flags = IORESOURCE_IRQ,
312 static struct platform_device da8xx_i2c_device0 = {
313 .name = "i2c_davinci",
314 .id = 1,
315 .num_resources = ARRAY_SIZE(da8xx_i2c_resources0),
316 .resource = da8xx_i2c_resources0,
319 static struct resource da8xx_i2c_resources1[] = {
321 .start = DA8XX_I2C1_BASE,
322 .end = DA8XX_I2C1_BASE + SZ_4K - 1,
323 .flags = IORESOURCE_MEM,
326 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_I2CINT1),
327 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_I2CINT1),
328 .flags = IORESOURCE_IRQ,
332 static struct platform_device da8xx_i2c_device1 = {
333 .name = "i2c_davinci",
334 .id = 2,
335 .num_resources = ARRAY_SIZE(da8xx_i2c_resources1),
336 .resource = da8xx_i2c_resources1,
339 int __init da8xx_register_i2c(int instance,
340 struct davinci_i2c_platform_data *pdata)
342 struct platform_device *pdev;
344 if (instance == 0)
345 pdev = &da8xx_i2c_device0;
346 else if (instance == 1)
347 pdev = &da8xx_i2c_device1;
348 else
349 return -EINVAL;
351 pdev->dev.platform_data = pdata;
352 return platform_device_register(pdev);
355 static struct resource da8xx_watchdog_resources[] = {
357 .start = DA8XX_WDOG_BASE,
358 .end = DA8XX_WDOG_BASE + SZ_4K - 1,
359 .flags = IORESOURCE_MEM,
363 static struct platform_device da8xx_wdt_device = {
364 .name = "davinci-wdt",
365 .id = -1,
366 .num_resources = ARRAY_SIZE(da8xx_watchdog_resources),
367 .resource = da8xx_watchdog_resources,
370 int __init da8xx_register_watchdog(void)
372 return platform_device_register(&da8xx_wdt_device);
375 static struct resource da8xx_emac_resources[] = {
377 .start = DA8XX_EMAC_CPPI_PORT_BASE,
378 .end = DA8XX_EMAC_CPPI_PORT_BASE + SZ_16K - 1,
379 .flags = IORESOURCE_MEM,
382 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_RX_THRESH_PULSE),
383 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_RX_THRESH_PULSE),
384 .flags = IORESOURCE_IRQ,
387 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_RX_PULSE),
388 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_RX_PULSE),
389 .flags = IORESOURCE_IRQ,
392 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_TX_PULSE),
393 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_TX_PULSE),
394 .flags = IORESOURCE_IRQ,
397 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_MISC_PULSE),
398 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_MISC_PULSE),
399 .flags = IORESOURCE_IRQ,
403 struct emac_platform_data da8xx_emac_pdata = {
404 .ctrl_reg_offset = DA8XX_EMAC_CTRL_REG_OFFSET,
405 .ctrl_mod_reg_offset = DA8XX_EMAC_MOD_REG_OFFSET,
406 .ctrl_ram_offset = DA8XX_EMAC_RAM_OFFSET,
407 .ctrl_ram_size = DA8XX_EMAC_CTRL_RAM_SIZE,
408 .version = EMAC_VERSION_2,
411 static struct platform_device da8xx_emac_device = {
412 .name = "davinci_emac",
413 .id = 1,
414 .dev = {
415 .platform_data = &da8xx_emac_pdata,
417 .num_resources = ARRAY_SIZE(da8xx_emac_resources),
418 .resource = da8xx_emac_resources,
421 static struct resource da8xx_mdio_resources[] = {
423 .start = DA8XX_EMAC_MDIO_BASE,
424 .end = DA8XX_EMAC_MDIO_BASE + SZ_4K - 1,
425 .flags = IORESOURCE_MEM,
429 static struct platform_device da8xx_mdio_device = {
430 .name = "davinci_mdio",
431 .id = 0,
432 .num_resources = ARRAY_SIZE(da8xx_mdio_resources),
433 .resource = da8xx_mdio_resources,
436 int __init da8xx_register_emac(void)
438 int ret;
440 ret = platform_device_register(&da8xx_mdio_device);
441 if (ret < 0)
442 return ret;
444 return platform_device_register(&da8xx_emac_device);
447 static struct resource da830_mcasp1_resources[] = {
449 .name = "mpu",
450 .start = DAVINCI_DA830_MCASP1_REG_BASE,
451 .end = DAVINCI_DA830_MCASP1_REG_BASE + (SZ_1K * 12) - 1,
452 .flags = IORESOURCE_MEM,
454 /* TX event */
456 .name = "tx",
457 .start = DAVINCI_DA830_DMA_MCASP1_AXEVT,
458 .end = DAVINCI_DA830_DMA_MCASP1_AXEVT,
459 .flags = IORESOURCE_DMA,
461 /* RX event */
463 .name = "rx",
464 .start = DAVINCI_DA830_DMA_MCASP1_AREVT,
465 .end = DAVINCI_DA830_DMA_MCASP1_AREVT,
466 .flags = IORESOURCE_DMA,
469 .name = "common",
470 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_MCASPINT),
471 .flags = IORESOURCE_IRQ,
475 static struct platform_device da830_mcasp1_device = {
476 .name = "davinci-mcasp",
477 .id = 1,
478 .num_resources = ARRAY_SIZE(da830_mcasp1_resources),
479 .resource = da830_mcasp1_resources,
482 static struct resource da830_mcasp2_resources[] = {
484 .name = "mpu",
485 .start = DAVINCI_DA830_MCASP2_REG_BASE,
486 .end = DAVINCI_DA830_MCASP2_REG_BASE + (SZ_1K * 12) - 1,
487 .flags = IORESOURCE_MEM,
489 /* TX event */
491 .name = "tx",
492 .start = DAVINCI_DA830_DMA_MCASP2_AXEVT,
493 .end = DAVINCI_DA830_DMA_MCASP2_AXEVT,
494 .flags = IORESOURCE_DMA,
496 /* RX event */
498 .name = "rx",
499 .start = DAVINCI_DA830_DMA_MCASP2_AREVT,
500 .end = DAVINCI_DA830_DMA_MCASP2_AREVT,
501 .flags = IORESOURCE_DMA,
504 .name = "common",
505 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_MCASPINT),
506 .flags = IORESOURCE_IRQ,
510 static struct platform_device da830_mcasp2_device = {
511 .name = "davinci-mcasp",
512 .id = 2,
513 .num_resources = ARRAY_SIZE(da830_mcasp2_resources),
514 .resource = da830_mcasp2_resources,
517 static struct resource da850_mcasp_resources[] = {
519 .name = "mpu",
520 .start = DAVINCI_DA8XX_MCASP0_REG_BASE,
521 .end = DAVINCI_DA8XX_MCASP0_REG_BASE + (SZ_1K * 12) - 1,
522 .flags = IORESOURCE_MEM,
524 /* TX event */
526 .name = "tx",
527 .start = DAVINCI_DA8XX_DMA_MCASP0_AXEVT,
528 .end = DAVINCI_DA8XX_DMA_MCASP0_AXEVT,
529 .flags = IORESOURCE_DMA,
531 /* RX event */
533 .name = "rx",
534 .start = DAVINCI_DA8XX_DMA_MCASP0_AREVT,
535 .end = DAVINCI_DA8XX_DMA_MCASP0_AREVT,
536 .flags = IORESOURCE_DMA,
539 .name = "common",
540 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_MCASPINT),
541 .flags = IORESOURCE_IRQ,
545 static struct platform_device da850_mcasp_device = {
546 .name = "davinci-mcasp",
547 .id = 0,
548 .num_resources = ARRAY_SIZE(da850_mcasp_resources),
549 .resource = da850_mcasp_resources,
552 void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata)
554 struct platform_device *pdev;
556 switch (id) {
557 case 0:
558 /* Valid for DA830/OMAP-L137 or DA850/OMAP-L138 */
559 pdev = &da850_mcasp_device;
560 break;
561 case 1:
562 /* Valid for DA830/OMAP-L137 only */
563 if (!cpu_is_davinci_da830())
564 return;
565 pdev = &da830_mcasp1_device;
566 break;
567 case 2:
568 /* Valid for DA830/OMAP-L137 only */
569 if (!cpu_is_davinci_da830())
570 return;
571 pdev = &da830_mcasp2_device;
572 break;
573 default:
574 return;
577 pdev->dev.platform_data = pdata;
578 platform_device_register(pdev);
581 static struct resource da8xx_pruss_resources[] = {
583 .start = DA8XX_PRUSS_MEM_BASE,
584 .end = DA8XX_PRUSS_MEM_BASE + 0xFFFF,
585 .flags = IORESOURCE_MEM,
588 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT0),
589 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT0),
590 .flags = IORESOURCE_IRQ,
593 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT1),
594 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT1),
595 .flags = IORESOURCE_IRQ,
598 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT2),
599 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT2),
600 .flags = IORESOURCE_IRQ,
603 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT3),
604 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT3),
605 .flags = IORESOURCE_IRQ,
608 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT4),
609 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT4),
610 .flags = IORESOURCE_IRQ,
613 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT5),
614 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT5),
615 .flags = IORESOURCE_IRQ,
618 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT6),
619 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT6),
620 .flags = IORESOURCE_IRQ,
623 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT7),
624 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT7),
625 .flags = IORESOURCE_IRQ,
629 static struct uio_pruss_pdata da8xx_uio_pruss_pdata = {
630 .pintc_base = 0x4000,
633 static struct platform_device da8xx_uio_pruss_dev = {
634 .name = "pruss_uio",
635 .id = -1,
636 .num_resources = ARRAY_SIZE(da8xx_pruss_resources),
637 .resource = da8xx_pruss_resources,
638 .dev = {
639 .coherent_dma_mask = DMA_BIT_MASK(32),
640 .platform_data = &da8xx_uio_pruss_pdata,
644 int __init da8xx_register_uio_pruss(void)
646 da8xx_uio_pruss_pdata.sram_pool = sram_get_gen_pool();
647 return platform_device_register(&da8xx_uio_pruss_dev);
650 static struct lcd_ctrl_config lcd_cfg = {
651 .panel_shade = COLOR_ACTIVE,
652 .bpp = 16,
655 struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata = {
656 .manu_name = "sharp",
657 .controller_data = &lcd_cfg,
658 .type = "Sharp_LCD035Q3DG01",
661 struct da8xx_lcdc_platform_data sharp_lk043t1dg01_pdata = {
662 .manu_name = "sharp",
663 .controller_data = &lcd_cfg,
664 .type = "Sharp_LK043T1DG01",
667 static struct resource da8xx_lcdc_resources[] = {
668 [0] = { /* registers */
669 .start = DA8XX_LCD_CNTRL_BASE,
670 .end = DA8XX_LCD_CNTRL_BASE + SZ_4K - 1,
671 .flags = IORESOURCE_MEM,
673 [1] = { /* interrupt */
674 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_LCDINT),
675 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_LCDINT),
676 .flags = IORESOURCE_IRQ,
680 static struct platform_device da8xx_lcdc_device = {
681 .name = "da8xx_lcdc",
682 .id = 0,
683 .num_resources = ARRAY_SIZE(da8xx_lcdc_resources),
684 .resource = da8xx_lcdc_resources,
685 .dev = {
686 .coherent_dma_mask = DMA_BIT_MASK(32),
690 int __init da8xx_register_lcdc(struct da8xx_lcdc_platform_data *pdata)
692 da8xx_lcdc_device.dev.platform_data = pdata;
693 return platform_device_register(&da8xx_lcdc_device);
696 static struct resource da8xx_gpio_resources[] = {
697 { /* registers */
698 .start = DA8XX_GPIO_BASE,
699 .end = DA8XX_GPIO_BASE + SZ_4K - 1,
700 .flags = IORESOURCE_MEM,
702 { /* interrupt */
703 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO0),
704 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO0),
705 .flags = IORESOURCE_IRQ,
708 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO1),
709 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO1),
710 .flags = IORESOURCE_IRQ,
713 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO2),
714 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO2),
715 .flags = IORESOURCE_IRQ,
718 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO3),
719 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO3),
720 .flags = IORESOURCE_IRQ,
723 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO4),
724 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO4),
725 .flags = IORESOURCE_IRQ,
728 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO5),
729 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO5),
730 .flags = IORESOURCE_IRQ,
733 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO6),
734 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO6),
735 .flags = IORESOURCE_IRQ,
738 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO7),
739 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO7),
740 .flags = IORESOURCE_IRQ,
743 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO8),
744 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO8),
745 .flags = IORESOURCE_IRQ,
749 static struct platform_device da8xx_gpio_device = {
750 .name = "davinci_gpio",
751 .id = -1,
752 .num_resources = ARRAY_SIZE(da8xx_gpio_resources),
753 .resource = da8xx_gpio_resources,
756 int __init da8xx_register_gpio(void *pdata)
758 da8xx_gpio_device.dev.platform_data = pdata;
759 return platform_device_register(&da8xx_gpio_device);
762 static struct resource da8xx_mmcsd0_resources[] = {
763 { /* registers */
764 .start = DA8XX_MMCSD0_BASE,
765 .end = DA8XX_MMCSD0_BASE + SZ_4K - 1,
766 .flags = IORESOURCE_MEM,
768 { /* interrupt */
769 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_MMCSDINT0),
770 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_MMCSDINT0),
771 .flags = IORESOURCE_IRQ,
775 static struct platform_device da8xx_mmcsd0_device = {
776 .name = "da830-mmc",
777 .id = 0,
778 .num_resources = ARRAY_SIZE(da8xx_mmcsd0_resources),
779 .resource = da8xx_mmcsd0_resources,
782 int __init da8xx_register_mmcsd0(struct davinci_mmc_config *config)
784 da8xx_mmcsd0_device.dev.platform_data = config;
785 return platform_device_register(&da8xx_mmcsd0_device);
788 #ifdef CONFIG_ARCH_DAVINCI_DA850
789 static struct resource da850_mmcsd1_resources[] = {
790 { /* registers */
791 .start = DA850_MMCSD1_BASE,
792 .end = DA850_MMCSD1_BASE + SZ_4K - 1,
793 .flags = IORESOURCE_MEM,
795 { /* interrupt */
796 .start = DAVINCI_INTC_IRQ(IRQ_DA850_MMCSDINT0_1),
797 .end = DAVINCI_INTC_IRQ(IRQ_DA850_MMCSDINT0_1),
798 .flags = IORESOURCE_IRQ,
802 static struct platform_device da850_mmcsd1_device = {
803 .name = "da830-mmc",
804 .id = 1,
805 .num_resources = ARRAY_SIZE(da850_mmcsd1_resources),
806 .resource = da850_mmcsd1_resources,
809 int __init da850_register_mmcsd1(struct davinci_mmc_config *config)
811 da850_mmcsd1_device.dev.platform_data = config;
812 return platform_device_register(&da850_mmcsd1_device);
814 #endif
816 static struct resource da8xx_rproc_resources[] = {
817 { /* DSP boot address */
818 .name = "host1cfg",
819 .start = DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG,
820 .end = DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG + 3,
821 .flags = IORESOURCE_MEM,
823 { /* DSP interrupt registers */
824 .name = "chipsig",
825 .start = DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG,
826 .end = DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG + 7,
827 .flags = IORESOURCE_MEM,
829 { /* DSP L2 RAM */
830 .name = "l2sram",
831 .start = DA8XX_DSP_L2_RAM_BASE,
832 .end = DA8XX_DSP_L2_RAM_BASE + SZ_256K - 1,
833 .flags = IORESOURCE_MEM,
835 { /* DSP L1P RAM */
836 .name = "l1pram",
837 .start = DA8XX_DSP_L1P_RAM_BASE,
838 .end = DA8XX_DSP_L1P_RAM_BASE + SZ_32K - 1,
839 .flags = IORESOURCE_MEM,
841 { /* DSP L1D RAM */
842 .name = "l1dram",
843 .start = DA8XX_DSP_L1D_RAM_BASE,
844 .end = DA8XX_DSP_L1D_RAM_BASE + SZ_32K - 1,
845 .flags = IORESOURCE_MEM,
847 { /* dsp irq */
848 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_CHIPINT0),
849 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_CHIPINT0),
850 .flags = IORESOURCE_IRQ,
854 static struct platform_device da8xx_dsp = {
855 .name = "davinci-rproc",
856 .dev = {
857 .coherent_dma_mask = DMA_BIT_MASK(32),
859 .num_resources = ARRAY_SIZE(da8xx_rproc_resources),
860 .resource = da8xx_rproc_resources,
863 static bool rproc_mem_inited __initdata;
865 #if IS_ENABLED(CONFIG_DA8XX_REMOTEPROC)
867 static phys_addr_t rproc_base __initdata;
868 static unsigned long rproc_size __initdata;
870 static int __init early_rproc_mem(char *p)
872 char *endp;
874 if (p == NULL)
875 return 0;
877 rproc_size = memparse(p, &endp);
878 if (*endp == '@')
879 rproc_base = memparse(endp + 1, NULL);
881 return 0;
883 early_param("rproc_mem", early_rproc_mem);
885 void __init da8xx_rproc_reserve_cma(void)
887 struct cma *cma;
888 int ret;
890 if (!rproc_base || !rproc_size) {
891 pr_err("%s: 'rproc_mem=nn@address' badly specified\n"
892 " 'nn' and 'address' must both be non-zero\n",
893 __func__);
895 return;
898 pr_info("%s: reserving 0x%lx @ 0x%lx...\n",
899 __func__, rproc_size, (unsigned long)rproc_base);
901 ret = dma_contiguous_reserve_area(rproc_size, rproc_base, 0, &cma,
902 true);
903 if (ret) {
904 pr_err("%s: dma_contiguous_reserve_area failed %d\n",
905 __func__, ret);
906 return;
908 da8xx_dsp.dev.cma_area = cma;
909 rproc_mem_inited = true;
911 #else
913 void __init da8xx_rproc_reserve_cma(void)
917 #endif
919 int __init da8xx_register_rproc(void)
921 int ret;
923 if (!rproc_mem_inited) {
924 pr_warn("%s: memory not reserved for DSP, not registering DSP device\n",
925 __func__);
926 return -ENOMEM;
929 ret = platform_device_register(&da8xx_dsp);
930 if (ret)
931 pr_err("%s: can't register DSP device: %d\n", __func__, ret);
933 return ret;
936 static struct resource da8xx_rtc_resources[] = {
938 .start = DA8XX_RTC_BASE,
939 .end = DA8XX_RTC_BASE + SZ_4K - 1,
940 .flags = IORESOURCE_MEM,
942 { /* timer irq */
943 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_RTC),
944 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_RTC),
945 .flags = IORESOURCE_IRQ,
947 { /* alarm irq */
948 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_RTC),
949 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_RTC),
950 .flags = IORESOURCE_IRQ,
954 static struct platform_device da8xx_rtc_device = {
955 .name = "da830-rtc",
956 .id = -1,
957 .num_resources = ARRAY_SIZE(da8xx_rtc_resources),
958 .resource = da8xx_rtc_resources,
961 int da8xx_register_rtc(void)
963 return platform_device_register(&da8xx_rtc_device);
966 static void __iomem *da8xx_ddr2_ctlr_base;
967 void __iomem * __init da8xx_get_mem_ctlr(void)
969 if (da8xx_ddr2_ctlr_base)
970 return da8xx_ddr2_ctlr_base;
972 da8xx_ddr2_ctlr_base = ioremap(DA8XX_DDR2_CTL_BASE, SZ_32K);
973 if (!da8xx_ddr2_ctlr_base)
974 pr_warn("%s: Unable to map DDR2 controller", __func__);
976 return da8xx_ddr2_ctlr_base;
979 static struct resource da8xx_cpuidle_resources[] = {
981 .start = DA8XX_DDR2_CTL_BASE,
982 .end = DA8XX_DDR2_CTL_BASE + SZ_32K - 1,
983 .flags = IORESOURCE_MEM,
987 /* DA8XX devices support DDR2 power down */
988 static struct davinci_cpuidle_config da8xx_cpuidle_pdata = {
989 .ddr2_pdown = 1,
993 static struct platform_device da8xx_cpuidle_device = {
994 .name = "cpuidle-davinci",
995 .num_resources = ARRAY_SIZE(da8xx_cpuidle_resources),
996 .resource = da8xx_cpuidle_resources,
997 .dev = {
998 .platform_data = &da8xx_cpuidle_pdata,
1002 int __init da8xx_register_cpuidle(void)
1004 da8xx_cpuidle_pdata.ddr2_ctlr_base = da8xx_get_mem_ctlr();
1006 return platform_device_register(&da8xx_cpuidle_device);
1009 static struct resource da8xx_spi0_resources[] = {
1010 [0] = {
1011 .start = DA8XX_SPI0_BASE,
1012 .end = DA8XX_SPI0_BASE + SZ_4K - 1,
1013 .flags = IORESOURCE_MEM,
1015 [1] = {
1016 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_SPINT0),
1017 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_SPINT0),
1018 .flags = IORESOURCE_IRQ,
1022 static struct resource da8xx_spi1_resources[] = {
1023 [0] = {
1024 .start = DA830_SPI1_BASE,
1025 .end = DA830_SPI1_BASE + SZ_4K - 1,
1026 .flags = IORESOURCE_MEM,
1028 [1] = {
1029 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_SPINT1),
1030 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_SPINT1),
1031 .flags = IORESOURCE_IRQ,
1035 static struct davinci_spi_platform_data da8xx_spi_pdata[] = {
1036 [0] = {
1037 .version = SPI_VERSION_2,
1038 .intr_line = 1,
1039 .dma_event_q = EVENTQ_0,
1040 .prescaler_limit = 2,
1042 [1] = {
1043 .version = SPI_VERSION_2,
1044 .intr_line = 1,
1045 .dma_event_q = EVENTQ_0,
1046 .prescaler_limit = 2,
1050 static struct platform_device da8xx_spi_device[] = {
1051 [0] = {
1052 .name = "spi_davinci",
1053 .id = 0,
1054 .num_resources = ARRAY_SIZE(da8xx_spi0_resources),
1055 .resource = da8xx_spi0_resources,
1056 .dev = {
1057 .platform_data = &da8xx_spi_pdata[0],
1060 [1] = {
1061 .name = "spi_davinci",
1062 .id = 1,
1063 .num_resources = ARRAY_SIZE(da8xx_spi1_resources),
1064 .resource = da8xx_spi1_resources,
1065 .dev = {
1066 .platform_data = &da8xx_spi_pdata[1],
1071 int __init da8xx_register_spi_bus(int instance, unsigned num_chipselect)
1073 if (instance < 0 || instance > 1)
1074 return -EINVAL;
1076 da8xx_spi_pdata[instance].num_chipselect = num_chipselect;
1078 if (instance == 1 && cpu_is_davinci_da850()) {
1079 da8xx_spi1_resources[0].start = DA850_SPI1_BASE;
1080 da8xx_spi1_resources[0].end = DA850_SPI1_BASE + SZ_4K - 1;
1083 return platform_device_register(&da8xx_spi_device[instance]);
1086 #ifdef CONFIG_ARCH_DAVINCI_DA850
1087 int __init da850_register_sata_refclk(int rate)
1089 struct clk *clk;
1091 clk = clk_register_fixed_rate(NULL, "sata_refclk", NULL, 0, rate);
1092 if (IS_ERR(clk))
1093 return PTR_ERR(clk);
1095 return clk_register_clkdev(clk, "refclk", "ahci_da850");
1098 static struct resource da850_sata_resources[] = {
1100 .start = DA850_SATA_BASE,
1101 .end = DA850_SATA_BASE + 0x1fff,
1102 .flags = IORESOURCE_MEM,
1105 .start = DA8XX_SYSCFG1_BASE + DA8XX_PWRDN_REG,
1106 .end = DA8XX_SYSCFG1_BASE + DA8XX_PWRDN_REG + 0x3,
1107 .flags = IORESOURCE_MEM,
1110 .start = DAVINCI_INTC_IRQ(IRQ_DA850_SATAINT),
1111 .flags = IORESOURCE_IRQ,
1115 static u64 da850_sata_dmamask = DMA_BIT_MASK(32);
1117 static struct platform_device da850_sata_device = {
1118 .name = "ahci_da850",
1119 .id = -1,
1120 .dev = {
1121 .dma_mask = &da850_sata_dmamask,
1122 .coherent_dma_mask = DMA_BIT_MASK(32),
1124 .num_resources = ARRAY_SIZE(da850_sata_resources),
1125 .resource = da850_sata_resources,
1128 int __init da850_register_sata(unsigned long refclkpn)
1130 int ret;
1132 ret = da850_register_sata_refclk(refclkpn);
1133 if (ret)
1134 return ret;
1136 return platform_device_register(&da850_sata_device);
1138 #endif
1140 static struct regmap *da8xx_cfgchip;
1142 static const struct regmap_config da8xx_cfgchip_config __initconst = {
1143 .name = "cfgchip",
1144 .reg_bits = 32,
1145 .val_bits = 32,
1146 .reg_stride = 4,
1147 .max_register = DA8XX_CFGCHIP4_REG - DA8XX_CFGCHIP0_REG,
1151 * da8xx_get_cfgchip - Lazy gets CFGCHIP as regmap
1153 * This is for use on non-DT boards only. For DT boards, use
1154 * syscon_regmap_lookup_by_compatible("ti,da830-cfgchip")
1156 * Returns: Pointer to the CFGCHIP regmap or negative error code.
1158 struct regmap * __init da8xx_get_cfgchip(void)
1160 if (IS_ERR_OR_NULL(da8xx_cfgchip))
1161 da8xx_cfgchip = regmap_init_mmio(NULL,
1162 DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP0_REG),
1163 &da8xx_cfgchip_config);
1165 return da8xx_cfgchip;