Linux Audio

Check our new training course

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