blob: 53130fe1bf7086719971641b5eb097738a386df0 [file] [log] [blame]
Matt Spinlerb54357f2017-08-21 14:38:54 -05001#pragma once
2
Brad Bishop5e361c52018-02-21 13:06:03 -05003#include <functional>
Matt Spinlerb54357f2017-08-21 14:38:54 -05004#include <map>
5#include <string>
6#include <tuple>
Matt Spinlere7e432b2017-08-21 15:01:40 -05007#include <vector>
Matt Spinlerb54357f2017-08-21 14:38:54 -05008
Lei YUab093322019-10-09 16:43:22 +08009namespace phosphor
Matt Spinlerb54357f2017-08-21 14:38:54 -050010{
11namespace power
12{
Matt Spinler2d248ae2017-09-19 11:06:48 -050013
14class UCD90160;
15
Matt Spinlerb54357f2017-08-21 14:38:54 -050016namespace ucd90160
17{
18
Matt Spinler2d248ae2017-09-19 11:06:48 -050019/**
20 * Defines which extra analysis is required
21 * on failures, if any.
22 */
23enum class extraAnalysisType
24{
25 none,
26 gpuPGOOD,
Brandon Wyman03c19db2019-05-10 17:46:41 -050027 gpuOverTemp,
28 memGOOD0,
29 memGOOD1
Matt Spinler2d248ae2017-09-19 11:06:48 -050030};
31
32/**
33 * Options for the GPIOs
34 *
35 * Used as a bitmask
36 */
37enum class optionFlags
38{
Matt Spinlerf0f02b92018-10-25 16:12:43 -050039 none = 0,
40 shutdownOnFault = 1
Matt Spinler2d248ae2017-09-19 11:06:48 -050041};
42
43constexpr auto gpioNumField = 0;
44constexpr auto gpioCalloutField = 1;
45using GPIODefinition = std::tuple<gpio::gpioNum_t, std::string>;
46using GPIODefinitions = std::vector<GPIODefinition>;
47
48constexpr auto gpioDevicePathField = 0;
49constexpr auto gpioPolarityField = 1;
50constexpr auto errorFunctionField = 2;
51constexpr auto optionFlagsField = 3;
52constexpr auto gpioDefinitionField = 4;
53
54using ErrorFunction = std::function<void(UCD90160&, const std::string&)>;
55
Matt Spinlerf0f02b92018-10-25 16:12:43 -050056using GPIOGroup = std::tuple<std::string, gpio::Value, ErrorFunction,
57 optionFlags, GPIODefinitions>;
Matt Spinler2d248ae2017-09-19 11:06:48 -050058
59using GPIOAnalysis = std::map<extraAnalysisType, GPIOGroup>;
60
Matt Spinlerd998b732017-08-21 15:35:54 -050061constexpr auto gpiNumField = 0;
62constexpr auto pinIDField = 1;
63constexpr auto gpiNameField = 2;
64constexpr auto pollField = 3;
Matt Spinler2d248ae2017-09-19 11:06:48 -050065constexpr auto extraAnalysisField = 4;
Matt Spinlerd998b732017-08-21 15:35:54 -050066
Matt Spinlerf0f02b92018-10-25 16:12:43 -050067using GPIConfig =
68 std::tuple<size_t, size_t, std::string, bool, extraAnalysisType>;
Matt Spinlerd998b732017-08-21 15:35:54 -050069
70using GPIConfigs = std::vector<GPIConfig>;
71
Matt Spinlere7e432b2017-08-21 15:01:40 -050072using RailNames = std::vector<std::string>;
Matt Spinlerb54357f2017-08-21 14:38:54 -050073
Matt Spinlere7e432b2017-08-21 15:01:40 -050074constexpr auto pathField = 0;
75constexpr auto railNamesField = 1;
Matt Spinlerd998b732017-08-21 15:35:54 -050076constexpr auto gpiConfigField = 2;
Matt Spinler2d248ae2017-09-19 11:06:48 -050077constexpr auto gpioAnalysisField = 3;
Matt Spinlere7e432b2017-08-21 15:01:40 -050078
Matt Spinlerf0f02b92018-10-25 16:12:43 -050079using DeviceDefinition =
80 std::tuple<std::string, RailNames, GPIConfigs, GPIOAnalysis>;
Matt Spinlerb54357f2017-08-21 14:38:54 -050081
Matt Spinlerf0f02b92018-10-25 16:12:43 -050082// Maps a device instance to its definition
Matt Spinlerb54357f2017-08-21 14:38:54 -050083using DeviceMap = std::map<size_t, DeviceDefinition>;
84
Matt Spinlerf0f02b92018-10-25 16:12:43 -050085} // namespace ucd90160
86} // namespace power
Lei YUab093322019-10-09 16:43:22 +080087} // namespace phosphor