1a2461b34SShawn McCarney /** 2a2461b34SShawn McCarney * Copyright © 2019 IBM Corporation 3a2461b34SShawn McCarney * 4a2461b34SShawn McCarney * Licensed under the Apache License, Version 2.0 (the "License"); 5a2461b34SShawn McCarney * you may not use this file except in compliance with the License. 6a2461b34SShawn McCarney * You may obtain a copy of the License at 7a2461b34SShawn McCarney * 8a2461b34SShawn McCarney * http://www.apache.org/licenses/LICENSE-2.0 9a2461b34SShawn McCarney * 10a2461b34SShawn McCarney * Unless required by applicable law or agreed to in writing, software 11a2461b34SShawn McCarney * distributed under the License is distributed on an "AS IS" BASIS, 12a2461b34SShawn McCarney * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a2461b34SShawn McCarney * See the License for the specific language governing permissions and 14a2461b34SShawn McCarney * limitations under the License. 15a2461b34SShawn McCarney */ 16a2461b34SShawn McCarney #pragma once 17a2461b34SShawn McCarney 184bf310e3SShawn McCarney #include "configuration.hpp" 194bf310e3SShawn McCarney #include "sensor_monitoring.hpp" 204bf310e3SShawn McCarney 214bf310e3SShawn McCarney #include <memory> 22a2461b34SShawn McCarney #include <string> 234bf310e3SShawn McCarney #include <utility> 24a2461b34SShawn McCarney 25ea7385b8SShawn McCarney namespace phosphor::power::regulators 26a2461b34SShawn McCarney { 27a2461b34SShawn McCarney 28*779b9565SShawn McCarney // Forward declarations to avoid circular dependencies 29*779b9565SShawn McCarney class Chassis; 30*779b9565SShawn McCarney class Device; 31*779b9565SShawn McCarney class System; 32*779b9565SShawn McCarney 33a2461b34SShawn McCarney /** 34a2461b34SShawn McCarney * @class Rail 35a2461b34SShawn McCarney * 36a2461b34SShawn McCarney * A voltage rail produced by a voltage regulator. 37a2461b34SShawn McCarney * 38a2461b34SShawn McCarney * Voltage regulators produce one or more rails. Each rail typically provides a 39a2461b34SShawn McCarney * different output voltage level, such as 1.1V. 40a2461b34SShawn McCarney */ 41a2461b34SShawn McCarney class Rail 42a2461b34SShawn McCarney { 43a2461b34SShawn McCarney public: 44a2461b34SShawn McCarney // Specify which compiler-generated methods we want 45a2461b34SShawn McCarney Rail() = delete; 46a2461b34SShawn McCarney Rail(const Rail&) = delete; 47a2461b34SShawn McCarney Rail(Rail&&) = delete; 48a2461b34SShawn McCarney Rail& operator=(const Rail&) = delete; 49a2461b34SShawn McCarney Rail& operator=(Rail&&) = delete; 50a2461b34SShawn McCarney ~Rail() = default; 51a2461b34SShawn McCarney 52a2461b34SShawn McCarney /** 53a2461b34SShawn McCarney * Constructor. 54a2461b34SShawn McCarney * 55a2461b34SShawn McCarney * @param id unique rail ID 564bf310e3SShawn McCarney * @param configuration configuration changes to apply to this rail, if any 574bf310e3SShawn McCarney * @param sensorMonitoring sensor monitoring for this rail, if any 58a2461b34SShawn McCarney */ 594bf310e3SShawn McCarney explicit Rail( 604bf310e3SShawn McCarney const std::string& id, 614bf310e3SShawn McCarney std::unique_ptr<Configuration> configuration = nullptr, 624bf310e3SShawn McCarney std::unique_ptr<SensorMonitoring> sensorMonitoring = nullptr) : 634bf310e3SShawn McCarney id{id}, 644bf310e3SShawn McCarney configuration{std::move(configuration)}, sensorMonitoring{std::move( 654bf310e3SShawn McCarney sensorMonitoring)} 66a2461b34SShawn McCarney { 67a2461b34SShawn McCarney } 68a2461b34SShawn McCarney 69a2461b34SShawn McCarney /** 70*779b9565SShawn McCarney * Configure this rail. 71*779b9565SShawn McCarney * 72*779b9565SShawn McCarney * Applies the configuration changes that are defined for this rail, if any. 73*779b9565SShawn McCarney * 74*779b9565SShawn McCarney * This method should be called during the boot before regulators are 75*779b9565SShawn McCarney * enabled. 76*779b9565SShawn McCarney * 77*779b9565SShawn McCarney * @param system system that contains the chassis 78*779b9565SShawn McCarney * @param chassis chassis that contains the device 79*779b9565SShawn McCarney * @param device device that contains this rail 80*779b9565SShawn McCarney */ 81*779b9565SShawn McCarney void configure(System& system, Chassis& chassis, Device& device); 82*779b9565SShawn McCarney 83*779b9565SShawn McCarney /** 844bf310e3SShawn McCarney * Returns the configuration changes to apply to this rail, if any. 854bf310e3SShawn McCarney * 864bf310e3SShawn McCarney * @return Pointer to Configuration object. Will equal nullptr if no 874bf310e3SShawn McCarney * configuration changes are defined for this rail. 884bf310e3SShawn McCarney */ 894bf310e3SShawn McCarney const std::unique_ptr<Configuration>& getConfiguration() const 904bf310e3SShawn McCarney { 914bf310e3SShawn McCarney return configuration; 924bf310e3SShawn McCarney } 934bf310e3SShawn McCarney 944bf310e3SShawn McCarney /** 95a2461b34SShawn McCarney * Returns the unique ID of this rail. 96a2461b34SShawn McCarney * 97a2461b34SShawn McCarney * @return rail ID 98a2461b34SShawn McCarney */ 994afb285eSShawn McCarney const std::string& getID() const 100a2461b34SShawn McCarney { 101a2461b34SShawn McCarney return id; 102a2461b34SShawn McCarney } 103a2461b34SShawn McCarney 1044bf310e3SShawn McCarney /** 1054bf310e3SShawn McCarney * Returns the sensor monitoring for this rail, if any. 1064bf310e3SShawn McCarney * 1074bf310e3SShawn McCarney * @return Pointer to SensorMonitoring object. Will equal nullptr if no 1084bf310e3SShawn McCarney * sensor monitoring is defined for this rail. 1094bf310e3SShawn McCarney */ 1104bf310e3SShawn McCarney const std::unique_ptr<SensorMonitoring>& getSensorMonitoring() const 1114bf310e3SShawn McCarney { 1124bf310e3SShawn McCarney return sensorMonitoring; 1134bf310e3SShawn McCarney } 1144bf310e3SShawn McCarney 115a2461b34SShawn McCarney private: 116a2461b34SShawn McCarney /** 117a2461b34SShawn McCarney * Unique ID of this rail. 118a2461b34SShawn McCarney */ 119a2461b34SShawn McCarney const std::string id{}; 1204bf310e3SShawn McCarney 1214bf310e3SShawn McCarney /** 1224bf310e3SShawn McCarney * Configuration changes to apply to this rail, if any. Set to nullptr if 1234bf310e3SShawn McCarney * no configuration changes are defined for this rail. 1244bf310e3SShawn McCarney */ 1254bf310e3SShawn McCarney std::unique_ptr<Configuration> configuration{}; 1264bf310e3SShawn McCarney 1274bf310e3SShawn McCarney /** 1284bf310e3SShawn McCarney * Sensor monitoring for this rail, if any. Set to nullptr if no sensor 1294bf310e3SShawn McCarney * monitoring is defined for this rail. 1304bf310e3SShawn McCarney */ 1314bf310e3SShawn McCarney std::unique_ptr<SensorMonitoring> sensorMonitoring{}; 132a2461b34SShawn McCarney }; 133a2461b34SShawn McCarney 134ea7385b8SShawn McCarney } // namespace phosphor::power::regulators 135