blob: e7d8c54ce1af332ec1775a70e3b7442893f42eb6 [file] [log] [blame]
Andrey Petrov42c4e882016-02-25 14:17:45 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015 Intel Corp.
5 * (Written by Andrey Petrov <andrey.petrov@intel.com> for Intel Corp.)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#include <arch/cpu.h>
14#include <cbfs.h>
15#include <console/console.h>
16#include <fsp/api.h>
17#include <fsp/util.h>
18#include <string.h>
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070019#include <timestamp.h>
Andrey Petrov42c4e882016-02-25 14:17:45 -080020
21struct fsp_header fsps_hdr;
22
23typedef asmlinkage enum fsp_status (*fsp_silicon_init_fn)
24 (void *silicon_upd);
25
26static enum fsp_status do_silicon_init(struct fsp_header *hdr)
27{
28 struct FSPS_UPD upd, *supd;
29 fsp_silicon_init_fn silicon_init;
30 enum fsp_status status;
31
32 supd = (struct FSPS_UPD *) (hdr->cfg_region_offset + hdr->image_base);
33
34 if (supd->FspUpdHeader.Signature != FSPS_UPD_SIGNATURE) {
35 printk(BIOS_ERR, "Invalid FSPS signature\n");
36 return FSP_INCOMPATIBLE_VERSION;
37 }
38
39 memcpy(&upd, supd, sizeof(upd));
40
41 /* Give SoC/mainboard a chance to populate entries */
42 platform_fsp_silicon_init_params_cb(&upd);
43
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070044 timestamp_add_now(TS_FSP_SILICON_INIT_START);
Andrey Petrov42c4e882016-02-25 14:17:45 -080045 silicon_init = (void *) (hdr->image_base +
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070046 hdr->silicon_init_entry_offset);
Andrey Petrov42c4e882016-02-25 14:17:45 -080047 status = silicon_init(&upd);
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070048 timestamp_add_now(TS_FSP_SILICON_INIT_END);
49
Andrey Petrov42c4e882016-02-25 14:17:45 -080050 printk(BIOS_DEBUG, "FspSiliconInit returned 0x%08x\n", status);
51 return status;
52}
53
54enum fsp_status fsp_silicon_init(struct range_entry *range)
55{
56 /* Load FSP-S and save FSP header. We will need it for Notify */
57 /* TODO: do not hardcode CBFS file names */
58 if (fsp_load_binary(&fsps_hdr, "blobs/fsps.bin", range) != CB_SUCCESS)
59 return FSP_NOT_FOUND;
60
61 return do_silicon_init(&fsps_hdr);
62}