Matt Spinler | b54357f | 2017-08-21 14:38:54 -0500 | [diff] [blame^] | 1 | /** |
| 2 | * Copyright © 2017 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #include <map> |
| 17 | #include <memory> |
| 18 | #include <phosphor-logging/elog.hpp> |
| 19 | #include <phosphor-logging/log.hpp> |
| 20 | #include <elog-errors.hpp> |
| 21 | #include <xyz/openbmc_project/Sensor/Device/error.hpp> |
| 22 | #include <xyz/openbmc_project/Control/Device/error.hpp> |
| 23 | #include <xyz/openbmc_project/Power/Fault/error.hpp> |
| 24 | #include "ucd90160.hpp" |
| 25 | |
| 26 | namespace witherspoon |
| 27 | { |
| 28 | namespace power |
| 29 | { |
| 30 | |
| 31 | using namespace std::string_literals; |
| 32 | |
| 33 | const auto DEVICE_NAME = "UCD90160"s; |
| 34 | const auto DRIVER_NAME = "ucd9000"s; |
| 35 | |
| 36 | using namespace pmbus; |
| 37 | using namespace phosphor::logging; |
| 38 | using namespace sdbusplus::xyz::openbmc_project::Control::Device::Error; |
| 39 | using namespace sdbusplus::xyz::openbmc_project::Sensor::Device::Error; |
| 40 | using namespace sdbusplus::xyz::openbmc_project::Power::Fault::Error; |
| 41 | |
| 42 | UCD90160::UCD90160(size_t instance) : |
| 43 | Device(DEVICE_NAME, instance), |
| 44 | interface(std::get<ucd90160::pathField>( |
| 45 | deviceMap.find(instance)->second), |
| 46 | DRIVER_NAME, |
| 47 | instance) |
| 48 | { |
| 49 | } |
| 50 | |
| 51 | void UCD90160::onFailure() |
| 52 | { |
| 53 | try |
| 54 | { |
| 55 | auto voutError = checkVOUTFaults(); |
| 56 | |
| 57 | auto pgoodError = checkPGOODFaults(false); |
| 58 | |
| 59 | //Not a voltage or PGOOD fault, but we know something |
| 60 | //failed so still create an error log. |
| 61 | if (!voutError && !pgoodError) |
| 62 | { |
| 63 | createPowerFaultLog(); |
| 64 | } |
| 65 | } |
| 66 | catch (ReadFailure& e) |
| 67 | { |
| 68 | if (!accessError) |
| 69 | { |
| 70 | commit<ReadFailure>(); |
| 71 | accessError = true; |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | void UCD90160::analyze() |
| 77 | { |
| 78 | try |
| 79 | { |
| 80 | //Note: Voltage faults are always fatal, so they just |
| 81 | //need to be analyzed in onFailure(). |
| 82 | |
| 83 | checkPGOODFaults(true); |
| 84 | } |
| 85 | catch (ReadFailure& e) |
| 86 | { |
| 87 | if (!accessError) |
| 88 | { |
| 89 | commit<ReadFailure>(); |
| 90 | accessError = true; |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | void UCD90160::clearFaults() |
| 96 | { |
| 97 | |
| 98 | } |
| 99 | |
| 100 | bool UCD90160::checkVOUTFaults() |
| 101 | { |
| 102 | return false; |
| 103 | } |
| 104 | |
| 105 | bool UCD90160::checkPGOODFaults(bool polling) |
| 106 | { |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | void UCD90160::createPowerFaultLog() |
| 111 | { |
| 112 | |
| 113 | } |
| 114 | |
| 115 | } |
| 116 | } |