| 1 |
|
| 2 |
|
| 3 |
#include <amdblocks/cppc.h> |
| 4 |
#include <ccx_cppc_data.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <FspGuids.h> |
| 7 |
#include <fsp/util.h> |
| 8 |
#include <types.h> |
| 9 |
|
| 10 |
|
| 11 |
static enum cb_err get_ccx_cppc_data_hob(const struct fsp_ccx_cppc_data **cppc_data) |
| 12 |
{ |
| 13 |
static const struct fsp_ccx_cppc_data *cppc_data_cache; |
| 14 |
size_t hob_size = 0; |
| 15 |
const struct fsp_ccx_cppc_data *hob; |
| 16 |
|
| 17 |
if (cppc_data_cache) { |
| 18 |
*cppc_data = cppc_data_cache; |
| 19 |
return CB_SUCCESS; |
| 20 |
} |
| 21 |
|
| 22 |
hob = fsp_find_extension_hob_by_guid(AMD_FSP_CCX_CPPC_DATA_HOB_GUID.b, &hob_size); |
| 23 |
|
| 24 |
if (hob == NULL || hob_size < sizeof(struct fsp_ccx_cppc_data)) { |
| 25 |
printk(BIOS_ERR, "Couldn't find CCX CPPC data HOB.\n"); |
| 26 |
return CB_ERR; |
| 27 |
} |
| 28 |
|
| 29 |
if (hob->version != FSP_CCX_CPPC_DATA_VERSION) { |
| 30 |
printk(BIOS_ERR, "Unexpected CCX CPPC data HOB version.\n"); |
| 31 |
return CB_ERR; |
| 32 |
} |
| 33 |
|
| 34 |
cppc_data_cache = hob; |
| 35 |
*cppc_data = cppc_data_cache; |
| 36 |
return CB_SUCCESS; |
| 37 |
} |
| 38 |
|
| 39 |
enum cb_err get_ccx_cppc_min_frequency(uint32_t *freq) |
| 40 |
{ |
| 41 |
const struct fsp_ccx_cppc_data *cppc_data = NULL; |
| 42 |
|
| 43 |
if (get_ccx_cppc_data_hob(&cppc_data) != CB_SUCCESS) |
| 44 |
return CB_ERR; |
| 45 |
|
| 46 |
*freq = cppc_data->ccx_cppc_min_speed; |
| 47 |
printk(BIOS_SPEW, "CCX CPPC min speed: %d MHz\n", *freq); |
| 48 |
|
| 49 |
return CB_SUCCESS; |
| 50 |
} |
| 51 |
|
| 52 |
enum cb_err get_ccx_cppc_nom_frequency(uint32_t *freq) |
| 53 |
{ |
| 54 |
const struct fsp_ccx_cppc_data *cppc_data = NULL; |
| 55 |
|
| 56 |
if (get_ccx_cppc_data_hob(&cppc_data) != CB_SUCCESS) |
| 57 |
return CB_ERR; |
| 58 |
|
| 59 |
*freq = cppc_data->ccx_cppc_nom_speed; |
| 60 |
printk(BIOS_SPEW, "CCX CPPC nom speed: %d MHz\n", *freq); |
| 61 |
|
| 62 |
return CB_SUCCESS; |
| 63 |
} |