debug-devices.c 2.1 KB

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