aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/devices.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/devices.c')
-rw-r--r--arch/arm/mach-omap2/devices.c228
1 files changed, 81 insertions, 147 deletions
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index e0f0ef952bc..9ee876fd367 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -15,6 +15,7 @@
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/clk.h> 16#include <linux/clk.h>
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/slab.h>
18 19
19#include <mach/hardware.h> 20#include <mach/hardware.h>
20#include <mach/irqs.h> 21#include <mach/irqs.h>
@@ -30,6 +31,7 @@
30#include <plat/dma.h> 31#include <plat/dma.h>
31#include <plat/omap_hwmod.h> 32#include <plat/omap_hwmod.h>
32#include <plat/omap_device.h> 33#include <plat/omap_device.h>
34#include <plat/omap4-keypad.h>
33 35
34#include "mux.h" 36#include "mux.h"
35#include "control.h" 37#include "control.h"
@@ -141,6 +143,46 @@ static inline void omap_init_camera(void)
141} 143}
142#endif 144#endif
143 145
146struct 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
144#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE) 186#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
145 187
146#define MBOX_REG_SIZE 0x120 188#define MBOX_REG_SIZE 0x120
@@ -279,163 +321,55 @@ static inline void omap_init_audio(void) {}
279 321
280#include <plat/mcspi.h> 322#include <plat/mcspi.h>
281 323
282#define OMAP2_MCSPI1_BASE 0x48098000 324struct omap_device_pm_latency omap_mcspi_latency[] = {
283#define OMAP2_MCSPI2_BASE 0x4809a000 325 [0] = {
284#define OMAP2_MCSPI3_BASE 0x480b8000 326 .deactivate_func = omap_device_idle_hwmods,
285#define OMAP2_MCSPI4_BASE 0x480ba000 327 .activate_func = omap_device_enable_hwmods,
286 328 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
287#define OMAP4_MCSPI1_BASE 0x48098100
288#define OMAP4_MCSPI2_BASE 0x4809a100
289#define OMAP4_MCSPI3_BASE 0x480b8100
290#define OMAP4_MCSPI4_BASE 0x480ba100
291
292static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
293 .num_cs = 4,
294};
295
296static struct resource omap2_mcspi1_resources[] = {
297 {
298 .start = OMAP2_MCSPI1_BASE,
299 .end = OMAP2_MCSPI1_BASE + 0xff,
300 .flags = IORESOURCE_MEM,
301 },
302};
303
304static struct platform_device omap2_mcspi1 = {
305 .name = "omap2_mcspi",
306 .id = 1,
307 .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
308 .resource = omap2_mcspi1_resources,
309 .dev = {
310 .platform_data = &omap2_mcspi1_config,
311 },
312};
313
314static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
315 .num_cs = 2,
316};
317
318static struct resource omap2_mcspi2_resources[] = {
319 {
320 .start = OMAP2_MCSPI2_BASE,
321 .end = OMAP2_MCSPI2_BASE + 0xff,
322 .flags = IORESOURCE_MEM,
323 },
324};
325
326static struct platform_device omap2_mcspi2 = {
327 .name = "omap2_mcspi",
328 .id = 2,
329 .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
330 .resource = omap2_mcspi2_resources,
331 .dev = {
332 .platform_data = &omap2_mcspi2_config,
333 },
334};
335
336#if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
337 defined(CONFIG_ARCH_OMAP4)
338static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
339 .num_cs = 2,
340};
341
342static struct resource omap2_mcspi3_resources[] = {
343 {
344 .start = OMAP2_MCSPI3_BASE,
345 .end = OMAP2_MCSPI3_BASE + 0xff,
346 .flags = IORESOURCE_MEM,
347 },
348};
349
350static struct platform_device omap2_mcspi3 = {
351 .name = "omap2_mcspi",
352 .id = 3,
353 .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
354 .resource = omap2_mcspi3_resources,
355 .dev = {
356 .platform_data = &omap2_mcspi3_config,
357 },
358};
359#endif
360
361#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
362static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
363 .num_cs = 1,
364};
365
366static struct resource omap2_mcspi4_resources[] = {
367 {
368 .start = OMAP2_MCSPI4_BASE,
369 .end = OMAP2_MCSPI4_BASE + 0xff,
370 .flags = IORESOURCE_MEM,
371 },
372};
373
374static struct platform_device omap2_mcspi4 = {
375 .name = "omap2_mcspi",
376 .id = 4,
377 .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
378 .resource = omap2_mcspi4_resources,
379 .dev = {
380 .platform_data = &omap2_mcspi4_config,
381 }, 329 },
382}; 330};
383#endif
384 331
385#ifdef CONFIG_ARCH_OMAP4 332static int omap_mcspi_init(struct omap_hwmod *oh, void *unused)
386static inline void omap4_mcspi_fixup(void)
387{
388 omap2_mcspi1_resources[0].start = OMAP4_MCSPI1_BASE;
389 omap2_mcspi1_resources[0].end = OMAP4_MCSPI1_BASE + 0xff;
390 omap2_mcspi2_resources[0].start = OMAP4_MCSPI2_BASE;
391 omap2_mcspi2_resources[0].end = OMAP4_MCSPI2_BASE + 0xff;
392 omap2_mcspi3_resources[0].start = OMAP4_MCSPI3_BASE;
393 omap2_mcspi3_resources[0].end = OMAP4_MCSPI3_BASE + 0xff;
394 omap2_mcspi4_resources[0].start = OMAP4_MCSPI4_BASE;
395 omap2_mcspi4_resources[0].end = OMAP4_MCSPI4_BASE + 0xff;
396}
397#else
398static inline void omap4_mcspi_fixup(void)
399{ 333{
400} 334 struct omap_device *od;
401#endif 335 char *name = "omap2_mcspi";
336 struct omap2_mcspi_platform_config *pdata;
337 static int spi_num;
338 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
339
340 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
341 if (!pdata) {
342 pr_err("Memory allocation for McSPI device failed\n");
343 return -ENOMEM;
344 }
402 345
403#if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ 346 pdata->num_cs = mcspi_attrib->num_chipselect;
404 defined(CONFIG_ARCH_OMAP4) 347 switch (oh->class->rev) {
405static inline void omap2_mcspi3_init(void) 348 case OMAP2_MCSPI_REV:
406{ 349 case OMAP3_MCSPI_REV:
407 platform_device_register(&omap2_mcspi3); 350 pdata->regs_offset = 0;
408} 351 break;
409#else 352 case OMAP4_MCSPI_REV:
410static inline void omap2_mcspi3_init(void) 353 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
411{ 354 break;
412} 355 default:
413#endif 356 pr_err("Invalid McSPI Revision value\n");
357 return -EINVAL;
358 }
414 359
415#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) 360 spi_num++;
416static inline void omap2_mcspi4_init(void) 361 od = omap_device_build(name, spi_num, oh, pdata,
417{ 362 sizeof(*pdata), omap_mcspi_latency,
418 platform_device_register(&omap2_mcspi4); 363 ARRAY_SIZE(omap_mcspi_latency), 0);
419} 364 WARN(IS_ERR(od), "Cant build omap_device for %s:%s\n",
420#else 365 name, oh->name);
421static inline void omap2_mcspi4_init(void) 366 kfree(pdata);
422{ 367 return 0;
423} 368}
424#endif
425 369
426static void omap_init_mcspi(void) 370static void omap_init_mcspi(void)
427{ 371{
428 if (cpu_is_omap44xx()) 372 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
429 omap4_mcspi_fixup();
430
431 platform_device_register(&omap2_mcspi1);
432 platform_device_register(&omap2_mcspi2);
433
434 if (cpu_is_omap2430() || cpu_is_omap343x() || cpu_is_omap44xx())
435 omap2_mcspi3_init();
436
437 if (cpu_is_omap343x() || cpu_is_omap44xx())
438 omap2_mcspi4_init();
439} 373}
440 374
441#else 375#else