Andrey Petrov | 42c4e88 | 2016-02-25 14:17:45 -0800 | [diff] [blame] | 1 | /* |
| 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 Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 19 | #include <timestamp.h> |
Andrey Petrov | 42c4e88 | 2016-02-25 14:17:45 -0800 | [diff] [blame] | 20 | |
| 21 | struct fsp_header fsps_hdr; |
| 22 | |
| 23 | typedef asmlinkage enum fsp_status (*fsp_silicon_init_fn) |
| 24 | (void *silicon_upd); |
| 25 | |
| 26 | static 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 Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 44 | timestamp_add_now(TS_FSP_SILICON_INIT_START); |
Andrey Petrov | 42c4e88 | 2016-02-25 14:17:45 -0800 | [diff] [blame] | 45 | silicon_init = (void *) (hdr->image_base + |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 46 | hdr->silicon_init_entry_offset); |
Andrey Petrov | 42c4e88 | 2016-02-25 14:17:45 -0800 | [diff] [blame] | 47 | status = silicon_init(&upd); |
Alexandru Gagniuc | 010225c | 2016-05-06 08:22:45 -0700 | [diff] [blame] | 48 | timestamp_add_now(TS_FSP_SILICON_INIT_END); |
| 49 | |
Andrey Petrov | 42c4e88 | 2016-02-25 14:17:45 -0800 | [diff] [blame] | 50 | printk(BIOS_DEBUG, "FspSiliconInit returned 0x%08x\n", status); |
| 51 | return status; |
| 52 | } |
| 53 | |
| 54 | enum fsp_status fsp_silicon_init(struct range_entry *range) |
| 55 | { |
| 56 | /* Load FSP-S and save FSP header. We will need it for Notify */ |
Andrey Petrov | 9be1a11 | 2016-05-14 16:32:39 -0700 | [diff] [blame^] | 57 | if (fsp_load_binary(&fsps_hdr, CONFIG_FSP_S_CBFS, range) != CB_SUCCESS) |
Andrey Petrov | 42c4e88 | 2016-02-25 14:17:45 -0800 | [diff] [blame] | 58 | return FSP_NOT_FOUND; |
| 59 | |
| 60 | return do_silicon_init(&fsps_hdr); |
| 61 | } |