blob: 308a853ac4f19ac3a126821b34d10f46ddb8776d [file] [log] [blame]
Olof Johansson9742e122013-11-12 13:32:13 -08001/*
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
Aaron Durbin59a356d2016-02-16 08:25:15 +010011#include <linux/acpi.h>
Olof Johansson9742e122013-11-12 13:32:13 -080012#include <linux/dmi.h>
13#include <linux/module.h>
14#include <linux/platform_device.h>
15#include <linux/pstore_ram.h>
16
17static struct dmi_system_id chromeos_pstore_dmi_table[] __initdata = {
18 {
19 /*
Olof Johanssond1c14372014-07-10 10:17:35 -070020 * Today all Chromebooks/boxes ship with Google_* as version and
Olof Johansson9742e122013-11-12 13:32:13 -080021 * coreboot as bios vendor. No other systems with this
22 * combination are known to date.
23 */
24 .matches = {
Olof Johansson9742e122013-11-12 13:32:13 -080025 DMI_MATCH(DMI_BIOS_VENDOR, "coreboot"),
Olof Johanssond1c14372014-07-10 10:17:35 -070026 DMI_MATCH(DMI_BIOS_VERSION, "Google_"),
Olof Johansson9742e122013-11-12 13:32:13 -080027 },
28 },
29 {
30 /* x86-alex, the first Samsung Chromebook. */
31 .matches = {
32 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
33 DMI_MATCH(DMI_PRODUCT_NAME, "Alex"),
34 },
35 },
36 {
37 /* x86-mario, the Cr-48 pilot device from Google. */
38 .matches = {
39 DMI_MATCH(DMI_SYS_VENDOR, "IEC"),
40 DMI_MATCH(DMI_PRODUCT_NAME, "Mario"),
41 },
42 },
43 {
44 /* x86-zgb, the first Acer Chromebook. */
45 .matches = {
46 DMI_MATCH(DMI_SYS_VENDOR, "ACER"),
47 DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"),
48 },
49 },
50 { }
51};
52MODULE_DEVICE_TABLE(dmi, chromeos_pstore_dmi_table);
53
54/*
55 * On x86 chromebooks/boxes, the firmware will keep the legacy VGA memory
56 * range untouched across reboots, so we use that to store our pstore
57 * contents for panic logs, etc.
58 */
59static struct ramoops_platform_data chromeos_ramoops_data = {
60 .mem_size = 0x100000,
61 .mem_address = 0xf00000,
Olof Johanssonf929efb2016-02-16 08:25:16 +010062 .record_size = 0x40000,
Olof Johansson9742e122013-11-12 13:32:13 -080063 .console_size = 0x20000,
64 .ftrace_size = 0x20000,
65 .dump_oops = 1,
66};
67
68static struct platform_device chromeos_ramoops = {
69 .name = "ramoops",
70 .dev = {
71 .platform_data = &chromeos_ramoops_data,
72 },
73};
74
Aaron Durbin59a356d2016-02-16 08:25:15 +010075#ifdef CONFIG_ACPI
76static const struct acpi_device_id cros_ramoops_acpi_match[] = {
77 { "GOOG9999", 0 },
78 { }
79};
80MODULE_DEVICE_TABLE(acpi, cros_ramoops_acpi_match);
81
82static struct platform_driver chromeos_ramoops_acpi = {
83 .driver = {
84 .name = "chromeos_pstore",
85 .acpi_match_table = ACPI_PTR(cros_ramoops_acpi_match),
86 },
87};
88
89static int __init chromeos_probe_acpi(struct platform_device *pdev)
90{
91 struct resource *res;
92 resource_size_t len;
93
94 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
95 if (!res)
96 return -ENOMEM;
97
98 len = resource_size(res);
99 if (!res->start || !len)
100 return -ENOMEM;
101
102 pr_info("chromeos ramoops using acpi device.\n");
103
104 chromeos_ramoops_data.mem_size = len;
105 chromeos_ramoops_data.mem_address = res->start;
106
107 return 0;
108}
109
110static bool __init chromeos_check_acpi(void)
111{
112 if (!platform_driver_probe(&chromeos_ramoops_acpi, chromeos_probe_acpi))
113 return true;
114 return false;
115}
116#else
117static inline bool chromeos_check_acpi(void) { return false; }
118#endif
119
Olof Johansson9742e122013-11-12 13:32:13 -0800120static int __init chromeos_pstore_init(void)
121{
Aaron Durbin59a356d2016-02-16 08:25:15 +0100122 bool acpi_dev_found;
123
124 /* First check ACPI for non-hardcoded values from firmware. */
125 acpi_dev_found = chromeos_check_acpi();
126
127 if (acpi_dev_found || dmi_check_system(chromeos_pstore_dmi_table))
Olof Johansson9742e122013-11-12 13:32:13 -0800128 return platform_device_register(&chromeos_ramoops);
129
130 return -ENODEV;
131}
132
133static void __exit chromeos_pstore_exit(void)
134{
135 platform_device_unregister(&chromeos_ramoops);
136}
137
138module_init(chromeos_pstore_init);
139module_exit(chromeos_pstore_exit);
140
141MODULE_DESCRIPTION("Chrome OS pstore module");
142MODULE_LICENSE("GPL");