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