blob: 8f655f017a7ccd9787fab28c672f0142f7e4f25a [file] [log] [blame]
Shawn McCarney421128e2021-08-25 10:00:59 -05001/**
2 * Copyright © 2021 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
Shawn McCarneye6d54a12021-09-02 15:21:50 -050018#include "error_history.hpp"
19
Shawn McCarney421128e2021-08-25 10:00:59 -050020#include <string>
21
22namespace phosphor::power::regulators
23{
24
25/**
26 * Redundant phase fault type.
27 *
28 * A voltage regulator is sometimes called a "phase controller" because it
29 * controls one or more phases that perform the actual voltage regulation.
30 *
31 * A regulator may have redundant phases. If a redundant phase fails, the
32 * regulator will continue to provide the desired output voltage. However, a
33 * phase fault error should be logged warning the user that the regulator has
34 * lost redundancy.
35 */
36enum class PhaseFaultType : unsigned char
37{
38 /**
39 * N phase fault type.
40 *
41 * Regulator has lost all redundant phases. The regulator is now at
42 * redundancy level N.
43 */
44 n,
45
46 /**
47 * N+1 phase fault type.
48 *
49 * An "N+2" regulator has lost one redundant phase. The regulator is now at
50 * redundancy level "N+1".
51 */
52 n_plus_1
53};
54
55/**
Shawn McCarneye6d54a12021-09-02 15:21:50 -050056 * Returns the ErrorType that corresponds to the specified PhaseFaultType.
57 *
58 * The ErrorType enum is used with the ErrorHistory class.
59 *
60 * @param type phase fault type
61 * @return error type
62 */
63inline ErrorType toErrorType(PhaseFaultType type)
64{
Shawn McCarneyf7019cb2022-09-12 13:18:01 -050065 ErrorType errorType{ErrorType::phaseFaultN};
Shawn McCarneye6d54a12021-09-02 15:21:50 -050066 switch (type)
67 {
68 case PhaseFaultType::n:
69 errorType = ErrorType::phaseFaultN;
70 break;
71 case PhaseFaultType::n_plus_1:
72 errorType = ErrorType::phaseFaultNPlus1;
73 break;
74 }
75 return errorType;
76}
77
78/**
Shawn McCarney421128e2021-08-25 10:00:59 -050079 * Returns the name of the specified PhaseFaultType.
80 *
81 * @param type phase fault type
82 * @return phase fault type name
83 */
84inline std::string toString(PhaseFaultType type)
85{
86 std::string name{};
87 switch (type)
88 {
89 case PhaseFaultType::n:
90 name = "n";
91 break;
92 case PhaseFaultType::n_plus_1:
93 name = "n+1";
94 break;
95 }
96 return name;
97}
98
99} // namespace phosphor::power::regulators