blob: 836660d59d8f9e9e1d1e1f195c01bc714cb213a1 [file] [log] [blame]
Simon Glass466c7852019-12-06 21:42:18 -07001/* SPDX-License-Identifier: Intel */
2/*
3 * Copyright (C) 2015-2016 Intel Corp.
4 * (Written by Alexandru Gagniuc <alexandrux.gagniuc@intel.com> for Intel Corp.)
5 * Mostly taken from coreboot
6 */
7
8#ifndef __ASM_FSP_INTERNAL_H
9#define __ASM_FSP_INTERNAL_H
10
11struct binman_entry;
12struct fsp_header;
13struct fspm_upd;
14struct fsps_upd;
15
16enum fsp_type_t {
17 FSP_M,
18 FSP_S,
19};
20
21int fsp_get_header(ulong offset, ulong size, bool use_spi_flash,
22 struct fsp_header **fspp);
23
24/**
25 * fsp_locate_fsp() - Locate an FSP component
26 *
27 * This finds an FSP component by various methods. It is not as general-purpose
28 * as it looks, since it expects FSP-M to be requested in SPL (only), and FSP-S
29 * to be requested in U-Boot proper.
30 *
31 * @type: Component to locate
32 * @entry: Returns location of component
33 * @use_spi_flash: true to read using the Fast SPI driver, false to use
34 * memory-mapped SPI flash
35 * @devp: Returns northbridge device
36 * @hdrp: Returns FSP header
37 * @rom_offsetp: If non-NULL, returns the offset to add to any image position to
38 * find the memory-mapped location of that position. For example, for ROM
39 * position 0x1000, it will be mapped into 0x1000 + *rom_offsetp.
40 */
41int fsp_locate_fsp(enum fsp_type_t type, struct binman_entry *entry,
42 bool use_spi_flash, struct udevice **devp,
43 struct fsp_header **hdrp, ulong *rom_offsetp);
44
45/**
46 * arch_fsps_preinit() - Perform init needed before calling FSP-S
47 *
48 * This allows use of probed drivers and PCI so is a convenient place to do any
49 * init that is needed before FSP-S is called. After this, U-Boot relocates and
50 * calls arch_fsp_init_r() before PCI is probed, and that function is not
51 * allowed to probe PCI before calling FSP-S.
52 */
53int arch_fsps_preinit(void);
54
55/**
56 * fspm_update_config() - Set up the config structure for FSP-M
57 *
58 * @dev: Hostbridge device containing config
59 * @upd: Config data to fill in
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010060 * Return: 0 if OK, -ENOENT if OK but no MRC-cache data was found, other -ve on
Simon Glass1d2a3342020-07-09 18:43:17 -060061 * error
Simon Glass466c7852019-12-06 21:42:18 -070062 */
63int fspm_update_config(struct udevice *dev, struct fspm_upd *upd);
64
65/**
66 * fspm_done() - Indicate that memory init is complete
67 *
68 * This allows the board to do whatever post-init it needs before things
69 * continue.
70 *
71 * @dev: Hostbridge device
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010072 * Return: 0 if OK, -ve on error
Simon Glass466c7852019-12-06 21:42:18 -070073 */
74int fspm_done(struct udevice *dev);
75
76/**
77 * fsps_update_config() - Set up the config structure for FSP-S
78 *
79 * @dev: Hostbridge device containing config
80 * @rom_offset: Value to add to convert from ROM offset to memory-mapped address
81 * @upd: Config data to fill in
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010082 * Return: 0 if OK, -ve on error
Simon Glass466c7852019-12-06 21:42:18 -070083 */
84int fsps_update_config(struct udevice *dev, ulong rom_offset,
85 struct fsps_upd *upd);
86
87/**
88 * prepare_mrc_cache() - Read the MRC cache into the product-data struct
89 *
90 * This looks for cached Memory-reference code (MRC) data and stores it into
91 * @upd for use by the FSP-M binary.
92 *
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010093 * Return: 0 if OK, -ENOENT if no data (whereupon the caller can continue and
Simon Glass466c7852019-12-06 21:42:18 -070094 * expect a slower boot), other -ve value on other error
95 */
96int prepare_mrc_cache(struct fspm_upd *upd);
97
98#endif