debug-devices.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * linux/arch/arm/plat-omap/debug-devices.c
  3. *
  4. * Copyright (C) 2005 Nokia Corporation
  5. * Modified from mach-omap2/board-h4.c
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/io.h>
  15. #include <mach/hardware.h>
  16. #include <mach/board.h>
  17. #include <mach/gpio.h>
  18. /* Many OMAP development platforms reuse the same "debug board"; these
  19. * platforms include H2, H3, H4, and Perseus2.
  20. */
  21. static struct resource smc91x_resources[] = {
  22. [0] = {
  23. .flags = IORESOURCE_MEM,
  24. },
  25. [1] = {
  26. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  27. },
  28. };
  29. static struct platform_device smc91x_device = {
  30. .name = "smc91x",
  31. .id = -1,
  32. .num_resources = ARRAY_SIZE(smc91x_resources),
  33. .resource = smc91x_resources,
  34. };
  35. static struct resource led_resources[] = {
  36. [0] = {
  37. .flags = IORESOURCE_MEM,
  38. },
  39. };
  40. static struct platform_device led_device = {
  41. .name = "omap_dbg_led",
  42. .id = -1,
  43. .num_resources = ARRAY_SIZE(led_resources),
  44. .resource = led_resources,
  45. };
  46. static struct platform_device *debug_devices[] __initdata = {
  47. &smc91x_device,
  48. &led_device,
  49. /* ps2 kbd + mouse ports */
  50. /* 4 extra uarts */
  51. /* 6 input dip switches */
  52. /* 8 output pins */
  53. };
  54. int __init debug_card_init(u32 addr, unsigned gpio)
  55. {
  56. int status;
  57. smc91x_resources[0].start = addr + 0x300;
  58. smc91x_resources[0].end = addr + 0x30f;
  59. smc91x_resources[1].start = gpio_to_irq(gpio);
  60. smc91x_resources[1].end = gpio_to_irq(gpio);
  61. status = gpio_request(gpio, "SMC91x irq");
  62. if (status < 0) {
  63. printk(KERN_ERR "GPIO%d unavailable for smc91x IRQ\n", gpio);
  64. return status;
  65. }
  66. gpio_direction_input(gpio);
  67. led_resources[0].start = addr;
  68. led_resources[0].end = addr + SZ_4K - 1;
  69. return platform_add_devices(debug_devices, ARRAY_SIZE(debug_devices));
  70. }