xref: /openbmc/phosphor-power/power-sequencer/types.hpp (revision 8b38b177315d40f1f9bc1e4d0784d45ea17cbd5c)
1 #pragma once
2 
3 #include "gpio.hpp"
4 
5 #include <functional>
6 #include <map>
7 #include <string>
8 #include <tuple>
9 #include <vector>
10 
11 namespace phosphor
12 {
13 namespace power
14 {
15 
16 class UCD90160;
17 
18 namespace ucd90160
19 {
20 
21 /**
22  * Defines which extra analysis is required
23  * on failures, if any.
24  */
25 enum class extraAnalysisType
26 {
27     none,
28     gpuPGOOD,
29     gpuOverTemp,
30     memGOOD0,
31     memGOOD1
32 };
33 
34 /**
35  * Options for the GPIOs
36  *
37  * Used as a bitmask
38  */
39 enum class optionFlags
40 {
41     none = 0,
42     shutdownOnFault = 1
43 };
44 
45 constexpr auto gpioNumField = 0;
46 constexpr auto gpioCalloutField = 1;
47 using GPIODefinition = std::tuple<gpio::gpioNum_t, std::string>;
48 using GPIODefinitions = std::vector<GPIODefinition>;
49 
50 constexpr auto gpioDevicePathField = 0;
51 constexpr auto gpioPolarityField = 1;
52 constexpr auto errorFunctionField = 2;
53 constexpr auto optionFlagsField = 3;
54 constexpr auto gpioDefinitionField = 4;
55 
56 using ErrorFunction = std::function<void(UCD90160&, const std::string&)>;
57 
58 using GPIOGroup = std::tuple<std::string, gpio::Value, ErrorFunction,
59                              optionFlags, GPIODefinitions>;
60 
61 using GPIOAnalysis = std::map<extraAnalysisType, GPIOGroup>;
62 
63 constexpr auto gpiNumField = 0;
64 constexpr auto pinIDField = 1;
65 constexpr auto gpiNameField = 2;
66 constexpr auto pollField = 3;
67 constexpr auto extraAnalysisField = 4;
68 
69 using GPIConfig =
70     std::tuple<size_t, size_t, std::string, bool, extraAnalysisType>;
71 
72 using GPIConfigs = std::vector<GPIConfig>;
73 
74 using RailNames = std::vector<std::string>;
75 
76 constexpr auto pathField = 0;
77 constexpr auto railNamesField = 1;
78 constexpr auto gpiConfigField = 2;
79 constexpr auto gpioAnalysisField = 3;
80 
81 using DeviceDefinition =
82     std::tuple<std::string, RailNames, GPIConfigs, GPIOAnalysis>;
83 
84 // Maps a device instance to its definition
85 using DeviceMap = std::map<size_t, DeviceDefinition>;
86 
87 } // namespace ucd90160
88 } // namespace power
89 } // namespace phosphor
90