1421128efSShawn McCarney /** 2421128efSShawn McCarney * Copyright © 2021 IBM Corporation 3421128efSShawn McCarney * 4421128efSShawn McCarney * Licensed under the Apache License, Version 2.0 (the "License"); 5421128efSShawn McCarney * you may not use this file except in compliance with the License. 6421128efSShawn McCarney * You may obtain a copy of the License at 7421128efSShawn McCarney * 8421128efSShawn McCarney * http://www.apache.org/licenses/LICENSE-2.0 9421128efSShawn McCarney * 10421128efSShawn McCarney * Unless required by applicable law or agreed to in writing, software 11421128efSShawn McCarney * distributed under the License is distributed on an "AS IS" BASIS, 12421128efSShawn McCarney * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13421128efSShawn McCarney * See the License for the specific language governing permissions and 14421128efSShawn McCarney * limitations under the License. 15421128efSShawn McCarney */ 16421128efSShawn McCarney #pragma once 17421128efSShawn McCarney 18e6d54a1fSShawn McCarney #include "error_history.hpp" 19e6d54a1fSShawn McCarney 20421128efSShawn McCarney #include <string> 21421128efSShawn McCarney 22421128efSShawn McCarney namespace phosphor::power::regulators 23421128efSShawn McCarney { 24421128efSShawn McCarney 25421128efSShawn McCarney /** 26421128efSShawn McCarney * Redundant phase fault type. 27421128efSShawn McCarney * 28421128efSShawn McCarney * A voltage regulator is sometimes called a "phase controller" because it 29421128efSShawn McCarney * controls one or more phases that perform the actual voltage regulation. 30421128efSShawn McCarney * 31421128efSShawn McCarney * A regulator may have redundant phases. If a redundant phase fails, the 32421128efSShawn McCarney * regulator will continue to provide the desired output voltage. However, a 33421128efSShawn McCarney * phase fault error should be logged warning the user that the regulator has 34421128efSShawn McCarney * lost redundancy. 35421128efSShawn McCarney */ 36421128efSShawn McCarney enum class PhaseFaultType : unsigned char 37421128efSShawn McCarney { 38421128efSShawn McCarney /** 39421128efSShawn McCarney * N phase fault type. 40421128efSShawn McCarney * 41421128efSShawn McCarney * Regulator has lost all redundant phases. The regulator is now at 42421128efSShawn McCarney * redundancy level N. 43421128efSShawn McCarney */ 44421128efSShawn McCarney n, 45421128efSShawn McCarney 46421128efSShawn McCarney /** 47421128efSShawn McCarney * N+1 phase fault type. 48421128efSShawn McCarney * 49421128efSShawn McCarney * An "N+2" regulator has lost one redundant phase. The regulator is now at 50421128efSShawn McCarney * redundancy level "N+1". 51421128efSShawn McCarney */ 52421128efSShawn McCarney n_plus_1 53421128efSShawn McCarney }; 54421128efSShawn McCarney 55421128efSShawn McCarney /** 56e6d54a1fSShawn McCarney * Returns the ErrorType that corresponds to the specified PhaseFaultType. 57e6d54a1fSShawn McCarney * 58e6d54a1fSShawn McCarney * The ErrorType enum is used with the ErrorHistory class. 59e6d54a1fSShawn McCarney * 60e6d54a1fSShawn McCarney * @param type phase fault type 61e6d54a1fSShawn McCarney * @return error type 62e6d54a1fSShawn McCarney */ toErrorType(PhaseFaultType type)63e6d54a1fSShawn McCarneyinline ErrorType toErrorType(PhaseFaultType type) 64e6d54a1fSShawn McCarney { 65*f7019cb5SShawn McCarney ErrorType errorType{ErrorType::phaseFaultN}; 66e6d54a1fSShawn McCarney switch (type) 67e6d54a1fSShawn McCarney { 68e6d54a1fSShawn McCarney case PhaseFaultType::n: 69e6d54a1fSShawn McCarney errorType = ErrorType::phaseFaultN; 70e6d54a1fSShawn McCarney break; 71e6d54a1fSShawn McCarney case PhaseFaultType::n_plus_1: 72e6d54a1fSShawn McCarney errorType = ErrorType::phaseFaultNPlus1; 73e6d54a1fSShawn McCarney break; 74e6d54a1fSShawn McCarney } 75e6d54a1fSShawn McCarney return errorType; 76e6d54a1fSShawn McCarney } 77e6d54a1fSShawn McCarney 78e6d54a1fSShawn McCarney /** 79421128efSShawn McCarney * Returns the name of the specified PhaseFaultType. 80421128efSShawn McCarney * 81421128efSShawn McCarney * @param type phase fault type 82421128efSShawn McCarney * @return phase fault type name 83421128efSShawn McCarney */ toString(PhaseFaultType type)84421128efSShawn McCarneyinline std::string toString(PhaseFaultType type) 85421128efSShawn McCarney { 86421128efSShawn McCarney std::string name{}; 87421128efSShawn McCarney switch (type) 88421128efSShawn McCarney { 89421128efSShawn McCarney case PhaseFaultType::n: 90421128efSShawn McCarney name = "n"; 91421128efSShawn McCarney break; 92421128efSShawn McCarney case PhaseFaultType::n_plus_1: 93421128efSShawn McCarney name = "n+1"; 94421128efSShawn McCarney break; 95421128efSShawn McCarney } 96421128efSShawn McCarney return name; 97421128efSShawn McCarney } 98421128efSShawn McCarney 99421128efSShawn McCarney } // namespace phosphor::power::regulators 100