mirror of
https://github.com/torvalds/linux.git
synced 2024-12-26 04:42:12 +00:00
d384d6f43d
Coreboot (http://www.coreboot.org) allows to save the firmware console output in a memory buffer. With this patch, the address of this memory buffer is obtained from coreboot tables on x86 chromebook devices declaring an ACPI device with name matching GOOGCB00 or BOOT0000. If the memconsole-coreboot driver is able to find the coreboot table, the memconsole driver sets the cbmem_console address and initializes the memconsole sysfs entries. The coreboot_table-acpi driver is responsible for setting the address of the coreboot table header when probed. If this address is not yet set when memconsole-coreboot is probed, then the probe is deferred by returning -EPROBE_DEFER. This patch is a rework/split/merge of patches from the chromeos v4.4 kernel tree originally authored by: Vadim Bendebury <vbendeb@chromium.org> Wei-Ning Huang <wnhuang@google.com> Yuji Sasaki <sasakiy@google.com> Duncan Laurie <dlaurie@chromium.org> Julius Werner <jwerner@chromium.org> Brian Norris <briannorris@chromium.org> Signed-off-by: Thierry Escande <thierry.escande@collabora.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
89 lines
2.1 KiB
C
89 lines
2.1 KiB
C
/*
|
|
* coreboot_table-acpi.c
|
|
*
|
|
* Using ACPI to locate Coreboot table and provide coreboot table access.
|
|
*
|
|
* Copyright 2017 Google Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License v2.0 as published by
|
|
* the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include <linux/acpi.h>
|
|
#include <linux/device.h>
|
|
#include <linux/err.h>
|
|
#include <linux/init.h>
|
|
#include <linux/io.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
|
|
#include "coreboot_table.h"
|
|
|
|
static int coreboot_table_acpi_probe(struct platform_device *pdev)
|
|
{
|
|
phys_addr_t phyaddr;
|
|
resource_size_t len;
|
|
struct coreboot_table_header __iomem *header = NULL;
|
|
struct resource *res;
|
|
void __iomem *ptr = NULL;
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
if (!res)
|
|
return -EINVAL;
|
|
|
|
len = resource_size(res);
|
|
if (!res->start || !len)
|
|
return -EINVAL;
|
|
|
|
phyaddr = res->start;
|
|
header = ioremap_cache(phyaddr, sizeof(*header));
|
|
if (header == NULL)
|
|
return -ENOMEM;
|
|
|
|
ptr = ioremap_cache(phyaddr,
|
|
header->header_bytes + header->table_bytes);
|
|
iounmap(header);
|
|
if (!ptr)
|
|
return -ENOMEM;
|
|
|
|
return coreboot_table_init(ptr);
|
|
}
|
|
|
|
static int coreboot_table_acpi_remove(struct platform_device *pdev)
|
|
{
|
|
return coreboot_table_exit();
|
|
}
|
|
|
|
static const struct acpi_device_id cros_coreboot_acpi_match[] = {
|
|
{ "GOOGCB00", 0 },
|
|
{ "BOOT0000", 0 },
|
|
{ }
|
|
};
|
|
MODULE_DEVICE_TABLE(acpi, cros_coreboot_acpi_match);
|
|
|
|
static struct platform_driver coreboot_table_acpi_driver = {
|
|
.probe = coreboot_table_acpi_probe,
|
|
.remove = coreboot_table_acpi_remove,
|
|
.driver = {
|
|
.name = "coreboot_table_acpi",
|
|
.acpi_match_table = ACPI_PTR(cros_coreboot_acpi_match),
|
|
},
|
|
};
|
|
|
|
static int __init coreboot_table_acpi_init(void)
|
|
{
|
|
return platform_driver_register(&coreboot_table_acpi_driver);
|
|
}
|
|
|
|
module_init(coreboot_table_acpi_init);
|
|
|
|
MODULE_AUTHOR("Google, Inc.");
|
|
MODULE_LICENSE("GPL");
|