001-alix_platform.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. index dc5f1d3..a24bf8c 100644
  2. --- a/arch/x86/platform/geode/alix.c
  3. +++ b/arch/x86/platform/geode/alix.c
  4. @@ -6,6 +6,7 @@
  5. *
  6. * Copyright (C) 2008 Constantin Baranov <const@mimas.ru>
  7. * Copyright (C) 2011 Ed Wildgoose <kernel@wildgooses.com>
  8. + * and Philip Prindeville <philipp@redfish-solutions.com>
  9. *
  10. * TODO: There are large similarities with leds-net5501.c
  11. * by Alessandro Zummo <a.zummo@towertech.it>
  12. @@ -24,14 +25,47 @@
  13. #include <linux/leds.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/gpio.h>
  16. +#include <linux/input.h>
  17. +#include <linux/gpio_keys.h>
  18. +#include <linux/dmi.h>
  19. #include <asm/geode.h>
  20. +#define BIOS_SIGNATURE_TINYBIOS 0xf0000
  21. +#define BIOS_SIGNATURE_COREBOOT 0x500
  22. +#define BIOS_REGION_SIZE 0x10000
  23. +
  24. static bool force = 0;
  25. module_param(force, bool, 0444);
  26. /* FIXME: Award bios is not automatically detected as Alix platform */
  27. MODULE_PARM_DESC(force, "Force detection as ALIX.2/ALIX.3 platform");
  28. +static struct gpio_keys_button alix_gpio_buttons[] = {
  29. + {
  30. + .code = KEY_RESTART,
  31. + .gpio = 24,
  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 alix_buttons_data = {
  41. + .buttons = alix_gpio_buttons,
  42. + .nbuttons = ARRAY_SIZE(alix_gpio_buttons),
  43. + .poll_interval = 20,
  44. +};
  45. +
  46. +static struct platform_device alix_buttons_dev = {
  47. + .name = "gpio-keys-polled",
  48. + .id = 1,
  49. + .dev = {
  50. + .platform_data = &alix_buttons_data,
  51. + }
  52. +};
  53. +
  54. static struct gpio_led alix_leds[] = {
  55. {
  56. .name = "alix:1",
  57. @@ -64,17 +98,22 @@ static struct platform_device alix_leds_
  58. .dev.platform_data = &alix_leds_data,
  59. };
  60. +static struct __initdata platform_device *alix_devs[] = {
  61. + &alix_buttons_dev,
  62. + &alix_leds_dev,
  63. +};
  64. +
  65. static void __init register_alix(void)
  66. {
  67. /* Setup LED control through leds-gpio driver */
  68. - platform_device_register(&alix_leds_dev);
  69. + platform_add_devices(alix_devs, ARRAY_SIZE(alix_devs));
  70. }
  71. static int __init alix_present(unsigned long bios_phys,
  72. const char *alix_sig,
  73. size_t alix_sig_len)
  74. {
  75. - const size_t bios_len = 0x00010000;
  76. + const size_t bios_len = BIOS_REGION_SIZE;
  77. const char *bios_virt;
  78. const char *scan_end;
  79. const char *p;
  80. @@ -109,7 +148,8 @@ static int __init alix_present(unsigned
  81. *a = '\0';
  82. tail = p + alix_sig_len;
  83. - if ((tail[0] == '2' || tail[0] == '3')) {
  84. + if ((tail[0] == '2' || tail[0] == '3' || tail[0] == '6')) {
  85. +
  86. printk(KERN_INFO
  87. "%s: system is recognized as \"%s\"\n",
  88. KBUILD_MODNAME, name);
  89. @@ -120,6 +160,24 @@ static int __init alix_present(unsigned
  90. return 0;
  91. }
  92. +static bool __init alix_present_dmi(void)
  93. +{
  94. + const char *vendor, *product;
  95. +
  96. + vendor = dmi_get_system_info(DMI_SYS_VENDOR);
  97. + if (!vendor || strcmp(vendor, "PC Engines"))
  98. + return false;
  99. +
  100. + product = dmi_get_system_info(DMI_PRODUCT_NAME);
  101. + if (!product || (strcmp(product, "ALIX.2D") && strcmp(product, "ALIX.6")))
  102. + return false;
  103. +
  104. + printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n",
  105. + KBUILD_MODNAME, vendor, product);
  106. +
  107. + return true;
  108. +}
  109. +
  110. static int __init alix_init(void)
  111. {
  112. const char tinybios_sig[] = "PC Engines ALIX.";
  113. @@ -128,8 +186,9 @@ static int __init alix_init(void)
  114. if (!is_geode())
  115. return 0;
  116. - if (alix_present(0xf0000, tinybios_sig, sizeof(tinybios_sig) - 1) ||
  117. - alix_present(0x500, coreboot_sig, sizeof(coreboot_sig) - 1))
  118. + if (alix_present(BIOS_SIGNATURE_TINYBIOS, tinybios_sig, sizeof(tinybios_sig) - 1) ||
  119. + alix_present(BIOS_SIGNATURE_COREBOOT, coreboot_sig, sizeof(coreboot_sig) - 1) ||
  120. + alix_present_dmi())
  121. register_alix();
  122. return 0;