Komal Shah | d395e6a | 2008-09-07 23:41:28 -0700 | [diff] [blame] | 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 | |
Komal Shah | d395e6a | 2008-09-07 23:41:28 -0700 | [diff] [blame] | 12 | #include <linux/init.h> |
| 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/dma-mapping.h> |
| 15 | #include <linux/io.h> |
| 16 | |
Komal Shah | d395e6a | 2008-09-07 23:41:28 -0700 | [diff] [blame] | 17 | #include <mach/hardware.h> |
| 18 | #include <mach/i2c.h> |
Russell King | 80b02c1 | 2009-01-08 10:01:47 +0000 | [diff] [blame] | 19 | #include <mach/irqs.h> |
Kevin Hilman | 5526b3f | 2009-04-14 09:50:37 -0500 | [diff] [blame] | 20 | #include <mach/cputype.h> |
| 21 | #include <mach/mux.h> |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 22 | #include <mach/edma.h> |
| 23 | #include <mach/mmc.h> |
Mark A. Greer | f64691b | 2009-04-15 12:40:11 -0700 | [diff] [blame] | 24 | #include <mach/time.h> |
Komal Shah | d395e6a | 2008-09-07 23:41:28 -0700 | [diff] [blame] | 25 | |
Kevin Hilman | 28552c2 | 2010-02-25 15:36:38 -0800 | [diff] [blame] | 26 | #include "clock.h" |
| 27 | |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 28 | #define DAVINCI_I2C_BASE 0x01C21000 |
Sergei Shtylyov | 7a9978a | 2010-04-21 18:11:33 +0400 | [diff] [blame] | 29 | #define DAVINCI_ATA_BASE 0x01C66000 |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 30 | #define DAVINCI_MMCSD0_BASE 0x01E10000 |
| 31 | #define DM355_MMCSD0_BASE 0x01E11000 |
| 32 | #define DM355_MMCSD1_BASE 0x01E00000 |
Sandeep Paulraj | 19ff3bf | 2009-06-20 13:58:32 -0400 | [diff] [blame] | 33 | #define DM365_MMCSD0_BASE 0x01D11000 |
| 34 | #define DM365_MMCSD1_BASE 0x01D00000 |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 35 | |
Manjunath Hadli | 1a717c0 | 2011-05-23 21:05:48 +0530 | [diff] [blame] | 36 | /* System control register offsets */ |
| 37 | #define DM64XX_VDD3P3V_PWDN 0x48 |
| 38 | |
Komal Shah | d395e6a | 2008-09-07 23:41:28 -0700 | [diff] [blame] | 39 | static struct resource i2c_resources[] = { |
| 40 | { |
| 41 | .start = DAVINCI_I2C_BASE, |
| 42 | .end = DAVINCI_I2C_BASE + 0x40, |
| 43 | .flags = IORESOURCE_MEM, |
| 44 | }, |
| 45 | { |
| 46 | .start = IRQ_I2C, |
| 47 | .flags = IORESOURCE_IRQ, |
| 48 | }, |
| 49 | }; |
| 50 | |
| 51 | static struct platform_device davinci_i2c_device = { |
| 52 | .name = "i2c_davinci", |
| 53 | .id = 1, |
| 54 | .num_resources = ARRAY_SIZE(i2c_resources), |
| 55 | .resource = i2c_resources, |
| 56 | }; |
| 57 | |
| 58 | void __init davinci_init_i2c(struct davinci_i2c_platform_data *pdata) |
| 59 | { |
Kevin Hilman | 5526b3f | 2009-04-14 09:50:37 -0500 | [diff] [blame] | 60 | if (cpu_is_davinci_dm644x()) |
| 61 | davinci_cfg_reg(DM644X_I2C); |
| 62 | |
Komal Shah | d395e6a | 2008-09-07 23:41:28 -0700 | [diff] [blame] | 63 | davinci_i2c_device.dev.platform_data = pdata; |
| 64 | (void) platform_device_register(&davinci_i2c_device); |
| 65 | } |
| 66 | |
Sergei Shtylyov | 7a9978a | 2010-04-21 18:11:33 +0400 | [diff] [blame] | 67 | static struct resource ide_resources[] = { |
| 68 | { |
| 69 | .start = DAVINCI_ATA_BASE, |
| 70 | .end = DAVINCI_ATA_BASE + 0x7ff, |
| 71 | .flags = IORESOURCE_MEM, |
| 72 | }, |
| 73 | { |
| 74 | .start = IRQ_IDE, |
| 75 | .end = IRQ_IDE, |
| 76 | .flags = IORESOURCE_IRQ, |
| 77 | }, |
| 78 | }; |
| 79 | |
| 80 | static u64 ide_dma_mask = DMA_BIT_MASK(32); |
| 81 | |
| 82 | static struct platform_device ide_device = { |
| 83 | .name = "palm_bk3710", |
| 84 | .id = -1, |
| 85 | .resource = ide_resources, |
| 86 | .num_resources = ARRAY_SIZE(ide_resources), |
| 87 | .dev = { |
| 88 | .dma_mask = &ide_dma_mask, |
| 89 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 90 | }, |
| 91 | }; |
| 92 | |
| 93 | void __init davinci_init_ide(void) |
| 94 | { |
| 95 | if (cpu_is_davinci_dm644x()) { |
| 96 | davinci_cfg_reg(DM644X_HPIEN_DISABLE); |
| 97 | davinci_cfg_reg(DM644X_ATAEN); |
| 98 | davinci_cfg_reg(DM644X_HDIREN); |
| 99 | } else if (cpu_is_davinci_dm646x()) { |
| 100 | /* IRQ_DM646X_IDE is the same as IRQ_IDE */ |
| 101 | davinci_cfg_reg(DM646X_ATAEN); |
| 102 | } else { |
| 103 | WARN_ON(1); |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | platform_device_register(&ide_device); |
| 108 | } |
| 109 | |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 110 | #if defined(CONFIG_MMC_DAVINCI) || defined(CONFIG_MMC_DAVINCI_MODULE) |
| 111 | |
Kevin Hilman | b0958ae | 2009-05-29 18:54:14 +0100 | [diff] [blame] | 112 | static u64 mmcsd0_dma_mask = DMA_BIT_MASK(32); |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 113 | |
| 114 | static struct resource mmcsd0_resources[] = { |
| 115 | { |
| 116 | /* different on dm355 */ |
| 117 | .start = DAVINCI_MMCSD0_BASE, |
| 118 | .end = DAVINCI_MMCSD0_BASE + SZ_4K - 1, |
| 119 | .flags = IORESOURCE_MEM, |
| 120 | }, |
| 121 | /* IRQs: MMC/SD, then SDIO */ |
| 122 | { |
| 123 | .start = IRQ_MMCINT, |
| 124 | .flags = IORESOURCE_IRQ, |
| 125 | }, { |
| 126 | /* different on dm355 */ |
| 127 | .start = IRQ_SDIOINT, |
| 128 | .flags = IORESOURCE_IRQ, |
| 129 | }, |
| 130 | /* DMA channels: RX, then TX */ |
| 131 | { |
Sudhakar Rajashekhara | 60902a2 | 2009-05-21 07:41:35 -0400 | [diff] [blame] | 132 | .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCRXEVT), |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 133 | .flags = IORESOURCE_DMA, |
| 134 | }, { |
Sudhakar Rajashekhara | 60902a2 | 2009-05-21 07:41:35 -0400 | [diff] [blame] | 135 | .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCTXEVT), |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 136 | .flags = IORESOURCE_DMA, |
| 137 | }, |
| 138 | }; |
| 139 | |
| 140 | static struct platform_device davinci_mmcsd0_device = { |
| 141 | .name = "davinci_mmc", |
| 142 | .id = 0, |
| 143 | .dev = { |
| 144 | .dma_mask = &mmcsd0_dma_mask, |
Kevin Hilman | b0958ae | 2009-05-29 18:54:14 +0100 | [diff] [blame] | 145 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 146 | }, |
| 147 | .num_resources = ARRAY_SIZE(mmcsd0_resources), |
| 148 | .resource = mmcsd0_resources, |
| 149 | }; |
| 150 | |
Kevin Hilman | b0958ae | 2009-05-29 18:54:14 +0100 | [diff] [blame] | 151 | static u64 mmcsd1_dma_mask = DMA_BIT_MASK(32); |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 152 | |
| 153 | static struct resource mmcsd1_resources[] = { |
| 154 | { |
| 155 | .start = DM355_MMCSD1_BASE, |
| 156 | .end = DM355_MMCSD1_BASE + SZ_4K - 1, |
| 157 | .flags = IORESOURCE_MEM, |
| 158 | }, |
| 159 | /* IRQs: MMC/SD, then SDIO */ |
| 160 | { |
| 161 | .start = IRQ_DM355_MMCINT1, |
| 162 | .flags = IORESOURCE_IRQ, |
| 163 | }, { |
| 164 | .start = IRQ_DM355_SDIOINT1, |
| 165 | .flags = IORESOURCE_IRQ, |
| 166 | }, |
| 167 | /* DMA channels: RX, then TX */ |
| 168 | { |
Sudhakar Rajashekhara | 60902a2 | 2009-05-21 07:41:35 -0400 | [diff] [blame] | 169 | .start = EDMA_CTLR_CHAN(0, 30), /* rx */ |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 170 | .flags = IORESOURCE_DMA, |
| 171 | }, { |
Sudhakar Rajashekhara | 60902a2 | 2009-05-21 07:41:35 -0400 | [diff] [blame] | 172 | .start = EDMA_CTLR_CHAN(0, 31), /* tx */ |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 173 | .flags = IORESOURCE_DMA, |
| 174 | }, |
| 175 | }; |
| 176 | |
| 177 | static struct platform_device davinci_mmcsd1_device = { |
| 178 | .name = "davinci_mmc", |
| 179 | .id = 1, |
| 180 | .dev = { |
| 181 | .dma_mask = &mmcsd1_dma_mask, |
Kevin Hilman | b0958ae | 2009-05-29 18:54:14 +0100 | [diff] [blame] | 182 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 183 | }, |
| 184 | .num_resources = ARRAY_SIZE(mmcsd1_resources), |
| 185 | .resource = mmcsd1_resources, |
| 186 | }; |
| 187 | |
| 188 | |
| 189 | void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config) |
| 190 | { |
| 191 | struct platform_device *pdev = NULL; |
| 192 | |
| 193 | if (WARN_ON(cpu_is_davinci_dm646x())) |
| 194 | return; |
| 195 | |
| 196 | /* REVISIT: update PINMUX, ARM_IRQMUX, and EDMA_EVTMUX here too; |
| 197 | * for example if MMCSD1 is used for SDIO, maybe DAT2 is unused. |
| 198 | * |
| 199 | * FIXME dm6441 (no MMC/SD), dm357 (one), and dm335 (two) are |
| 200 | * not handled right here ... |
| 201 | */ |
| 202 | switch (module) { |
| 203 | case 1: |
Sandeep Paulraj | 19ff3bf | 2009-06-20 13:58:32 -0400 | [diff] [blame] | 204 | if (cpu_is_davinci_dm355()) { |
| 205 | /* REVISIT we may not need all these pins if e.g. this |
| 206 | * is a hard-wired SDIO device... |
| 207 | */ |
| 208 | davinci_cfg_reg(DM355_SD1_CMD); |
| 209 | davinci_cfg_reg(DM355_SD1_CLK); |
| 210 | davinci_cfg_reg(DM355_SD1_DATA0); |
| 211 | davinci_cfg_reg(DM355_SD1_DATA1); |
| 212 | davinci_cfg_reg(DM355_SD1_DATA2); |
| 213 | davinci_cfg_reg(DM355_SD1_DATA3); |
| 214 | } else if (cpu_is_davinci_dm365()) { |
| 215 | void __iomem *pupdctl1 = |
| 216 | IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE + 0x7c); |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 217 | |
Sandeep Paulraj | 19ff3bf | 2009-06-20 13:58:32 -0400 | [diff] [blame] | 218 | /* Configure pull down control */ |
Sekhar Nori | 0a477f6 | 2010-07-14 17:09:45 +0530 | [diff] [blame] | 219 | __raw_writel((__raw_readl(pupdctl1) & ~0xfc0), |
Sandeep Paulraj | 19ff3bf | 2009-06-20 13:58:32 -0400 | [diff] [blame] | 220 | pupdctl1); |
| 221 | |
| 222 | mmcsd1_resources[0].start = DM365_MMCSD1_BASE; |
| 223 | mmcsd1_resources[0].end = DM365_MMCSD1_BASE + |
| 224 | SZ_4K - 1; |
Phaneendra Kumar | eb5ba37 | 2009-08-27 17:06:56 -0400 | [diff] [blame] | 225 | mmcsd1_resources[2].start = IRQ_DM365_SDIOINT1; |
Sandeep Paulraj | 19ff3bf | 2009-06-20 13:58:32 -0400 | [diff] [blame] | 226 | } else |
| 227 | break; |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 228 | |
| 229 | pdev = &davinci_mmcsd1_device; |
| 230 | break; |
| 231 | case 0: |
| 232 | if (cpu_is_davinci_dm355()) { |
| 233 | mmcsd0_resources[0].start = DM355_MMCSD0_BASE; |
| 234 | mmcsd0_resources[0].end = DM355_MMCSD0_BASE + SZ_4K - 1; |
| 235 | mmcsd0_resources[2].start = IRQ_DM355_SDIOINT0; |
| 236 | |
| 237 | /* expose all 6 MMC0 signals: CLK, CMD, DATA[0..3] */ |
| 238 | davinci_cfg_reg(DM355_MMCSD0); |
| 239 | |
| 240 | /* enable RX EDMA */ |
| 241 | davinci_cfg_reg(DM355_EVT26_MMC0_RX); |
Sandeep Paulraj | 19ff3bf | 2009-06-20 13:58:32 -0400 | [diff] [blame] | 242 | } else if (cpu_is_davinci_dm365()) { |
| 243 | mmcsd0_resources[0].start = DM365_MMCSD0_BASE; |
| 244 | mmcsd0_resources[0].end = DM365_MMCSD0_BASE + |
| 245 | SZ_4K - 1; |
| 246 | mmcsd0_resources[2].start = IRQ_DM365_SDIOINT0; |
| 247 | } else if (cpu_is_davinci_dm644x()) { |
Kevin Hilman | 2dbf56ae | 2009-05-11 15:55:03 -0700 | [diff] [blame] | 248 | /* REVISIT: should this be in board-init code? */ |
| 249 | void __iomem *base = |
| 250 | IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE); |
| 251 | |
| 252 | /* Power-on 3.3V IO cells */ |
| 253 | __raw_writel(0, base + DM64XX_VDD3P3V_PWDN); |
| 254 | /*Set up the pull regiter for MMC */ |
| 255 | davinci_cfg_reg(DM644X_MSTK); |
| 256 | } |
| 257 | |
| 258 | pdev = &davinci_mmcsd0_device; |
| 259 | break; |
| 260 | } |
| 261 | |
| 262 | if (WARN_ON(!pdev)) |
| 263 | return; |
| 264 | |
| 265 | pdev->dev.platform_data = config; |
| 266 | platform_device_register(pdev); |
| 267 | } |
| 268 | |
| 269 | #else |
| 270 | |
| 271 | void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config) |
| 272 | { |
| 273 | } |
| 274 | |
| 275 | #endif |
| 276 | |
Kevin Hilman | fb63138 | 2009-04-29 16:23:59 -0700 | [diff] [blame] | 277 | /*-------------------------------------------------------------------------*/ |
| 278 | |
| 279 | static struct resource wdt_resources[] = { |
| 280 | { |
Kevin Hilman | 5fcd294 | 2009-06-03 12:24:50 -0700 | [diff] [blame] | 281 | .start = DAVINCI_WDOG_BASE, |
| 282 | .end = DAVINCI_WDOG_BASE + SZ_1K - 1, |
Kevin Hilman | fb63138 | 2009-04-29 16:23:59 -0700 | [diff] [blame] | 283 | .flags = IORESOURCE_MEM, |
| 284 | }, |
| 285 | }; |
| 286 | |
| 287 | struct platform_device davinci_wdt_device = { |
| 288 | .name = "watchdog", |
| 289 | .id = -1, |
| 290 | .num_resources = ARRAY_SIZE(wdt_resources), |
| 291 | .resource = wdt_resources, |
| 292 | }; |
| 293 | |
Sekhar Nori | c6121dd | 2011-12-05 11:29:46 +0100 | [diff] [blame] | 294 | void davinci_restart(char mode, const char *cmd) |
| 295 | { |
| 296 | davinci_watchdog_reset(&davinci_wdt_device); |
| 297 | } |
| 298 | |
Kevin Hilman | fb63138 | 2009-04-29 16:23:59 -0700 | [diff] [blame] | 299 | static void davinci_init_wdt(void) |
| 300 | { |
| 301 | platform_device_register(&davinci_wdt_device); |
| 302 | } |
| 303 | |
| 304 | /*-------------------------------------------------------------------------*/ |
| 305 | |
Sekhar Nori | 7e9f194 | 2011-06-05 17:33:33 +0530 | [diff] [blame] | 306 | static struct platform_device davinci_pcm_device = { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 307 | .name = "davinci-pcm-audio", |
| 308 | .id = -1, |
| 309 | }; |
| 310 | |
| 311 | static void davinci_init_pcm(void) |
| 312 | { |
| 313 | platform_device_register(&davinci_pcm_device); |
| 314 | } |
| 315 | |
| 316 | /*-------------------------------------------------------------------------*/ |
| 317 | |
Mark A. Greer | f64691b | 2009-04-15 12:40:11 -0700 | [diff] [blame] | 318 | struct davinci_timer_instance davinci_timer_instance[2] = { |
| 319 | { |
Cyril Chemparathy | 1bcd38a | 2010-05-07 17:06:35 -0400 | [diff] [blame] | 320 | .base = DAVINCI_TIMER0_BASE, |
Mark A. Greer | f64691b | 2009-04-15 12:40:11 -0700 | [diff] [blame] | 321 | .bottom_irq = IRQ_TINT0_TINT12, |
| 322 | .top_irq = IRQ_TINT0_TINT34, |
| 323 | }, |
| 324 | { |
Cyril Chemparathy | 1bcd38a | 2010-05-07 17:06:35 -0400 | [diff] [blame] | 325 | .base = DAVINCI_TIMER1_BASE, |
Mark A. Greer | f64691b | 2009-04-15 12:40:11 -0700 | [diff] [blame] | 326 | .bottom_irq = IRQ_TINT1_TINT12, |
| 327 | .top_irq = IRQ_TINT1_TINT34, |
| 328 | }, |
| 329 | }; |
| 330 | |
| 331 | /*-------------------------------------------------------------------------*/ |
| 332 | |
Kevin Hilman | fb63138 | 2009-04-29 16:23:59 -0700 | [diff] [blame] | 333 | static int __init davinci_init_devices(void) |
| 334 | { |
| 335 | /* please keep these calls, and their implementations above, |
| 336 | * in alphabetical order so they're easier to sort through. |
| 337 | */ |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 338 | davinci_init_pcm(); |
Kevin Hilman | fb63138 | 2009-04-29 16:23:59 -0700 | [diff] [blame] | 339 | davinci_init_wdt(); |
| 340 | |
| 341 | return 0; |
| 342 | } |
| 343 | arch_initcall(davinci_init_devices); |
| 344 | |