2 * coreboot_table-acpi.c
4 * Using ACPI to locate Coreboot table and provide coreboot table access.
6 * Copyright 2017 Google Inc.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License v2.0 as published by
10 * the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <linux/acpi.h>
19 #include <linux/device.h>
20 #include <linux/err.h>
21 #include <linux/init.h>
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/platform_device.h>
27 #include "coreboot_table.h"
29 static int coreboot_table_acpi_probe(struct platform_device
*pdev
)
33 struct coreboot_table_header __iomem
*header
= NULL
;
35 void __iomem
*ptr
= NULL
;
37 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
41 len
= resource_size(res
);
42 if (!res
->start
|| !len
)
46 header
= ioremap_cache(phyaddr
, sizeof(*header
));
50 ptr
= ioremap_cache(phyaddr
,
51 header
->header_bytes
+ header
->table_bytes
);
56 return coreboot_table_init(ptr
);
59 static int coreboot_table_acpi_remove(struct platform_device
*pdev
)
61 return coreboot_table_exit();
64 static const struct acpi_device_id cros_coreboot_acpi_match
[] = {
69 MODULE_DEVICE_TABLE(acpi
, cros_coreboot_acpi_match
);
71 static struct platform_driver coreboot_table_acpi_driver
= {
72 .probe
= coreboot_table_acpi_probe
,
73 .remove
= coreboot_table_acpi_remove
,
75 .name
= "coreboot_table_acpi",
76 .acpi_match_table
= ACPI_PTR(cros_coreboot_acpi_match
),
80 static int __init
coreboot_table_acpi_init(void)
82 return platform_driver_register(&coreboot_table_acpi_driver
);
85 module_init(coreboot_table_acpi_init
);
87 MODULE_AUTHOR("Google, Inc.");
88 MODULE_LICENSE("GPL");