blob: f1deed78d8cdd1124a7ae9a5d89955d9e153b513 [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);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070045 post_code(POST_FSP_SILICON_INIT);
Andrey Petrov42c4e882016-02-25 14:17:45 -080046 silicon_init = (void *) (hdr->image_base +
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070047 hdr->silicon_init_entry_offset);
Andrey Petrov42c4e882016-02-25 14:17:45 -080048 status = silicon_init(&upd);
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070049 timestamp_add_now(TS_FSP_SILICON_INIT_END);
Alexandru Gagniucc4ea8f72016-05-23 12:16:58 -070050 post_code(POST_FSP_SILICON_INIT);
Alexandru Gagniuc010225c2016-05-06 08:22:45 -070051
Andrey Petrov42c4e882016-02-25 14:17:45 -080052 printk(BIOS_DEBUG, "FspSiliconInit returned 0x%08x\n", status);
53 return status;
54}
55
56enum fsp_status fsp_silicon_init(struct range_entry *range)
57{
58 /* Load FSP-S and save FSP header. We will need it for Notify */
Andrey Petrov9be1a112016-05-14 16:32:39 -070059 if (fsp_load_binary(&fsps_hdr, CONFIG_FSP_S_CBFS, range) != CB_SUCCESS)
Andrey Petrov42c4e882016-02-25 14:17:45 -080060 return FSP_NOT_FOUND;
61
62 return do_silicon_init(&fsps_hdr);
63}