blob: fbcb255c3335418b405b0d011b9d8ed5dac7041e [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
18#include <string>
19
20namespace phosphor::power::regulators
21{
22
23/**
24 * Redundant phase fault type.
25 *
26 * A voltage regulator is sometimes called a "phase controller" because it
27 * controls one or more phases that perform the actual voltage regulation.
28 *
29 * A regulator may have redundant phases. If a redundant phase fails, the
30 * regulator will continue to provide the desired output voltage. However, a
31 * phase fault error should be logged warning the user that the regulator has
32 * lost redundancy.
33 */
34enum class PhaseFaultType : unsigned char
35{
36 /**
37 * N phase fault type.
38 *
39 * Regulator has lost all redundant phases. The regulator is now at
40 * redundancy level N.
41 */
42 n,
43
44 /**
45 * N+1 phase fault type.
46 *
47 * An "N+2" regulator has lost one redundant phase. The regulator is now at
48 * redundancy level "N+1".
49 */
50 n_plus_1
51};
52
53/**
54 * Returns the name of the specified PhaseFaultType.
55 *
56 * @param type phase fault type
57 * @return phase fault type name
58 */
59inline std::string toString(PhaseFaultType type)
60{
61 std::string name{};
62 switch (type)
63 {
64 case PhaseFaultType::n:
65 name = "n";
66 break;
67 case PhaseFaultType::n_plus_1:
68 name = "n+1";
69 break;
70 }
71 return name;
72}
73
74} // namespace phosphor::power::regulators