geos.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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/leds.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/gpio.h>
  24. #include <linux/input.h>
  25. #include <linux/gpio_keys.h>
  26. #include <linux/dmi.h>
  27. #include <asm/geode.h>
  28. static struct gpio_keys_button geos_gpio_buttons[] = {
  29. {
  30. .code = KEY_RESTART,
  31. .gpio = 3,
  32. .active_low = 1,
  33. .desc = "Reset button",
  34. .type = EV_KEY,
  35. .wakeup = 0,
  36. .debounce_interval = 100,
  37. .can_disable = 0,
  38. }
  39. };
  40. static struct gpio_keys_platform_data geos_buttons_data = {
  41. .buttons = geos_gpio_buttons,
  42. .nbuttons = ARRAY_SIZE(geos_gpio_buttons),
  43. .poll_interval = 20,
  44. };
  45. static struct platform_device geos_buttons_dev = {
  46. .name = "gpio-keys-polled",
  47. .id = 1,
  48. .dev = {
  49. .platform_data = &geos_buttons_data,
  50. }
  51. };
  52. static struct gpio_led geos_leds[] = {
  53. {
  54. .name = "geos:1",
  55. .gpio = 6,
  56. .default_trigger = "default-on",
  57. .active_low = 1,
  58. },
  59. {
  60. .name = "geos:2",
  61. .gpio = 25,
  62. .default_trigger = "default-off",
  63. .active_low = 1,
  64. },
  65. {
  66. .name = "geos:3",
  67. .gpio = 27,
  68. .default_trigger = "default-off",
  69. .active_low = 1,
  70. },
  71. };
  72. static struct gpio_led_platform_data geos_leds_data = {
  73. .num_leds = ARRAY_SIZE(geos_leds),
  74. .leds = geos_leds,
  75. };
  76. static struct platform_device geos_leds_dev = {
  77. .name = "leds-gpio",
  78. .id = -1,
  79. .dev.platform_data = &geos_leds_data,
  80. };
  81. static struct platform_device *geos_devs[] __initdata = {
  82. &geos_buttons_dev,
  83. &geos_leds_dev,
  84. };
  85. static void __init register_geos(void)
  86. {
  87. /* Setup LED control through leds-gpio driver */
  88. platform_add_devices(geos_devs, ARRAY_SIZE(geos_devs));
  89. }
  90. static int __init geos_init(void)
  91. {
  92. const char *vendor, *product;
  93. if (!is_geode())
  94. return 0;
  95. vendor = dmi_get_system_info(DMI_SYS_VENDOR);
  96. if (!vendor || strcmp(vendor, "Traverse Technologies"))
  97. return 0;
  98. product = dmi_get_system_info(DMI_PRODUCT_NAME);
  99. if (!product || strcmp(product, "Geos"))
  100. return 0;
  101. printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n",
  102. KBUILD_MODNAME, vendor, product);
  103. register_geos();
  104. return 0;
  105. }
  106. device_initcall(geos_init);