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