blob: fcb30e327bf0eecc0e711a315b7f7adba8df5d40 [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
9namespace witherspoon
10{
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,
27 gpuOverTemp
28};
29
30/**
31 * Options for the GPIOs
32 *
33 * Used as a bitmask
34 */
35enum class optionFlags
36{
Matt Spinlerf0f02b92018-10-25 16:12:43 -050037 none = 0,
38 shutdownOnFault = 1
Matt Spinler2d248ae2017-09-19 11:06:48 -050039};
40
41constexpr auto gpioNumField = 0;
42constexpr auto gpioCalloutField = 1;
43using GPIODefinition = std::tuple<gpio::gpioNum_t, std::string>;
44using GPIODefinitions = std::vector<GPIODefinition>;
45
46constexpr auto gpioDevicePathField = 0;
47constexpr auto gpioPolarityField = 1;
48constexpr auto errorFunctionField = 2;
49constexpr auto optionFlagsField = 3;
50constexpr auto gpioDefinitionField = 4;
51
52using ErrorFunction = std::function<void(UCD90160&, const std::string&)>;
53
Matt Spinlerf0f02b92018-10-25 16:12:43 -050054using GPIOGroup = std::tuple<std::string, gpio::Value, ErrorFunction,
55 optionFlags, GPIODefinitions>;
Matt Spinler2d248ae2017-09-19 11:06:48 -050056
57using GPIOAnalysis = std::map<extraAnalysisType, GPIOGroup>;
58
Matt Spinlerd998b732017-08-21 15:35:54 -050059constexpr auto gpiNumField = 0;
60constexpr auto pinIDField = 1;
61constexpr auto gpiNameField = 2;
62constexpr auto pollField = 3;
Matt Spinler2d248ae2017-09-19 11:06:48 -050063constexpr auto extraAnalysisField = 4;
Matt Spinlerd998b732017-08-21 15:35:54 -050064
Matt Spinlerf0f02b92018-10-25 16:12:43 -050065using GPIConfig =
66 std::tuple<size_t, size_t, std::string, bool, extraAnalysisType>;
Matt Spinlerd998b732017-08-21 15:35:54 -050067
68using GPIConfigs = std::vector<GPIConfig>;
69
Matt Spinlere7e432b2017-08-21 15:01:40 -050070using RailNames = std::vector<std::string>;
Matt Spinlerb54357f2017-08-21 14:38:54 -050071
Matt Spinlere7e432b2017-08-21 15:01:40 -050072constexpr auto pathField = 0;
73constexpr auto railNamesField = 1;
Matt Spinlerd998b732017-08-21 15:35:54 -050074constexpr auto gpiConfigField = 2;
Matt Spinler2d248ae2017-09-19 11:06:48 -050075constexpr auto gpioAnalysisField = 3;
Matt Spinlere7e432b2017-08-21 15:01:40 -050076
Matt Spinlerf0f02b92018-10-25 16:12:43 -050077using DeviceDefinition =
78 std::tuple<std::string, RailNames, GPIConfigs, GPIOAnalysis>;
Matt Spinlerb54357f2017-08-21 14:38:54 -050079
Matt Spinlerf0f02b92018-10-25 16:12:43 -050080// Maps a device instance to its definition
Matt Spinlerb54357f2017-08-21 14:38:54 -050081using DeviceMap = std::map<size_t, DeviceDefinition>;
82
Matt Spinlerf0f02b92018-10-25 16:12:43 -050083} // namespace ucd90160
84} // namespace power
85} // namespace witherspoon