geos.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * System Specific setup for Traverse Technologies GEOS.
  3. * At the moment this means setup of GPIO control of LEDs.
  4. *
  5. * Copyright (C) 2008 Constantin Baranov <const@mimas.ru>
  6. * Copyright (C) 2011 Ed Wildgoose <kernel@wildgooses.com>
  7. * and Philip Prindeville <philipp@redfish-solutions.com>
  8. *
  9. * TODO: There are large similarities with leds-net5501.c
  10. * by Alessandro Zummo <a.zummo@towertech.it>
  11. * In the future leds-net5501.c should be migrated over to platform
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License version 2
  15. * as published by the Free Software Foundation.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/io.h>
  20. #include <linux/string.h>
  21. #include <linux/module.h>
  22. #include <linux/leds.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/gpio.h>
  25. #include <linux/input.h>
  26. #include <linux/gpio_keys.h>
  27. #include <linux/dmi.h>
  28. #include <asm/geode.h>
  29. static struct gpio_keys_button geos_gpio_buttons[] = {
  30. {
  31. .code = KEY_RESTART,
  32. .gpio = 3,
  33. .active_low = 1,
  34. .desc = "Reset button",
  35. .type = EV_KEY,
  36. .wakeup = 0,
  37. .debounce_interval = 100,
  38. .can_disable = 0,
  39. }
  40. };
  41. static struct gpio_keys_platform_data geos_buttons_data = {
  42. .buttons = geos_gpio_buttons,
  43. .nbuttons = ARRAY_SIZE(geos_gpio_buttons),
  44. .poll_interval = 20,
  45. };
  46. static struct platform_device geos_buttons_dev = {
  47. .name = "gpio-keys-polled",
  48. .id = 1,
  49. .dev = {
  50. .platform_data = &geos_buttons_data,
  51. }
  52. };
  53. static struct gpio_led geos_leds[] = {
  54. {
  55. .name = "geos:1",
  56. .gpio = 6,
  57. .default_trigger = "default-on",
  58. .active_low = 1,
  59. },
  60. {
  61. .name = "geos:2",
  62. .gpio = 25,
  63. .default_trigger = "default-off",
  64. .active_low = 1,
  65. },
  66. {
  67. .name = "geos:3",
  68. .gpio = 27,
  69. .default_trigger = "default-off",
  70. .active_low = 1,
  71. },
  72. };
  73. static struct gpio_led_platform_data geos_leds_data = {
  74. .num_leds = ARRAY_SIZE(geos_leds),
  75. .leds = geos_leds,
  76. };
  77. static struct platform_device geos_leds_dev = {
  78. .name = "leds-gpio",
  79. .id = -1,
  80. .dev.platform_data = &geos_leds_data,
  81. };
  82. static struct platform_device *geos_devs[] __initdata = {
  83. &geos_buttons_dev,
  84. &geos_leds_dev,
  85. };
  86. static void __init register_geos(void)
  87. {
  88. /* Setup LED control through leds-gpio driver */
  89. platform_add_devices(geos_devs, ARRAY_SIZE(geos_devs));
  90. }
  91. static int __init geos_init(void)
  92. {
  93. const char *vendor, *product;
  94. if (!is_geode())
  95. return 0;
  96. vendor = dmi_get_system_info(DMI_SYS_VENDOR);
  97. if (!vendor || strcmp(vendor, "Traverse Technologies"))
  98. return 0;
  99. product = dmi_get_system_info(DMI_PRODUCT_NAME);
  100. if (!product || strcmp(product, "Geos"))
  101. return 0;
  102. printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n",
  103. KBUILD_MODNAME, vendor, product);
  104. register_geos();
  105. return 0;
  106. }
  107. module_init(geos_init);
  108. MODULE_AUTHOR("Philip Prindeville <philipp@redfish-solutions.com>");
  109. MODULE_DESCRIPTION("Traverse Technologies Geos System Setup");
  110. MODULE_LICENSE("GPL");