summaryrefslogtreecommitdiffstats
path: root/drivers/misc/acpi-test.c
blob: 970b435a0eec2fee5b85dbf9415d2a9367ffc810 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2019 Ahmad Fatoum
 */

#include <common.h>
#include <init.h>
#include <acpi.h>

static const char *profiles[] = {
	"Unspecified",
	"Desktop",
	"Mobile",
	"Workstation",
	"Enterprise Server",
	"SOHO Server",
	"Applicance PC",
	"Performance Server",
	"Tablet",
};

static int acpi_test_probe(struct device_d *dev)
{
	const char *profile = "reserved";
	u8 *sdt;
	u8 profileno;

	dev_dbg(dev, "driver initializing...\n");

	sdt = (u8 __force *)dev_request_mem_region_by_name(dev, "SDT");
	if (IS_ERR(sdt)) {
		dev_err(dev, "no SDT resource available: %s\n", strerrorp(sdt));
		return PTR_ERR(sdt);
	}

	dev_dbg(dev, "SDT is at 0x%p\n", sdt);

	profileno = sdt[45];

	if (profileno < ARRAY_SIZE(profiles))
		profile = profiles[profileno];

	dev_info(dev, "PM profile is for '%s'\n", profile);

	return 0;
}

static void acpi_test_remove(struct device_d *dev)
{
	dev_info(dev, "FADT driver removed\n");
}

static struct acpi_driver acpi_test_driver = {
	.signature = "FACP",
	.driver = {
		.name = "acpi-test",
		.probe = acpi_test_probe,
		.remove = acpi_test_remove,
	}
};
device_acpi_driver(acpi_test_driver);