diff options
author | Robert Lippert <rlippert@google.com> | 2013-12-04 11:39:19 -0800 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2014-09-25 15:40:25 -0500 |
commit | 1300dc02979646be65a39097f86a559cf68bcfb7 (patch) | |
tree | 3534a1faea1271391446accc5a8502dfa109e852 /src/usr/hwpf/hwp/pstates | |
parent | 1605c532b9d3abfad74be513be8975b66cef3525 (diff) | |
download | talos-hostboot-1300dc02979646be65a39097f86a559cf68bcfb7.tar.gz talos-hostboot-1300dc02979646be65a39097f86a559cf68bcfb7.zip |
pstate: set all cores to nominal freq/volt during boot.
As last step of boot process determine the nominal pstate for each
core and set it as the current operating value.
Change-Id: Ifc452977d89971e84f73177885306aa3259408f4
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/13350
Tested-by: Jenkins Server
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/hwp/pstates')
-rw-r--r-- | src/usr/hwpf/hwp/pstates/makefile | 7 | ||||
-rwxr-xr-x | src/usr/hwpf/hwp/pstates/pstates/p8_build_pstate_datablock.C | 54 | ||||
-rwxr-xr-x | src/usr/hwpf/hwp/pstates/pstates/proc_set_max_pstate.C | 165 | ||||
-rwxr-xr-x | src/usr/hwpf/hwp/pstates/pstates/proc_set_max_pstate.H | 43 | ||||
-rwxr-xr-x | src/usr/hwpf/hwp/pstates/pstates/pstate_tables.h | 9 | ||||
-rwxr-xr-x | src/usr/hwpf/hwp/pstates/pstates/pstates.h | 13 |
6 files changed, 286 insertions, 5 deletions
diff --git a/src/usr/hwpf/hwp/pstates/makefile b/src/usr/hwpf/hwp/pstates/makefile index 1ef54e851..defe4b1e4 100644 --- a/src/usr/hwpf/hwp/pstates/makefile +++ b/src/usr/hwpf/hwp/pstates/makefile @@ -5,7 +5,10 @@ # # OpenPOWER HostBoot Project # -# COPYRIGHT International Business Machines Corp. 2013,2014 +# Contributors Listed Below - COPYRIGHT 2013,2014 +# [+] International Business Machines Corp. +# [+] Google Inc. +# # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -52,6 +55,8 @@ OBJS += proc_get_voltage.o OBJS += pstates.o OBJS += pstate_tables.o +OBJS += proc_set_max_pstate.o + ## NOTE: add a new directory onto the vpaths when you add a new HWP ##@ VPATH += ${ROOTPATH}/src/usr/hwpf/hwp/??? VPATH += ${ROOTPATH}/src/usr/hwpf/hwp/pstates/pstates diff --git a/src/usr/hwpf/hwp/pstates/pstates/p8_build_pstate_datablock.C b/src/usr/hwpf/hwp/pstates/pstates/p8_build_pstate_datablock.C index 0855dc3cf..54a2290d6 100755 --- a/src/usr/hwpf/hwp/pstates/pstates/p8_build_pstate_datablock.C +++ b/src/usr/hwpf/hwp/pstates/pstates/p8_build_pstate_datablock.C @@ -7,6 +7,7 @@ /* */ /* Contributors Listed Below - COPYRIGHT 2013,2014 */ /* [+] International Business Machines Corp. */ +/* [+] Google Inc. */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ @@ -22,7 +23,7 @@ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ -// $Id: p8_build_pstate_datablock.C,v 1.39 2014/07/22 21:45:45 daviddu Exp $ +// $Id: p8_build_pstate_datablock.C,v 1.00039 2014/07/22 21:45:45 daviddu Exp $ // $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/ipl/fapi/p8_build_pstate_datablock.C,v $ //------------------------------------------------------------------------------ // *! (C) Copyright International Business Machines Corp. 2012 @@ -705,6 +706,36 @@ ReturnCode proc_get_attributes(const Target& i_target, return l_rc; } +const uint8_t NON_ECO_VOLTAGE_BUCKET_OFFFSET = 0x04; +const uint8_t ALTERNATE_BUCKET_OFFSET = 0x05; +const uint8_t BUCKET_ID_MASK = 0x0F; +const uint8_t VPD_VINI_PR_DATA_LENGTH = 8; + +const uint8_t DEFAULT_BUCKET = 1; + +static int get_bucket_from_pr(const Target& i_target) +{ + ReturnCode l_rc; + uint8_t l_buffer[VPD_VINI_PR_DATA_LENGTH]; + uint32_t l_bufferSize = sizeof(l_buffer); + + l_rc = fapiGetMvpdField(fapi::MVPD_RECORD_VINI, + fapi::MVPD_KEYWORD_PR, + i_target, + l_buffer, + l_bufferSize); + + if (l_rc) + { + return DEFAULT_BUCKET; + } + + uint8_t l_bucketId = l_buffer[NON_ECO_VOLTAGE_BUCKET_OFFFSET] & + BUCKET_ID_MASK; + + return l_bucketId != 0 ? l_bucketId : DEFAULT_BUCKET; +} + /// ---------------------------------------------------------------- /// \brief Get #V data and put into array /// \param[in] i_target => Chip Target @@ -735,6 +766,7 @@ ReturnCode proc_get_mvpd_data(const Target& i_target, uint8_t ii = 0; uint8_t first_chplt = 1; uint8_t bucket_id = 0; + uint8_t pr_bucket_id = 0; uint16_t cal_data[4]; do @@ -795,6 +827,16 @@ ReturnCode proc_get_mvpd_data(const Target& i_target, break; } + // Get the correct bucket according to FRU PR data. + pr_bucket_id = get_bucket_from_pr(i_target); + if (l_bufferSize < PDV_BUFFER_SIZE * pr_bucket_id) { + const uint32_t &BUFFER_SIZE = l_bufferSize; + const Target &CHIP_TARGET= i_target; + FAPI_ERR("**** ERROR : Not enough buckets returned from fapiGetMvpdField for #V => %d", l_bufferSize ); + FAPI_SET_HWP_ERROR(l_rc, RC_PROCPM_PSTATE_DATABLOCK_PDV_BUFFER_SIZE_ERROR); + break; + } + // clear array memset(chiplet_mvpd_data, 0, sizeof(chiplet_mvpd_data)); @@ -802,9 +844,15 @@ ReturnCode proc_get_mvpd_data(const Target& i_target, #define UINT16_GET(__uint8_ptr) ((uint16_t)( ( (*((const uint8_t *)(__uint8_ptr)) << 8) | *((const uint8_t *)(__uint8_ptr) + 1) ) )) // use copy of allocated buffer pointer to increment through buffer - l_buffer_inc = l_buffer; + // Skip version and 'PNP' from header. + l_buffer_inc = l_buffer + 4; bucket_id = *l_buffer_inc; + while (bucket_id != pr_bucket_id && + (l_buffer_inc - l_buffer) < l_bufferSize) { + l_buffer_inc += PDV_BUFFER_SIZE; + bucket_id = *l_buffer_inc; + } l_buffer_inc++; FAPI_INF("#V chiplet = %u bucket id = %u", l_chipNum, bucket_id); @@ -1282,7 +1330,7 @@ ReturnCode proc_res_clock (PstateSuperStructure *pss, freq_khz = attr_list->attr_name; \ FAPI_INF("Converting %s (%u khz) to Pstate", #attr_name, freq_khz); \ rc = freq2pState(&(pss->gpst), freq_khz, &pstate); \ - if (rc) break; \ + if ((rc) && (rc != -PSTATE_LT_PSTATE_MIN)) break; \ rc = pstate_minmax_chk(&(pss->gpst), &pstate); \ if (rc == -GPST_PSTATE_GT_GPST_PMAX) { \ pstate = gpst_pmax(&(pss->gpst)); \ diff --git a/src/usr/hwpf/hwp/pstates/pstates/proc_set_max_pstate.C b/src/usr/hwpf/hwp/pstates/pstates/proc_set_max_pstate.C new file mode 100755 index 000000000..73032a166 --- /dev/null +++ b/src/usr/hwpf/hwp/pstates/pstates/proc_set_max_pstate.C @@ -0,0 +1,165 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/hwpf/hwp/pstates/pstates/proc_set_max_pstate.C $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2013,2014 */ +/* [+] Google Inc. */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/// \file proc_set_max_pstate.C +//------------------------------------------------------------------------------ + +// ---------------------------------------------------------------------- +// Includes +// ---------------------------------------------------------------------- +#include <fapi.H> + +#include "ecmdDataBufferBase.H" +#include "pstate_tables.h" +#include "lab_pstates.h" +#include "pstates.h" + +#include "proc_get_voltage.H" +#include "p8_scom_addresses.H" + +extern "C" { + +fapi::ReturnCode proc_set_max_pstate(const fapi::Target& i_proc_target) +{ + fapi::ReturnCode l_rc; + uint32_t i = 0; + PstateSuperStructure pss; + gpst_entry_t entry; + Pstate pnom = 0; + uint8_t freq_pstate_index = 0; + uint64_t freq_nom_khz = 0; + uint32_t vdd = 0; + uint32_t vcs = 0; + std::vector<fapi::Target> l_exChiplets; + std::vector<fapi::Target> l_coreChiplets; + + // Create pstate super structure + FAPI_ERR("Executing proc_set_max_pstate"); + + FAPI_EXEC_HWP(l_rc, p8_build_pstate_datablock, i_proc_target, &pss); + if (!l_rc.ok()) { + FAPI_ERR("Error calling p8_build_pstate_datablock"); + return l_rc; + } + + // Get nominal frequency. + uint32_t sys_freq_nom = 0; + l_rc = FAPI_ATTR_GET(ATTR_FREQ_CORE_NOMINAL, NULL, sys_freq_nom); + if (l_rc) { return l_rc; } + sys_freq_nom *= 1000; // Convert to khz. + + // Get the pstate closest to nominal frequency. + if (freq2pState(&pss.gpst, sys_freq_nom, &pnom)) + { + // Failed to find a frequency. Use pmin. + FAPI_ERR("Unable to find a frequency closest to nominal. Using pmin."); + pnom = gpst_pmin(&pss.gpst); + } + + freq_nom_khz = (pss.gpst.pstate0_frequency_khz + + pss.gpst.frequency_step_khz * pnom); + + // Convert pstate to pstate table index and lookup voltages + freq_pstate_index = pnom - pss.gpst.pmin; + entry.value = revle64(pss.gpst.pstate[freq_pstate_index].value); + vdd = entry.fields.evid_vdd; + vcs = entry.fields.evid_vcs; + + FAPI_INF("%s nominal pstate is %d, freq: %dKhz VDD: %dmV VCS: %dmV", + i_proc_target.toEcmdString(), pnom, freq_nom_khz, + VRM11_BASE_UV - 6250 * vdd, VRM11_BASE_UV - 6250 * vcs); + + // Set the voltage. + ecmdDataBufferBase wdata_reg(64); + wdata_reg.setByte(0, 0); + wdata_reg.setByte(1, vdd); + wdata_reg.setByte(2, vcs); + wdata_reg.setByte(3, 0); + l_rc = fapiPutScom(i_proc_target, PMC_O2S_WDATA_REG_0x00062058, wdata_reg); + if (l_rc) + { + FAPI_ERR("SCOM to PMC_O2S_WDATA_REG_0x00062058 failed."); + return l_rc; + } + // Wait for voltage ramp. + fapiDelay(1e8, 0); + + // Set the frequency on each EX. + l_rc = fapiGetChildChiplets (i_proc_target, fapi::TARGET_TYPE_EX_CHIPLET, + l_exChiplets, fapi::TARGET_STATE_FUNCTIONAL); + if (l_rc) + { + FAPI_ERR("Error from fapiGetChildChiplets!"); + return l_rc; + } + + for (i = 0; i < l_exChiplets.size(); i++) + { + uint8_t l_chipNum = 0xFF; + l_rc = FAPI_ATTR_GET(ATTR_CHIP_UNIT_POS, &l_exChiplets[i], l_chipNum); + if (l_rc) + { + FAPI_ERR("fapiGetAttribute of ATTR_CHIP_UNIT_POS error"); + return l_rc; + } + + ecmdDataBufferBase freqcntl_reg(64); + l_rc = fapiGetScom(i_proc_target, + EX_FREQCNTL_0x100F0151 + (l_chipNum * 0x01000000), + freqcntl_reg); + if (l_rc) + { + return l_rc; + } + + // Set frequency multiplier based on ref clock. + uint32_t mult = freq_nom_khz / 1000 / 33; + freqcntl_reg.insertFromRight(&mult, 0, 9); + freqcntl_reg.insertFromRight(&mult, 9, 9); + + FAPI_ERR("%s setting to multiplier %dX", + l_exChiplets[i].toEcmdString(), + mult); + l_rc = fapiPutScom(i_proc_target, + EX_FREQCNTL_0x100F0151 + (l_chipNum * 0x01000000), + freqcntl_reg); + if (l_rc) + { + return l_rc; + } + + unsigned int freq_mhz = freq_nom_khz / 1000; + l_rc = FAPI_ATTR_SET(ATTR_FREQ_CORE, &l_exChiplets[i], freq_mhz); + if (l_rc) + { + return l_rc; + } + } + + return l_rc; +} + +} //end extern C + diff --git a/src/usr/hwpf/hwp/pstates/pstates/proc_set_max_pstate.H b/src/usr/hwpf/hwp/pstates/pstates/proc_set_max_pstate.H new file mode 100755 index 000000000..bf3d2d0d6 --- /dev/null +++ b/src/usr/hwpf/hwp/pstates/pstates/proc_set_max_pstate.H @@ -0,0 +1,43 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/hwpf/hwp/pstates/pstates/proc_set_max_pstate.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2013,2014 */ +/* [+] International Business Machines Corp. */ +/* [+] Google Inc. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +#ifndef _proc_set_max_pstate_H_ +#define _proc_set_max_pstate_H_ + +#include <fapi.H> + +extern "C" { + +//------------------------------------------------------------------------------ +// Function prototype +//------------------------------------------------------------------------------ +/// \brief Set Maximum pstate +/// \param[in] i_target Chip Target + +fapi::ReturnCode proc_set_max_pstate(const fapi::Target& i_target); + +} // extern "C" + +#endif diff --git a/src/usr/hwpf/hwp/pstates/pstates/pstate_tables.h b/src/usr/hwpf/hwp/pstates/pstates/pstate_tables.h index be0116f10..49d56eff3 100755 --- a/src/usr/hwpf/hwp/pstates/pstates/pstate_tables.h +++ b/src/usr/hwpf/hwp/pstates/pstates/pstate_tables.h @@ -7,6 +7,7 @@ /* */ /* Contributors Listed Below - COPYRIGHT 2013,2014 */ /* [+] International Business Machines Corp. */ +/* [+] Google Inc. */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ @@ -43,6 +44,10 @@ #ifndef __ASSEMBLER__ +#ifdef __cplusplus +extern "C" { +#endif + /// A VPD operating point /// /// VPD operating points are stored without load-line correction. Frequencies @@ -197,6 +202,10 @@ void write_HWtab_bin(ivrm_parm_data_t* i_ivrm_parms, double C[], PstateSuperStructure* pss); +#ifdef __cplusplus +} // extern "C" +#endif + #endif // __ASSEMBLER__ #endif // __PSTATE_TABLES_H__ diff --git a/src/usr/hwpf/hwp/pstates/pstates/pstates.h b/src/usr/hwpf/hwp/pstates/pstates/pstates.h index aabd7d9c8..8c5ea2b6d 100755 --- a/src/usr/hwpf/hwp/pstates/pstates/pstates.h +++ b/src/usr/hwpf/hwp/pstates/pstates/pstates.h @@ -5,7 +5,10 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2013,2014 */ +/* Contributors Listed Below - COPYRIGHT 2013,2014 */ +/* [+] International Business Machines Corp. */ +/* [+] Google Inc. */ +/* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -30,6 +33,10 @@ #include "pgp_common.h" +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////////// // Global and Local Pstate Tables //////////////////////////////////////////////////////////////////////////// @@ -605,6 +612,10 @@ lpst_pmax(const LocalPstateArray* lpsa) return (int)(lpsa->pmin) + (int)(lpsa->entries) - 1; } +#ifdef __cplusplus +} // extern "C" +#endif + #endif /* __ASSEMBLER__ */ #endif /* __PSTATES_H__ */ |