davinci: dm365: add EDMA support
[deliverable/linux.git] / arch / arm / mach-davinci / devices.c
CommitLineData
d395e6ad
KS
1/*
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
12#include <linux/module.h>
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
16#include <linux/dma-mapping.h>
17#include <linux/io.h>
18
19#include <asm/mach/map.h>
20
21#include <mach/hardware.h>
22#include <mach/i2c.h>
80b02c17 23#include <mach/irqs.h>
5526b3f7
KH
24#include <mach/cputype.h>
25#include <mach/mux.h>
2dbf56ae
KH
26#include <mach/edma.h>
27#include <mach/mmc.h>
f64691b3 28#include <mach/time.h>
d395e6ad 29
f5c122da 30#define DAVINCI_I2C_BASE 0x01C21000
2dbf56ae
KH
31#define DAVINCI_MMCSD0_BASE 0x01E10000
32#define DM355_MMCSD0_BASE 0x01E11000
33#define DM355_MMCSD1_BASE 0x01E00000
f5c122da 34
d395e6ad
KS
35static struct resource i2c_resources[] = {
36 {
37 .start = DAVINCI_I2C_BASE,
38 .end = DAVINCI_I2C_BASE + 0x40,
39 .flags = IORESOURCE_MEM,
40 },
41 {
42 .start = IRQ_I2C,
43 .flags = IORESOURCE_IRQ,
44 },
45};
46
47static struct platform_device davinci_i2c_device = {
48 .name = "i2c_davinci",
49 .id = 1,
50 .num_resources = ARRAY_SIZE(i2c_resources),
51 .resource = i2c_resources,
52};
53
54void __init davinci_init_i2c(struct davinci_i2c_platform_data *pdata)
55{
5526b3f7
KH
56 if (cpu_is_davinci_dm644x())
57 davinci_cfg_reg(DM644X_I2C);
58
d395e6ad
KS
59 davinci_i2c_device.dev.platform_data = pdata;
60 (void) platform_device_register(&davinci_i2c_device);
61}
62
2dbf56ae
KH
63#if defined(CONFIG_MMC_DAVINCI) || defined(CONFIG_MMC_DAVINCI_MODULE)
64
b0958aed 65static u64 mmcsd0_dma_mask = DMA_BIT_MASK(32);
2dbf56ae
KH
66
67static struct resource mmcsd0_resources[] = {
68 {
69 /* different on dm355 */
70 .start = DAVINCI_MMCSD0_BASE,
71 .end = DAVINCI_MMCSD0_BASE + SZ_4K - 1,
72 .flags = IORESOURCE_MEM,
73 },
74 /* IRQs: MMC/SD, then SDIO */
75 {
76 .start = IRQ_MMCINT,
77 .flags = IORESOURCE_IRQ,
78 }, {
79 /* different on dm355 */
80 .start = IRQ_SDIOINT,
81 .flags = IORESOURCE_IRQ,
82 },
83 /* DMA channels: RX, then TX */
84 {
60902a2c 85 .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCRXEVT),
2dbf56ae
KH
86 .flags = IORESOURCE_DMA,
87 }, {
60902a2c 88 .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCTXEVT),
2dbf56ae
KH
89 .flags = IORESOURCE_DMA,
90 },
91};
92
93static struct platform_device davinci_mmcsd0_device = {
94 .name = "davinci_mmc",
95 .id = 0,
96 .dev = {
97 .dma_mask = &mmcsd0_dma_mask,
b0958aed 98 .coherent_dma_mask = DMA_BIT_MASK(32),
2dbf56ae
KH
99 },
100 .num_resources = ARRAY_SIZE(mmcsd0_resources),
101 .resource = mmcsd0_resources,
102};
103
b0958aed 104static u64 mmcsd1_dma_mask = DMA_BIT_MASK(32);
2dbf56ae
KH
105
106static struct resource mmcsd1_resources[] = {
107 {
108 .start = DM355_MMCSD1_BASE,
109 .end = DM355_MMCSD1_BASE + SZ_4K - 1,
110 .flags = IORESOURCE_MEM,
111 },
112 /* IRQs: MMC/SD, then SDIO */
113 {
114 .start = IRQ_DM355_MMCINT1,
115 .flags = IORESOURCE_IRQ,
116 }, {
117 .start = IRQ_DM355_SDIOINT1,
118 .flags = IORESOURCE_IRQ,
119 },
120 /* DMA channels: RX, then TX */
121 {
60902a2c 122 .start = EDMA_CTLR_CHAN(0, 30), /* rx */
2dbf56ae
KH
123 .flags = IORESOURCE_DMA,
124 }, {
60902a2c 125 .start = EDMA_CTLR_CHAN(0, 31), /* tx */
2dbf56ae
KH
126 .flags = IORESOURCE_DMA,
127 },
128};
129
130static struct platform_device davinci_mmcsd1_device = {
131 .name = "davinci_mmc",
132 .id = 1,
133 .dev = {
134 .dma_mask = &mmcsd1_dma_mask,
b0958aed 135 .coherent_dma_mask = DMA_BIT_MASK(32),
2dbf56ae
KH
136 },
137 .num_resources = ARRAY_SIZE(mmcsd1_resources),
138 .resource = mmcsd1_resources,
139};
140
141
142void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
143{
144 struct platform_device *pdev = NULL;
145
146 if (WARN_ON(cpu_is_davinci_dm646x()))
147 return;
148
149 /* REVISIT: update PINMUX, ARM_IRQMUX, and EDMA_EVTMUX here too;
150 * for example if MMCSD1 is used for SDIO, maybe DAT2 is unused.
151 *
152 * FIXME dm6441 (no MMC/SD), dm357 (one), and dm335 (two) are
153 * not handled right here ...
154 */
155 switch (module) {
156 case 1:
157 if (!cpu_is_davinci_dm355())
158 break;
159
160 /* REVISIT we may not need all these pins if e.g. this
161 * is a hard-wired SDIO device...
162 */
163 davinci_cfg_reg(DM355_SD1_CMD);
164 davinci_cfg_reg(DM355_SD1_CLK);
165 davinci_cfg_reg(DM355_SD1_DATA0);
166 davinci_cfg_reg(DM355_SD1_DATA1);
167 davinci_cfg_reg(DM355_SD1_DATA2);
168 davinci_cfg_reg(DM355_SD1_DATA3);
169
170 pdev = &davinci_mmcsd1_device;
171 break;
172 case 0:
173 if (cpu_is_davinci_dm355()) {
174 mmcsd0_resources[0].start = DM355_MMCSD0_BASE;
175 mmcsd0_resources[0].end = DM355_MMCSD0_BASE + SZ_4K - 1;
176 mmcsd0_resources[2].start = IRQ_DM355_SDIOINT0;
177
178 /* expose all 6 MMC0 signals: CLK, CMD, DATA[0..3] */
179 davinci_cfg_reg(DM355_MMCSD0);
180
181 /* enable RX EDMA */
182 davinci_cfg_reg(DM355_EVT26_MMC0_RX);
183 }
184
185 else if (cpu_is_davinci_dm644x()) {
186 /* REVISIT: should this be in board-init code? */
187 void __iomem *base =
188 IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE);
189
190 /* Power-on 3.3V IO cells */
191 __raw_writel(0, base + DM64XX_VDD3P3V_PWDN);
192 /*Set up the pull regiter for MMC */
193 davinci_cfg_reg(DM644X_MSTK);
194 }
195
196 pdev = &davinci_mmcsd0_device;
197 break;
198 }
199
200 if (WARN_ON(!pdev))
201 return;
202
203 pdev->dev.platform_data = config;
204 platform_device_register(pdev);
205}
206
207#else
208
209void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
210{
211}
212
213#endif
214
fb631387
KH
215/*-------------------------------------------------------------------------*/
216
217static struct resource wdt_resources[] = {
218 {
5fcd294d
KH
219 .start = DAVINCI_WDOG_BASE,
220 .end = DAVINCI_WDOG_BASE + SZ_1K - 1,
fb631387
KH
221 .flags = IORESOURCE_MEM,
222 },
223};
224
225struct platform_device davinci_wdt_device = {
226 .name = "watchdog",
227 .id = -1,
228 .num_resources = ARRAY_SIZE(wdt_resources),
229 .resource = wdt_resources,
230};
231
232static void davinci_init_wdt(void)
233{
234 platform_device_register(&davinci_wdt_device);
235}
236
237/*-------------------------------------------------------------------------*/
238
f64691b3
MG
239struct davinci_timer_instance davinci_timer_instance[2] = {
240 {
241 .base = IO_ADDRESS(DAVINCI_TIMER0_BASE),
242 .bottom_irq = IRQ_TINT0_TINT12,
243 .top_irq = IRQ_TINT0_TINT34,
244 },
245 {
246 .base = IO_ADDRESS(DAVINCI_TIMER1_BASE),
247 .bottom_irq = IRQ_TINT1_TINT12,
248 .top_irq = IRQ_TINT1_TINT34,
249 },
250};
251
252/*-------------------------------------------------------------------------*/
253
fb631387
KH
254static int __init davinci_init_devices(void)
255{
256 /* please keep these calls, and their implementations above,
257 * in alphabetical order so they're easier to sort through.
258 */
259 davinci_init_wdt();
260
261 return 0;
262}
263arch_initcall(davinci_init_devices);
264
This page took 0.094903 seconds and 5 git commands to generate.