1 // SPDX-License-Identifier: GPL-2.0
2 // Driver to instantiate Chromebook ramoops device.
4 // Copyright (C) 2013 Google, Inc.
6 #include <linux/acpi.h>
8 #include <linux/module.h>
9 #include <linux/platform_device.h>
10 #include <linux/pstore_ram.h>
12 static const struct dmi_system_id chromeos_pstore_dmi_table
[] __initconst
= {
15 * Today all Chromebooks/boxes ship with Google_* as version and
16 * coreboot as bios vendor. No other systems with this
17 * combination are known to date.
20 DMI_MATCH(DMI_BIOS_VENDOR
, "coreboot"),
21 DMI_MATCH(DMI_BIOS_VERSION
, "Google_"),
25 /* x86-alex, the first Samsung Chromebook. */
27 DMI_MATCH(DMI_SYS_VENDOR
, "SAMSUNG ELECTRONICS CO., LTD."),
28 DMI_MATCH(DMI_PRODUCT_NAME
, "Alex"),
32 /* x86-mario, the Cr-48 pilot device from Google. */
34 DMI_MATCH(DMI_SYS_VENDOR
, "IEC"),
35 DMI_MATCH(DMI_PRODUCT_NAME
, "Mario"),
39 /* x86-zgb, the first Acer Chromebook. */
41 DMI_MATCH(DMI_SYS_VENDOR
, "ACER"),
42 DMI_MATCH(DMI_PRODUCT_NAME
, "ZGB"),
47 MODULE_DEVICE_TABLE(dmi
, chromeos_pstore_dmi_table
);
50 * On x86 chromebooks/boxes, the firmware will keep the legacy VGA memory
51 * range untouched across reboots, so we use that to store our pstore
52 * contents for panic logs, etc.
54 static struct ramoops_platform_data chromeos_ramoops_data
= {
56 .mem_address
= 0xf00000,
57 .record_size
= 0x40000,
58 .console_size
= 0x20000,
59 .ftrace_size
= 0x20000,
61 .max_reason
= KMSG_DUMP_OOPS
,
64 static struct platform_device chromeos_ramoops
= {
67 .platform_data
= &chromeos_ramoops_data
,
72 static const struct acpi_device_id cros_ramoops_acpi_match
[] = {
76 MODULE_DEVICE_TABLE(acpi
, cros_ramoops_acpi_match
);
78 static struct platform_driver chromeos_ramoops_acpi
= {
80 .name
= "chromeos_pstore",
81 .acpi_match_table
= ACPI_PTR(cros_ramoops_acpi_match
),
85 static int __init
chromeos_probe_acpi(struct platform_device
*pdev
)
90 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
94 len
= resource_size(res
);
95 if (!res
->start
|| !len
)
98 pr_info("chromeos ramoops using acpi device.\n");
100 chromeos_ramoops_data
.mem_size
= len
;
101 chromeos_ramoops_data
.mem_address
= res
->start
;
106 static bool __init
chromeos_check_acpi(void)
108 if (!platform_driver_probe(&chromeos_ramoops_acpi
, chromeos_probe_acpi
))
113 static inline bool chromeos_check_acpi(void) { return false; }
116 static int __init
chromeos_pstore_init(void)
120 /* First check ACPI for non-hardcoded values from firmware. */
121 acpi_dev_found
= chromeos_check_acpi();
123 if (acpi_dev_found
|| dmi_check_system(chromeos_pstore_dmi_table
))
124 return platform_device_register(&chromeos_ramoops
);
129 static void __exit
chromeos_pstore_exit(void)
131 platform_device_unregister(&chromeos_ramoops
);
134 module_init(chromeos_pstore_init
);
135 module_exit(chromeos_pstore_exit
);
137 MODULE_DESCRIPTION("ChromeOS pstore module");
138 MODULE_LICENSE("GPL v2");