debug-devices.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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/gpio.h>
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/io.h>
  16. #include <linux/smc91x.h>
  17. #include <mach/hardware.h>
  18. /* Many OMAP development platforms reuse the same "debug board"; these
  19. * platforms include H2, H3, H4, and Perseus2.
  20. */
  21. static struct smc91x_platdata smc91x_info = {
  22. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  23. .leda = RPC_LED_100_10,
  24. .ledb = RPC_LED_TX_RX,
  25. };
  26. static struct resource smc91x_resources[] = {
  27. [0] = {
  28. .flags = IORESOURCE_MEM,
  29. },
  30. [1] = {
  31. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  32. },
  33. };
  34. static struct platform_device smc91x_device = {
  35. .name = "smc91x",
  36. .id = -1,
  37. .dev = {
  38. .platform_data = &smc91x_info,
  39. },
  40. .num_resources = ARRAY_SIZE(smc91x_resources),
  41. .resource = smc91x_resources,
  42. };
  43. static struct resource led_resources[] = {
  44. [0] = {
  45. .flags = IORESOURCE_MEM,
  46. },
  47. };
  48. static struct platform_device led_device = {
  49. .name = "omap_dbg_led",
  50. .id = -1,
  51. .num_resources = ARRAY_SIZE(led_resources),
  52. .resource = led_resources,
  53. };
  54. static struct platform_device *debug_devices[] __initdata = {
  55. &smc91x_device,
  56. &led_device,
  57. /* ps2 kbd + mouse ports */
  58. /* 4 extra uarts */
  59. /* 6 input dip switches */
  60. /* 8 output pins */
  61. };
  62. int __init debug_card_init(u32 addr, unsigned gpio)
  63. {
  64. int status;
  65. smc91x_resources[0].start = addr + 0x300;
  66. smc91x_resources[0].end = addr + 0x30f;
  67. smc91x_resources[1].start = gpio_to_irq(gpio);
  68. smc91x_resources[1].end = gpio_to_irq(gpio);
  69. status = gpio_request(gpio, "SMC91x irq");
  70. if (status < 0) {
  71. printk(KERN_ERR "GPIO%d unavailable for smc91x IRQ\n", gpio);
  72. return status;
  73. }
  74. gpio_direction_input(gpio);
  75. led_resources[0].start = addr;
  76. led_resources[0].end = addr + SZ_4K - 1;
  77. return platform_add_devices(debug_devices, ARRAY_SIZE(debug_devices));
  78. }