From 4cea4d2b36a0bfc212f34e72792cfa00e43384e9 Mon Sep 17 00:00:00 2001 From: Andrew Geissler Date: Mon, 10 Jul 2017 15:13:33 -0500 Subject: Determine pcap value to send to occ Change-Id: Ie60aac151f5fd8ce091020ce756834e4877cbc93 Signed-off-by: Andrew Geissler --- powercap.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'powercap.cpp') diff --git a/powercap.cpp b/powercap.cpp index 2ecad0c..7e8c0db 100644 --- a/powercap.cpp +++ b/powercap.cpp @@ -54,6 +54,19 @@ std::string PowerCap::getService(std::string path, return mapperResponse.begin()->first; } +uint32_t PowerCap::getOccInput(uint32_t pcap, bool pcapEnabled) +{ + if (!pcapEnabled) + { + // Pcap disabled, return 0 to indicate disabled + return 0; + } + + // If pcap is not disabled then just return the pcap with the derating + // factor applied. + return( (static_cast(pcap) * PS_DERATING_FACTOR) /100); +} + uint32_t PowerCap::getPcap() { auto settingService = getService(PCAP_PATH,PCAP_INTERFACE); @@ -144,7 +157,9 @@ void PowerCap::pcapChanged(sdbusplus::message::message& msg) entry("PCAP_ENABLED=%u",pcapEnabled)); // Determine desired action to write to occ - // TODO + auto occInput = getOccInput(pcap, pcapEnabled); + log("Writing new power cap setting to OCC", + entry("OCC_PCAP_VAL=%u",occInput)); // Write action to occ // TODO -- cgit v1.2.1