1279183feSMatthew Barth /** 2279183feSMatthew Barth * Copyright © 2021 IBM Corporation 3279183feSMatthew Barth * 4279183feSMatthew Barth * Licensed under the Apache License, Version 2.0 (the "License"); 5279183feSMatthew Barth * you may not use this file except in compliance with the License. 6279183feSMatthew Barth * You may obtain a copy of the License at 7279183feSMatthew Barth * 8279183feSMatthew Barth * http://www.apache.org/licenses/LICENSE-2.0 9279183feSMatthew Barth * 10279183feSMatthew Barth * Unless required by applicable law or agreed to in writing, software 11279183feSMatthew Barth * distributed under the License is distributed on an "AS IS" BASIS, 12279183feSMatthew Barth * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13279183feSMatthew Barth * See the License for the specific language governing permissions and 14279183feSMatthew Barth * limitations under the License. 15279183feSMatthew Barth */ 16279183feSMatthew Barth #pragma once 17279183feSMatthew Barth 18279183feSMatthew Barth #include "xyz/openbmc_project/Control/ThermalMode/server.hpp" 19279183feSMatthew Barth 20279183feSMatthew Barth /* Extend the Control::ThermalMode interface */ 21cb356d48SPatrick Williams using ThermalModeIntf = sdbusplus::server::object_t< 22279183feSMatthew Barth sdbusplus::xyz::openbmc_project::Control::server::ThermalMode>; 23279183feSMatthew Barth 24279183feSMatthew Barth namespace phosphor::fan::control::json 25279183feSMatthew Barth { 26279183feSMatthew Barth 27279183feSMatthew Barth class Zone; 28279183feSMatthew Barth 29279183feSMatthew Barth class DBusZone : public ThermalModeIntf 30279183feSMatthew Barth { 31279183feSMatthew Barth public: 32279183feSMatthew Barth static constexpr auto thermalModeIntf = 33279183feSMatthew Barth "xyz.openbmc_project.Control.ThermalMode"; 34279183feSMatthew Barth static constexpr auto supportedProp = "Supported"; 35279183feSMatthew Barth static constexpr auto currentProp = "Current"; 36279183feSMatthew Barth 37279183feSMatthew Barth DBusZone() = delete; 38279183feSMatthew Barth DBusZone(const DBusZone&) = delete; 39279183feSMatthew Barth DBusZone(DBusZone&&) = delete; 40279183feSMatthew Barth DBusZone& operator=(const DBusZone&) = delete; 41279183feSMatthew Barth DBusZone& operator=(DBusZone&&) = delete; 42279183feSMatthew Barth ~DBusZone() = default; 43279183feSMatthew Barth 44279183feSMatthew Barth /** 45279183feSMatthew Barth * Constructor 46279183feSMatthew Barth * Creates a thermal control dbus object associated with the given zone 47279183feSMatthew Barth * 48279183feSMatthew Barth * @param[in] zone - Zone object 49279183feSMatthew Barth */ 50*9b06243dSMatt Spinler explicit DBusZone(const Zone& zone); 51279183feSMatthew Barth 52279183feSMatthew Barth /** 53279183feSMatthew Barth * @brief Overridden thermalmode interface's set 'Current' property function 54279183feSMatthew Barth * 55279183feSMatthew Barth * @param[in] value - Value to set 'Current' to 56279183feSMatthew Barth * 57279183feSMatthew Barth * @return - The updated value of the 'Current' property 58279183feSMatthew Barth */ 59279183feSMatthew Barth std::string current(std::string value) override; 60279183feSMatthew Barth 61279183feSMatthew Barth /** 62279183feSMatthew Barth * @brief Restore persisted thermalmode `Current` mode property value, 63279183feSMatthew Barth * setting the mode to "Default" otherwise 64279183feSMatthew Barth */ 65279183feSMatthew Barth void restoreCurrentMode(); 66279183feSMatthew Barth 67279183feSMatthew Barth private: 68279183feSMatthew Barth /* Zone object associated with this thermal control dbus object */ 69279183feSMatthew Barth const Zone& _zone; 70279183feSMatthew Barth 71279183feSMatthew Barth /** 72279183feSMatthew Barth * @brief Save the thermalmode `Current` mode property to persisted storage 73279183feSMatthew Barth */ 74279183feSMatthew Barth void saveCurrentMode(); 75279183feSMatthew Barth }; 76279183feSMatthew Barth 77279183feSMatthew Barth } // namespace phosphor::fan::control::json 78