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>
17 /* Coreboot table header structure */
18 struct coreboot_table_header {
27 /* List of coreboot entry structures that is used */
29 struct coreboot_table_entry {
34 /* Points to a CBMEM entry */
42 #define LB_TAG_CBMEM_ENTRY 0x31
44 /* Corresponds to LB_TAG_CBMEM_ENTRY */
45 struct lb_cbmem_entry {
54 /* Describes framebuffer setup by coreboot */
55 struct lb_framebuffer {
71 u8 reserved_mask_size;
74 /* A device, additionally with information from coreboot. */
75 struct coreboot_device {
78 struct coreboot_table_entry entry;
79 struct lb_cbmem_ref cbmem_ref;
80 struct lb_cbmem_entry cbmem_entry;
81 struct lb_framebuffer framebuffer;
82 DECLARE_FLEX_ARRAY(u8, raw);
86 static inline struct coreboot_device *dev_to_coreboot_device(struct device *dev)
88 return container_of(dev, struct coreboot_device, dev);
91 /* A driver for handling devices described in coreboot tables. */
92 struct coreboot_driver {
93 int (*probe)(struct coreboot_device *);
94 void (*remove)(struct coreboot_device *);
95 struct device_driver drv;
99 /* Register a driver that uses the data from a coreboot table. */
100 int coreboot_driver_register(struct coreboot_driver *driver);
102 /* Unregister a driver that uses the data from a coreboot table. */
103 void coreboot_driver_unregister(struct coreboot_driver *driver);
105 /* module_coreboot_driver() - Helper macro for drivers that don't do
106 * anything special in module init/exit. This eliminates a lot of
107 * boilerplate. Each module may only use this macro once, and
108 * calling it replaces module_init() and module_exit()
110 #define module_coreboot_driver(__coreboot_driver) \
111 module_driver(__coreboot_driver, coreboot_driver_register, \
112 coreboot_driver_unregister)
114 #endif /* __COREBOOT_TABLE_H */