blob: 22ebc64bc9d99a5bd71a52f801f3903a6f5b04d9 [file] [log] [blame]
Komal Shahd395e6a2008-09-07 23:41:28 -07001/*
2 * mach-davinci/devices.c
3 *
4 * DaVinci platform device setup/initialization
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
Komal Shahd395e6a2008-09-07 23:41:28 -070012#include <linux/init.h>
13#include <linux/platform_device.h>
14#include <linux/dma-mapping.h>
15#include <linux/io.h>
16
Komal Shahd395e6a2008-09-07 23:41:28 -070017#include <mach/hardware.h>
18#include <mach/i2c.h>
Russell King80b02c12009-01-08 10:01:47 +000019#include <mach/irqs.h>
Kevin Hilman5526b3f2009-04-14 09:50:37 -050020#include <mach/cputype.h>
21#include <mach/mux.h>
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -070022#include <mach/edma.h>
23#include <mach/mmc.h>
Mark A. Greerf64691b2009-04-15 12:40:11 -070024#include <mach/time.h>
Komal Shahd395e6a2008-09-07 23:41:28 -070025
Kevin Hilman28552c22010-02-25 15:36:38 -080026#include "clock.h"
27
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050028#define DAVINCI_I2C_BASE 0x01C21000
Sergei Shtylyov7a9978a2010-04-21 18:11:33 +040029#define DAVINCI_ATA_BASE 0x01C66000
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -070030#define DAVINCI_MMCSD0_BASE 0x01E10000
31#define DM355_MMCSD0_BASE 0x01E11000
32#define DM355_MMCSD1_BASE 0x01E00000
Sandeep Paulraj19ff3bf2009-06-20 13:58:32 -040033#define DM365_MMCSD0_BASE 0x01D11000
34#define DM365_MMCSD1_BASE 0x01D00000
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050035
Komal Shahd395e6a2008-09-07 23:41:28 -070036static struct resource i2c_resources[] = {
37 {
38 .start = DAVINCI_I2C_BASE,
39 .end = DAVINCI_I2C_BASE + 0x40,
40 .flags = IORESOURCE_MEM,
41 },
42 {
43 .start = IRQ_I2C,
44 .flags = IORESOURCE_IRQ,
45 },
46};
47
48static struct platform_device davinci_i2c_device = {
49 .name = "i2c_davinci",
50 .id = 1,
51 .num_resources = ARRAY_SIZE(i2c_resources),
52 .resource = i2c_resources,
53};
54
55void __init davinci_init_i2c(struct davinci_i2c_platform_data *pdata)
56{
Kevin Hilman5526b3f2009-04-14 09:50:37 -050057 if (cpu_is_davinci_dm644x())
58 davinci_cfg_reg(DM644X_I2C);
59
Komal Shahd395e6a2008-09-07 23:41:28 -070060 davinci_i2c_device.dev.platform_data = pdata;
61 (void) platform_device_register(&davinci_i2c_device);
62}
63
Sergei Shtylyov7a9978a2010-04-21 18:11:33 +040064static struct resource ide_resources[] = {
65 {
66 .start = DAVINCI_ATA_BASE,
67 .end = DAVINCI_ATA_BASE + 0x7ff,
68 .flags = IORESOURCE_MEM,
69 },
70 {
71 .start = IRQ_IDE,
72 .end = IRQ_IDE,
73 .flags = IORESOURCE_IRQ,
74 },
75};
76
77static u64 ide_dma_mask = DMA_BIT_MASK(32);
78
79static struct platform_device ide_device = {
80 .name = "palm_bk3710",
81 .id = -1,
82 .resource = ide_resources,
83 .num_resources = ARRAY_SIZE(ide_resources),
84 .dev = {
85 .dma_mask = &ide_dma_mask,
86 .coherent_dma_mask = DMA_BIT_MASK(32),
87 },
88};
89
90void __init davinci_init_ide(void)
91{
92 if (cpu_is_davinci_dm644x()) {
93 davinci_cfg_reg(DM644X_HPIEN_DISABLE);
94 davinci_cfg_reg(DM644X_ATAEN);
95 davinci_cfg_reg(DM644X_HDIREN);
96 } else if (cpu_is_davinci_dm646x()) {
97 /* IRQ_DM646X_IDE is the same as IRQ_IDE */
98 davinci_cfg_reg(DM646X_ATAEN);
99 } else {
100 WARN_ON(1);
101 return;
102 }
103
104 platform_device_register(&ide_device);
105}
106
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700107#if defined(CONFIG_MMC_DAVINCI) || defined(CONFIG_MMC_DAVINCI_MODULE)
108
Kevin Hilmanb0958ae2009-05-29 18:54:14 +0100109static u64 mmcsd0_dma_mask = DMA_BIT_MASK(32);
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700110
111static struct resource mmcsd0_resources[] = {
112 {
113 /* different on dm355 */
114 .start = DAVINCI_MMCSD0_BASE,
115 .end = DAVINCI_MMCSD0_BASE + SZ_4K - 1,
116 .flags = IORESOURCE_MEM,
117 },
118 /* IRQs: MMC/SD, then SDIO */
119 {
120 .start = IRQ_MMCINT,
121 .flags = IORESOURCE_IRQ,
122 }, {
123 /* different on dm355 */
124 .start = IRQ_SDIOINT,
125 .flags = IORESOURCE_IRQ,
126 },
127 /* DMA channels: RX, then TX */
128 {
Sudhakar Rajashekhara60902a22009-05-21 07:41:35 -0400129 .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCRXEVT),
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700130 .flags = IORESOURCE_DMA,
131 }, {
Sudhakar Rajashekhara60902a22009-05-21 07:41:35 -0400132 .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCTXEVT),
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700133 .flags = IORESOURCE_DMA,
134 },
135};
136
137static struct platform_device davinci_mmcsd0_device = {
138 .name = "davinci_mmc",
139 .id = 0,
140 .dev = {
141 .dma_mask = &mmcsd0_dma_mask,
Kevin Hilmanb0958ae2009-05-29 18:54:14 +0100142 .coherent_dma_mask = DMA_BIT_MASK(32),
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700143 },
144 .num_resources = ARRAY_SIZE(mmcsd0_resources),
145 .resource = mmcsd0_resources,
146};
147
Kevin Hilmanb0958ae2009-05-29 18:54:14 +0100148static u64 mmcsd1_dma_mask = DMA_BIT_MASK(32);
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700149
150static struct resource mmcsd1_resources[] = {
151 {
152 .start = DM355_MMCSD1_BASE,
153 .end = DM355_MMCSD1_BASE + SZ_4K - 1,
154 .flags = IORESOURCE_MEM,
155 },
156 /* IRQs: MMC/SD, then SDIO */
157 {
158 .start = IRQ_DM355_MMCINT1,
159 .flags = IORESOURCE_IRQ,
160 }, {
161 .start = IRQ_DM355_SDIOINT1,
162 .flags = IORESOURCE_IRQ,
163 },
164 /* DMA channels: RX, then TX */
165 {
Sudhakar Rajashekhara60902a22009-05-21 07:41:35 -0400166 .start = EDMA_CTLR_CHAN(0, 30), /* rx */
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700167 .flags = IORESOURCE_DMA,
168 }, {
Sudhakar Rajashekhara60902a22009-05-21 07:41:35 -0400169 .start = EDMA_CTLR_CHAN(0, 31), /* tx */
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700170 .flags = IORESOURCE_DMA,
171 },
172};
173
174static struct platform_device davinci_mmcsd1_device = {
175 .name = "davinci_mmc",
176 .id = 1,
177 .dev = {
178 .dma_mask = &mmcsd1_dma_mask,
Kevin Hilmanb0958ae2009-05-29 18:54:14 +0100179 .coherent_dma_mask = DMA_BIT_MASK(32),
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700180 },
181 .num_resources = ARRAY_SIZE(mmcsd1_resources),
182 .resource = mmcsd1_resources,
183};
184
185
186void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
187{
188 struct platform_device *pdev = NULL;
189
190 if (WARN_ON(cpu_is_davinci_dm646x()))
191 return;
192
193 /* REVISIT: update PINMUX, ARM_IRQMUX, and EDMA_EVTMUX here too;
194 * for example if MMCSD1 is used for SDIO, maybe DAT2 is unused.
195 *
196 * FIXME dm6441 (no MMC/SD), dm357 (one), and dm335 (two) are
197 * not handled right here ...
198 */
199 switch (module) {
200 case 1:
Sandeep Paulraj19ff3bf2009-06-20 13:58:32 -0400201 if (cpu_is_davinci_dm355()) {
202 /* REVISIT we may not need all these pins if e.g. this
203 * is a hard-wired SDIO device...
204 */
205 davinci_cfg_reg(DM355_SD1_CMD);
206 davinci_cfg_reg(DM355_SD1_CLK);
207 davinci_cfg_reg(DM355_SD1_DATA0);
208 davinci_cfg_reg(DM355_SD1_DATA1);
209 davinci_cfg_reg(DM355_SD1_DATA2);
210 davinci_cfg_reg(DM355_SD1_DATA3);
211 } else if (cpu_is_davinci_dm365()) {
212 void __iomem *pupdctl1 =
213 IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE + 0x7c);
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700214
Sandeep Paulraj19ff3bf2009-06-20 13:58:32 -0400215 /* Configure pull down control */
Sekhar Nori0a477f62010-07-14 17:09:45 +0530216 __raw_writel((__raw_readl(pupdctl1) & ~0xfc0),
Sandeep Paulraj19ff3bf2009-06-20 13:58:32 -0400217 pupdctl1);
218
219 mmcsd1_resources[0].start = DM365_MMCSD1_BASE;
220 mmcsd1_resources[0].end = DM365_MMCSD1_BASE +
221 SZ_4K - 1;
Phaneendra Kumareb5ba372009-08-27 17:06:56 -0400222 mmcsd1_resources[2].start = IRQ_DM365_SDIOINT1;
Sandeep Paulraj19ff3bf2009-06-20 13:58:32 -0400223 } else
224 break;
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700225
226 pdev = &davinci_mmcsd1_device;
227 break;
228 case 0:
229 if (cpu_is_davinci_dm355()) {
230 mmcsd0_resources[0].start = DM355_MMCSD0_BASE;
231 mmcsd0_resources[0].end = DM355_MMCSD0_BASE + SZ_4K - 1;
232 mmcsd0_resources[2].start = IRQ_DM355_SDIOINT0;
233
234 /* expose all 6 MMC0 signals: CLK, CMD, DATA[0..3] */
235 davinci_cfg_reg(DM355_MMCSD0);
236
237 /* enable RX EDMA */
238 davinci_cfg_reg(DM355_EVT26_MMC0_RX);
Sandeep Paulraj19ff3bf2009-06-20 13:58:32 -0400239 } else if (cpu_is_davinci_dm365()) {
240 mmcsd0_resources[0].start = DM365_MMCSD0_BASE;
241 mmcsd0_resources[0].end = DM365_MMCSD0_BASE +
242 SZ_4K - 1;
243 mmcsd0_resources[2].start = IRQ_DM365_SDIOINT0;
244 } else if (cpu_is_davinci_dm644x()) {
Kevin Hilman2dbf56ae2009-05-11 15:55:03 -0700245 /* REVISIT: should this be in board-init code? */
246 void __iomem *base =
247 IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE);
248
249 /* Power-on 3.3V IO cells */
250 __raw_writel(0, base + DM64XX_VDD3P3V_PWDN);
251 /*Set up the pull regiter for MMC */
252 davinci_cfg_reg(DM644X_MSTK);
253 }
254
255 pdev = &davinci_mmcsd0_device;
256 break;
257 }
258
259 if (WARN_ON(!pdev))
260 return;
261
262 pdev->dev.platform_data = config;
263 platform_device_register(pdev);
264}
265
266#else
267
268void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
269{
270}
271
272#endif
273
Kevin Hilmanfb631382009-04-29 16:23:59 -0700274/*-------------------------------------------------------------------------*/
275
276static struct resource wdt_resources[] = {
277 {
Kevin Hilman5fcd2942009-06-03 12:24:50 -0700278 .start = DAVINCI_WDOG_BASE,
279 .end = DAVINCI_WDOG_BASE + SZ_1K - 1,
Kevin Hilmanfb631382009-04-29 16:23:59 -0700280 .flags = IORESOURCE_MEM,
281 },
282};
283
284struct platform_device davinci_wdt_device = {
285 .name = "watchdog",
286 .id = -1,
287 .num_resources = ARRAY_SIZE(wdt_resources),
288 .resource = wdt_resources,
289};
290
291static void davinci_init_wdt(void)
292{
293 platform_device_register(&davinci_wdt_device);
294}
295
296/*-------------------------------------------------------------------------*/
297
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000298struct platform_device davinci_pcm_device = {
299 .name = "davinci-pcm-audio",
300 .id = -1,
301};
302
303static void davinci_init_pcm(void)
304{
305 platform_device_register(&davinci_pcm_device);
306}
307
308/*-------------------------------------------------------------------------*/
309
Mark A. Greerf64691b2009-04-15 12:40:11 -0700310struct davinci_timer_instance davinci_timer_instance[2] = {
311 {
Cyril Chemparathy1bcd38a2010-05-07 17:06:35 -0400312 .base = DAVINCI_TIMER0_BASE,
Mark A. Greerf64691b2009-04-15 12:40:11 -0700313 .bottom_irq = IRQ_TINT0_TINT12,
314 .top_irq = IRQ_TINT0_TINT34,
315 },
316 {
Cyril Chemparathy1bcd38a2010-05-07 17:06:35 -0400317 .base = DAVINCI_TIMER1_BASE,
Mark A. Greerf64691b2009-04-15 12:40:11 -0700318 .bottom_irq = IRQ_TINT1_TINT12,
319 .top_irq = IRQ_TINT1_TINT34,
320 },
321};
322
323/*-------------------------------------------------------------------------*/
324
Kevin Hilmanfb631382009-04-29 16:23:59 -0700325static int __init davinci_init_devices(void)
326{
327 /* please keep these calls, and their implementations above,
328 * in alphabetical order so they're easier to sort through.
329 */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000330 davinci_init_pcm();
Kevin Hilmanfb631382009-04-29 16:23:59 -0700331 davinci_init_wdt();
332
333 return 0;
334}
335arch_initcall(davinci_init_devices);
336