blob: fcb30d3ae24eff4c5516ffffdd5292e6bc704892 [file] [log] [blame]
Mark A. Greer55c79a42009-06-03 18:36:54 -07001/*
2 * DA8XX/OMAP L1XX platform device data
3 *
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>
7 *
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.
12 */
Mark A. Greer55c79a42009-06-03 18:36:54 -070013#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <linux/dma-mapping.h>
16#include <linux/serial_8250.h>
Sekhar Noricbb2c962011-07-06 06:01:23 +000017#include <linux/ahci_platform.h>
18#include <linux/clk.h>
Mark A. Greer55c79a42009-06-03 18:36:54 -070019
20#include <mach/cputype.h>
21#include <mach/common.h>
22#include <mach/time.h>
23#include <mach/da8xx.h>
Sekhar Nori1960e692009-10-22 15:12:14 +053024#include <mach/cpuidle.h>
Mark A. Greer55c79a42009-06-03 18:36:54 -070025
26#include "clock.h"
Hebbar, Gururaja896f66b2012-08-27 18:56:41 +053027#include "asp.h"
Mark A. Greer55c79a42009-06-03 18:36:54 -070028
29#define DA8XX_TPCC_BASE 0x01c00000
30#define DA8XX_TPTC0_BASE 0x01c08000
31#define DA8XX_TPTC1_BASE 0x01c08400
32#define DA8XX_WDOG_BASE 0x01c21000 /* DA8XX_TIMER64P1_BASE */
33#define DA8XX_I2C0_BASE 0x01c22000
Sergei Shtylyov8ac764e2011-04-06 17:29:24 +000034#define DA8XX_RTC_BASE 0x01c23000
35#define DA8XX_MMCSD0_BASE 0x01c40000
36#define DA8XX_SPI0_BASE 0x01c41000
37#define DA830_SPI1_BASE 0x01e12000
38#define DA8XX_LCD_CNTRL_BASE 0x01e13000
Sekhar Noricbb2c962011-07-06 06:01:23 +000039#define DA850_SATA_BASE 0x01e18000
Sergei Shtylyov8ac764e2011-04-06 17:29:24 +000040#define DA850_MMCSD1_BASE 0x01e1b000
Mark A. Greer55c79a42009-06-03 18:36:54 -070041#define DA8XX_EMAC_CPPI_PORT_BASE 0x01e20000
42#define DA8XX_EMAC_CPGMACSS_BASE 0x01e22000
43#define DA8XX_EMAC_CPGMAC_BASE 0x01e23000
44#define DA8XX_EMAC_MDIO_BASE 0x01e24000
Mark A. Greer55c79a42009-06-03 18:36:54 -070045#define DA8XX_I2C1_BASE 0x01e28000
Sergei Shtylyov8ac764e2011-04-06 17:29:24 +000046#define DA850_TPCC1_BASE 0x01e30000
47#define DA850_TPTC2_BASE 0x01e38000
Sergei Shtylyov9e7d24f2011-04-06 17:17:21 +000048#define DA850_SPI1_BASE 0x01f0e000
Sergei Shtylyov8ac764e2011-04-06 17:29:24 +000049#define DA8XX_DDR2_CTL_BASE 0xb0000000
Mark A. Greer55c79a42009-06-03 18:36:54 -070050
51#define DA8XX_EMAC_CTRL_REG_OFFSET 0x3000
52#define DA8XX_EMAC_MOD_REG_OFFSET 0x2000
53#define DA8XX_EMAC_RAM_OFFSET 0x0000
Mark A. Greer55c79a42009-06-03 18:36:54 -070054#define DA8XX_EMAC_CTRL_RAM_SIZE SZ_8K
55
Michael Williamson54ce6882011-02-24 10:18:28 +053056#define DA8XX_DMA_SPI0_RX EDMA_CTLR_CHAN(0, 14)
57#define DA8XX_DMA_SPI0_TX EDMA_CTLR_CHAN(0, 15)
Michael Williamsone38c2b22011-02-22 13:36:57 +000058#define DA8XX_DMA_MMCSD0_RX EDMA_CTLR_CHAN(0, 16)
59#define DA8XX_DMA_MMCSD0_TX EDMA_CTLR_CHAN(0, 17)
Michael Williamson54ce6882011-02-24 10:18:28 +053060#define DA8XX_DMA_SPI1_RX EDMA_CTLR_CHAN(0, 18)
61#define DA8XX_DMA_SPI1_TX EDMA_CTLR_CHAN(0, 19)
Michael Williamsone38c2b22011-02-22 13:36:57 +000062#define DA850_DMA_MMCSD1_RX EDMA_CTLR_CHAN(1, 28)
63#define DA850_DMA_MMCSD1_TX EDMA_CTLR_CHAN(1, 29)
64
Sekhar Norid2de0582009-11-16 17:21:32 +053065void __iomem *da8xx_syscfg0_base;
66void __iomem *da8xx_syscfg1_base;
Sekhar Nori6a28adef2009-08-31 15:47:59 +053067
Mark A. Greer55c79a42009-06-03 18:36:54 -070068static struct plat_serial8250_port da8xx_serial_pdata[] = {
69 {
70 .mapbase = DA8XX_UART0_BASE,
71 .irq = IRQ_DA8XX_UARTINT0,
72 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
73 UPF_IOREMAP,
74 .iotype = UPIO_MEM,
75 .regshift = 2,
76 },
77 {
78 .mapbase = DA8XX_UART1_BASE,
79 .irq = IRQ_DA8XX_UARTINT1,
80 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
81 UPF_IOREMAP,
82 .iotype = UPIO_MEM,
83 .regshift = 2,
84 },
85 {
86 .mapbase = DA8XX_UART2_BASE,
87 .irq = IRQ_DA8XX_UARTINT2,
88 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
89 UPF_IOREMAP,
90 .iotype = UPIO_MEM,
91 .regshift = 2,
92 },
93 {
94 .flags = 0,
95 },
96};
97
98struct platform_device da8xx_serial_device = {
99 .name = "serial8250",
100 .id = PLAT8250_DEV_PLATFORM,
101 .dev = {
102 .platform_data = da8xx_serial_pdata,
103 },
104};
105
Mark A. Greer55c79a42009-06-03 18:36:54 -0700106static const s8 da8xx_queue_tc_mapping[][2] = {
107 /* {event queue no, TC no} */
108 {0, 0},
109 {1, 1},
110 {-1, -1}
111};
112
113static const s8 da8xx_queue_priority_mapping[][2] = {
114 /* {event queue no, Priority} */
115 {0, 3},
116 {1, 7},
117 {-1, -1}
118};
119
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530120static const s8 da850_queue_tc_mapping[][2] = {
121 /* {event queue no, TC no} */
122 {0, 0},
123 {-1, -1}
124};
125
126static const s8 da850_queue_priority_mapping[][2] = {
127 /* {event queue no, Priority} */
128 {0, 3},
129 {-1, -1}
130};
131
Sekhar Noribc3ac9f2010-06-29 11:35:12 +0530132static struct edma_soc_info da830_edma_cc0_info = {
133 .n_channel = 32,
134 .n_region = 4,
135 .n_slot = 128,
136 .n_tc = 2,
137 .n_cc = 1,
138 .queue_tc_mapping = da8xx_queue_tc_mapping,
139 .queue_priority_mapping = da8xx_queue_priority_mapping,
Ido Yarivf23fe852011-07-10 16:14:35 +0300140 .default_queue = EVENTQ_1,
Mark A. Greer55c79a42009-06-03 18:36:54 -0700141};
142
Sekhar Noribc3ac9f2010-06-29 11:35:12 +0530143static struct edma_soc_info *da830_edma_info[EDMA_MAX_CC] = {
144 &da830_edma_cc0_info,
145};
146
147static struct edma_soc_info da850_edma_cc_info[] = {
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530148 {
149 .n_channel = 32,
150 .n_region = 4,
151 .n_slot = 128,
152 .n_tc = 2,
153 .n_cc = 1,
154 .queue_tc_mapping = da8xx_queue_tc_mapping,
155 .queue_priority_mapping = da8xx_queue_priority_mapping,
Ido Yarivf23fe852011-07-10 16:14:35 +0300156 .default_queue = EVENTQ_1,
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530157 },
158 {
159 .n_channel = 32,
160 .n_region = 4,
161 .n_slot = 128,
162 .n_tc = 1,
163 .n_cc = 1,
164 .queue_tc_mapping = da850_queue_tc_mapping,
165 .queue_priority_mapping = da850_queue_priority_mapping,
Ido Yarivf23fe852011-07-10 16:14:35 +0300166 .default_queue = EVENTQ_0,
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530167 },
168};
169
Sekhar Noribc3ac9f2010-06-29 11:35:12 +0530170static struct edma_soc_info *da850_edma_info[EDMA_MAX_CC] = {
171 &da850_edma_cc_info[0],
172 &da850_edma_cc_info[1],
173};
174
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530175static struct resource da830_edma_resources[] = {
Mark A. Greer55c79a42009-06-03 18:36:54 -0700176 {
177 .name = "edma_cc0",
178 .start = DA8XX_TPCC_BASE,
179 .end = DA8XX_TPCC_BASE + SZ_32K - 1,
180 .flags = IORESOURCE_MEM,
181 },
182 {
183 .name = "edma_tc0",
184 .start = DA8XX_TPTC0_BASE,
185 .end = DA8XX_TPTC0_BASE + SZ_1K - 1,
186 .flags = IORESOURCE_MEM,
187 },
188 {
189 .name = "edma_tc1",
190 .start = DA8XX_TPTC1_BASE,
191 .end = DA8XX_TPTC1_BASE + SZ_1K - 1,
192 .flags = IORESOURCE_MEM,
193 },
194 {
195 .name = "edma0",
Sudhakar Rajashekhara2259bbd2009-07-10 06:28:52 -0400196 .start = IRQ_DA8XX_CCINT0,
Mark A. Greer55c79a42009-06-03 18:36:54 -0700197 .flags = IORESOURCE_IRQ,
198 },
199 {
200 .name = "edma0_err",
201 .start = IRQ_DA8XX_CCERRINT,
202 .flags = IORESOURCE_IRQ,
203 },
204};
205
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530206static struct resource da850_edma_resources[] = {
207 {
208 .name = "edma_cc0",
209 .start = DA8XX_TPCC_BASE,
210 .end = DA8XX_TPCC_BASE + SZ_32K - 1,
211 .flags = IORESOURCE_MEM,
212 },
213 {
214 .name = "edma_tc0",
215 .start = DA8XX_TPTC0_BASE,
216 .end = DA8XX_TPTC0_BASE + SZ_1K - 1,
217 .flags = IORESOURCE_MEM,
218 },
219 {
220 .name = "edma_tc1",
221 .start = DA8XX_TPTC1_BASE,
222 .end = DA8XX_TPTC1_BASE + SZ_1K - 1,
223 .flags = IORESOURCE_MEM,
224 },
225 {
226 .name = "edma_cc1",
227 .start = DA850_TPCC1_BASE,
228 .end = DA850_TPCC1_BASE + SZ_32K - 1,
229 .flags = IORESOURCE_MEM,
230 },
231 {
232 .name = "edma_tc2",
233 .start = DA850_TPTC2_BASE,
234 .end = DA850_TPTC2_BASE + SZ_1K - 1,
235 .flags = IORESOURCE_MEM,
236 },
237 {
238 .name = "edma0",
239 .start = IRQ_DA8XX_CCINT0,
240 .flags = IORESOURCE_IRQ,
241 },
242 {
243 .name = "edma0_err",
244 .start = IRQ_DA8XX_CCERRINT,
245 .flags = IORESOURCE_IRQ,
246 },
247 {
248 .name = "edma1",
249 .start = IRQ_DA850_CCINT1,
250 .flags = IORESOURCE_IRQ,
251 },
252 {
253 .name = "edma1_err",
254 .start = IRQ_DA850_CCERRINT1,
255 .flags = IORESOURCE_IRQ,
256 },
257};
258
259static struct platform_device da830_edma_device = {
Mark A. Greer55c79a42009-06-03 18:36:54 -0700260 .name = "edma",
261 .id = -1,
262 .dev = {
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530263 .platform_data = da830_edma_info,
Mark A. Greer55c79a42009-06-03 18:36:54 -0700264 },
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530265 .num_resources = ARRAY_SIZE(da830_edma_resources),
266 .resource = da830_edma_resources,
267};
268
269static struct platform_device da850_edma_device = {
270 .name = "edma",
271 .id = -1,
272 .dev = {
273 .platform_data = da850_edma_info,
274 },
275 .num_resources = ARRAY_SIZE(da850_edma_resources),
276 .resource = da850_edma_resources,
Mark A. Greer55c79a42009-06-03 18:36:54 -0700277};
278
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530279int __init da830_register_edma(struct edma_rsv_info *rsv)
Mark A. Greer55c79a42009-06-03 18:36:54 -0700280{
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530281 da830_edma_cc0_info.rsv = rsv;
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530282
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530283 return platform_device_register(&da830_edma_device);
284}
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530285
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530286int __init da850_register_edma(struct edma_rsv_info *rsv[2])
287{
288 if (rsv) {
289 da850_edma_cc_info[0].rsv = rsv[0];
290 da850_edma_cc_info[1].rsv = rsv[1];
291 }
292
293 return platform_device_register(&da850_edma_device);
Mark A. Greer55c79a42009-06-03 18:36:54 -0700294}
295
296static struct resource da8xx_i2c_resources0[] = {
297 {
298 .start = DA8XX_I2C0_BASE,
299 .end = DA8XX_I2C0_BASE + SZ_4K - 1,
300 .flags = IORESOURCE_MEM,
301 },
302 {
303 .start = IRQ_DA8XX_I2CINT0,
304 .end = IRQ_DA8XX_I2CINT0,
305 .flags = IORESOURCE_IRQ,
306 },
307};
308
309static struct platform_device da8xx_i2c_device0 = {
310 .name = "i2c_davinci",
311 .id = 1,
312 .num_resources = ARRAY_SIZE(da8xx_i2c_resources0),
313 .resource = da8xx_i2c_resources0,
314};
315
316static struct resource da8xx_i2c_resources1[] = {
317 {
318 .start = DA8XX_I2C1_BASE,
319 .end = DA8XX_I2C1_BASE + SZ_4K - 1,
320 .flags = IORESOURCE_MEM,
321 },
322 {
323 .start = IRQ_DA8XX_I2CINT1,
324 .end = IRQ_DA8XX_I2CINT1,
325 .flags = IORESOURCE_IRQ,
326 },
327};
328
329static struct platform_device da8xx_i2c_device1 = {
330 .name = "i2c_davinci",
331 .id = 2,
332 .num_resources = ARRAY_SIZE(da8xx_i2c_resources1),
333 .resource = da8xx_i2c_resources1,
334};
335
336int __init da8xx_register_i2c(int instance,
337 struct davinci_i2c_platform_data *pdata)
338{
339 struct platform_device *pdev;
340
341 if (instance == 0)
342 pdev = &da8xx_i2c_device0;
343 else if (instance == 1)
344 pdev = &da8xx_i2c_device1;
345 else
346 return -EINVAL;
347
348 pdev->dev.platform_data = pdata;
349 return platform_device_register(pdev);
350}
351
352static struct resource da8xx_watchdog_resources[] = {
353 {
354 .start = DA8XX_WDOG_BASE,
355 .end = DA8XX_WDOG_BASE + SZ_4K - 1,
356 .flags = IORESOURCE_MEM,
357 },
358};
359
Cyril Chemparathyc78a5bc2010-05-01 18:38:28 -0400360struct platform_device da8xx_wdt_device = {
Mark A. Greer55c79a42009-06-03 18:36:54 -0700361 .name = "watchdog",
362 .id = -1,
363 .num_resources = ARRAY_SIZE(da8xx_watchdog_resources),
364 .resource = da8xx_watchdog_resources,
365};
366
Sekhar Noric6121dd2011-12-05 11:29:46 +0100367void da8xx_restart(char mode, const char *cmd)
368{
369 davinci_watchdog_reset(&da8xx_wdt_device);
370}
371
Mark A. Greer55c79a42009-06-03 18:36:54 -0700372int __init da8xx_register_watchdog(void)
373{
Cyril Chemparathyc78a5bc2010-05-01 18:38:28 -0400374 return platform_device_register(&da8xx_wdt_device);
Mark A. Greer55c79a42009-06-03 18:36:54 -0700375}
376
377static struct resource da8xx_emac_resources[] = {
378 {
379 .start = DA8XX_EMAC_CPPI_PORT_BASE,
Cyril Chemparathyd22960c2010-09-15 10:11:22 -0400380 .end = DA8XX_EMAC_CPPI_PORT_BASE + SZ_16K - 1,
Mark A. Greer55c79a42009-06-03 18:36:54 -0700381 .flags = IORESOURCE_MEM,
382 },
383 {
384 .start = IRQ_DA8XX_C0_RX_THRESH_PULSE,
385 .end = IRQ_DA8XX_C0_RX_THRESH_PULSE,
386 .flags = IORESOURCE_IRQ,
387 },
388 {
389 .start = IRQ_DA8XX_C0_RX_PULSE,
390 .end = IRQ_DA8XX_C0_RX_PULSE,
391 .flags = IORESOURCE_IRQ,
392 },
393 {
394 .start = IRQ_DA8XX_C0_TX_PULSE,
395 .end = IRQ_DA8XX_C0_TX_PULSE,
396 .flags = IORESOURCE_IRQ,
397 },
398 {
399 .start = IRQ_DA8XX_C0_MISC_PULSE,
400 .end = IRQ_DA8XX_C0_MISC_PULSE,
401 .flags = IORESOURCE_IRQ,
402 },
403};
404
405struct emac_platform_data da8xx_emac_pdata = {
406 .ctrl_reg_offset = DA8XX_EMAC_CTRL_REG_OFFSET,
407 .ctrl_mod_reg_offset = DA8XX_EMAC_MOD_REG_OFFSET,
408 .ctrl_ram_offset = DA8XX_EMAC_RAM_OFFSET,
Mark A. Greer55c79a42009-06-03 18:36:54 -0700409 .ctrl_ram_size = DA8XX_EMAC_CTRL_RAM_SIZE,
410 .version = EMAC_VERSION_2,
411};
412
413static struct platform_device da8xx_emac_device = {
414 .name = "davinci_emac",
415 .id = 1,
416 .dev = {
417 .platform_data = &da8xx_emac_pdata,
418 },
419 .num_resources = ARRAY_SIZE(da8xx_emac_resources),
420 .resource = da8xx_emac_resources,
421};
422
Cyril Chemparathyd22960c2010-09-15 10:11:22 -0400423static struct resource da8xx_mdio_resources[] = {
424 {
425 .start = DA8XX_EMAC_MDIO_BASE,
426 .end = DA8XX_EMAC_MDIO_BASE + SZ_4K - 1,
427 .flags = IORESOURCE_MEM,
428 },
429};
430
431static struct platform_device da8xx_mdio_device = {
432 .name = "davinci_mdio",
433 .id = 0,
434 .num_resources = ARRAY_SIZE(da8xx_mdio_resources),
435 .resource = da8xx_mdio_resources,
436};
437
Mark A. Greer31f53cf2009-08-28 15:02:54 -0700438int __init da8xx_register_emac(void)
439{
Cyril Chemparathyd22960c2010-09-15 10:11:22 -0400440 int ret;
441
442 ret = platform_device_register(&da8xx_mdio_device);
443 if (ret < 0)
444 return ret;
445 ret = platform_device_register(&da8xx_emac_device);
446 if (ret < 0)
447 return ret;
448 ret = clk_add_alias(NULL, dev_name(&da8xx_mdio_device.dev),
449 NULL, &da8xx_emac_device.dev);
450 return ret;
Mark A. Greer31f53cf2009-08-28 15:02:54 -0700451}
452
Chaithrika U Se33ef5e2009-08-11 17:01:59 -0400453static struct resource da830_mcasp1_resources[] = {
454 {
455 .name = "mcasp1",
456 .start = DAVINCI_DA830_MCASP1_REG_BASE,
457 .end = DAVINCI_DA830_MCASP1_REG_BASE + (SZ_1K * 12) - 1,
458 .flags = IORESOURCE_MEM,
459 },
460 /* TX event */
461 {
462 .start = DAVINCI_DA830_DMA_MCASP1_AXEVT,
463 .end = DAVINCI_DA830_DMA_MCASP1_AXEVT,
464 .flags = IORESOURCE_DMA,
465 },
466 /* RX event */
467 {
468 .start = DAVINCI_DA830_DMA_MCASP1_AREVT,
469 .end = DAVINCI_DA830_DMA_MCASP1_AREVT,
470 .flags = IORESOURCE_DMA,
471 },
472};
473
474static struct platform_device da830_mcasp1_device = {
475 .name = "davinci-mcasp",
476 .id = 1,
477 .num_resources = ARRAY_SIZE(da830_mcasp1_resources),
478 .resource = da830_mcasp1_resources,
479};
480
Chaithrika U S491214e2009-08-11 17:03:25 -0400481static struct resource da850_mcasp_resources[] = {
482 {
483 .name = "mcasp",
484 .start = DAVINCI_DA8XX_MCASP0_REG_BASE,
485 .end = DAVINCI_DA8XX_MCASP0_REG_BASE + (SZ_1K * 12) - 1,
486 .flags = IORESOURCE_MEM,
487 },
488 /* TX event */
489 {
490 .start = DAVINCI_DA8XX_DMA_MCASP0_AXEVT,
491 .end = DAVINCI_DA8XX_DMA_MCASP0_AXEVT,
492 .flags = IORESOURCE_DMA,
493 },
494 /* RX event */
495 {
496 .start = DAVINCI_DA8XX_DMA_MCASP0_AREVT,
497 .end = DAVINCI_DA8XX_DMA_MCASP0_AREVT,
498 .flags = IORESOURCE_DMA,
499 },
500};
501
502static struct platform_device da850_mcasp_device = {
503 .name = "davinci-mcasp",
504 .id = 0,
505 .num_resources = ARRAY_SIZE(da850_mcasp_resources),
506 .resource = da850_mcasp_resources,
507};
508
Mark A. Greerb8864aa2009-08-28 15:05:02 -0700509void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata)
Chaithrika U Se33ef5e2009-08-11 17:01:59 -0400510{
Chaithrika U S491214e2009-08-11 17:03:25 -0400511 /* DA830/OMAP-L137 has 3 instances of McASP */
512 if (cpu_is_davinci_da830() && id == 1) {
Chaithrika U Se33ef5e2009-08-11 17:01:59 -0400513 da830_mcasp1_device.dev.platform_data = pdata;
514 platform_device_register(&da830_mcasp1_device);
Chaithrika U S491214e2009-08-11 17:03:25 -0400515 } else if (cpu_is_davinci_da850()) {
516 da850_mcasp_device.dev.platform_data = pdata;
517 platform_device_register(&da850_mcasp_device);
Chaithrika U Se33ef5e2009-08-11 17:01:59 -0400518 }
519}
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400520
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400521static struct lcd_ctrl_config lcd_cfg = {
Manjunathappa, Prakash3b43ad22012-10-16 10:23:16 +0530522 .panel_shade = COLOR_ACTIVE,
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400523 .bpp = 16,
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400524};
525
Mark A. Greerb9e63422009-09-15 18:14:19 -0700526struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata = {
527 .manu_name = "sharp",
528 .controller_data = &lcd_cfg,
529 .type = "Sharp_LCD035Q3DG01",
530};
531
532struct da8xx_lcdc_platform_data sharp_lk043t1dg01_pdata = {
533 .manu_name = "sharp",
534 .controller_data = &lcd_cfg,
535 .type = "Sharp_LK043T1DG01",
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400536};
537
538static struct resource da8xx_lcdc_resources[] = {
539 [0] = { /* registers */
540 .start = DA8XX_LCD_CNTRL_BASE,
541 .end = DA8XX_LCD_CNTRL_BASE + SZ_4K - 1,
542 .flags = IORESOURCE_MEM,
543 },
544 [1] = { /* interrupt */
545 .start = IRQ_DA8XX_LCDINT,
546 .end = IRQ_DA8XX_LCDINT,
547 .flags = IORESOURCE_IRQ,
548 },
549};
550
Mark A. Greerb9e63422009-09-15 18:14:19 -0700551static struct platform_device da8xx_lcdc_device = {
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400552 .name = "da8xx_lcdc",
553 .id = 0,
554 .num_resources = ARRAY_SIZE(da8xx_lcdc_resources),
555 .resource = da8xx_lcdc_resources,
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400556};
557
Mark A. Greerb9e63422009-09-15 18:14:19 -0700558int __init da8xx_register_lcdc(struct da8xx_lcdc_platform_data *pdata)
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400559{
Mark A. Greerb9e63422009-09-15 18:14:19 -0700560 da8xx_lcdc_device.dev.platform_data = pdata;
561 return platform_device_register(&da8xx_lcdc_device);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400562}
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400563
564static struct resource da8xx_mmcsd0_resources[] = {
565 { /* registers */
566 .start = DA8XX_MMCSD0_BASE,
567 .end = DA8XX_MMCSD0_BASE + SZ_4K - 1,
568 .flags = IORESOURCE_MEM,
569 },
570 { /* interrupt */
571 .start = IRQ_DA8XX_MMCSDINT0,
572 .end = IRQ_DA8XX_MMCSDINT0,
573 .flags = IORESOURCE_IRQ,
574 },
575 { /* DMA RX */
Michael Williamsone38c2b22011-02-22 13:36:57 +0000576 .start = DA8XX_DMA_MMCSD0_RX,
577 .end = DA8XX_DMA_MMCSD0_RX,
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400578 .flags = IORESOURCE_DMA,
579 },
580 { /* DMA TX */
Michael Williamsone38c2b22011-02-22 13:36:57 +0000581 .start = DA8XX_DMA_MMCSD0_TX,
582 .end = DA8XX_DMA_MMCSD0_TX,
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400583 .flags = IORESOURCE_DMA,
584 },
585};
586
587static struct platform_device da8xx_mmcsd0_device = {
588 .name = "davinci_mmc",
589 .id = 0,
590 .num_resources = ARRAY_SIZE(da8xx_mmcsd0_resources),
591 .resource = da8xx_mmcsd0_resources,
592};
593
594int __init da8xx_register_mmcsd0(struct davinci_mmc_config *config)
595{
596 da8xx_mmcsd0_device.dev.platform_data = config;
597 return platform_device_register(&da8xx_mmcsd0_device);
598}
Mark A. Greerc51df702009-09-15 18:15:54 -0700599
Juha Kuikkab8241ae2010-08-26 12:40:47 -0700600#ifdef CONFIG_ARCH_DAVINCI_DA850
601static struct resource da850_mmcsd1_resources[] = {
602 { /* registers */
603 .start = DA850_MMCSD1_BASE,
604 .end = DA850_MMCSD1_BASE + SZ_4K - 1,
605 .flags = IORESOURCE_MEM,
606 },
607 { /* interrupt */
608 .start = IRQ_DA850_MMCSDINT0_1,
609 .end = IRQ_DA850_MMCSDINT0_1,
610 .flags = IORESOURCE_IRQ,
611 },
612 { /* DMA RX */
Michael Williamsone38c2b22011-02-22 13:36:57 +0000613 .start = DA850_DMA_MMCSD1_RX,
614 .end = DA850_DMA_MMCSD1_RX,
Juha Kuikkab8241ae2010-08-26 12:40:47 -0700615 .flags = IORESOURCE_DMA,
616 },
617 { /* DMA TX */
Michael Williamsone38c2b22011-02-22 13:36:57 +0000618 .start = DA850_DMA_MMCSD1_TX,
619 .end = DA850_DMA_MMCSD1_TX,
Juha Kuikkab8241ae2010-08-26 12:40:47 -0700620 .flags = IORESOURCE_DMA,
621 },
622};
623
624static struct platform_device da850_mmcsd1_device = {
625 .name = "davinci_mmc",
626 .id = 1,
627 .num_resources = ARRAY_SIZE(da850_mmcsd1_resources),
628 .resource = da850_mmcsd1_resources,
629};
630
631int __init da850_register_mmcsd1(struct davinci_mmc_config *config)
632{
633 da850_mmcsd1_device.dev.platform_data = config;
634 return platform_device_register(&da850_mmcsd1_device);
635}
636#endif
637
Mark A. Greerc51df702009-09-15 18:15:54 -0700638static struct resource da8xx_rtc_resources[] = {
639 {
640 .start = DA8XX_RTC_BASE,
641 .end = DA8XX_RTC_BASE + SZ_4K - 1,
642 .flags = IORESOURCE_MEM,
643 },
644 { /* timer irq */
645 .start = IRQ_DA8XX_RTC,
646 .end = IRQ_DA8XX_RTC,
647 .flags = IORESOURCE_IRQ,
648 },
649 { /* alarm irq */
650 .start = IRQ_DA8XX_RTC,
651 .end = IRQ_DA8XX_RTC,
652 .flags = IORESOURCE_IRQ,
653 },
654};
655
656static struct platform_device da8xx_rtc_device = {
657 .name = "omap_rtc",
658 .id = -1,
659 .num_resources = ARRAY_SIZE(da8xx_rtc_resources),
660 .resource = da8xx_rtc_resources,
661};
662
663int da8xx_register_rtc(void)
664{
Sekhar Nori75c99bb2009-11-16 17:21:31 +0530665 int ret;
Cyril Chemparathydb6db5d2010-05-07 17:06:33 -0400666 void __iomem *base;
667
668 base = ioremap(DA8XX_RTC_BASE, SZ_4K);
669 if (WARN_ON(!base))
670 return -ENOMEM;
Sekhar Nori75c99bb2009-11-16 17:21:31 +0530671
Mark A. Greerc51df702009-09-15 18:15:54 -0700672 /* Unlock the rtc's registers */
Cyril Chemparathydb6db5d2010-05-07 17:06:33 -0400673 __raw_writel(0x83e70b13, base + 0x6c);
674 __raw_writel(0x95a4f1e0, base + 0x70);
675
676 iounmap(base);
Mark A. Greerc51df702009-09-15 18:15:54 -0700677
Sekhar Nori75c99bb2009-11-16 17:21:31 +0530678 ret = platform_device_register(&da8xx_rtc_device);
679 if (!ret)
680 /* Atleast on DA850, RTC is a wakeup source */
681 device_init_wakeup(&da8xx_rtc_device.dev, true);
682
683 return ret;
Mark A. Greerc51df702009-09-15 18:15:54 -0700684}
Sekhar Nori1960e692009-10-22 15:12:14 +0530685
Sekhar Nori948c66d2009-11-16 17:21:37 +0530686static void __iomem *da8xx_ddr2_ctlr_base;
687void __iomem * __init da8xx_get_mem_ctlr(void)
688{
689 if (da8xx_ddr2_ctlr_base)
690 return da8xx_ddr2_ctlr_base;
691
692 da8xx_ddr2_ctlr_base = ioremap(DA8XX_DDR2_CTL_BASE, SZ_32K);
693 if (!da8xx_ddr2_ctlr_base)
694 pr_warning("%s: Unable to map DDR2 controller", __func__);
695
696 return da8xx_ddr2_ctlr_base;
697}
698
Sekhar Nori1960e692009-10-22 15:12:14 +0530699static struct resource da8xx_cpuidle_resources[] = {
700 {
701 .start = DA8XX_DDR2_CTL_BASE,
702 .end = DA8XX_DDR2_CTL_BASE + SZ_32K - 1,
703 .flags = IORESOURCE_MEM,
704 },
705};
706
707/* DA8XX devices support DDR2 power down */
708static struct davinci_cpuidle_config da8xx_cpuidle_pdata = {
709 .ddr2_pdown = 1,
710};
711
712
713static struct platform_device da8xx_cpuidle_device = {
714 .name = "cpuidle-davinci",
715 .num_resources = ARRAY_SIZE(da8xx_cpuidle_resources),
716 .resource = da8xx_cpuidle_resources,
717 .dev = {
718 .platform_data = &da8xx_cpuidle_pdata,
719 },
720};
721
722int __init da8xx_register_cpuidle(void)
723{
Sekhar Nori948c66d2009-11-16 17:21:37 +0530724 da8xx_cpuidle_pdata.ddr2_ctlr_base = da8xx_get_mem_ctlr();
725
Sekhar Nori1960e692009-10-22 15:12:14 +0530726 return platform_device_register(&da8xx_cpuidle_device);
727}
Michael Williamson54ce6882011-02-24 10:18:28 +0530728
729static struct resource da8xx_spi0_resources[] = {
730 [0] = {
731 .start = DA8XX_SPI0_BASE,
732 .end = DA8XX_SPI0_BASE + SZ_4K - 1,
733 .flags = IORESOURCE_MEM,
734 },
735 [1] = {
736 .start = IRQ_DA8XX_SPINT0,
737 .end = IRQ_DA8XX_SPINT0,
738 .flags = IORESOURCE_IRQ,
739 },
740 [2] = {
741 .start = DA8XX_DMA_SPI0_RX,
742 .end = DA8XX_DMA_SPI0_RX,
743 .flags = IORESOURCE_DMA,
744 },
745 [3] = {
746 .start = DA8XX_DMA_SPI0_TX,
747 .end = DA8XX_DMA_SPI0_TX,
748 .flags = IORESOURCE_DMA,
749 },
750};
751
752static struct resource da8xx_spi1_resources[] = {
753 [0] = {
Sergei Shtylyov9e7d24f2011-04-06 17:17:21 +0000754 .start = DA830_SPI1_BASE,
755 .end = DA830_SPI1_BASE + SZ_4K - 1,
Michael Williamson54ce6882011-02-24 10:18:28 +0530756 .flags = IORESOURCE_MEM,
757 },
758 [1] = {
759 .start = IRQ_DA8XX_SPINT1,
760 .end = IRQ_DA8XX_SPINT1,
761 .flags = IORESOURCE_IRQ,
762 },
763 [2] = {
764 .start = DA8XX_DMA_SPI1_RX,
765 .end = DA8XX_DMA_SPI1_RX,
766 .flags = IORESOURCE_DMA,
767 },
768 [3] = {
769 .start = DA8XX_DMA_SPI1_TX,
770 .end = DA8XX_DMA_SPI1_TX,
771 .flags = IORESOURCE_DMA,
772 },
773};
774
775struct davinci_spi_platform_data da8xx_spi_pdata[] = {
776 [0] = {
777 .version = SPI_VERSION_2,
778 .intr_line = 1,
779 .dma_event_q = EVENTQ_0,
780 },
781 [1] = {
782 .version = SPI_VERSION_2,
783 .intr_line = 1,
784 .dma_event_q = EVENTQ_0,
785 },
786};
787
788static struct platform_device da8xx_spi_device[] = {
789 [0] = {
790 .name = "spi_davinci",
791 .id = 0,
792 .num_resources = ARRAY_SIZE(da8xx_spi0_resources),
793 .resource = da8xx_spi0_resources,
794 .dev = {
795 .platform_data = &da8xx_spi_pdata[0],
796 },
797 },
798 [1] = {
799 .name = "spi_davinci",
800 .id = 1,
801 .num_resources = ARRAY_SIZE(da8xx_spi1_resources),
802 .resource = da8xx_spi1_resources,
803 .dev = {
804 .platform_data = &da8xx_spi_pdata[1],
805 },
806 },
807};
808
Uwe Kleine-Königd65566e2012-03-30 22:13:53 +0200809int __init da8xx_register_spi(int instance, const struct spi_board_info *info,
Michael Williamson54ce6882011-02-24 10:18:28 +0530810 unsigned len)
811{
812 int ret;
813
814 if (instance < 0 || instance > 1)
815 return -EINVAL;
816
817 ret = spi_register_board_info(info, len);
818 if (ret)
819 pr_warning("%s: failed to register board info for spi %d :"
820 " %d\n", __func__, instance, ret);
821
822 da8xx_spi_pdata[instance].num_chipselect = len;
823
Sergei Shtylyov9e7d24f2011-04-06 17:17:21 +0000824 if (instance == 1 && cpu_is_davinci_da850()) {
825 da8xx_spi1_resources[0].start = DA850_SPI1_BASE;
826 da8xx_spi1_resources[0].end = DA850_SPI1_BASE + SZ_4K - 1;
827 }
828
Michael Williamson54ce6882011-02-24 10:18:28 +0530829 return platform_device_register(&da8xx_spi_device[instance]);
830}
Sekhar Noricbb2c962011-07-06 06:01:23 +0000831
832#ifdef CONFIG_ARCH_DAVINCI_DA850
833
834static struct resource da850_sata_resources[] = {
835 {
836 .start = DA850_SATA_BASE,
837 .end = DA850_SATA_BASE + 0x1fff,
838 .flags = IORESOURCE_MEM,
839 },
840 {
841 .start = IRQ_DA850_SATAINT,
842 .flags = IORESOURCE_IRQ,
843 },
844};
845
846/* SATA PHY Control Register offset from AHCI base */
847#define SATA_P0PHYCR_REG 0x178
848
849#define SATA_PHY_MPY(x) ((x) << 0)
850#define SATA_PHY_LOS(x) ((x) << 6)
851#define SATA_PHY_RXCDR(x) ((x) << 10)
852#define SATA_PHY_RXEQ(x) ((x) << 13)
853#define SATA_PHY_TXSWING(x) ((x) << 19)
854#define SATA_PHY_ENPLL(x) ((x) << 31)
855
856static struct clk *da850_sata_clk;
857static unsigned long da850_sata_refclkpn;
858
859/* Supported DA850 SATA crystal frequencies */
860#define KHZ_TO_HZ(freq) ((freq) * 1000)
861static unsigned long da850_sata_xtal[] = {
862 KHZ_TO_HZ(300000),
863 KHZ_TO_HZ(250000),
864 0, /* Reserved */
865 KHZ_TO_HZ(187500),
866 KHZ_TO_HZ(150000),
867 KHZ_TO_HZ(125000),
868 KHZ_TO_HZ(120000),
869 KHZ_TO_HZ(100000),
870 KHZ_TO_HZ(75000),
871 KHZ_TO_HZ(60000),
872};
873
874static int da850_sata_init(struct device *dev, void __iomem *addr)
875{
876 int i, ret;
877 unsigned int val;
878
879 da850_sata_clk = clk_get(dev, NULL);
880 if (IS_ERR(da850_sata_clk))
881 return PTR_ERR(da850_sata_clk);
882
883 ret = clk_enable(da850_sata_clk);
884 if (ret)
885 goto err0;
886
887 /* Enable SATA clock receiver */
888 val = __raw_readl(DA8XX_SYSCFG1_VIRT(DA8XX_PWRDN_REG));
889 val &= ~BIT(0);
890 __raw_writel(val, DA8XX_SYSCFG1_VIRT(DA8XX_PWRDN_REG));
891
892 /* Get the multiplier needed for 1.5GHz PLL output */
893 for (i = 0; i < ARRAY_SIZE(da850_sata_xtal); i++)
894 if (da850_sata_xtal[i] == da850_sata_refclkpn)
895 break;
896
897 if (i == ARRAY_SIZE(da850_sata_xtal)) {
898 ret = -EINVAL;
899 goto err1;
900 }
901
902 val = SATA_PHY_MPY(i + 1) |
903 SATA_PHY_LOS(1) |
904 SATA_PHY_RXCDR(4) |
905 SATA_PHY_RXEQ(1) |
906 SATA_PHY_TXSWING(3) |
907 SATA_PHY_ENPLL(1);
908
909 __raw_writel(val, addr + SATA_P0PHYCR_REG);
910
911 return 0;
912
913err1:
914 clk_disable(da850_sata_clk);
915err0:
916 clk_put(da850_sata_clk);
917 return ret;
918}
919
920static void da850_sata_exit(struct device *dev)
921{
922 clk_disable(da850_sata_clk);
923 clk_put(da850_sata_clk);
924}
925
926static struct ahci_platform_data da850_sata_pdata = {
927 .init = da850_sata_init,
928 .exit = da850_sata_exit,
929};
930
931static u64 da850_sata_dmamask = DMA_BIT_MASK(32);
932
933static struct platform_device da850_sata_device = {
934 .name = "ahci",
935 .id = -1,
936 .dev = {
937 .platform_data = &da850_sata_pdata,
938 .dma_mask = &da850_sata_dmamask,
939 .coherent_dma_mask = DMA_BIT_MASK(32),
940 },
941 .num_resources = ARRAY_SIZE(da850_sata_resources),
942 .resource = da850_sata_resources,
943};
944
945int __init da850_register_sata(unsigned long refclkpn)
946{
947 da850_sata_refclkpn = refclkpn;
948 if (!da850_sata_refclkpn)
949 return -EINVAL;
950
951 return platform_device_register(&da850_sata_device);
952}
953#endif