Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
fork
Configure Feed
Select the types of activity you want to include in your feed.
1/*
2 * coreboot_table-of.c
3 *
4 * Coreboot table access through open firmware.
5 *
6 * Copyright 2017 Google Inc.
7 *
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.
11 *
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.
16 */
17
18#include <linux/device.h>
19#include <linux/io.h>
20#include <linux/module.h>
21#include <linux/of_address.h>
22#include <linux/of_platform.h>
23#include <linux/platform_device.h>
24
25#include "coreboot_table.h"
26
27static int coreboot_table_of_probe(struct platform_device *pdev)
28{
29 struct device_node *fw_dn = pdev->dev.of_node;
30 void __iomem *ptr;
31
32 ptr = of_iomap(fw_dn, 0);
33 of_node_put(fw_dn);
34 if (!ptr)
35 return -ENOMEM;
36
37 return coreboot_table_init(&pdev->dev, ptr);
38}
39
40static int coreboot_table_of_remove(struct platform_device *pdev)
41{
42 return coreboot_table_exit();
43}
44
45static const struct of_device_id coreboot_of_match[] = {
46 { .compatible = "coreboot" },
47 {},
48};
49
50static struct platform_driver coreboot_table_of_driver = {
51 .probe = coreboot_table_of_probe,
52 .remove = coreboot_table_of_remove,
53 .driver = {
54 .name = "coreboot_table_of",
55 .of_match_table = coreboot_of_match,
56 },
57};
58
59static int __init platform_coreboot_table_of_init(void)
60{
61 struct platform_device *pdev;
62 struct device_node *of_node;
63
64 /* Limit device creation to the presence of /firmware/coreboot node */
65 of_node = of_find_node_by_path("/firmware/coreboot");
66 if (!of_node)
67 return -ENODEV;
68
69 if (!of_match_node(coreboot_of_match, of_node))
70 return -ENODEV;
71
72 pdev = of_platform_device_create(of_node, "coreboot_table_of", NULL);
73 if (!pdev)
74 return -ENODEV;
75
76 return platform_driver_register(&coreboot_table_of_driver);
77}
78
79module_init(platform_coreboot_table_of_init);
80
81MODULE_AUTHOR("Google, Inc.");
82MODULE_LICENSE("GPL");