1 /* SPDX-License-Identifier: GPL-2.0-only */
5 * Internal header for coreboot table access.
8 * Copyright 2017 Google Inc.
12 #ifndef __COREBOOT_TABLE_H
13 #define __COREBOOT_TABLE_H
15 #include <linux/device.h>
16 #include <linux/mod_devicetable.h>
18 /* Coreboot table header structure */
19 struct coreboot_table_header {
28 /* List of coreboot entry structures that is used */
30 struct coreboot_table_entry {
35 /* Points to a CBMEM entry */
43 #define LB_TAG_CBMEM_ENTRY 0x31
45 /* Corresponds to LB_TAG_CBMEM_ENTRY */
46 struct lb_cbmem_entry {
55 /* Describes framebuffer setup by coreboot */
56 struct lb_framebuffer {
72 u8 reserved_mask_size;
75 /* A device, additionally with information from coreboot. */
76 struct coreboot_device {
79 struct coreboot_table_entry entry;
80 struct lb_cbmem_ref cbmem_ref;
81 struct lb_cbmem_entry cbmem_entry;
82 struct lb_framebuffer framebuffer;
83 DECLARE_FLEX_ARRAY(u8, raw);
87 static inline struct coreboot_device *dev_to_coreboot_device(struct device *dev)
89 return container_of(dev, struct coreboot_device, dev);
92 /* A driver for handling devices described in coreboot tables. */
93 struct coreboot_driver {
94 int (*probe)(struct coreboot_device *);
95 void (*remove)(struct coreboot_device *);
96 struct device_driver drv;
97 const struct coreboot_device_id *id_table;
100 /* Register a driver that uses the data from a coreboot table. */
101 int coreboot_driver_register(struct coreboot_driver *driver);
103 /* Unregister a driver that uses the data from a coreboot table. */
104 void coreboot_driver_unregister(struct coreboot_driver *driver);
106 /* module_coreboot_driver() - Helper macro for drivers that don't do
107 * anything special in module init/exit. This eliminates a lot of
108 * boilerplate. Each module may only use this macro once, and
109 * calling it replaces module_init() and module_exit()
111 #define module_coreboot_driver(__coreboot_driver) \
112 module_driver(__coreboot_driver, coreboot_driver_register, \
113 coreboot_driver_unregister)
115 #endif /* __COREBOOT_TABLE_H */