chromeos_pstore.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * chromeos_pstore.c - Driver to instantiate Chromebook ramoops device
  3. *
  4. * Copyright (C) 2013 Google, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, version 2 of the License.
  9. */
  10. #include <linux/acpi.h>
  11. #include <linux/dmi.h>
  12. #include <linux/module.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/pstore_ram.h>
  15. static struct dmi_system_id chromeos_pstore_dmi_table[] __initdata = {
  16. {
  17. /*
  18. * Today all Chromebooks/boxes ship with Google_* as version and
  19. * coreboot as bios vendor. No other systems with this
  20. * combination are known to date.
  21. */
  22. .matches = {
  23. DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
  24. DMI_MATCH(DMI_BIOS_VERSION, "Google_"),
  25. },
  26. },
  27. {
  28. /* x86-alex, the first Samsung Chromebook. */
  29. .matches = {
  30. DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
  31. DMI_MATCH(DMI_PRODUCT_NAME, "Alex"),
  32. },
  33. },
  34. {
  35. /* x86-mario, the Cr-48 pilot device from Google. */
  36. .matches = {
  37. DMI_MATCH(DMI_SYS_VENDOR, "IEC"),
  38. DMI_MATCH(DMI_PRODUCT_NAME, "Mario"),
  39. },
  40. },
  41. {
  42. /* x86-zgb, the first Acer Chromebook. */
  43. .matches = {
  44. DMI_MATCH(DMI_SYS_VENDOR, "ACER"),
  45. DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"),
  46. },
  47. },
  48. { }
  49. };
  50. MODULE_DEVICE_TABLE(dmi, chromeos_pstore_dmi_table);
  51. /*
  52. * On x86 chromebooks/boxes, the firmware will keep the legacy VGA memory
  53. * range untouched across reboots, so we use that to store our pstore
  54. * contents for panic logs, etc.
  55. */
  56. static struct ramoops_platform_data chromeos_ramoops_data = {
  57. .mem_size = 0x100000,
  58. .mem_address = 0xf00000,
  59. .record_size = 0x40000,
  60. .console_size = 0x20000,
  61. .ftrace_size = 0x20000,
  62. .dump_oops = 1,
  63. };
  64. static struct platform_device chromeos_ramoops = {
  65. .name = "ramoops",
  66. .dev = {
  67. .platform_data = &chromeos_ramoops_data,
  68. },
  69. };
  70. #ifdef CONFIG_ACPI
  71. static const struct acpi_device_id cros_ramoops_acpi_match[] = {
  72. { "GOOG9999", 0 },
  73. { }
  74. };
  75. MODULE_DEVICE_TABLE(acpi, cros_ramoops_acpi_match);
  76. static struct platform_driver chromeos_ramoops_acpi = {
  77. .driver = {
  78. .name = "chromeos_pstore",
  79. .acpi_match_table = ACPI_PTR(cros_ramoops_acpi_match),
  80. },
  81. };
  82. static int __init chromeos_probe_acpi(struct platform_device *pdev)
  83. {
  84. struct resource *res;
  85. resource_size_t len;
  86. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  87. if (!res)
  88. return -ENOMEM;
  89. len = resource_size(res);
  90. if (!res->start || !len)
  91. return -ENOMEM;
  92. pr_info("chromeos ramoops using acpi device.\n");
  93. chromeos_ramoops_data.mem_size = len;
  94. chromeos_ramoops_data.mem_address = res->start;
  95. return 0;
  96. }
  97. static bool __init chromeos_check_acpi(void)
  98. {
  99. if (!platform_driver_probe(&chromeos_ramoops_acpi, chromeos_probe_acpi))
  100. return true;
  101. return false;
  102. }
  103. #else
  104. static inline bool chromeos_check_acpi(void) { return false; }
  105. #endif
  106. static int __init chromeos_pstore_init(void)
  107. {
  108. bool acpi_dev_found;
  109. /* First check ACPI for non-hardcoded values from firmware. */
  110. acpi_dev_found = chromeos_check_acpi();
  111. if (acpi_dev_found || dmi_check_system(chromeos_pstore_dmi_table))
  112. return platform_device_register(&chromeos_ramoops);
  113. return -ENODEV;
  114. }
  115. static void __exit chromeos_pstore_exit(void)
  116. {
  117. platform_device_unregister(&chromeos_ramoops);
  118. }
  119. module_init(chromeos_pstore_init);
  120. module_exit(chromeos_pstore_exit);
  121. MODULE_DESCRIPTION("Chrome OS pstore module");
  122. MODULE_LICENSE("GPL");