summaryrefslogtreecommitdiff
path: root/drivers/firmware/google/coreboot_table-of.c
diff options
context:
space:
mode:
authorThierry Escande <thierry.escande@collabora.com>2017-03-28 19:11:29 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-04-08 19:05:36 +0300
commita1d6f9cfc7c6f55ae65430c2fd0eb2bae69dc246 (patch)
tree9643a350048611b2f6bef0a9646535f90d768a9b /drivers/firmware/google/coreboot_table-of.c
parent88cfb1eefca9a403a76dc3e151adb7565b10e77d (diff)
downloadlinux-a1d6f9cfc7c6f55ae65430c2fd0eb2bae69dc246.tar.xz
firmware: google memconsole: Add ARM/ARM64 support
This patch expands the Google firmware memory console driver to also work on certain tree based platforms running coreboot, such as ARM/ARM64 Chromebooks. This patch now adds another path to find the coreboot table through the device tree. In order to find that, a second level bootloader must have installed the 'coreboot' compatible device tree node that describes its base address and size. This patch is a rework/split/merge of patches from the chromeos v4.4 kernel tree originally authored by: Wei-Ning Huang <wnhuang@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>
Diffstat (limited to 'drivers/firmware/google/coreboot_table-of.c')
-rw-r--r--drivers/firmware/google/coreboot_table-of.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/drivers/firmware/google/coreboot_table-of.c b/drivers/firmware/google/coreboot_table-of.c
new file mode 100644
index 000000000000..727acdc83e83
--- /dev/null
+++ b/drivers/firmware/google/coreboot_table-of.c
@@ -0,0 +1,82 @@
+/*
+ * coreboot_table-of.c
+ *
+ * Coreboot table access through open firmware.
+ *
+ * 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/device.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+
+#include "coreboot_table.h"
+
+static int coreboot_table_of_probe(struct platform_device *pdev)
+{
+ struct device_node *fw_dn = pdev->dev.of_node;
+ void __iomem *ptr;
+
+ ptr = of_iomap(fw_dn, 0);
+ of_node_put(fw_dn);
+ if (!ptr)
+ return -ENOMEM;
+
+ return coreboot_table_init(ptr);
+}
+
+static int coreboot_table_of_remove(struct platform_device *pdev)
+{
+ return coreboot_table_exit();
+}
+
+static const struct of_device_id coreboot_of_match[] = {
+ { .compatible = "coreboot" },
+ {},
+};
+
+static struct platform_driver coreboot_table_of_driver = {
+ .probe = coreboot_table_of_probe,
+ .remove = coreboot_table_of_remove,
+ .driver = {
+ .name = "coreboot_table_of",
+ .of_match_table = coreboot_of_match,
+ },
+};
+
+static int __init platform_coreboot_table_of_init(void)
+{
+ struct platform_device *pdev;
+ struct device_node *of_node;
+
+ /* Limit device creation to the presence of /firmware/coreboot node */
+ of_node = of_find_node_by_path("/firmware/coreboot");
+ if (!of_node)
+ return -ENODEV;
+
+ if (!of_match_node(coreboot_of_match, of_node))
+ return -ENODEV;
+
+ pdev = of_platform_device_create(of_node, "coreboot_table_of", NULL);
+ if (!pdev)
+ return -ENODEV;
+
+ return platform_driver_register(&coreboot_table_of_driver);
+}
+
+module_init(platform_coreboot_table_of_init);
+
+MODULE_AUTHOR("Google, Inc.");
+MODULE_LICENSE("GPL");