Path: blob/master/drivers/firmware/google/coreboot_table.h
26444 views
/* SPDX-License-Identifier: GPL-2.0-only */1/*2* coreboot_table.h3*4* Internal header for coreboot table access.5*6* Copyright 2014 Gerd Hoffmann <[email protected]>7* Copyright 2017 Google Inc.8* Copyright 2017 Samuel Holland <[email protected]>9*/1011#ifndef __COREBOOT_TABLE_H12#define __COREBOOT_TABLE_H1314#include <linux/device.h>15#include <linux/mod_devicetable.h>1617/* Coreboot table header structure */18struct coreboot_table_header {19char signature[4];20u32 header_bytes;21u32 header_checksum;22u32 table_bytes;23u32 table_checksum;24u32 table_entries;25};2627/* List of coreboot entry structures that is used */28/* Generic */29struct coreboot_table_entry {30u32 tag;31u32 size;32};3334/* Points to a CBMEM entry */35struct lb_cbmem_ref {36u32 tag;37u32 size;3839u64 cbmem_addr;40};4142#define LB_TAG_CBMEM_ENTRY 0x314344/* Corresponds to LB_TAG_CBMEM_ENTRY */45struct lb_cbmem_entry {46u32 tag;47u32 size;4849u64 address;50u32 entry_size;51u32 id;52};5354/* Describes framebuffer setup by coreboot */55struct lb_framebuffer {56u32 tag;57u32 size;5859u64 physical_address;60u32 x_resolution;61u32 y_resolution;62u32 bytes_per_line;63u8 bits_per_pixel;64u8 red_mask_pos;65u8 red_mask_size;66u8 green_mask_pos;67u8 green_mask_size;68u8 blue_mask_pos;69u8 blue_mask_size;70u8 reserved_mask_pos;71u8 reserved_mask_size;72};7374/* A device, additionally with information from coreboot. */75struct coreboot_device {76struct device dev;77union {78struct coreboot_table_entry entry;79struct lb_cbmem_ref cbmem_ref;80struct lb_cbmem_entry cbmem_entry;81struct lb_framebuffer framebuffer;82DECLARE_FLEX_ARRAY(u8, raw);83};84};8586static inline struct coreboot_device *dev_to_coreboot_device(struct device *dev)87{88return container_of(dev, struct coreboot_device, dev);89}9091/* A driver for handling devices described in coreboot tables. */92struct coreboot_driver {93int (*probe)(struct coreboot_device *);94void (*remove)(struct coreboot_device *);95struct device_driver drv;96const struct coreboot_device_id *id_table;97};9899/* use a macro to avoid include chaining to get THIS_MODULE */100#define coreboot_driver_register(driver) \101__coreboot_driver_register(driver, THIS_MODULE)102/* Register a driver that uses the data from a coreboot table. */103int __coreboot_driver_register(struct coreboot_driver *driver,104struct module *owner);105106/* Unregister a driver that uses the data from a coreboot table. */107void coreboot_driver_unregister(struct coreboot_driver *driver);108109/* module_coreboot_driver() - Helper macro for drivers that don't do110* anything special in module init/exit. This eliminates a lot of111* boilerplate. Each module may only use this macro once, and112* calling it replaces module_init() and module_exit()113*/114#define module_coreboot_driver(__coreboot_driver) \115module_driver(__coreboot_driver, coreboot_driver_register, \116coreboot_driver_unregister)117118#endif /* __COREBOOT_TABLE_H */119120121