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/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/dma-mapping.h>
16 #include <linux/reboot.h>
18 #include <mach/hardware.h>
19 #include <linux/platform_data/i2c-davinci.h>
20 #include <mach/irqs.h>
21 #include <mach/cputype.h>
23 #include <linux/platform_data/mmc-davinci.h>
24 #include <mach/time.h>
25 #include <linux/platform_data/edma.h>
30 #define DAVINCI_I2C_BASE 0x01C21000
31 #define DAVINCI_ATA_BASE 0x01C66000
32 #define DAVINCI_MMCSD0_BASE 0x01E10000
33 #define DM355_MMCSD0_BASE 0x01E11000
34 #define DM355_MMCSD1_BASE 0x01E00000
35 #define DM365_MMCSD0_BASE 0x01D11000
36 #define DM365_MMCSD1_BASE 0x01D00000
38 void __iomem *davinci_sysmod_base;
40 void davinci_map_sysmod(void)
42 davinci_sysmod_base = ioremap_nocache(DAVINCI_SYSTEM_MODULE_BASE,
45 * Throw a bug since a lot of board initialization code depends
46 * on system module availability. ioremap() failing this early
47 * need careful looking into anyway.
49 BUG_ON(!davinci_sysmod_base);
52 static struct resource i2c_resources[] = {
54 .start = DAVINCI_I2C_BASE,
55 .end = DAVINCI_I2C_BASE + 0x40,
56 .flags = IORESOURCE_MEM,
60 .flags = IORESOURCE_IRQ,
64 static struct platform_device davinci_i2c_device = {
65 .name = "i2c_davinci",
67 .num_resources = ARRAY_SIZE(i2c_resources),
68 .resource = i2c_resources,
71 void __init davinci_init_i2c(struct davinci_i2c_platform_data *pdata)
73 if (cpu_is_davinci_dm644x())
74 davinci_cfg_reg(DM644X_I2C);
76 davinci_i2c_device.dev.platform_data = pdata;
77 (void) platform_device_register(&davinci_i2c_device);
80 static struct resource ide_resources[] = {
82 .start = DAVINCI_ATA_BASE,
83 .end = DAVINCI_ATA_BASE + 0x7ff,
84 .flags = IORESOURCE_MEM,
89 .flags = IORESOURCE_IRQ,
93 static u64 ide_dma_mask = DMA_BIT_MASK(32);
95 static struct platform_device ide_device = {
96 .name = "palm_bk3710",
98 .resource = ide_resources,
99 .num_resources = ARRAY_SIZE(ide_resources),
101 .dma_mask = &ide_dma_mask,
102 .coherent_dma_mask = DMA_BIT_MASK(32),
106 void __init davinci_init_ide(void)
108 if (cpu_is_davinci_dm644x()) {
109 davinci_cfg_reg(DM644X_HPIEN_DISABLE);
110 davinci_cfg_reg(DM644X_ATAEN);
111 davinci_cfg_reg(DM644X_HDIREN);
112 } else if (cpu_is_davinci_dm646x()) {
113 /* IRQ_DM646X_IDE is the same as IRQ_IDE */
114 davinci_cfg_reg(DM646X_ATAEN);
120 platform_device_register(&ide_device);
123 #if IS_ENABLED(CONFIG_MMC_DAVINCI)
125 static u64 mmcsd0_dma_mask = DMA_BIT_MASK(32);
127 static struct resource mmcsd0_resources[] = {
129 /* different on dm355 */
130 .start = DAVINCI_MMCSD0_BASE,
131 .end = DAVINCI_MMCSD0_BASE + SZ_4K - 1,
132 .flags = IORESOURCE_MEM,
134 /* IRQs: MMC/SD, then SDIO */
137 .flags = IORESOURCE_IRQ,
139 /* different on dm355 */
140 .start = IRQ_SDIOINT,
141 .flags = IORESOURCE_IRQ,
145 static struct platform_device davinci_mmcsd0_device = {
146 .name = "dm6441-mmc",
149 .dma_mask = &mmcsd0_dma_mask,
150 .coherent_dma_mask = DMA_BIT_MASK(32),
152 .num_resources = ARRAY_SIZE(mmcsd0_resources),
153 .resource = mmcsd0_resources,
156 static u64 mmcsd1_dma_mask = DMA_BIT_MASK(32);
158 static struct resource mmcsd1_resources[] = {
160 .start = DM355_MMCSD1_BASE,
161 .end = DM355_MMCSD1_BASE + SZ_4K - 1,
162 .flags = IORESOURCE_MEM,
164 /* IRQs: MMC/SD, then SDIO */
166 .start = IRQ_DM355_MMCINT1,
167 .flags = IORESOURCE_IRQ,
169 .start = IRQ_DM355_SDIOINT1,
170 .flags = IORESOURCE_IRQ,
174 static struct platform_device davinci_mmcsd1_device = {
175 .name = "dm6441-mmc",
178 .dma_mask = &mmcsd1_dma_mask,
179 .coherent_dma_mask = DMA_BIT_MASK(32),
181 .num_resources = ARRAY_SIZE(mmcsd1_resources),
182 .resource = mmcsd1_resources,
186 void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
188 struct platform_device *pdev = NULL;
190 if (WARN_ON(cpu_is_davinci_dm646x()))
193 /* REVISIT: update PINMUX, ARM_IRQMUX, and EDMA_EVTMUX here too;
194 * for example if MMCSD1 is used for SDIO, maybe DAT2 is unused.
196 * FIXME dm6441 (no MMC/SD), dm357 (one), and dm335 (two) are
197 * not handled right here ...
201 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...
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 /* Configure pull down control */
215 v = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_PUPDCTL1));
216 __raw_writel(v & ~0xfc0,
217 DAVINCI_SYSMOD_VIRT(SYSMOD_PUPDCTL1));
219 mmcsd1_resources[0].start = DM365_MMCSD1_BASE;
220 mmcsd1_resources[0].end = DM365_MMCSD1_BASE +
222 mmcsd1_resources[2].start = IRQ_DM365_SDIOINT1;
223 davinci_mmcsd1_device.name = "da830-mmc";
227 pdev = &davinci_mmcsd1_device;
230 if (cpu_is_davinci_dm355()) {
231 mmcsd0_resources[0].start = DM355_MMCSD0_BASE;
232 mmcsd0_resources[0].end = DM355_MMCSD0_BASE + SZ_4K - 1;
233 mmcsd0_resources[2].start = IRQ_DM355_SDIOINT0;
235 /* expose all 6 MMC0 signals: CLK, CMD, DATA[0..3] */
236 davinci_cfg_reg(DM355_MMCSD0);
239 davinci_cfg_reg(DM355_EVT26_MMC0_RX);
240 } else if (cpu_is_davinci_dm365()) {
241 mmcsd0_resources[0].start = DM365_MMCSD0_BASE;
242 mmcsd0_resources[0].end = DM365_MMCSD0_BASE +
244 mmcsd0_resources[2].start = IRQ_DM365_SDIOINT0;
245 davinci_mmcsd0_device.name = "da830-mmc";
246 } else if (cpu_is_davinci_dm644x()) {
247 /* REVISIT: should this be in board-init code? */
248 /* Power-on 3.3V IO cells */
250 DAVINCI_SYSMOD_VIRT(SYSMOD_VDD3P3VPWDN));
251 /*Set up the pull regiter for MMC */
252 davinci_cfg_reg(DM644X_MSTK);
255 pdev = &davinci_mmcsd0_device;
262 pdev->dev.platform_data = config;
263 platform_device_register(pdev);
268 void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
274 /*-------------------------------------------------------------------------*/
276 static struct resource wdt_resources[] = {
278 .start = DAVINCI_WDOG_BASE,
279 .end = DAVINCI_WDOG_BASE + SZ_1K - 1,
280 .flags = IORESOURCE_MEM,
284 static struct platform_device davinci_wdt_device = {
285 .name = "davinci-wdt",
287 .num_resources = ARRAY_SIZE(wdt_resources),
288 .resource = wdt_resources,
291 int davinci_init_wdt(void)
293 return platform_device_register(&davinci_wdt_device);
296 static struct platform_device davinci_gpio_device = {
297 .name = "davinci_gpio",
301 int davinci_gpio_register(struct resource *res, int size, void *pdata)
303 davinci_gpio_device.resource = res;
304 davinci_gpio_device.num_resources = size;
305 davinci_gpio_device.dev.platform_data = pdata;
306 return platform_device_register(&davinci_gpio_device);
309 /*-------------------------------------------------------------------------*/
311 /*-------------------------------------------------------------------------*/
313 struct davinci_timer_instance davinci_timer_instance[2] = {
315 .base = DAVINCI_TIMER0_BASE,
316 .bottom_irq = IRQ_TINT0_TINT12,
317 .top_irq = IRQ_TINT0_TINT34,
320 .base = DAVINCI_TIMER1_BASE,
321 .bottom_irq = IRQ_TINT1_TINT12,
322 .top_irq = IRQ_TINT1_TINT34,