Pratik Prajapati | 9027e1b | 2017-08-23 17:37:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2017 Intel Corporation. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #include <fsp/api.h> |
| 18 | #include <soc/ramstage.h> |
| 19 | #include <soc/vr_config.h> |
| 20 | |
| 21 | static const struct vr_config default_configs[NUM_VR_DOMAINS] = { |
| 22 | /* TODO: define this*/ |
| 23 | }; |
| 24 | |
| 25 | void fill_vr_domain_config(void *params, |
| 26 | int domain, const struct vr_config *chip_cfg) |
| 27 | { |
| 28 | FSP_S_CONFIG *vr_params = (FSP_S_CONFIG *)params; |
| 29 | const struct vr_config *cfg; |
| 30 | |
| 31 | if (domain < 0 || domain >= NUM_VR_DOMAINS) |
| 32 | return; |
| 33 | |
| 34 | /* Use device tree override if requested. */ |
| 35 | if (chip_cfg->vr_config_enable) |
| 36 | cfg = chip_cfg; |
| 37 | else |
| 38 | cfg = &default_configs[domain]; |
| 39 | |
| 40 | vr_params->VrConfigEnable[domain] = cfg->vr_config_enable; |
| 41 | vr_params->Psi1Threshold[domain] = cfg->psi1threshold; |
| 42 | vr_params->Psi2Threshold[domain] = cfg->psi2threshold; |
| 43 | vr_params->Psi3Threshold[domain] = cfg->psi3threshold; |
| 44 | vr_params->Psi3Enable[domain] = cfg->psi3enable; |
| 45 | vr_params->Psi4Enable[domain] = cfg->psi4enable; |
| 46 | vr_params->ImonSlope[domain] = cfg->imon_slope; |
| 47 | vr_params->ImonOffset[domain] = cfg->imon_offset; |
| 48 | vr_params->IccMax[domain] = cfg->icc_max; |
| 49 | vr_params->VrVoltageLimit[domain] = cfg->voltage_limit; |
| 50 | vr_params->AcLoadline[domain] = cfg->ac_loadline; |
| 51 | vr_params->DcLoadline[domain] = cfg->dc_loadline; |
| 52 | } |