OMAP3: SR: Remove redundant defines
[linux-ginger.git] / arch / arm / mach-davinci / devices.c
bloba55b650db71e20ecf9884b4bdbe5b1c1f2ee151d
1 /*
2 * mach-davinci/devices.c
4 * DaVinci platform device setup/initialization
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.
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>
19 #include <asm/mach/map.h>
21 #include <mach/hardware.h>
22 #include <mach/i2c.h>
23 #include <mach/irqs.h>
24 #include <mach/cputype.h>
25 #include <mach/mux.h>
26 #include <mach/edma.h>
27 #include <mach/mmc.h>
28 #include <mach/time.h>
30 #define DAVINCI_I2C_BASE 0x01C21000
31 #define DAVINCI_MMCSD0_BASE 0x01E10000
32 #define DM355_MMCSD0_BASE 0x01E11000
33 #define DM355_MMCSD1_BASE 0x01E00000
34 #define DM365_MMCSD0_BASE 0x01D11000
35 #define DM365_MMCSD1_BASE 0x01D00000
37 static struct resource i2c_resources[] = {
39 .start = DAVINCI_I2C_BASE,
40 .end = DAVINCI_I2C_BASE + 0x40,
41 .flags = IORESOURCE_MEM,
44 .start = IRQ_I2C,
45 .flags = IORESOURCE_IRQ,
49 static struct platform_device davinci_i2c_device = {
50 .name = "i2c_davinci",
51 .id = 1,
52 .num_resources = ARRAY_SIZE(i2c_resources),
53 .resource = i2c_resources,
56 void __init davinci_init_i2c(struct davinci_i2c_platform_data *pdata)
58 if (cpu_is_davinci_dm644x())
59 davinci_cfg_reg(DM644X_I2C);
61 davinci_i2c_device.dev.platform_data = pdata;
62 (void) platform_device_register(&davinci_i2c_device);
65 #if defined(CONFIG_MMC_DAVINCI) || defined(CONFIG_MMC_DAVINCI_MODULE)
67 static u64 mmcsd0_dma_mask = DMA_BIT_MASK(32);
69 static struct resource mmcsd0_resources[] = {
71 /* different on dm355 */
72 .start = DAVINCI_MMCSD0_BASE,
73 .end = DAVINCI_MMCSD0_BASE + SZ_4K - 1,
74 .flags = IORESOURCE_MEM,
76 /* IRQs: MMC/SD, then SDIO */
78 .start = IRQ_MMCINT,
79 .flags = IORESOURCE_IRQ,
80 }, {
81 /* different on dm355 */
82 .start = IRQ_SDIOINT,
83 .flags = IORESOURCE_IRQ,
85 /* DMA channels: RX, then TX */
87 .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCRXEVT),
88 .flags = IORESOURCE_DMA,
89 }, {
90 .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCTXEVT),
91 .flags = IORESOURCE_DMA,
95 static struct platform_device davinci_mmcsd0_device = {
96 .name = "davinci_mmc",
97 .id = 0,
98 .dev = {
99 .dma_mask = &mmcsd0_dma_mask,
100 .coherent_dma_mask = DMA_BIT_MASK(32),
102 .num_resources = ARRAY_SIZE(mmcsd0_resources),
103 .resource = mmcsd0_resources,
106 static u64 mmcsd1_dma_mask = DMA_BIT_MASK(32);
108 static struct resource mmcsd1_resources[] = {
110 .start = DM355_MMCSD1_BASE,
111 .end = DM355_MMCSD1_BASE + SZ_4K - 1,
112 .flags = IORESOURCE_MEM,
114 /* IRQs: MMC/SD, then SDIO */
116 .start = IRQ_DM355_MMCINT1,
117 .flags = IORESOURCE_IRQ,
118 }, {
119 .start = IRQ_DM355_SDIOINT1,
120 .flags = IORESOURCE_IRQ,
122 /* DMA channels: RX, then TX */
124 .start = EDMA_CTLR_CHAN(0, 30), /* rx */
125 .flags = IORESOURCE_DMA,
126 }, {
127 .start = EDMA_CTLR_CHAN(0, 31), /* tx */
128 .flags = IORESOURCE_DMA,
132 static struct platform_device davinci_mmcsd1_device = {
133 .name = "davinci_mmc",
134 .id = 1,
135 .dev = {
136 .dma_mask = &mmcsd1_dma_mask,
137 .coherent_dma_mask = DMA_BIT_MASK(32),
139 .num_resources = ARRAY_SIZE(mmcsd1_resources),
140 .resource = mmcsd1_resources,
144 void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
146 struct platform_device *pdev = NULL;
148 if (WARN_ON(cpu_is_davinci_dm646x()))
149 return;
151 /* REVISIT: update PINMUX, ARM_IRQMUX, and EDMA_EVTMUX here too;
152 * for example if MMCSD1 is used for SDIO, maybe DAT2 is unused.
154 * FIXME dm6441 (no MMC/SD), dm357 (one), and dm335 (two) are
155 * not handled right here ...
157 switch (module) {
158 case 1:
159 if (cpu_is_davinci_dm355()) {
160 /* REVISIT we may not need all these pins if e.g. this
161 * is a hard-wired SDIO device...
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 } else if (cpu_is_davinci_dm365()) {
170 void __iomem *pupdctl1 =
171 IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE + 0x7c);
173 /* Configure pull down control */
174 __raw_writel((__raw_readl(pupdctl1) & ~0x400),
175 pupdctl1);
177 mmcsd1_resources[0].start = DM365_MMCSD1_BASE;
178 mmcsd1_resources[0].end = DM365_MMCSD1_BASE +
179 SZ_4K - 1;
180 mmcsd0_resources[2].start = IRQ_DM365_SDIOINT1;
181 } else
182 break;
184 pdev = &davinci_mmcsd1_device;
185 break;
186 case 0:
187 if (cpu_is_davinci_dm355()) {
188 mmcsd0_resources[0].start = DM355_MMCSD0_BASE;
189 mmcsd0_resources[0].end = DM355_MMCSD0_BASE + SZ_4K - 1;
190 mmcsd0_resources[2].start = IRQ_DM355_SDIOINT0;
192 /* expose all 6 MMC0 signals: CLK, CMD, DATA[0..3] */
193 davinci_cfg_reg(DM355_MMCSD0);
195 /* enable RX EDMA */
196 davinci_cfg_reg(DM355_EVT26_MMC0_RX);
197 } else if (cpu_is_davinci_dm365()) {
198 mmcsd0_resources[0].start = DM365_MMCSD0_BASE;
199 mmcsd0_resources[0].end = DM365_MMCSD0_BASE +
200 SZ_4K - 1;
201 mmcsd0_resources[2].start = IRQ_DM365_SDIOINT0;
202 } else if (cpu_is_davinci_dm644x()) {
203 /* REVISIT: should this be in board-init code? */
204 void __iomem *base =
205 IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE);
207 /* Power-on 3.3V IO cells */
208 __raw_writel(0, base + DM64XX_VDD3P3V_PWDN);
209 /*Set up the pull regiter for MMC */
210 davinci_cfg_reg(DM644X_MSTK);
213 pdev = &davinci_mmcsd0_device;
214 break;
217 if (WARN_ON(!pdev))
218 return;
220 pdev->dev.platform_data = config;
221 platform_device_register(pdev);
224 #else
226 void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
230 #endif
232 /*-------------------------------------------------------------------------*/
234 static struct resource wdt_resources[] = {
236 .start = DAVINCI_WDOG_BASE,
237 .end = DAVINCI_WDOG_BASE + SZ_1K - 1,
238 .flags = IORESOURCE_MEM,
242 struct platform_device davinci_wdt_device = {
243 .name = "watchdog",
244 .id = -1,
245 .num_resources = ARRAY_SIZE(wdt_resources),
246 .resource = wdt_resources,
249 static void davinci_init_wdt(void)
251 platform_device_register(&davinci_wdt_device);
254 /*-------------------------------------------------------------------------*/
256 struct davinci_timer_instance davinci_timer_instance[2] = {
258 .base = IO_ADDRESS(DAVINCI_TIMER0_BASE),
259 .bottom_irq = IRQ_TINT0_TINT12,
260 .top_irq = IRQ_TINT0_TINT34,
263 .base = IO_ADDRESS(DAVINCI_TIMER1_BASE),
264 .bottom_irq = IRQ_TINT1_TINT12,
265 .top_irq = IRQ_TINT1_TINT34,
269 /*-------------------------------------------------------------------------*/
271 static int __init davinci_init_devices(void)
273 /* please keep these calls, and their implementations above,
274 * in alphabetical order so they're easier to sort through.
276 davinci_init_wdt();
278 return 0;
280 arch_initcall(davinci_init_devices);