blob: d216976988d759b1facffac8f27542e9956f0edf [file] [log] [blame]
Tony Lindgren1dbae812005-11-10 14:26:51 +00001/*
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 Lindgren1dbae812005-11-10 14:26:51 +000012#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010015#include <linux/io.h>
Kevin Hilman917fa282008-12-10 17:37:17 -080016#include <linux/clk.h>
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +053017#include <linux/err.h>
Charulatha V1a5d8192011-02-02 17:52:14 +053018#include <linux/slab.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000019
Russell Kinga09e64f2008-08-05 16:14:15 +010020#include <mach/hardware.h>
Will Deacon88341332010-04-09 13:54:43 +010021#include <mach/irqs.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000022#include <asm/mach-types.h>
23#include <asm/mach/map.h>
Will Deacon88341332010-04-09 13:54:43 +010024#include <asm/pmu.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000025
Tony Lindgrence491cf2009-10-20 09:40:47 -070026#include <plat/tc.h>
27#include <plat/board.h>
Jarkko Nikulaa09f73f2010-10-04 15:04:53 +030028#include <plat/mcbsp.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/gpio.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070030#include <plat/mmc.h>
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +080031#include <plat/dma.h>
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +053032#include <plat/omap_hwmod.h>
33#include <plat/omap_device.h>
Syed Rafiuddin59556762010-12-27 05:51:45 +000034#include <plat/omap4-keypad.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000035
Tony Lindgren4896e392009-12-11 16:16:32 -080036#include "mux.h"
Paul Walmsley4814ced2010-10-08 11:40:20 -060037#include "control.h"
Tony Lindgren4896e392009-12-11 16:16:32 -080038
Tony Lindgren828c7072009-03-23 18:23:49 -070039#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
Tony Lindgrenc40fae952006-12-07 13:58:10 -080040
Tony Lindgren828c7072009-03-23 18:23:49 -070041static struct resource cam_resources[] = {
Tony Lindgrenc40fae952006-12-07 13:58:10 -080042 {
Tony Lindgren828c7072009-03-23 18:23:49 -070043 .start = OMAP24XX_CAMERA_BASE,
44 .end = OMAP24XX_CAMERA_BASE + 0xfff,
45 .flags = IORESOURCE_MEM,
46 },
47 {
48 .start = INT_24XX_CAM_IRQ,
49 .flags = IORESOURCE_IRQ,
50 }
51};
52
53static struct platform_device omap_cam_device = {
54 .name = "omap24xxcam",
55 .id = -1,
56 .num_resources = ARRAY_SIZE(cam_resources),
57 .resource = cam_resources,
58};
59
60static inline void omap_init_camera(void)
61{
62 platform_device_register(&omap_cam_device);
63}
64
65#elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
66
67static struct resource omap3isp_resources[] = {
68 {
69 .start = OMAP3430_ISP_BASE,
70 .end = OMAP3430_ISP_END,
71 .flags = IORESOURCE_MEM,
72 },
73 {
74 .start = OMAP3430_ISP_CBUFF_BASE,
75 .end = OMAP3430_ISP_CBUFF_END,
76 .flags = IORESOURCE_MEM,
77 },
78 {
79 .start = OMAP3430_ISP_CCP2_BASE,
80 .end = OMAP3430_ISP_CCP2_END,
81 .flags = IORESOURCE_MEM,
82 },
83 {
84 .start = OMAP3430_ISP_CCDC_BASE,
85 .end = OMAP3430_ISP_CCDC_END,
86 .flags = IORESOURCE_MEM,
87 },
88 {
89 .start = OMAP3430_ISP_HIST_BASE,
90 .end = OMAP3430_ISP_HIST_END,
91 .flags = IORESOURCE_MEM,
92 },
93 {
94 .start = OMAP3430_ISP_H3A_BASE,
95 .end = OMAP3430_ISP_H3A_END,
96 .flags = IORESOURCE_MEM,
97 },
98 {
99 .start = OMAP3430_ISP_PREV_BASE,
100 .end = OMAP3430_ISP_PREV_END,
101 .flags = IORESOURCE_MEM,
102 },
103 {
104 .start = OMAP3430_ISP_RESZ_BASE,
105 .end = OMAP3430_ISP_RESZ_END,
106 .flags = IORESOURCE_MEM,
107 },
108 {
109 .start = OMAP3430_ISP_SBL_BASE,
110 .end = OMAP3430_ISP_SBL_END,
111 .flags = IORESOURCE_MEM,
112 },
113 {
114 .start = OMAP3430_ISP_CSI2A_BASE,
115 .end = OMAP3430_ISP_CSI2A_END,
116 .flags = IORESOURCE_MEM,
117 },
118 {
119 .start = OMAP3430_ISP_CSI2PHY_BASE,
120 .end = OMAP3430_ISP_CSI2PHY_END,
121 .flags = IORESOURCE_MEM,
122 },
123 {
124 .start = INT_34XX_CAM_IRQ,
125 .flags = IORESOURCE_IRQ,
126 }
127};
128
129static struct platform_device omap3isp_device = {
130 .name = "omap3isp",
131 .id = -1,
132 .num_resources = ARRAY_SIZE(omap3isp_resources),
133 .resource = omap3isp_resources,
134};
135
136static inline void omap_init_camera(void)
137{
138 platform_device_register(&omap3isp_device);
139}
140#else
141static inline void omap_init_camera(void)
142{
143}
144#endif
145
Syed Rafiuddin59556762010-12-27 05:51:45 +0000146struct omap_device_pm_latency omap_keyboard_latency[] = {
147 {
148 .deactivate_func = omap_device_idle_hwmods,
149 .activate_func = omap_device_enable_hwmods,
150 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
151 },
152};
153
154int __init omap4_keyboard_init(struct omap4_keypad_platform_data
155 *sdp4430_keypad_data)
156{
157 struct omap_device *od;
158 struct omap_hwmod *oh;
159 struct omap4_keypad_platform_data *keypad_data;
160 unsigned int id = -1;
161 char *oh_name = "kbd";
162 char *name = "omap4-keypad";
163
164 oh = omap_hwmod_lookup(oh_name);
165 if (!oh) {
166 pr_err("Could not look up %s\n", oh_name);
167 return -ENODEV;
168 }
169
170 keypad_data = sdp4430_keypad_data;
171
172 od = omap_device_build(name, id, oh, keypad_data,
173 sizeof(struct omap4_keypad_platform_data),
174 omap_keyboard_latency,
175 ARRAY_SIZE(omap_keyboard_latency), 0);
176
177 if (IS_ERR(od)) {
178 WARN(1, "Cant build omap_device for %s:%s.\n",
179 name, oh->name);
180 return PTR_ERR(od);
181 }
182
183 return 0;
184}
185
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700186#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
Felipe Contreras69dbf852011-02-24 12:51:33 -0800187static struct omap_device_pm_latency mbox_latencies[] = {
188 [0] = {
189 .activate_func = omap_device_enable_hwmods,
190 .deactivate_func = omap_device_idle_hwmods,
191 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800192 },
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800193};
194
195static inline void omap_init_mbox(void)
196{
Felipe Contreras69dbf852011-02-24 12:51:33 -0800197 struct omap_hwmod *oh;
198 struct omap_device *od;
199
200 oh = omap_hwmod_lookup("mailbox");
201 if (!oh) {
202 pr_err("%s: unable to find hwmod\n", __func__);
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700203 return;
204 }
Felipe Contreras69dbf852011-02-24 12:51:33 -0800205
206 od = omap_device_build("omap-mailbox", -1, oh, NULL, 0,
207 mbox_latencies, ARRAY_SIZE(mbox_latencies), 0);
208 WARN(IS_ERR(od), "%s: could not build device, err %ld\n",
209 __func__, PTR_ERR(od));
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800210}
211#else
212static inline void omap_init_mbox(void) { }
Hiroshi DOYU6c20a682009-03-23 18:07:23 -0700213#endif /* CONFIG_OMAP_MBOX_FWK */
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800214
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100215static inline void omap_init_sti(void) {}
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100216
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000217#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
218
219static struct platform_device omap_pcm = {
220 .name = "omap-pcm-audio",
221 .id = -1,
222};
223
224/*
225 * OMAP2420 has 2 McBSP ports
226 * OMAP2430 has 5 McBSP ports
227 * OMAP3 has 5 McBSP ports
228 * OMAP4 has 4 McBSP ports
229 */
230OMAP_MCBSP_PLATFORM_DEVICE(1);
231OMAP_MCBSP_PLATFORM_DEVICE(2);
232OMAP_MCBSP_PLATFORM_DEVICE(3);
233OMAP_MCBSP_PLATFORM_DEVICE(4);
234OMAP_MCBSP_PLATFORM_DEVICE(5);
235
236static void omap_init_audio(void)
237{
238 platform_device_register(&omap_mcbsp1);
239 platform_device_register(&omap_mcbsp2);
240 if (cpu_is_omap243x() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
241 platform_device_register(&omap_mcbsp3);
242 platform_device_register(&omap_mcbsp4);
243 }
244 if (cpu_is_omap243x() || cpu_is_omap34xx())
245 platform_device_register(&omap_mcbsp5);
246
247 platform_device_register(&omap_pcm);
248}
249
250#else
251static inline void omap_init_audio(void) {}
252#endif
253
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300254#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700255
Tony Lindgrence491cf2009-10-20 09:40:47 -0700256#include <plat/mcspi.h>
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700257
Charulatha V1a5d8192011-02-02 17:52:14 +0530258struct omap_device_pm_latency omap_mcspi_latency[] = {
259 [0] = {
260 .deactivate_func = omap_device_idle_hwmods,
261 .activate_func = omap_device_enable_hwmods,
262 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800263 },
264};
265
Charulatha V1a5d8192011-02-02 17:52:14 +0530266static int omap_mcspi_init(struct omap_hwmod *oh, void *unused)
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700267{
Charulatha V1a5d8192011-02-02 17:52:14 +0530268 struct omap_device *od;
269 char *name = "omap2_mcspi";
270 struct omap2_mcspi_platform_config *pdata;
271 static int spi_num;
272 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700273
Charulatha V1a5d8192011-02-02 17:52:14 +0530274 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
275 if (!pdata) {
276 pr_err("Memory allocation for McSPI device failed\n");
277 return -ENOMEM;
278 }
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700279
Charulatha V1a5d8192011-02-02 17:52:14 +0530280 pdata->num_cs = mcspi_attrib->num_chipselect;
281 switch (oh->class->rev) {
282 case OMAP2_MCSPI_REV:
283 case OMAP3_MCSPI_REV:
284 pdata->regs_offset = 0;
285 break;
286 case OMAP4_MCSPI_REV:
287 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
288 break;
289 default:
290 pr_err("Invalid McSPI Revision value\n");
291 return -EINVAL;
292 }
293
294 spi_num++;
295 od = omap_device_build(name, spi_num, oh, pdata,
296 sizeof(*pdata), omap_mcspi_latency,
297 ARRAY_SIZE(omap_mcspi_latency), 0);
298 WARN(IS_ERR(od), "Cant build omap_device for %s:%s\n",
299 name, oh->name);
300 kfree(pdata);
301 return 0;
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700302}
Tony Lindgrenaf41a122009-09-24 16:23:05 -0700303
304static void omap_init_mcspi(void)
305{
Charulatha V1a5d8192011-02-02 17:52:14 +0530306 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700307}
308
309#else
310static inline void omap_init_mcspi(void) {}
311#endif
312
Will Deacon88341332010-04-09 13:54:43 +0100313static struct resource omap2_pmu_resource = {
314 .start = 3,
315 .end = 3,
316 .flags = IORESOURCE_IRQ,
317};
318
319static struct resource omap3_pmu_resource = {
320 .start = INT_34XX_BENCH_MPU_EMUL,
321 .end = INT_34XX_BENCH_MPU_EMUL,
322 .flags = IORESOURCE_IRQ,
323};
324
325static struct platform_device omap_pmu_device = {
326 .name = "arm-pmu",
327 .id = ARM_PMU_DEVICE_CPU,
328 .num_resources = 1,
329};
330
331static void omap_init_pmu(void)
332{
333 if (cpu_is_omap24xx())
334 omap_pmu_device.resource = &omap2_pmu_resource;
335 else if (cpu_is_omap34xx())
336 omap_pmu_device.resource = &omap3_pmu_resource;
337 else
338 return;
339
340 platform_device_register(&omap_pmu_device);
341}
342
343
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800344#if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
345
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000346#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800347static struct resource omap2_sham_resources[] = {
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300348 {
349 .start = OMAP24XX_SEC_SHA1MD5_BASE,
350 .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
351 .flags = IORESOURCE_MEM,
352 },
353 {
354 .start = INT_24XX_SHA1MD5,
355 .flags = IORESOURCE_IRQ,
356 }
357};
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800358static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
359#else
360#define omap2_sham_resources NULL
361#define omap2_sham_resources_sz 0
362#endif
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300363
Dmitry Kasatkinedc774e2010-05-14 14:45:08 +1000364#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800365static struct resource omap3_sham_resources[] = {
366 {
367 .start = OMAP34XX_SEC_SHA1MD5_BASE,
368 .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
369 .flags = IORESOURCE_MEM,
370 },
371 {
372 .start = INT_34XX_SHA1MD52_IRQ,
373 .flags = IORESOURCE_IRQ,
374 },
375 {
376 .start = OMAP34XX_DMA_SHA1MD5_RX,
377 .flags = IORESOURCE_DMA,
378 }
379};
380static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
381#else
382#define omap3_sham_resources NULL
383#define omap3_sham_resources_sz 0
384#endif
385
386static struct platform_device sham_device = {
387 .name = "omap-sham",
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300388 .id = -1,
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300389};
390
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800391static void omap_init_sham(void)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300392{
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800393 if (cpu_is_omap24xx()) {
394 sham_device.resource = omap2_sham_resources;
395 sham_device.num_resources = omap2_sham_resources_sz;
396 } else if (cpu_is_omap34xx()) {
397 sham_device.resource = omap3_sham_resources;
398 sham_device.num_resources = omap3_sham_resources_sz;
399 } else {
400 pr_err("%s: platform not supported\n", __func__);
401 return;
402 }
403 platform_device_register(&sham_device);
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300404}
405#else
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800406static inline void omap_init_sham(void) { }
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300407#endif
408
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800409#if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
410
Dmitry Kasatkin82a0c142010-08-20 13:44:46 +0000411#ifdef CONFIG_ARCH_OMAP2
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800412static struct resource omap2_aes_resources[] = {
413 {
414 .start = OMAP24XX_SEC_AES_BASE,
415 .end = OMAP24XX_SEC_AES_BASE + 0x4C,
416 .flags = IORESOURCE_MEM,
417 },
418 {
419 .start = OMAP24XX_DMA_AES_TX,
420 .flags = IORESOURCE_DMA,
421 },
422 {
423 .start = OMAP24XX_DMA_AES_RX,
424 .flags = IORESOURCE_DMA,
425 }
426};
427static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
428#else
429#define omap2_aes_resources NULL
430#define omap2_aes_resources_sz 0
431#endif
432
Dmitry Kasatkin82a0c142010-08-20 13:44:46 +0000433#ifdef CONFIG_ARCH_OMAP3
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800434static struct resource omap3_aes_resources[] = {
435 {
436 .start = OMAP34XX_SEC_AES_BASE,
437 .end = OMAP34XX_SEC_AES_BASE + 0x4C,
438 .flags = IORESOURCE_MEM,
439 },
440 {
441 .start = OMAP34XX_DMA_AES2_TX,
442 .flags = IORESOURCE_DMA,
443 },
444 {
445 .start = OMAP34XX_DMA_AES2_RX,
446 .flags = IORESOURCE_DMA,
447 }
448};
449static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
450#else
451#define omap3_aes_resources NULL
452#define omap3_aes_resources_sz 0
453#endif
454
455static struct platform_device aes_device = {
456 .name = "omap-aes",
457 .id = -1,
458};
459
460static void omap_init_aes(void)
461{
462 if (cpu_is_omap24xx()) {
463 aes_device.resource = omap2_aes_resources;
464 aes_device.num_resources = omap2_aes_resources_sz;
465 } else if (cpu_is_omap34xx()) {
466 aes_device.resource = omap3_aes_resources;
467 aes_device.num_resources = omap3_aes_resources_sz;
468 } else {
469 pr_err("%s: platform not supported\n", __func__);
470 return;
471 }
472 platform_device_register(&aes_device);
473}
474
475#else
476static inline void omap_init_aes(void) { }
477#endif
478
Tony Lindgrend8874662008-12-10 17:37:16 -0800479/*-------------------------------------------------------------------------*/
480
kishore kadiyala82cf8182009-09-22 16:45:25 -0700481#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Kevin Hilman917fa282008-12-10 17:37:17 -0800482
483#define MMCHS_SYSCONFIG 0x0010
484#define MMCHS_SYSCONFIG_SWRESET (1 << 1)
485#define MMCHS_SYSSTATUS 0x0014
486#define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
487
488static struct platform_device dummy_pdev = {
489 .dev = {
490 .bus = &platform_bus_type,
491 },
492};
493
494/**
495 * omap_hsmmc_reset() - Full reset of each HS-MMC controller
496 *
497 * Ensure that each MMC controller is fully reset. Controllers
498 * left in an unknown state (by bootloader) may prevent retention
499 * or OFF-mode. This is especially important in cases where the
500 * MMC driver is not enabled, _or_ built as a module.
501 *
502 * In order for reset to work, interface, functional and debounce
503 * clocks must be enabled. The debounce clock comes from func_32k_clk
504 * and is not under SW control, so we only enable i- and f-clocks.
505 **/
506static void __init omap_hsmmc_reset(void)
507{
Tony Lindgren4323e9f2010-02-12 12:26:48 -0800508 u32 i, nr_controllers;
Aaro Koskinen434c23a2010-12-20 18:48:15 -0800509 struct clk *iclk, *fclk;
Tony Lindgren4323e9f2010-02-12 12:26:48 -0800510
511 if (cpu_is_omap242x())
512 return;
513
514 nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC :
kishore kadiyala82cf8182009-09-22 16:45:25 -0700515 (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC);
Kevin Hilman917fa282008-12-10 17:37:17 -0800516
517 for (i = 0; i < nr_controllers; i++) {
518 u32 v, base = 0;
Kevin Hilman917fa282008-12-10 17:37:17 -0800519 struct device *dev = &dummy_pdev.dev;
520
521 switch (i) {
522 case 0:
523 base = OMAP2_MMC1_BASE;
524 break;
525 case 1:
526 base = OMAP2_MMC2_BASE;
527 break;
528 case 2:
529 base = OMAP3_MMC3_BASE;
530 break;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700531 case 3:
532 if (!cpu_is_omap44xx())
533 return;
534 base = OMAP4_MMC4_BASE;
535 break;
536 case 4:
537 if (!cpu_is_omap44xx())
538 return;
539 base = OMAP4_MMC5_BASE;
540 break;
Kevin Hilman917fa282008-12-10 17:37:17 -0800541 }
542
kishore kadiyala82cf8182009-09-22 16:45:25 -0700543 if (cpu_is_omap44xx())
544 base += OMAP4_MMC_REG_OFFSET;
545
Kevin Hilman917fa282008-12-10 17:37:17 -0800546 dummy_pdev.id = i;
Russell King1e98ffa2009-01-19 18:56:17 +0000547 dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
Russell King6f7607c2009-01-28 10:22:50 +0000548 iclk = clk_get(dev, "ick");
Aaro Koskinen434c23a2010-12-20 18:48:15 -0800549 if (IS_ERR(iclk))
550 goto err1;
551 if (clk_enable(iclk))
552 goto err2;
Kevin Hilman917fa282008-12-10 17:37:17 -0800553
Russell King6f7607c2009-01-28 10:22:50 +0000554 fclk = clk_get(dev, "fck");
Aaro Koskinen434c23a2010-12-20 18:48:15 -0800555 if (IS_ERR(fclk))
556 goto err3;
557 if (clk_enable(fclk))
558 goto err4;
Kevin Hilman917fa282008-12-10 17:37:17 -0800559
560 omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
561 v = omap_readl(base + MMCHS_SYSSTATUS);
562 while (!(omap_readl(base + MMCHS_SYSSTATUS) &
563 MMCHS_SYSSTATUS_RESETDONE))
564 cpu_relax();
565
Aaro Koskinen434c23a2010-12-20 18:48:15 -0800566 clk_disable(fclk);
567 clk_put(fclk);
568 clk_disable(iclk);
569 clk_put(iclk);
Kevin Hilman917fa282008-12-10 17:37:17 -0800570 }
Aaro Koskinen434c23a2010-12-20 18:48:15 -0800571 return;
572
573err4:
574 clk_put(fclk);
575err3:
576 clk_disable(iclk);
577err2:
578 clk_put(iclk);
579err1:
580 printk(KERN_WARNING "%s: Unable to enable clocks for MMC%d, "
581 "cannot reset.\n", __func__, i);
Kevin Hilman917fa282008-12-10 17:37:17 -0800582}
583#else
584static inline void omap_hsmmc_reset(void) {}
585#endif
586
Tony Lindgrend8874662008-12-10 17:37:16 -0800587#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
588 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
589
590static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
591 int controller_nr)
592{
stanley.miaoed8303fc2010-05-13 12:39:30 +0000593 if ((mmc_controller->slots[0].switch_pin > 0) && \
594 (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
595 omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
596 OMAP_PIN_INPUT_PULLUP);
597 if ((mmc_controller->slots[0].gpio_wp > 0) && \
598 (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
599 omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
600 OMAP_PIN_INPUT_PULLUP);
601
Tony Lindgrend8874662008-12-10 17:37:16 -0800602 if (cpu_is_omap2420() && controller_nr == 0) {
Tony Lindgrenf99bf162010-07-05 16:31:40 +0300603 omap_mux_init_signal("sdmmc_cmd", 0);
604 omap_mux_init_signal("sdmmc_clki", 0);
605 omap_mux_init_signal("sdmmc_clko", 0);
606 omap_mux_init_signal("sdmmc_dat0", 0);
607 omap_mux_init_signal("sdmmc_dat_dir0", 0);
608 omap_mux_init_signal("sdmmc_cmd_dir", 0);
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000609 if (mmc_controller->slots[0].caps & MMC_CAP_4_BIT_DATA) {
Tony Lindgrenf99bf162010-07-05 16:31:40 +0300610 omap_mux_init_signal("sdmmc_dat1", 0);
611 omap_mux_init_signal("sdmmc_dat2", 0);
612 omap_mux_init_signal("sdmmc_dat3", 0);
613 omap_mux_init_signal("sdmmc_dat_dir1", 0);
614 omap_mux_init_signal("sdmmc_dat_dir2", 0);
615 omap_mux_init_signal("sdmmc_dat_dir3", 0);
Tony Lindgrend8874662008-12-10 17:37:16 -0800616 }
617
618 /*
619 * Use internal loop-back in MMC/SDIO Module Input Clock
620 * selection
621 */
622 if (mmc_controller->slots[0].internal_clock) {
623 u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
624 v |= (1 << 24);
625 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
626 }
627 }
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700628
Madhu4596d142009-11-22 10:11:06 -0800629 if (cpu_is_omap34xx()) {
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700630 if (controller_nr == 0) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800631 omap_mux_init_signal("sdmmc1_clk",
632 OMAP_PIN_INPUT_PULLUP);
633 omap_mux_init_signal("sdmmc1_cmd",
634 OMAP_PIN_INPUT_PULLUP);
635 omap_mux_init_signal("sdmmc1_dat0",
636 OMAP_PIN_INPUT_PULLUP);
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000637 if (mmc_controller->slots[0].caps &
638 (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800639 omap_mux_init_signal("sdmmc1_dat1",
640 OMAP_PIN_INPUT_PULLUP);
641 omap_mux_init_signal("sdmmc1_dat2",
642 OMAP_PIN_INPUT_PULLUP);
643 omap_mux_init_signal("sdmmc1_dat3",
644 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700645 }
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000646 if (mmc_controller->slots[0].caps &
647 MMC_CAP_8_BIT_DATA) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800648 omap_mux_init_signal("sdmmc1_dat4",
649 OMAP_PIN_INPUT_PULLUP);
650 omap_mux_init_signal("sdmmc1_dat5",
651 OMAP_PIN_INPUT_PULLUP);
652 omap_mux_init_signal("sdmmc1_dat6",
653 OMAP_PIN_INPUT_PULLUP);
654 omap_mux_init_signal("sdmmc1_dat7",
655 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700656 }
657 }
658 if (controller_nr == 1) {
659 /* MMC2 */
Tony Lindgren4896e392009-12-11 16:16:32 -0800660 omap_mux_init_signal("sdmmc2_clk",
661 OMAP_PIN_INPUT_PULLUP);
662 omap_mux_init_signal("sdmmc2_cmd",
663 OMAP_PIN_INPUT_PULLUP);
664 omap_mux_init_signal("sdmmc2_dat0",
665 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700666
667 /*
668 * For 8 wire configurations, Lines DAT4, 5, 6 and 7 need to be muxed
669 * in the board-*.c files
670 */
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000671 if (mmc_controller->slots[0].caps &
672 (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800673 omap_mux_init_signal("sdmmc2_dat1",
674 OMAP_PIN_INPUT_PULLUP);
675 omap_mux_init_signal("sdmmc2_dat2",
676 OMAP_PIN_INPUT_PULLUP);
677 omap_mux_init_signal("sdmmc2_dat3",
678 OMAP_PIN_INPUT_PULLUP);
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700679 }
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000680 if (mmc_controller->slots[0].caps &
681 MMC_CAP_8_BIT_DATA) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800682 omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4",
683 OMAP_PIN_INPUT_PULLUP);
684 omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5",
685 OMAP_PIN_INPUT_PULLUP);
686 omap_mux_init_signal("sdmmc2_dat6.sdmmc2_dat6",
687 OMAP_PIN_INPUT_PULLUP);
688 omap_mux_init_signal("sdmmc2_dat7.sdmmc2_dat7",
689 OMAP_PIN_INPUT_PULLUP);
Madhu46792322009-11-22 10:11:08 -0800690 }
Vikram Pandita57b9daa2009-08-28 11:24:11 -0700691 }
692
693 /*
694 * For MMC3 the pins need to be muxed in the board-*.c files
695 */
696 }
Tony Lindgrend8874662008-12-10 17:37:16 -0800697}
698
699void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
700 int nr_controllers)
701{
702 int i;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800703 char *name;
Tony Lindgrend8874662008-12-10 17:37:16 -0800704
705 for (i = 0; i < nr_controllers; i++) {
706 unsigned long base, size;
707 unsigned int irq = 0;
708
709 if (!mmc_data[i])
710 continue;
711
712 omap2_mmc_mux(mmc_data[i], i);
713
714 switch (i) {
715 case 0:
716 base = OMAP2_MMC1_BASE;
717 irq = INT_24XX_MMC_IRQ;
718 break;
719 case 1:
720 base = OMAP2_MMC2_BASE;
721 irq = INT_24XX_MMC2_IRQ;
722 break;
723 case 2:
kishore kadiyala82cf8182009-09-22 16:45:25 -0700724 if (!cpu_is_omap44xx() && !cpu_is_omap34xx())
Tony Lindgrend8874662008-12-10 17:37:16 -0800725 return;
726 base = OMAP3_MMC3_BASE;
727 irq = INT_34XX_MMC3_IRQ;
728 break;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700729 case 3:
730 if (!cpu_is_omap44xx())
731 return;
kishore kadiyala91a0b082010-10-01 16:35:28 -0700732 base = OMAP4_MMC4_BASE;
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530733 irq = OMAP44XX_IRQ_MMC4;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700734 break;
735 case 4:
736 if (!cpu_is_omap44xx())
737 return;
kishore kadiyala91a0b082010-10-01 16:35:28 -0700738 base = OMAP4_MMC5_BASE;
kishore kadiyala9df76b72010-04-21 18:19:37 +0000739 irq = OMAP44XX_IRQ_MMC5;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700740 break;
Tony Lindgrend8874662008-12-10 17:37:16 -0800741 default:
742 continue;
743 }
744
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800745 if (cpu_is_omap2420()) {
Tony Lindgrend8874662008-12-10 17:37:16 -0800746 size = OMAP2420_MMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800747 name = "mmci-omap";
kishore kadiyala82cf8182009-09-22 16:45:25 -0700748 } else if (cpu_is_omap44xx()) {
kishore kadiyala91a0b082010-10-01 16:35:28 -0700749 if (i < 3)
Santosh Shilimkar5772ca72010-02-18 03:14:12 +0530750 irq += OMAP44XX_IRQ_GIC_START;
kishore kadiyala82cf8182009-09-22 16:45:25 -0700751 size = OMAP4_HSMMC_SIZE;
752 name = "mmci-omap-hs";
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800753 } else {
kishore kadiyala82cf8182009-09-22 16:45:25 -0700754 size = OMAP3_HSMMC_SIZE;
Tony Lindgren0dffb5c2009-01-29 08:57:16 -0800755 name = "mmci-omap-hs";
756 }
757 omap_mmc_add(name, i, base, size, irq, mmc_data[i]);
Tony Lindgrend8874662008-12-10 17:37:16 -0800758 };
759}
760
761#endif
762
763/*-------------------------------------------------------------------------*/
764
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300765#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
Tony Lindgren59b479e2011-01-27 16:39:40 -0800766#if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430)
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300767#define OMAP_HDQ_BASE 0x480B2000
768#endif
769static struct resource omap_hdq_resources[] = {
770 {
771 .start = OMAP_HDQ_BASE,
772 .end = OMAP_HDQ_BASE + 0x1C,
773 .flags = IORESOURCE_MEM,
774 },
775 {
776 .start = INT_24XX_HDQ_IRQ,
777 .flags = IORESOURCE_IRQ,
778 },
779};
780static struct platform_device omap_hdq_dev = {
781 .name = "omap_hdq",
782 .id = 0,
783 .dev = {
784 .platform_data = NULL,
785 },
786 .num_resources = ARRAY_SIZE(omap_hdq_resources),
787 .resource = omap_hdq_resources,
788};
789static inline void omap_hdq_init(void)
790{
791 (void) platform_device_register(&omap_hdq_dev);
792}
793#else
794static inline void omap_hdq_init(void) {}
795#endif
796
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700797/*---------------------------------------------------------------------------*/
798
799#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
800 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
801#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
802static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
803};
804#else
805static struct resource omap_vout_resource[2] = {
806};
807#endif
808
809static struct platform_device omap_vout_device = {
810 .name = "omap_vout",
811 .num_resources = ARRAY_SIZE(omap_vout_resource),
812 .resource = &omap_vout_resource[0],
813 .id = -1,
814};
815static void omap_init_vout(void)
816{
817 if (platform_device_register(&omap_vout_device) < 0)
818 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
819}
820#else
821static inline void omap_init_vout(void) {}
822#endif
823
Tony Lindgren1dbae812005-11-10 14:26:51 +0000824/*-------------------------------------------------------------------------*/
825
826static int __init omap2_init_devices(void)
827{
Paul Walmsley81fbc5ef2010-12-21 19:56:17 -0700828 /*
829 * please keep these calls, and their implementations above,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000830 * in alphabetical order so they're easier to sort through.
831 */
Kevin Hilman917fa282008-12-10 17:37:17 -0800832 omap_hsmmc_reset();
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000833 omap_init_audio();
Tony Lindgren828c7072009-03-23 18:23:49 -0700834 omap_init_camera();
Tony Lindgrenc40fae952006-12-07 13:58:10 -0800835 omap_init_mbox();
Juha Yrjolaed7eb9d2006-06-26 16:16:10 -0700836 omap_init_mcspi();
Will Deacon88341332010-04-09 13:54:43 +0100837 omap_init_pmu();
Tony Lindgren646e3ed2008-10-06 15:49:36 +0300838 omap_hdq_init();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100839 omap_init_sti();
Dmitry Kasatkinee5500c2010-05-03 11:10:03 +0800840 omap_init_sham();
Dmitry Kasatkinb744c672010-09-03 19:13:55 +0800841 omap_init_aes();
Vaibhav Hiremathb2273582010-05-10 14:29:14 -0700842 omap_init_vout();
Tony Lindgren1dbae812005-11-10 14:26:51 +0000843
844 return 0;
845}
846arch_initcall(omap2_init_devices);
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +0530847
848#if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
Nishanth Menona9b365b2011-01-06 19:49:29 -0800849static struct omap_device_pm_latency omap_wdt_latency[] = {
Varadarajan, Charulathaf2ce6232010-09-23 20:02:42 +0530850 [0] = {
851 .deactivate_func = omap_device_idle_hwmods,
852 .activate_func = omap_device_enable_hwmods,
853 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
854 },
855};
856
857static int __init omap_init_wdt(void)
858{
859 int id = -1;
860 struct omap_device *od;
861 struct omap_hwmod *oh;
862 char *oh_name = "wd_timer2";
863 char *dev_name = "omap_wdt";
864
865 if (!cpu_class_is_omap2())
866 return 0;
867
868 oh = omap_hwmod_lookup(oh_name);
869 if (!oh) {
870 pr_err("Could not look up wd_timer%d hwmod\n", id);
871 return -EINVAL;
872 }
873
874 od = omap_device_build(dev_name, id, oh, NULL, 0,
875 omap_wdt_latency,
876 ARRAY_SIZE(omap_wdt_latency), 0);
877 WARN(IS_ERR(od), "Cant build omap_device for %s:%s.\n",
878 dev_name, oh->name);
879 return 0;
880}
881subsys_initcall(omap_init_wdt);
882#endif