diff options
author | Charulatha V <charu@ti.com> | 2011-02-02 07:22:14 -0500 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2011-02-17 12:53:31 -0500 |
commit | 1a5d81905aec1536783fb6ab875f31910f449941 (patch) | |
tree | 73b594a73cb333496e48210d4a5c29e501bd46f0 /arch/arm/mach-omap2/devices.c | |
parent | 0f616a4e17ea244f882056656964b792edde8364 (diff) |
OMAP: devices: Modify McSPI device to adapt to hwmod framework
Cleans up all base address definitions for omap_mcspi
and adapts the device registration and driver to hwmod framework.
Changes involves:
1) Removing all base address macro defines.
2) Using omap-device layer to register device and utilizing data from
hwmod data file for base address, dma channel number, Irq_number,
device attribute(number of chipselect).
3) Appending base address with pdata reg_offset for omap4 boards.
For omap4 all regs used in driver deviate with reg_offset_macros
defined with an value of 0x100. So pass this offset through pdata
and append the same to base address retrieved from hwmod data file
and we are not mapping *_HL_* regs which are not used in driver.
Signed-off-by: Charulatha V <charu@ti.com>
Signed-off-by: Govindraj.R <govindraj.raja@ti.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Reviewed-by: Partha Basak <p-basak2@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/devices.c')
-rw-r--r-- | arch/arm/mach-omap2/devices.c | 187 |
1 files changed, 40 insertions, 147 deletions
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index e0f0ef952bc9..71f099b85e7c 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> |
@@ -279,163 +280,55 @@ static inline void omap_init_audio(void) {} | |||
279 | 280 | ||
280 | #include <plat/mcspi.h> | 281 | #include <plat/mcspi.h> |
281 | 282 | ||
282 | #define OMAP2_MCSPI1_BASE 0x48098000 | 283 | struct omap_device_pm_latency omap_mcspi_latency[] = { |
283 | #define OMAP2_MCSPI2_BASE 0x4809a000 | 284 | [0] = { |
284 | #define OMAP2_MCSPI3_BASE 0x480b8000 | 285 | .deactivate_func = omap_device_idle_hwmods, |
285 | #define OMAP2_MCSPI4_BASE 0x480ba000 | 286 | .activate_func = omap_device_enable_hwmods, |
286 | 287 | .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 | |||
292 | static struct omap2_mcspi_platform_config omap2_mcspi1_config = { | ||
293 | .num_cs = 4, | ||
294 | }; | ||
295 | |||
296 | static struct resource omap2_mcspi1_resources[] = { | ||
297 | { | ||
298 | .start = OMAP2_MCSPI1_BASE, | ||
299 | .end = OMAP2_MCSPI1_BASE + 0xff, | ||
300 | .flags = IORESOURCE_MEM, | ||
301 | }, | ||
302 | }; | ||
303 | |||
304 | static 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 | |||
314 | static struct omap2_mcspi_platform_config omap2_mcspi2_config = { | ||
315 | .num_cs = 2, | ||
316 | }; | ||
317 | |||
318 | static struct resource omap2_mcspi2_resources[] = { | ||
319 | { | ||
320 | .start = OMAP2_MCSPI2_BASE, | ||
321 | .end = OMAP2_MCSPI2_BASE + 0xff, | ||
322 | .flags = IORESOURCE_MEM, | ||
323 | }, | ||
324 | }; | ||
325 | |||
326 | static 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) | ||
338 | static struct omap2_mcspi_platform_config omap2_mcspi3_config = { | ||
339 | .num_cs = 2, | ||
340 | }; | ||
341 | |||
342 | static struct resource omap2_mcspi3_resources[] = { | ||
343 | { | ||
344 | .start = OMAP2_MCSPI3_BASE, | ||
345 | .end = OMAP2_MCSPI3_BASE + 0xff, | ||
346 | .flags = IORESOURCE_MEM, | ||
347 | }, | ||
348 | }; | ||
349 | |||
350 | static 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) | ||
362 | static struct omap2_mcspi_platform_config omap2_mcspi4_config = { | ||
363 | .num_cs = 1, | ||
364 | }; | ||
365 | |||
366 | static struct resource omap2_mcspi4_resources[] = { | ||
367 | { | ||
368 | .start = OMAP2_MCSPI4_BASE, | ||
369 | .end = OMAP2_MCSPI4_BASE + 0xff, | ||
370 | .flags = IORESOURCE_MEM, | ||
371 | }, | ||
372 | }; | ||
373 | |||
374 | static 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 | }, | 288 | }, |
382 | }; | 289 | }; |
383 | #endif | ||
384 | 290 | ||
385 | #ifdef CONFIG_ARCH_OMAP4 | 291 | static int omap_mcspi_init(struct omap_hwmod *oh, void *unused) |
386 | static inline void omap4_mcspi_fixup(void) | ||
387 | { | 292 | { |
388 | omap2_mcspi1_resources[0].start = OMAP4_MCSPI1_BASE; | 293 | struct omap_device *od; |
389 | omap2_mcspi1_resources[0].end = OMAP4_MCSPI1_BASE + 0xff; | 294 | char *name = "omap2_mcspi"; |
390 | omap2_mcspi2_resources[0].start = OMAP4_MCSPI2_BASE; | 295 | struct omap2_mcspi_platform_config *pdata; |
391 | omap2_mcspi2_resources[0].end = OMAP4_MCSPI2_BASE + 0xff; | 296 | static int spi_num; |
392 | omap2_mcspi3_resources[0].start = OMAP4_MCSPI3_BASE; | 297 | struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr; |
393 | omap2_mcspi3_resources[0].end = OMAP4_MCSPI3_BASE + 0xff; | 298 | |
394 | omap2_mcspi4_resources[0].start = OMAP4_MCSPI4_BASE; | 299 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); |
395 | omap2_mcspi4_resources[0].end = OMAP4_MCSPI4_BASE + 0xff; | 300 | if (!pdata) { |
396 | } | 301 | pr_err("Memory allocation for McSPI device failed\n"); |
397 | #else | 302 | return -ENOMEM; |
398 | static inline void omap4_mcspi_fixup(void) | 303 | } |
399 | { | ||
400 | } | ||
401 | #endif | ||
402 | 304 | ||
403 | #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ | 305 | pdata->num_cs = mcspi_attrib->num_chipselect; |
404 | defined(CONFIG_ARCH_OMAP4) | 306 | switch (oh->class->rev) { |
405 | static inline void omap2_mcspi3_init(void) | 307 | case OMAP2_MCSPI_REV: |
406 | { | 308 | case OMAP3_MCSPI_REV: |
407 | platform_device_register(&omap2_mcspi3); | 309 | pdata->regs_offset = 0; |
408 | } | 310 | break; |
409 | #else | 311 | case OMAP4_MCSPI_REV: |
410 | static inline void omap2_mcspi3_init(void) | 312 | pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET; |
411 | { | 313 | break; |
412 | } | 314 | default: |
413 | #endif | 315 | pr_err("Invalid McSPI Revision value\n"); |
316 | return -EINVAL; | ||
317 | } | ||
414 | 318 | ||
415 | #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) | 319 | spi_num++; |
416 | static inline void omap2_mcspi4_init(void) | 320 | od = omap_device_build(name, spi_num, oh, pdata, |
417 | { | 321 | sizeof(*pdata), omap_mcspi_latency, |
418 | platform_device_register(&omap2_mcspi4); | 322 | ARRAY_SIZE(omap_mcspi_latency), 0); |
419 | } | 323 | WARN(IS_ERR(od), "Cant build omap_device for %s:%s\n", |
420 | #else | 324 | name, oh->name); |
421 | static inline void omap2_mcspi4_init(void) | 325 | kfree(pdata); |
422 | { | 326 | return 0; |
423 | } | 327 | } |
424 | #endif | ||
425 | 328 | ||
426 | static void omap_init_mcspi(void) | 329 | static void omap_init_mcspi(void) |
427 | { | 330 | { |
428 | if (cpu_is_omap44xx()) | 331 | 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 | } | 332 | } |
440 | 333 | ||
441 | #else | 334 | #else |