Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Brad Bishop | 5e361c5 | 2018-02-21 13:06:03 -0500 | [diff] [blame] | 3 | #include <functional> |
Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame] | 4 | #include <map> |
| 5 | #include <string> |
| 6 | #include <tuple> |
Matt Spinler | e7e432b | 2017-08-21 15:01:40 -0500 | [diff] [blame] | 7 | #include <vector> |
Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame] | 8 | |
Lei YU | ab09332 | 2019-10-09 16:43:22 +0800 | [diff] [blame] | 9 | namespace phosphor |
Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame] | 10 | { |
| 11 | namespace power |
| 12 | { |
Matt Spinler | 2d248ae | 2017-09-19 11:06:48 -0500 | [diff] [blame] | 13 | |
| 14 | class UCD90160; |
| 15 | |
Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame] | 16 | namespace ucd90160 |
| 17 | { |
| 18 | |
Matt Spinler | 2d248ae | 2017-09-19 11:06:48 -0500 | [diff] [blame] | 19 | /** |
| 20 | * Defines which extra analysis is required |
| 21 | * on failures, if any. |
| 22 | */ |
| 23 | enum class extraAnalysisType |
| 24 | { |
| 25 | none, |
| 26 | gpuPGOOD, |
Brandon Wyman | 03c19db | 2019-05-10 17:46:41 -0500 | [diff] [blame] | 27 | gpuOverTemp, |
| 28 | memGOOD0, |
| 29 | memGOOD1 |
Matt Spinler | 2d248ae | 2017-09-19 11:06:48 -0500 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | /** |
| 33 | * Options for the GPIOs |
| 34 | * |
| 35 | * Used as a bitmask |
| 36 | */ |
| 37 | enum class optionFlags |
| 38 | { |
Matt Spinler | f0f02b9 | 2018-10-25 16:12:43 -0500 | [diff] [blame] | 39 | none = 0, |
| 40 | shutdownOnFault = 1 |
Matt Spinler | 2d248ae | 2017-09-19 11:06:48 -0500 | [diff] [blame] | 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 | |
Matt Spinler | f0f02b9 | 2018-10-25 16:12:43 -0500 | [diff] [blame] | 56 | using GPIOGroup = std::tuple<std::string, gpio::Value, ErrorFunction, |
| 57 | optionFlags, GPIODefinitions>; |
Matt Spinler | 2d248ae | 2017-09-19 11:06:48 -0500 | [diff] [blame] | 58 | |
| 59 | using GPIOAnalysis = std::map<extraAnalysisType, GPIOGroup>; |
| 60 | |
Matt Spinler | d998b73 | 2017-08-21 15:35:54 -0500 | [diff] [blame] | 61 | constexpr auto gpiNumField = 0; |
| 62 | constexpr auto pinIDField = 1; |
| 63 | constexpr auto gpiNameField = 2; |
| 64 | constexpr auto pollField = 3; |
Matt Spinler | 2d248ae | 2017-09-19 11:06:48 -0500 | [diff] [blame] | 65 | constexpr auto extraAnalysisField = 4; |
Matt Spinler | d998b73 | 2017-08-21 15:35:54 -0500 | [diff] [blame] | 66 | |
Matt Spinler | f0f02b9 | 2018-10-25 16:12:43 -0500 | [diff] [blame] | 67 | using GPIConfig = |
| 68 | std::tuple<size_t, size_t, std::string, bool, extraAnalysisType>; |
Matt Spinler | d998b73 | 2017-08-21 15:35:54 -0500 | [diff] [blame] | 69 | |
| 70 | using GPIConfigs = std::vector<GPIConfig>; |
| 71 | |
Matt Spinler | e7e432b | 2017-08-21 15:01:40 -0500 | [diff] [blame] | 72 | using RailNames = std::vector<std::string>; |
Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame] | 73 | |
Matt Spinler | e7e432b | 2017-08-21 15:01:40 -0500 | [diff] [blame] | 74 | constexpr auto pathField = 0; |
| 75 | constexpr auto railNamesField = 1; |
Matt Spinler | d998b73 | 2017-08-21 15:35:54 -0500 | [diff] [blame] | 76 | constexpr auto gpiConfigField = 2; |
Matt Spinler | 2d248ae | 2017-09-19 11:06:48 -0500 | [diff] [blame] | 77 | constexpr auto gpioAnalysisField = 3; |
Matt Spinler | e7e432b | 2017-08-21 15:01:40 -0500 | [diff] [blame] | 78 | |
Matt Spinler | f0f02b9 | 2018-10-25 16:12:43 -0500 | [diff] [blame] | 79 | using DeviceDefinition = |
| 80 | std::tuple<std::string, RailNames, GPIConfigs, GPIOAnalysis>; |
Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame] | 81 | |
Matt Spinler | f0f02b9 | 2018-10-25 16:12:43 -0500 | [diff] [blame] | 82 | // Maps a device instance to its definition |
Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame] | 83 | using DeviceMap = std::map<size_t, DeviceDefinition>; |
| 84 | |
Matt Spinler | f0f02b9 | 2018-10-25 16:12:43 -0500 | [diff] [blame] | 85 | } // namespace ucd90160 |
| 86 | } // namespace power |
Lei YU | ab09332 | 2019-10-09 16:43:22 +0800 | [diff] [blame] | 87 | } // namespace phosphor |