intel-smartconnect.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright 2013 Matthew Garrett <mjg59@srcf.ucam.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #include <linux/init.h>
  19. #include <linux/module.h>
  20. #include <acpi/acpi_drivers.h>
  21. MODULE_LICENSE("GPL");
  22. static int smartconnect_acpi_init(struct acpi_device *acpi)
  23. {
  24. struct acpi_object_list input;
  25. struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
  26. union acpi_object *result;
  27. union acpi_object param;
  28. acpi_status status;
  29. status = acpi_evaluate_object(acpi->handle, "GAOS", NULL, &output);
  30. if (!ACPI_SUCCESS(status))
  31. return -EINVAL;
  32. result = output.pointer;
  33. if (result->type != ACPI_TYPE_INTEGER) {
  34. kfree(result);
  35. return -EINVAL;
  36. }
  37. if (result->integer.value & 0x1) {
  38. param.type = ACPI_TYPE_INTEGER;
  39. param.integer.value = 0;
  40. input.count = 1;
  41. input.pointer = &param;
  42. dev_info(&acpi->dev, "Disabling Intel Smart Connect\n");
  43. status = acpi_evaluate_object(acpi->handle, "SAOS", &input,
  44. NULL);
  45. }
  46. kfree(result);
  47. return 0;
  48. }
  49. static const struct acpi_device_id smartconnect_ids[] = {
  50. {"INT33A0", 0},
  51. {"", 0}
  52. };
  53. static struct acpi_driver smartconnect_driver = {
  54. .owner = THIS_MODULE,
  55. .name = "intel_smart_connect",
  56. .class = "intel_smart_connect",
  57. .ids = smartconnect_ids,
  58. .ops = {
  59. .add = smartconnect_acpi_init,
  60. },
  61. };
  62. static int smartconnect_init(void)
  63. {
  64. return acpi_bus_register_driver(&smartconnect_driver);
  65. }
  66. static void smartconnect_exit(void)
  67. {
  68. acpi_bus_unregister_driver(&smartconnect_driver);
  69. }
  70. module_init(smartconnect_init);
  71. module_exit(smartconnect_exit);
  72. MODULE_DEVICE_TABLE(acpi, smartconnect_ids);