1d9523678SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2d384d6f4SThierry Escande /* 3d384d6f4SThierry Escande * coreboot_table.h 4d384d6f4SThierry Escande * 5d384d6f4SThierry Escande * Internal header for coreboot table access. 6d384d6f4SThierry Escande * 7851b4c14SSamuel Holland * Copyright 2014 Gerd Hoffmann <kraxel@redhat.com> 8d384d6f4SThierry Escande * Copyright 2017 Google Inc. 9570d30c2SSamuel Holland * Copyright 2017 Samuel Holland <samuel@sholland.org> 10d384d6f4SThierry Escande */ 11d384d6f4SThierry Escande 12d384d6f4SThierry Escande #ifndef __COREBOOT_TABLE_H 13d384d6f4SThierry Escande #define __COREBOOT_TABLE_H 14d384d6f4SThierry Escande 1535463503SStephen Boyd #include <linux/device.h> 16d384d6f4SThierry Escande 17d384d6f4SThierry Escande /* Coreboot table header structure */ 18d384d6f4SThierry Escande struct coreboot_table_header { 19d384d6f4SThierry Escande char signature[4]; 20d384d6f4SThierry Escande u32 header_bytes; 21d384d6f4SThierry Escande u32 header_checksum; 22d384d6f4SThierry Escande u32 table_bytes; 23d384d6f4SThierry Escande u32 table_checksum; 24d384d6f4SThierry Escande u32 table_entries; 25d384d6f4SThierry Escande }; 26d384d6f4SThierry Escande 27570d30c2SSamuel Holland /* List of coreboot entry structures that is used */ 28570d30c2SSamuel Holland /* Generic */ 29570d30c2SSamuel Holland struct coreboot_table_entry { 30570d30c2SSamuel Holland u32 tag; 31570d30c2SSamuel Holland u32 size; 32570d30c2SSamuel Holland }; 33570d30c2SSamuel Holland 34570d30c2SSamuel Holland /* Points to a CBMEM entry */ 35570d30c2SSamuel Holland struct lb_cbmem_ref { 36570d30c2SSamuel Holland u32 tag; 37570d30c2SSamuel Holland u32 size; 38570d30c2SSamuel Holland 39570d30c2SSamuel Holland u64 cbmem_addr; 40570d30c2SSamuel Holland }; 41570d30c2SSamuel Holland 4219d54020SJack Rosenthal #define LB_TAG_CBMEM_ENTRY 0x31 4319d54020SJack Rosenthal 4419d54020SJack Rosenthal /* Corresponds to LB_TAG_CBMEM_ENTRY */ 4519d54020SJack Rosenthal struct lb_cbmem_entry { 4619d54020SJack Rosenthal u32 tag; 4719d54020SJack Rosenthal u32 size; 4819d54020SJack Rosenthal 4919d54020SJack Rosenthal u64 address; 5019d54020SJack Rosenthal u32 entry_size; 5119d54020SJack Rosenthal u32 id; 5219d54020SJack Rosenthal }; 5319d54020SJack Rosenthal 54851b4c14SSamuel Holland /* Describes framebuffer setup by coreboot */ 55851b4c14SSamuel Holland struct lb_framebuffer { 56851b4c14SSamuel Holland u32 tag; 57851b4c14SSamuel Holland u32 size; 58851b4c14SSamuel Holland 59851b4c14SSamuel Holland u64 physical_address; 60851b4c14SSamuel Holland u32 x_resolution; 61851b4c14SSamuel Holland u32 y_resolution; 62851b4c14SSamuel Holland u32 bytes_per_line; 63851b4c14SSamuel Holland u8 bits_per_pixel; 64851b4c14SSamuel Holland u8 red_mask_pos; 65851b4c14SSamuel Holland u8 red_mask_size; 66851b4c14SSamuel Holland u8 green_mask_pos; 67851b4c14SSamuel Holland u8 green_mask_size; 68851b4c14SSamuel Holland u8 blue_mask_pos; 69851b4c14SSamuel Holland u8 blue_mask_size; 70851b4c14SSamuel Holland u8 reserved_mask_pos; 71851b4c14SSamuel Holland u8 reserved_mask_size; 72851b4c14SSamuel Holland }; 73851b4c14SSamuel Holland 74570d30c2SSamuel Holland /* A device, additionally with information from coreboot. */ 75570d30c2SSamuel Holland struct coreboot_device { 76570d30c2SSamuel Holland struct device dev; 77570d30c2SSamuel Holland union { 78570d30c2SSamuel Holland struct coreboot_table_entry entry; 79570d30c2SSamuel Holland struct lb_cbmem_ref cbmem_ref; 8019d54020SJack Rosenthal struct lb_cbmem_entry cbmem_entry; 81851b4c14SSamuel Holland struct lb_framebuffer framebuffer; 82*3b293487SKees Cook DECLARE_FLEX_ARRAY(u8, raw); 83570d30c2SSamuel Holland }; 84570d30c2SSamuel Holland }; 85570d30c2SSamuel Holland dev_to_coreboot_device(struct device * dev)8619d54020SJack Rosenthalstatic inline struct coreboot_device *dev_to_coreboot_device(struct device *dev) 8719d54020SJack Rosenthal { 8819d54020SJack Rosenthal return container_of(dev, struct coreboot_device, dev); 8919d54020SJack Rosenthal } 9019d54020SJack Rosenthal 91570d30c2SSamuel Holland /* A driver for handling devices described in coreboot tables. */ 92570d30c2SSamuel Holland struct coreboot_driver { 93570d30c2SSamuel Holland int (*probe)(struct coreboot_device *); 945f680532SUwe Kleine-König void (*remove)(struct coreboot_device *); 95570d30c2SSamuel Holland struct device_driver drv; 96570d30c2SSamuel Holland u32 tag; 97570d30c2SSamuel Holland }; 98570d30c2SSamuel Holland 99570d30c2SSamuel Holland /* Register a driver that uses the data from a coreboot table. */ 100570d30c2SSamuel Holland int coreboot_driver_register(struct coreboot_driver *driver); 101570d30c2SSamuel Holland 102570d30c2SSamuel Holland /* Unregister a driver that uses the data from a coreboot table. */ 103570d30c2SSamuel Holland void coreboot_driver_unregister(struct coreboot_driver *driver); 104570d30c2SSamuel Holland 10535463503SStephen Boyd /* module_coreboot_driver() - Helper macro for drivers that don't do 10635463503SStephen Boyd * anything special in module init/exit. This eliminates a lot of 10735463503SStephen Boyd * boilerplate. Each module may only use this macro once, and 10835463503SStephen Boyd * calling it replaces module_init() and module_exit() 10935463503SStephen Boyd */ 11035463503SStephen Boyd #define module_coreboot_driver(__coreboot_driver) \ 11135463503SStephen Boyd module_driver(__coreboot_driver, coreboot_driver_register, \ 11235463503SStephen Boyd coreboot_driver_unregister) 11335463503SStephen Boyd 114d384d6f4SThierry Escande #endif /* __COREBOOT_TABLE_H */ 115