Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap2/devices.c |
| 3 | * |
| 4 | * OMAP2 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 | |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 12 | #include <linux/kernel.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/platform_device.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 15 | #include <linux/io.h> |
Kevin Hilman | 917fa28 | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 16 | #include <linux/clk.h> |
Varadarajan, Charulatha | f2ce623 | 2010-09-23 20:02:42 +0530 | [diff] [blame] | 17 | #include <linux/err.h> |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 18 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 19 | #include <mach/hardware.h> |
Will Deacon | 8834133 | 2010-04-09 13:54:43 +0100 | [diff] [blame] | 20 | #include <mach/irqs.h> |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 21 | #include <asm/mach-types.h> |
| 22 | #include <asm/mach/map.h> |
Will Deacon | 8834133 | 2010-04-09 13:54:43 +0100 | [diff] [blame] | 23 | #include <asm/pmu.h> |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 24 | |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 25 | #include <plat/tc.h> |
| 26 | #include <plat/board.h> |
Jarkko Nikula | a09f73f | 2010-10-04 15:04:53 +0300 | [diff] [blame] | 27 | #include <plat/mcbsp.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 28 | #include <mach/gpio.h> |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 29 | #include <plat/mmc.h> |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 30 | #include <plat/dma.h> |
Varadarajan, Charulatha | f2ce623 | 2010-09-23 20:02:42 +0530 | [diff] [blame] | 31 | #include <plat/omap_hwmod.h> |
| 32 | #include <plat/omap_device.h> |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 33 | |
Tony Lindgren | 4896e39 | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 34 | #include "mux.h" |
Paul Walmsley | 4814ced | 2010-10-08 11:40:20 -0600 | [diff] [blame] | 35 | #include "control.h" |
Tony Lindgren | 4896e39 | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 36 | |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 37 | #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE) |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 38 | |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 39 | static struct resource cam_resources[] = { |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 40 | { |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 41 | .start = OMAP24XX_CAMERA_BASE, |
| 42 | .end = OMAP24XX_CAMERA_BASE + 0xfff, |
| 43 | .flags = IORESOURCE_MEM, |
| 44 | }, |
| 45 | { |
| 46 | .start = INT_24XX_CAM_IRQ, |
| 47 | .flags = IORESOURCE_IRQ, |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | static struct platform_device omap_cam_device = { |
| 52 | .name = "omap24xxcam", |
| 53 | .id = -1, |
| 54 | .num_resources = ARRAY_SIZE(cam_resources), |
| 55 | .resource = cam_resources, |
| 56 | }; |
| 57 | |
| 58 | static inline void omap_init_camera(void) |
| 59 | { |
| 60 | platform_device_register(&omap_cam_device); |
| 61 | } |
| 62 | |
| 63 | #elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE) |
| 64 | |
| 65 | static struct resource omap3isp_resources[] = { |
| 66 | { |
| 67 | .start = OMAP3430_ISP_BASE, |
| 68 | .end = OMAP3430_ISP_END, |
| 69 | .flags = IORESOURCE_MEM, |
| 70 | }, |
| 71 | { |
| 72 | .start = OMAP3430_ISP_CBUFF_BASE, |
| 73 | .end = OMAP3430_ISP_CBUFF_END, |
| 74 | .flags = IORESOURCE_MEM, |
| 75 | }, |
| 76 | { |
| 77 | .start = OMAP3430_ISP_CCP2_BASE, |
| 78 | .end = OMAP3430_ISP_CCP2_END, |
| 79 | .flags = IORESOURCE_MEM, |
| 80 | }, |
| 81 | { |
| 82 | .start = OMAP3430_ISP_CCDC_BASE, |
| 83 | .end = OMAP3430_ISP_CCDC_END, |
| 84 | .flags = IORESOURCE_MEM, |
| 85 | }, |
| 86 | { |
| 87 | .start = OMAP3430_ISP_HIST_BASE, |
| 88 | .end = OMAP3430_ISP_HIST_END, |
| 89 | .flags = IORESOURCE_MEM, |
| 90 | }, |
| 91 | { |
| 92 | .start = OMAP3430_ISP_H3A_BASE, |
| 93 | .end = OMAP3430_ISP_H3A_END, |
| 94 | .flags = IORESOURCE_MEM, |
| 95 | }, |
| 96 | { |
| 97 | .start = OMAP3430_ISP_PREV_BASE, |
| 98 | .end = OMAP3430_ISP_PREV_END, |
| 99 | .flags = IORESOURCE_MEM, |
| 100 | }, |
| 101 | { |
| 102 | .start = OMAP3430_ISP_RESZ_BASE, |
| 103 | .end = OMAP3430_ISP_RESZ_END, |
| 104 | .flags = IORESOURCE_MEM, |
| 105 | }, |
| 106 | { |
| 107 | .start = OMAP3430_ISP_SBL_BASE, |
| 108 | .end = OMAP3430_ISP_SBL_END, |
| 109 | .flags = IORESOURCE_MEM, |
| 110 | }, |
| 111 | { |
Tuukka Toivonen | 6817a69 | 2010-02-02 11:17:33 -0300 | [diff] [blame^] | 112 | .start = OMAP3430_ISP_CSI2A_REGS1_BASE, |
| 113 | .end = OMAP3430_ISP_CSI2A_REGS1_END, |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 114 | .flags = IORESOURCE_MEM, |
| 115 | }, |
| 116 | { |
Tuukka Toivonen | 6817a69 | 2010-02-02 11:17:33 -0300 | [diff] [blame^] | 117 | .start = OMAP3430_ISP_CSIPHY2_BASE, |
| 118 | .end = OMAP3430_ISP_CSIPHY2_END, |
| 119 | .flags = IORESOURCE_MEM, |
| 120 | }, |
| 121 | { |
| 122 | .start = OMAP3630_ISP_CSI2A_REGS2_BASE, |
| 123 | .end = OMAP3630_ISP_CSI2A_REGS2_END, |
| 124 | .flags = IORESOURCE_MEM, |
| 125 | }, |
| 126 | { |
| 127 | .start = OMAP3630_ISP_CSI2C_REGS1_BASE, |
| 128 | .end = OMAP3630_ISP_CSI2C_REGS1_END, |
| 129 | .flags = IORESOURCE_MEM, |
| 130 | }, |
| 131 | { |
| 132 | .start = OMAP3630_ISP_CSIPHY1_BASE, |
| 133 | .end = OMAP3630_ISP_CSIPHY1_END, |
| 134 | .flags = IORESOURCE_MEM, |
| 135 | }, |
| 136 | { |
| 137 | .start = OMAP3630_ISP_CSI2C_REGS2_BASE, |
| 138 | .end = OMAP3630_ISP_CSI2C_REGS2_END, |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 139 | .flags = IORESOURCE_MEM, |
| 140 | }, |
| 141 | { |
| 142 | .start = INT_34XX_CAM_IRQ, |
| 143 | .flags = IORESOURCE_IRQ, |
| 144 | } |
| 145 | }; |
| 146 | |
| 147 | static struct platform_device omap3isp_device = { |
| 148 | .name = "omap3isp", |
| 149 | .id = -1, |
| 150 | .num_resources = ARRAY_SIZE(omap3isp_resources), |
| 151 | .resource = omap3isp_resources, |
| 152 | }; |
| 153 | |
| 154 | static inline void omap_init_camera(void) |
| 155 | { |
| 156 | platform_device_register(&omap3isp_device); |
| 157 | } |
| 158 | #else |
| 159 | static inline void omap_init_camera(void) |
| 160 | { |
| 161 | } |
| 162 | #endif |
| 163 | |
Hiroshi DOYU | 6c20a68 | 2009-03-23 18:07:23 -0700 | [diff] [blame] | 164 | #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE) |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 165 | |
C A Subramaniam | 454bf34 | 2009-11-22 10:11:18 -0800 | [diff] [blame] | 166 | #define MBOX_REG_SIZE 0x120 |
Hiroshi DOYU | 6c20a68 | 2009-03-23 18:07:23 -0700 | [diff] [blame] | 167 | |
C A Subramaniam | 454bf34 | 2009-11-22 10:11:18 -0800 | [diff] [blame] | 168 | #ifdef CONFIG_ARCH_OMAP2 |
Tony Lindgren | d10f2b6 | 2010-02-12 12:26:47 -0800 | [diff] [blame] | 169 | static struct resource omap2_mbox_resources[] = { |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 170 | { |
Hiroshi DOYU | 6c20a68 | 2009-03-23 18:07:23 -0700 | [diff] [blame] | 171 | .start = OMAP24XX_MAILBOX_BASE, |
| 172 | .end = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1, |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 173 | .flags = IORESOURCE_MEM, |
| 174 | }, |
| 175 | { |
| 176 | .start = INT_24XX_MAIL_U0_MPU, |
| 177 | .flags = IORESOURCE_IRQ, |
Felipe Contreras | 1f2c4df | 2010-06-11 15:51:44 +0000 | [diff] [blame] | 178 | .name = "dsp", |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 179 | }, |
| 180 | { |
| 181 | .start = INT_24XX_MAIL_U3_MPU, |
| 182 | .flags = IORESOURCE_IRQ, |
Felipe Contreras | 1f2c4df | 2010-06-11 15:51:44 +0000 | [diff] [blame] | 183 | .name = "iva", |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 184 | }, |
| 185 | }; |
Tony Lindgren | d10f2b6 | 2010-02-12 12:26:47 -0800 | [diff] [blame] | 186 | static int omap2_mbox_resources_sz = ARRAY_SIZE(omap2_mbox_resources); |
| 187 | #else |
| 188 | #define omap2_mbox_resources NULL |
| 189 | #define omap2_mbox_resources_sz 0 |
C A Subramaniam | 454bf34 | 2009-11-22 10:11:18 -0800 | [diff] [blame] | 190 | #endif |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 191 | |
C A Subramaniam | 454bf34 | 2009-11-22 10:11:18 -0800 | [diff] [blame] | 192 | #ifdef CONFIG_ARCH_OMAP3 |
Tony Lindgren | d10f2b6 | 2010-02-12 12:26:47 -0800 | [diff] [blame] | 193 | static struct resource omap3_mbox_resources[] = { |
Hiroshi DOYU | 6c20a68 | 2009-03-23 18:07:23 -0700 | [diff] [blame] | 194 | { |
| 195 | .start = OMAP34XX_MAILBOX_BASE, |
| 196 | .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1, |
| 197 | .flags = IORESOURCE_MEM, |
| 198 | }, |
| 199 | { |
| 200 | .start = INT_24XX_MAIL_U0_MPU, |
| 201 | .flags = IORESOURCE_IRQ, |
Felipe Contreras | 1f2c4df | 2010-06-11 15:51:44 +0000 | [diff] [blame] | 202 | .name = "dsp", |
Hiroshi DOYU | 6c20a68 | 2009-03-23 18:07:23 -0700 | [diff] [blame] | 203 | }, |
| 204 | }; |
Tony Lindgren | d10f2b6 | 2010-02-12 12:26:47 -0800 | [diff] [blame] | 205 | static int omap3_mbox_resources_sz = ARRAY_SIZE(omap3_mbox_resources); |
| 206 | #else |
| 207 | #define omap3_mbox_resources NULL |
| 208 | #define omap3_mbox_resources_sz 0 |
C A Subramaniam | 454bf34 | 2009-11-22 10:11:18 -0800 | [diff] [blame] | 209 | #endif |
| 210 | |
| 211 | #ifdef CONFIG_ARCH_OMAP4 |
| 212 | |
| 213 | #define OMAP4_MBOX_REG_SIZE 0x130 |
Tony Lindgren | d10f2b6 | 2010-02-12 12:26:47 -0800 | [diff] [blame] | 214 | static struct resource omap4_mbox_resources[] = { |
C A Subramaniam | 454bf34 | 2009-11-22 10:11:18 -0800 | [diff] [blame] | 215 | { |
| 216 | .start = OMAP44XX_MAILBOX_BASE, |
| 217 | .end = OMAP44XX_MAILBOX_BASE + |
| 218 | OMAP4_MBOX_REG_SIZE - 1, |
| 219 | .flags = IORESOURCE_MEM, |
| 220 | }, |
| 221 | { |
Santosh Shilimkar | 5772ca7 | 2010-02-18 03:14:12 +0530 | [diff] [blame] | 222 | .start = OMAP44XX_IRQ_MAIL_U0, |
C A Subramaniam | 454bf34 | 2009-11-22 10:11:18 -0800 | [diff] [blame] | 223 | .flags = IORESOURCE_IRQ, |
Felipe Contreras | 1f2c4df | 2010-06-11 15:51:44 +0000 | [diff] [blame] | 224 | .name = "mbox", |
C A Subramaniam | 454bf34 | 2009-11-22 10:11:18 -0800 | [diff] [blame] | 225 | }, |
| 226 | }; |
Tony Lindgren | d10f2b6 | 2010-02-12 12:26:47 -0800 | [diff] [blame] | 227 | static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources); |
| 228 | #else |
| 229 | #define omap4_mbox_resources NULL |
| 230 | #define omap4_mbox_resources_sz 0 |
C A Subramaniam | 454bf34 | 2009-11-22 10:11:18 -0800 | [diff] [blame] | 231 | #endif |
Hiroshi DOYU | 6c20a68 | 2009-03-23 18:07:23 -0700 | [diff] [blame] | 232 | |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 233 | static struct platform_device mbox_device = { |
Felipe Contreras | d742709 | 2010-06-11 15:51:48 +0000 | [diff] [blame] | 234 | .name = "omap-mailbox", |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 235 | .id = -1, |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 236 | }; |
| 237 | |
| 238 | static inline void omap_init_mbox(void) |
| 239 | { |
Tony Lindgren | d10f2b6 | 2010-02-12 12:26:47 -0800 | [diff] [blame] | 240 | if (cpu_is_omap24xx()) { |
| 241 | mbox_device.resource = omap2_mbox_resources; |
| 242 | mbox_device.num_resources = omap2_mbox_resources_sz; |
| 243 | } else if (cpu_is_omap34xx()) { |
| 244 | mbox_device.resource = omap3_mbox_resources; |
| 245 | mbox_device.num_resources = omap3_mbox_resources_sz; |
| 246 | } else if (cpu_is_omap44xx()) { |
| 247 | mbox_device.resource = omap4_mbox_resources; |
| 248 | mbox_device.num_resources = omap4_mbox_resources_sz; |
Hiroshi DOYU | 6c20a68 | 2009-03-23 18:07:23 -0700 | [diff] [blame] | 249 | } else { |
| 250 | pr_err("%s: platform not supported\n", __func__); |
| 251 | return; |
| 252 | } |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 253 | platform_device_register(&mbox_device); |
| 254 | } |
| 255 | #else |
| 256 | static inline void omap_init_mbox(void) { } |
Hiroshi DOYU | 6c20a68 | 2009-03-23 18:07:23 -0700 | [diff] [blame] | 257 | #endif /* CONFIG_OMAP_MBOX_FWK */ |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 258 | |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 259 | static inline void omap_init_sti(void) {} |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 260 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 261 | #if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE) |
| 262 | |
| 263 | static struct platform_device omap_pcm = { |
| 264 | .name = "omap-pcm-audio", |
| 265 | .id = -1, |
| 266 | }; |
| 267 | |
| 268 | /* |
| 269 | * OMAP2420 has 2 McBSP ports |
| 270 | * OMAP2430 has 5 McBSP ports |
| 271 | * OMAP3 has 5 McBSP ports |
| 272 | * OMAP4 has 4 McBSP ports |
| 273 | */ |
| 274 | OMAP_MCBSP_PLATFORM_DEVICE(1); |
| 275 | OMAP_MCBSP_PLATFORM_DEVICE(2); |
| 276 | OMAP_MCBSP_PLATFORM_DEVICE(3); |
| 277 | OMAP_MCBSP_PLATFORM_DEVICE(4); |
| 278 | OMAP_MCBSP_PLATFORM_DEVICE(5); |
| 279 | |
| 280 | static void omap_init_audio(void) |
| 281 | { |
| 282 | platform_device_register(&omap_mcbsp1); |
| 283 | platform_device_register(&omap_mcbsp2); |
| 284 | if (cpu_is_omap243x() || cpu_is_omap34xx() || cpu_is_omap44xx()) { |
| 285 | platform_device_register(&omap_mcbsp3); |
| 286 | platform_device_register(&omap_mcbsp4); |
| 287 | } |
| 288 | if (cpu_is_omap243x() || cpu_is_omap34xx()) |
| 289 | platform_device_register(&omap_mcbsp5); |
| 290 | |
| 291 | platform_device_register(&omap_pcm); |
| 292 | } |
| 293 | |
| 294 | #else |
| 295 | static inline void omap_init_audio(void) {} |
| 296 | #endif |
| 297 | |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 298 | #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE) |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 299 | |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 300 | #include <plat/mcspi.h> |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 301 | |
| 302 | #define OMAP2_MCSPI1_BASE 0x48098000 |
| 303 | #define OMAP2_MCSPI2_BASE 0x4809a000 |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 304 | #define OMAP2_MCSPI3_BASE 0x480b8000 |
| 305 | #define OMAP2_MCSPI4_BASE 0x480ba000 |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 306 | |
Syed Rafiuddin | 7869c0b | 2009-09-22 16:46:18 -0700 | [diff] [blame] | 307 | #define OMAP4_MCSPI1_BASE 0x48098100 |
| 308 | #define OMAP4_MCSPI2_BASE 0x4809a100 |
| 309 | #define OMAP4_MCSPI3_BASE 0x480b8100 |
| 310 | #define OMAP4_MCSPI4_BASE 0x480ba100 |
| 311 | |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 312 | static struct omap2_mcspi_platform_config omap2_mcspi1_config = { |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 313 | .num_cs = 4, |
| 314 | }; |
| 315 | |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 316 | static struct resource omap2_mcspi1_resources[] = { |
| 317 | { |
| 318 | .start = OMAP2_MCSPI1_BASE, |
| 319 | .end = OMAP2_MCSPI1_BASE + 0xff, |
| 320 | .flags = IORESOURCE_MEM, |
| 321 | }, |
| 322 | }; |
| 323 | |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 324 | static struct platform_device omap2_mcspi1 = { |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 325 | .name = "omap2_mcspi", |
| 326 | .id = 1, |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 327 | .num_resources = ARRAY_SIZE(omap2_mcspi1_resources), |
| 328 | .resource = omap2_mcspi1_resources, |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 329 | .dev = { |
| 330 | .platform_data = &omap2_mcspi1_config, |
| 331 | }, |
| 332 | }; |
| 333 | |
| 334 | static struct omap2_mcspi_platform_config omap2_mcspi2_config = { |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 335 | .num_cs = 2, |
| 336 | }; |
| 337 | |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 338 | static struct resource omap2_mcspi2_resources[] = { |
| 339 | { |
| 340 | .start = OMAP2_MCSPI2_BASE, |
| 341 | .end = OMAP2_MCSPI2_BASE + 0xff, |
| 342 | .flags = IORESOURCE_MEM, |
| 343 | }, |
| 344 | }; |
| 345 | |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 346 | static struct platform_device omap2_mcspi2 = { |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 347 | .name = "omap2_mcspi", |
| 348 | .id = 2, |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 349 | .num_resources = ARRAY_SIZE(omap2_mcspi2_resources), |
| 350 | .resource = omap2_mcspi2_resources, |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 351 | .dev = { |
| 352 | .platform_data = &omap2_mcspi2_config, |
| 353 | }, |
| 354 | }; |
| 355 | |
Syed Rafiuddin | 7869c0b | 2009-09-22 16:46:18 -0700 | [diff] [blame] | 356 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ |
| 357 | defined(CONFIG_ARCH_OMAP4) |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 358 | static struct omap2_mcspi_platform_config omap2_mcspi3_config = { |
| 359 | .num_cs = 2, |
| 360 | }; |
| 361 | |
| 362 | static struct resource omap2_mcspi3_resources[] = { |
| 363 | { |
| 364 | .start = OMAP2_MCSPI3_BASE, |
| 365 | .end = OMAP2_MCSPI3_BASE + 0xff, |
| 366 | .flags = IORESOURCE_MEM, |
| 367 | }, |
| 368 | }; |
| 369 | |
| 370 | static struct platform_device omap2_mcspi3 = { |
| 371 | .name = "omap2_mcspi", |
| 372 | .id = 3, |
| 373 | .num_resources = ARRAY_SIZE(omap2_mcspi3_resources), |
| 374 | .resource = omap2_mcspi3_resources, |
| 375 | .dev = { |
| 376 | .platform_data = &omap2_mcspi3_config, |
| 377 | }, |
| 378 | }; |
| 379 | #endif |
| 380 | |
Syed Rafiuddin | 7869c0b | 2009-09-22 16:46:18 -0700 | [diff] [blame] | 381 | #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 382 | static struct omap2_mcspi_platform_config omap2_mcspi4_config = { |
| 383 | .num_cs = 1, |
| 384 | }; |
| 385 | |
| 386 | static struct resource omap2_mcspi4_resources[] = { |
| 387 | { |
| 388 | .start = OMAP2_MCSPI4_BASE, |
| 389 | .end = OMAP2_MCSPI4_BASE + 0xff, |
| 390 | .flags = IORESOURCE_MEM, |
| 391 | }, |
| 392 | }; |
| 393 | |
| 394 | static struct platform_device omap2_mcspi4 = { |
| 395 | .name = "omap2_mcspi", |
| 396 | .id = 4, |
| 397 | .num_resources = ARRAY_SIZE(omap2_mcspi4_resources), |
| 398 | .resource = omap2_mcspi4_resources, |
| 399 | .dev = { |
| 400 | .platform_data = &omap2_mcspi4_config, |
| 401 | }, |
| 402 | }; |
| 403 | #endif |
| 404 | |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 405 | #ifdef CONFIG_ARCH_OMAP4 |
| 406 | static inline void omap4_mcspi_fixup(void) |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 407 | { |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 408 | omap2_mcspi1_resources[0].start = OMAP4_MCSPI1_BASE; |
| 409 | omap2_mcspi1_resources[0].end = OMAP4_MCSPI1_BASE + 0xff; |
| 410 | omap2_mcspi2_resources[0].start = OMAP4_MCSPI2_BASE; |
| 411 | omap2_mcspi2_resources[0].end = OMAP4_MCSPI2_BASE + 0xff; |
| 412 | omap2_mcspi3_resources[0].start = OMAP4_MCSPI3_BASE; |
| 413 | omap2_mcspi3_resources[0].end = OMAP4_MCSPI3_BASE + 0xff; |
| 414 | omap2_mcspi4_resources[0].start = OMAP4_MCSPI4_BASE; |
| 415 | omap2_mcspi4_resources[0].end = OMAP4_MCSPI4_BASE + 0xff; |
| 416 | } |
| 417 | #else |
| 418 | static inline void omap4_mcspi_fixup(void) |
| 419 | { |
| 420 | } |
| 421 | #endif |
| 422 | |
Syed Rafiuddin | 7869c0b | 2009-09-22 16:46:18 -0700 | [diff] [blame] | 423 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ |
| 424 | defined(CONFIG_ARCH_OMAP4) |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 425 | static inline void omap2_mcspi3_init(void) |
| 426 | { |
| 427 | platform_device_register(&omap2_mcspi3); |
| 428 | } |
| 429 | #else |
| 430 | static inline void omap2_mcspi3_init(void) |
| 431 | { |
| 432 | } |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 433 | #endif |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 434 | |
Syed Rafiuddin | 7869c0b | 2009-09-22 16:46:18 -0700 | [diff] [blame] | 435 | #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 436 | static inline void omap2_mcspi4_init(void) |
| 437 | { |
| 438 | platform_device_register(&omap2_mcspi4); |
| 439 | } |
| 440 | #else |
| 441 | static inline void omap2_mcspi4_init(void) |
| 442 | { |
| 443 | } |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 444 | #endif |
Tony Lindgren | af41a12 | 2009-09-24 16:23:05 -0700 | [diff] [blame] | 445 | |
| 446 | static void omap_init_mcspi(void) |
| 447 | { |
| 448 | if (cpu_is_omap44xx()) |
| 449 | omap4_mcspi_fixup(); |
| 450 | |
| 451 | platform_device_register(&omap2_mcspi1); |
| 452 | platform_device_register(&omap2_mcspi2); |
| 453 | |
| 454 | if (cpu_is_omap2430() || cpu_is_omap343x() || cpu_is_omap44xx()) |
| 455 | omap2_mcspi3_init(); |
| 456 | |
| 457 | if (cpu_is_omap343x() || cpu_is_omap44xx()) |
| 458 | omap2_mcspi4_init(); |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | #else |
| 462 | static inline void omap_init_mcspi(void) {} |
| 463 | #endif |
| 464 | |
Will Deacon | 8834133 | 2010-04-09 13:54:43 +0100 | [diff] [blame] | 465 | static struct resource omap2_pmu_resource = { |
| 466 | .start = 3, |
| 467 | .end = 3, |
| 468 | .flags = IORESOURCE_IRQ, |
| 469 | }; |
| 470 | |
| 471 | static struct resource omap3_pmu_resource = { |
| 472 | .start = INT_34XX_BENCH_MPU_EMUL, |
| 473 | .end = INT_34XX_BENCH_MPU_EMUL, |
| 474 | .flags = IORESOURCE_IRQ, |
| 475 | }; |
| 476 | |
| 477 | static struct platform_device omap_pmu_device = { |
| 478 | .name = "arm-pmu", |
| 479 | .id = ARM_PMU_DEVICE_CPU, |
| 480 | .num_resources = 1, |
| 481 | }; |
| 482 | |
| 483 | static void omap_init_pmu(void) |
| 484 | { |
| 485 | if (cpu_is_omap24xx()) |
| 486 | omap_pmu_device.resource = &omap2_pmu_resource; |
| 487 | else if (cpu_is_omap34xx()) |
| 488 | omap_pmu_device.resource = &omap3_pmu_resource; |
| 489 | else |
| 490 | return; |
| 491 | |
| 492 | platform_device_register(&omap_pmu_device); |
| 493 | } |
| 494 | |
| 495 | |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 496 | #if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE) |
| 497 | |
Dmitry Kasatkin | edc774e | 2010-05-14 14:45:08 +1000 | [diff] [blame] | 498 | #ifdef CONFIG_ARCH_OMAP2 |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 499 | static struct resource omap2_sham_resources[] = { |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 500 | { |
| 501 | .start = OMAP24XX_SEC_SHA1MD5_BASE, |
| 502 | .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64, |
| 503 | .flags = IORESOURCE_MEM, |
| 504 | }, |
| 505 | { |
| 506 | .start = INT_24XX_SHA1MD5, |
| 507 | .flags = IORESOURCE_IRQ, |
| 508 | } |
| 509 | }; |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 510 | static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources); |
| 511 | #else |
| 512 | #define omap2_sham_resources NULL |
| 513 | #define omap2_sham_resources_sz 0 |
| 514 | #endif |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 515 | |
Dmitry Kasatkin | edc774e | 2010-05-14 14:45:08 +1000 | [diff] [blame] | 516 | #ifdef CONFIG_ARCH_OMAP3 |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 517 | static struct resource omap3_sham_resources[] = { |
| 518 | { |
| 519 | .start = OMAP34XX_SEC_SHA1MD5_BASE, |
| 520 | .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64, |
| 521 | .flags = IORESOURCE_MEM, |
| 522 | }, |
| 523 | { |
| 524 | .start = INT_34XX_SHA1MD52_IRQ, |
| 525 | .flags = IORESOURCE_IRQ, |
| 526 | }, |
| 527 | { |
| 528 | .start = OMAP34XX_DMA_SHA1MD5_RX, |
| 529 | .flags = IORESOURCE_DMA, |
| 530 | } |
| 531 | }; |
| 532 | static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources); |
| 533 | #else |
| 534 | #define omap3_sham_resources NULL |
| 535 | #define omap3_sham_resources_sz 0 |
| 536 | #endif |
| 537 | |
| 538 | static struct platform_device sham_device = { |
| 539 | .name = "omap-sham", |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 540 | .id = -1, |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 541 | }; |
| 542 | |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 543 | static void omap_init_sham(void) |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 544 | { |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 545 | if (cpu_is_omap24xx()) { |
| 546 | sham_device.resource = omap2_sham_resources; |
| 547 | sham_device.num_resources = omap2_sham_resources_sz; |
| 548 | } else if (cpu_is_omap34xx()) { |
| 549 | sham_device.resource = omap3_sham_resources; |
| 550 | sham_device.num_resources = omap3_sham_resources_sz; |
| 551 | } else { |
| 552 | pr_err("%s: platform not supported\n", __func__); |
| 553 | return; |
| 554 | } |
| 555 | platform_device_register(&sham_device); |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 556 | } |
| 557 | #else |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 558 | static inline void omap_init_sham(void) { } |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 559 | #endif |
| 560 | |
Dmitry Kasatkin | b744c67 | 2010-09-03 19:13:55 +0800 | [diff] [blame] | 561 | #if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE) |
| 562 | |
Dmitry Kasatkin | 82a0c14 | 2010-08-20 13:44:46 +0000 | [diff] [blame] | 563 | #ifdef CONFIG_ARCH_OMAP2 |
Dmitry Kasatkin | b744c67 | 2010-09-03 19:13:55 +0800 | [diff] [blame] | 564 | static struct resource omap2_aes_resources[] = { |
| 565 | { |
| 566 | .start = OMAP24XX_SEC_AES_BASE, |
| 567 | .end = OMAP24XX_SEC_AES_BASE + 0x4C, |
| 568 | .flags = IORESOURCE_MEM, |
| 569 | }, |
| 570 | { |
| 571 | .start = OMAP24XX_DMA_AES_TX, |
| 572 | .flags = IORESOURCE_DMA, |
| 573 | }, |
| 574 | { |
| 575 | .start = OMAP24XX_DMA_AES_RX, |
| 576 | .flags = IORESOURCE_DMA, |
| 577 | } |
| 578 | }; |
| 579 | static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources); |
| 580 | #else |
| 581 | #define omap2_aes_resources NULL |
| 582 | #define omap2_aes_resources_sz 0 |
| 583 | #endif |
| 584 | |
Dmitry Kasatkin | 82a0c14 | 2010-08-20 13:44:46 +0000 | [diff] [blame] | 585 | #ifdef CONFIG_ARCH_OMAP3 |
Dmitry Kasatkin | b744c67 | 2010-09-03 19:13:55 +0800 | [diff] [blame] | 586 | static struct resource omap3_aes_resources[] = { |
| 587 | { |
| 588 | .start = OMAP34XX_SEC_AES_BASE, |
| 589 | .end = OMAP34XX_SEC_AES_BASE + 0x4C, |
| 590 | .flags = IORESOURCE_MEM, |
| 591 | }, |
| 592 | { |
| 593 | .start = OMAP34XX_DMA_AES2_TX, |
| 594 | .flags = IORESOURCE_DMA, |
| 595 | }, |
| 596 | { |
| 597 | .start = OMAP34XX_DMA_AES2_RX, |
| 598 | .flags = IORESOURCE_DMA, |
| 599 | } |
| 600 | }; |
| 601 | static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources); |
| 602 | #else |
| 603 | #define omap3_aes_resources NULL |
| 604 | #define omap3_aes_resources_sz 0 |
| 605 | #endif |
| 606 | |
| 607 | static struct platform_device aes_device = { |
| 608 | .name = "omap-aes", |
| 609 | .id = -1, |
| 610 | }; |
| 611 | |
| 612 | static void omap_init_aes(void) |
| 613 | { |
| 614 | if (cpu_is_omap24xx()) { |
| 615 | aes_device.resource = omap2_aes_resources; |
| 616 | aes_device.num_resources = omap2_aes_resources_sz; |
| 617 | } else if (cpu_is_omap34xx()) { |
| 618 | aes_device.resource = omap3_aes_resources; |
| 619 | aes_device.num_resources = omap3_aes_resources_sz; |
| 620 | } else { |
| 621 | pr_err("%s: platform not supported\n", __func__); |
| 622 | return; |
| 623 | } |
| 624 | platform_device_register(&aes_device); |
| 625 | } |
| 626 | |
| 627 | #else |
| 628 | static inline void omap_init_aes(void) { } |
| 629 | #endif |
| 630 | |
Tony Lindgren | d887466 | 2008-12-10 17:37:16 -0800 | [diff] [blame] | 631 | /*-------------------------------------------------------------------------*/ |
| 632 | |
kishore kadiyala | 82cf818 | 2009-09-22 16:45:25 -0700 | [diff] [blame] | 633 | #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) |
Kevin Hilman | 917fa28 | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 634 | |
| 635 | #define MMCHS_SYSCONFIG 0x0010 |
| 636 | #define MMCHS_SYSCONFIG_SWRESET (1 << 1) |
| 637 | #define MMCHS_SYSSTATUS 0x0014 |
| 638 | #define MMCHS_SYSSTATUS_RESETDONE (1 << 0) |
| 639 | |
| 640 | static struct platform_device dummy_pdev = { |
| 641 | .dev = { |
| 642 | .bus = &platform_bus_type, |
| 643 | }, |
| 644 | }; |
| 645 | |
| 646 | /** |
| 647 | * omap_hsmmc_reset() - Full reset of each HS-MMC controller |
| 648 | * |
| 649 | * Ensure that each MMC controller is fully reset. Controllers |
| 650 | * left in an unknown state (by bootloader) may prevent retention |
| 651 | * or OFF-mode. This is especially important in cases where the |
| 652 | * MMC driver is not enabled, _or_ built as a module. |
| 653 | * |
| 654 | * In order for reset to work, interface, functional and debounce |
| 655 | * clocks must be enabled. The debounce clock comes from func_32k_clk |
| 656 | * and is not under SW control, so we only enable i- and f-clocks. |
| 657 | **/ |
| 658 | static void __init omap_hsmmc_reset(void) |
| 659 | { |
Tony Lindgren | 4323e9f | 2010-02-12 12:26:48 -0800 | [diff] [blame] | 660 | u32 i, nr_controllers; |
Aaro Koskinen | 434c23a | 2010-12-20 18:48:15 -0800 | [diff] [blame] | 661 | struct clk *iclk, *fclk; |
Tony Lindgren | 4323e9f | 2010-02-12 12:26:48 -0800 | [diff] [blame] | 662 | |
| 663 | if (cpu_is_omap242x()) |
| 664 | return; |
| 665 | |
| 666 | nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC : |
kishore kadiyala | 82cf818 | 2009-09-22 16:45:25 -0700 | [diff] [blame] | 667 | (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC); |
Kevin Hilman | 917fa28 | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 668 | |
| 669 | for (i = 0; i < nr_controllers; i++) { |
| 670 | u32 v, base = 0; |
Kevin Hilman | 917fa28 | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 671 | struct device *dev = &dummy_pdev.dev; |
| 672 | |
| 673 | switch (i) { |
| 674 | case 0: |
| 675 | base = OMAP2_MMC1_BASE; |
| 676 | break; |
| 677 | case 1: |
| 678 | base = OMAP2_MMC2_BASE; |
| 679 | break; |
| 680 | case 2: |
| 681 | base = OMAP3_MMC3_BASE; |
| 682 | break; |
kishore kadiyala | 82cf818 | 2009-09-22 16:45:25 -0700 | [diff] [blame] | 683 | case 3: |
| 684 | if (!cpu_is_omap44xx()) |
| 685 | return; |
| 686 | base = OMAP4_MMC4_BASE; |
| 687 | break; |
| 688 | case 4: |
| 689 | if (!cpu_is_omap44xx()) |
| 690 | return; |
| 691 | base = OMAP4_MMC5_BASE; |
| 692 | break; |
Kevin Hilman | 917fa28 | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 693 | } |
| 694 | |
kishore kadiyala | 82cf818 | 2009-09-22 16:45:25 -0700 | [diff] [blame] | 695 | if (cpu_is_omap44xx()) |
| 696 | base += OMAP4_MMC_REG_OFFSET; |
| 697 | |
Kevin Hilman | 917fa28 | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 698 | dummy_pdev.id = i; |
Russell King | 1e98ffa | 2009-01-19 18:56:17 +0000 | [diff] [blame] | 699 | dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i); |
Russell King | 6f7607c | 2009-01-28 10:22:50 +0000 | [diff] [blame] | 700 | iclk = clk_get(dev, "ick"); |
Aaro Koskinen | 434c23a | 2010-12-20 18:48:15 -0800 | [diff] [blame] | 701 | if (IS_ERR(iclk)) |
| 702 | goto err1; |
| 703 | if (clk_enable(iclk)) |
| 704 | goto err2; |
Kevin Hilman | 917fa28 | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 705 | |
Russell King | 6f7607c | 2009-01-28 10:22:50 +0000 | [diff] [blame] | 706 | fclk = clk_get(dev, "fck"); |
Aaro Koskinen | 434c23a | 2010-12-20 18:48:15 -0800 | [diff] [blame] | 707 | if (IS_ERR(fclk)) |
| 708 | goto err3; |
| 709 | if (clk_enable(fclk)) |
| 710 | goto err4; |
Kevin Hilman | 917fa28 | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 711 | |
| 712 | omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG); |
| 713 | v = omap_readl(base + MMCHS_SYSSTATUS); |
| 714 | while (!(omap_readl(base + MMCHS_SYSSTATUS) & |
| 715 | MMCHS_SYSSTATUS_RESETDONE)) |
| 716 | cpu_relax(); |
| 717 | |
Aaro Koskinen | 434c23a | 2010-12-20 18:48:15 -0800 | [diff] [blame] | 718 | clk_disable(fclk); |
| 719 | clk_put(fclk); |
| 720 | clk_disable(iclk); |
| 721 | clk_put(iclk); |
Kevin Hilman | 917fa28 | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 722 | } |
Aaro Koskinen | 434c23a | 2010-12-20 18:48:15 -0800 | [diff] [blame] | 723 | return; |
| 724 | |
| 725 | err4: |
| 726 | clk_put(fclk); |
| 727 | err3: |
| 728 | clk_disable(iclk); |
| 729 | err2: |
| 730 | clk_put(iclk); |
| 731 | err1: |
| 732 | printk(KERN_WARNING "%s: Unable to enable clocks for MMC%d, " |
| 733 | "cannot reset.\n", __func__, i); |
Kevin Hilman | 917fa28 | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 734 | } |
| 735 | #else |
| 736 | static inline void omap_hsmmc_reset(void) {} |
| 737 | #endif |
| 738 | |
Tony Lindgren | d887466 | 2008-12-10 17:37:16 -0800 | [diff] [blame] | 739 | #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \ |
| 740 | defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE) |
| 741 | |
| 742 | static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller, |
| 743 | int controller_nr) |
| 744 | { |
stanley.miao | ed8303fc | 2010-05-13 12:39:30 +0000 | [diff] [blame] | 745 | if ((mmc_controller->slots[0].switch_pin > 0) && \ |
| 746 | (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES)) |
| 747 | omap_mux_init_gpio(mmc_controller->slots[0].switch_pin, |
| 748 | OMAP_PIN_INPUT_PULLUP); |
| 749 | if ((mmc_controller->slots[0].gpio_wp > 0) && \ |
| 750 | (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES)) |
| 751 | omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp, |
| 752 | OMAP_PIN_INPUT_PULLUP); |
| 753 | |
Tony Lindgren | d887466 | 2008-12-10 17:37:16 -0800 | [diff] [blame] | 754 | if (cpu_is_omap2420() && controller_nr == 0) { |
Tony Lindgren | f99bf16 | 2010-07-05 16:31:40 +0300 | [diff] [blame] | 755 | omap_mux_init_signal("sdmmc_cmd", 0); |
| 756 | omap_mux_init_signal("sdmmc_clki", 0); |
| 757 | omap_mux_init_signal("sdmmc_clko", 0); |
| 758 | omap_mux_init_signal("sdmmc_dat0", 0); |
| 759 | omap_mux_init_signal("sdmmc_dat_dir0", 0); |
| 760 | omap_mux_init_signal("sdmmc_cmd_dir", 0); |
Sukumar Ghorai | 3a63833 | 2010-09-15 14:49:23 +0000 | [diff] [blame] | 761 | if (mmc_controller->slots[0].caps & MMC_CAP_4_BIT_DATA) { |
Tony Lindgren | f99bf16 | 2010-07-05 16:31:40 +0300 | [diff] [blame] | 762 | omap_mux_init_signal("sdmmc_dat1", 0); |
| 763 | omap_mux_init_signal("sdmmc_dat2", 0); |
| 764 | omap_mux_init_signal("sdmmc_dat3", 0); |
| 765 | omap_mux_init_signal("sdmmc_dat_dir1", 0); |
| 766 | omap_mux_init_signal("sdmmc_dat_dir2", 0); |
| 767 | omap_mux_init_signal("sdmmc_dat_dir3", 0); |
Tony Lindgren | d887466 | 2008-12-10 17:37:16 -0800 | [diff] [blame] | 768 | } |
| 769 | |
| 770 | /* |
| 771 | * Use internal loop-back in MMC/SDIO Module Input Clock |
| 772 | * selection |
| 773 | */ |
| 774 | if (mmc_controller->slots[0].internal_clock) { |
| 775 | u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); |
| 776 | v |= (1 << 24); |
| 777 | omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0); |
| 778 | } |
| 779 | } |
Vikram Pandita | 57b9daa | 2009-08-28 11:24:11 -0700 | [diff] [blame] | 780 | |
Madhu | 4596d14 | 2009-11-22 10:11:06 -0800 | [diff] [blame] | 781 | if (cpu_is_omap34xx()) { |
Vikram Pandita | 57b9daa | 2009-08-28 11:24:11 -0700 | [diff] [blame] | 782 | if (controller_nr == 0) { |
Tony Lindgren | 4896e39 | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 783 | omap_mux_init_signal("sdmmc1_clk", |
| 784 | OMAP_PIN_INPUT_PULLUP); |
| 785 | omap_mux_init_signal("sdmmc1_cmd", |
| 786 | OMAP_PIN_INPUT_PULLUP); |
| 787 | omap_mux_init_signal("sdmmc1_dat0", |
| 788 | OMAP_PIN_INPUT_PULLUP); |
Sukumar Ghorai | 3a63833 | 2010-09-15 14:49:23 +0000 | [diff] [blame] | 789 | if (mmc_controller->slots[0].caps & |
| 790 | (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) { |
Tony Lindgren | 4896e39 | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 791 | omap_mux_init_signal("sdmmc1_dat1", |
| 792 | OMAP_PIN_INPUT_PULLUP); |
| 793 | omap_mux_init_signal("sdmmc1_dat2", |
| 794 | OMAP_PIN_INPUT_PULLUP); |
| 795 | omap_mux_init_signal("sdmmc1_dat3", |
| 796 | OMAP_PIN_INPUT_PULLUP); |
Vikram Pandita | 57b9daa | 2009-08-28 11:24:11 -0700 | [diff] [blame] | 797 | } |
Sukumar Ghorai | 3a63833 | 2010-09-15 14:49:23 +0000 | [diff] [blame] | 798 | if (mmc_controller->slots[0].caps & |
| 799 | MMC_CAP_8_BIT_DATA) { |
Tony Lindgren | 4896e39 | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 800 | omap_mux_init_signal("sdmmc1_dat4", |
| 801 | OMAP_PIN_INPUT_PULLUP); |
| 802 | omap_mux_init_signal("sdmmc1_dat5", |
| 803 | OMAP_PIN_INPUT_PULLUP); |
| 804 | omap_mux_init_signal("sdmmc1_dat6", |
| 805 | OMAP_PIN_INPUT_PULLUP); |
| 806 | omap_mux_init_signal("sdmmc1_dat7", |
| 807 | OMAP_PIN_INPUT_PULLUP); |
Vikram Pandita | 57b9daa | 2009-08-28 11:24:11 -0700 | [diff] [blame] | 808 | } |
| 809 | } |
| 810 | if (controller_nr == 1) { |
| 811 | /* MMC2 */ |
Tony Lindgren | 4896e39 | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 812 | omap_mux_init_signal("sdmmc2_clk", |
| 813 | OMAP_PIN_INPUT_PULLUP); |
| 814 | omap_mux_init_signal("sdmmc2_cmd", |
| 815 | OMAP_PIN_INPUT_PULLUP); |
| 816 | omap_mux_init_signal("sdmmc2_dat0", |
| 817 | OMAP_PIN_INPUT_PULLUP); |
Vikram Pandita | 57b9daa | 2009-08-28 11:24:11 -0700 | [diff] [blame] | 818 | |
| 819 | /* |
| 820 | * For 8 wire configurations, Lines DAT4, 5, 6 and 7 need to be muxed |
| 821 | * in the board-*.c files |
| 822 | */ |
Sukumar Ghorai | 3a63833 | 2010-09-15 14:49:23 +0000 | [diff] [blame] | 823 | if (mmc_controller->slots[0].caps & |
| 824 | (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) { |
Tony Lindgren | 4896e39 | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 825 | omap_mux_init_signal("sdmmc2_dat1", |
| 826 | OMAP_PIN_INPUT_PULLUP); |
| 827 | omap_mux_init_signal("sdmmc2_dat2", |
| 828 | OMAP_PIN_INPUT_PULLUP); |
| 829 | omap_mux_init_signal("sdmmc2_dat3", |
| 830 | OMAP_PIN_INPUT_PULLUP); |
Vikram Pandita | 57b9daa | 2009-08-28 11:24:11 -0700 | [diff] [blame] | 831 | } |
Sukumar Ghorai | 3a63833 | 2010-09-15 14:49:23 +0000 | [diff] [blame] | 832 | if (mmc_controller->slots[0].caps & |
| 833 | MMC_CAP_8_BIT_DATA) { |
Tony Lindgren | 4896e39 | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 834 | omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4", |
| 835 | OMAP_PIN_INPUT_PULLUP); |
| 836 | omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5", |
| 837 | OMAP_PIN_INPUT_PULLUP); |
| 838 | omap_mux_init_signal("sdmmc2_dat6.sdmmc2_dat6", |
| 839 | OMAP_PIN_INPUT_PULLUP); |
| 840 | omap_mux_init_signal("sdmmc2_dat7.sdmmc2_dat7", |
| 841 | OMAP_PIN_INPUT_PULLUP); |
Madhu | 4679232 | 2009-11-22 10:11:08 -0800 | [diff] [blame] | 842 | } |
Vikram Pandita | 57b9daa | 2009-08-28 11:24:11 -0700 | [diff] [blame] | 843 | } |
| 844 | |
| 845 | /* |
| 846 | * For MMC3 the pins need to be muxed in the board-*.c files |
| 847 | */ |
| 848 | } |
Tony Lindgren | d887466 | 2008-12-10 17:37:16 -0800 | [diff] [blame] | 849 | } |
| 850 | |
| 851 | void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data, |
| 852 | int nr_controllers) |
| 853 | { |
| 854 | int i; |
Tony Lindgren | 0dffb5c | 2009-01-29 08:57:16 -0800 | [diff] [blame] | 855 | char *name; |
Tony Lindgren | d887466 | 2008-12-10 17:37:16 -0800 | [diff] [blame] | 856 | |
| 857 | for (i = 0; i < nr_controllers; i++) { |
| 858 | unsigned long base, size; |
| 859 | unsigned int irq = 0; |
| 860 | |
| 861 | if (!mmc_data[i]) |
| 862 | continue; |
| 863 | |
| 864 | omap2_mmc_mux(mmc_data[i], i); |
| 865 | |
| 866 | switch (i) { |
| 867 | case 0: |
| 868 | base = OMAP2_MMC1_BASE; |
| 869 | irq = INT_24XX_MMC_IRQ; |
| 870 | break; |
| 871 | case 1: |
| 872 | base = OMAP2_MMC2_BASE; |
| 873 | irq = INT_24XX_MMC2_IRQ; |
| 874 | break; |
| 875 | case 2: |
kishore kadiyala | 82cf818 | 2009-09-22 16:45:25 -0700 | [diff] [blame] | 876 | if (!cpu_is_omap44xx() && !cpu_is_omap34xx()) |
Tony Lindgren | d887466 | 2008-12-10 17:37:16 -0800 | [diff] [blame] | 877 | return; |
| 878 | base = OMAP3_MMC3_BASE; |
| 879 | irq = INT_34XX_MMC3_IRQ; |
| 880 | break; |
kishore kadiyala | 82cf818 | 2009-09-22 16:45:25 -0700 | [diff] [blame] | 881 | case 3: |
| 882 | if (!cpu_is_omap44xx()) |
| 883 | return; |
kishore kadiyala | 91a0b08 | 2010-10-01 16:35:28 -0700 | [diff] [blame] | 884 | base = OMAP4_MMC4_BASE; |
Santosh Shilimkar | 5772ca7 | 2010-02-18 03:14:12 +0530 | [diff] [blame] | 885 | irq = OMAP44XX_IRQ_MMC4; |
kishore kadiyala | 82cf818 | 2009-09-22 16:45:25 -0700 | [diff] [blame] | 886 | break; |
| 887 | case 4: |
| 888 | if (!cpu_is_omap44xx()) |
| 889 | return; |
kishore kadiyala | 91a0b08 | 2010-10-01 16:35:28 -0700 | [diff] [blame] | 890 | base = OMAP4_MMC5_BASE; |
kishore kadiyala | 9df76b7 | 2010-04-21 18:19:37 +0000 | [diff] [blame] | 891 | irq = OMAP44XX_IRQ_MMC5; |
kishore kadiyala | 82cf818 | 2009-09-22 16:45:25 -0700 | [diff] [blame] | 892 | break; |
Tony Lindgren | d887466 | 2008-12-10 17:37:16 -0800 | [diff] [blame] | 893 | default: |
| 894 | continue; |
| 895 | } |
| 896 | |
Tony Lindgren | 0dffb5c | 2009-01-29 08:57:16 -0800 | [diff] [blame] | 897 | if (cpu_is_omap2420()) { |
Tony Lindgren | d887466 | 2008-12-10 17:37:16 -0800 | [diff] [blame] | 898 | size = OMAP2420_MMC_SIZE; |
Tony Lindgren | 0dffb5c | 2009-01-29 08:57:16 -0800 | [diff] [blame] | 899 | name = "mmci-omap"; |
kishore kadiyala | 82cf818 | 2009-09-22 16:45:25 -0700 | [diff] [blame] | 900 | } else if (cpu_is_omap44xx()) { |
kishore kadiyala | 91a0b08 | 2010-10-01 16:35:28 -0700 | [diff] [blame] | 901 | if (i < 3) |
Santosh Shilimkar | 5772ca7 | 2010-02-18 03:14:12 +0530 | [diff] [blame] | 902 | irq += OMAP44XX_IRQ_GIC_START; |
kishore kadiyala | 82cf818 | 2009-09-22 16:45:25 -0700 | [diff] [blame] | 903 | size = OMAP4_HSMMC_SIZE; |
| 904 | name = "mmci-omap-hs"; |
Tony Lindgren | 0dffb5c | 2009-01-29 08:57:16 -0800 | [diff] [blame] | 905 | } else { |
kishore kadiyala | 82cf818 | 2009-09-22 16:45:25 -0700 | [diff] [blame] | 906 | size = OMAP3_HSMMC_SIZE; |
Tony Lindgren | 0dffb5c | 2009-01-29 08:57:16 -0800 | [diff] [blame] | 907 | name = "mmci-omap-hs"; |
| 908 | } |
| 909 | omap_mmc_add(name, i, base, size, irq, mmc_data[i]); |
Tony Lindgren | d887466 | 2008-12-10 17:37:16 -0800 | [diff] [blame] | 910 | }; |
| 911 | } |
| 912 | |
| 913 | #endif |
| 914 | |
| 915 | /*-------------------------------------------------------------------------*/ |
| 916 | |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 917 | #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE) |
| 918 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430) |
| 919 | #define OMAP_HDQ_BASE 0x480B2000 |
| 920 | #endif |
| 921 | static struct resource omap_hdq_resources[] = { |
| 922 | { |
| 923 | .start = OMAP_HDQ_BASE, |
| 924 | .end = OMAP_HDQ_BASE + 0x1C, |
| 925 | .flags = IORESOURCE_MEM, |
| 926 | }, |
| 927 | { |
| 928 | .start = INT_24XX_HDQ_IRQ, |
| 929 | .flags = IORESOURCE_IRQ, |
| 930 | }, |
| 931 | }; |
| 932 | static struct platform_device omap_hdq_dev = { |
| 933 | .name = "omap_hdq", |
| 934 | .id = 0, |
| 935 | .dev = { |
| 936 | .platform_data = NULL, |
| 937 | }, |
| 938 | .num_resources = ARRAY_SIZE(omap_hdq_resources), |
| 939 | .resource = omap_hdq_resources, |
| 940 | }; |
| 941 | static inline void omap_hdq_init(void) |
| 942 | { |
| 943 | (void) platform_device_register(&omap_hdq_dev); |
| 944 | } |
| 945 | #else |
| 946 | static inline void omap_hdq_init(void) {} |
| 947 | #endif |
| 948 | |
Vaibhav Hiremath | b227358 | 2010-05-10 14:29:14 -0700 | [diff] [blame] | 949 | /*---------------------------------------------------------------------------*/ |
| 950 | |
| 951 | #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \ |
| 952 | defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE) |
| 953 | #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE) |
| 954 | static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = { |
| 955 | }; |
| 956 | #else |
| 957 | static struct resource omap_vout_resource[2] = { |
| 958 | }; |
| 959 | #endif |
| 960 | |
| 961 | static struct platform_device omap_vout_device = { |
| 962 | .name = "omap_vout", |
| 963 | .num_resources = ARRAY_SIZE(omap_vout_resource), |
| 964 | .resource = &omap_vout_resource[0], |
| 965 | .id = -1, |
| 966 | }; |
| 967 | static void omap_init_vout(void) |
| 968 | { |
| 969 | if (platform_device_register(&omap_vout_device) < 0) |
| 970 | printk(KERN_ERR "Unable to register OMAP-VOUT device\n"); |
| 971 | } |
| 972 | #else |
| 973 | static inline void omap_init_vout(void) {} |
| 974 | #endif |
| 975 | |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 976 | /*-------------------------------------------------------------------------*/ |
| 977 | |
| 978 | static int __init omap2_init_devices(void) |
| 979 | { |
Paul Walmsley | 81fbc5ef | 2010-12-21 19:56:17 -0700 | [diff] [blame] | 980 | /* |
| 981 | * please keep these calls, and their implementations above, |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 982 | * in alphabetical order so they're easier to sort through. |
| 983 | */ |
Kevin Hilman | 917fa28 | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 984 | omap_hsmmc_reset(); |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 985 | omap_init_audio(); |
Tony Lindgren | 828c707 | 2009-03-23 18:23:49 -0700 | [diff] [blame] | 986 | omap_init_camera(); |
Tony Lindgren | c40fae95 | 2006-12-07 13:58:10 -0800 | [diff] [blame] | 987 | omap_init_mbox(); |
Juha Yrjola | ed7eb9d | 2006-06-26 16:16:10 -0700 | [diff] [blame] | 988 | omap_init_mcspi(); |
Will Deacon | 8834133 | 2010-04-09 13:54:43 +0100 | [diff] [blame] | 989 | omap_init_pmu(); |
Tony Lindgren | 646e3ed | 2008-10-06 15:49:36 +0300 | [diff] [blame] | 990 | omap_hdq_init(); |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 991 | omap_init_sti(); |
Dmitry Kasatkin | ee5500c | 2010-05-03 11:10:03 +0800 | [diff] [blame] | 992 | omap_init_sham(); |
Dmitry Kasatkin | b744c67 | 2010-09-03 19:13:55 +0800 | [diff] [blame] | 993 | omap_init_aes(); |
Vaibhav Hiremath | b227358 | 2010-05-10 14:29:14 -0700 | [diff] [blame] | 994 | omap_init_vout(); |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 995 | |
| 996 | return 0; |
| 997 | } |
| 998 | arch_initcall(omap2_init_devices); |
Varadarajan, Charulatha | f2ce623 | 2010-09-23 20:02:42 +0530 | [diff] [blame] | 999 | |
| 1000 | #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE) |
Nishanth Menon | a9b365b | 2011-01-06 19:49:29 -0800 | [diff] [blame] | 1001 | static struct omap_device_pm_latency omap_wdt_latency[] = { |
Varadarajan, Charulatha | f2ce623 | 2010-09-23 20:02:42 +0530 | [diff] [blame] | 1002 | [0] = { |
| 1003 | .deactivate_func = omap_device_idle_hwmods, |
| 1004 | .activate_func = omap_device_enable_hwmods, |
| 1005 | .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST, |
| 1006 | }, |
| 1007 | }; |
| 1008 | |
| 1009 | static int __init omap_init_wdt(void) |
| 1010 | { |
| 1011 | int id = -1; |
| 1012 | struct omap_device *od; |
| 1013 | struct omap_hwmod *oh; |
| 1014 | char *oh_name = "wd_timer2"; |
| 1015 | char *dev_name = "omap_wdt"; |
| 1016 | |
| 1017 | if (!cpu_class_is_omap2()) |
| 1018 | return 0; |
| 1019 | |
| 1020 | oh = omap_hwmod_lookup(oh_name); |
| 1021 | if (!oh) { |
| 1022 | pr_err("Could not look up wd_timer%d hwmod\n", id); |
| 1023 | return -EINVAL; |
| 1024 | } |
| 1025 | |
| 1026 | od = omap_device_build(dev_name, id, oh, NULL, 0, |
| 1027 | omap_wdt_latency, |
| 1028 | ARRAY_SIZE(omap_wdt_latency), 0); |
| 1029 | WARN(IS_ERR(od), "Cant build omap_device for %s:%s.\n", |
| 1030 | dev_name, oh->name); |
| 1031 | return 0; |
| 1032 | } |
| 1033 | subsys_initcall(omap_init_wdt); |
| 1034 | #endif |