Shawn McCarney | 71d7fe4 | 2024-05-02 16:06:10 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2024 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 | |
| 17 | #include "ucd90x_device.hpp" |
| 18 | |
| 19 | #include "pmbus.hpp" |
| 20 | |
| 21 | #include <exception> |
| 22 | #include <format> |
| 23 | #include <stdexcept> |
| 24 | |
| 25 | namespace phosphor::power::sequencer |
| 26 | { |
| 27 | |
| 28 | using namespace pmbus; |
| 29 | |
| 30 | uint64_t UCD90xDevice::getMfrStatus() |
| 31 | { |
| 32 | uint64_t value{0}; |
| 33 | try |
| 34 | { |
| 35 | std::string fileName{"mfr_status"}; |
| 36 | value = pmbusInterface->read(fileName, Type::HwmonDeviceDebug); |
| 37 | } |
| 38 | catch (const std::exception& e) |
| 39 | { |
| 40 | throw std::runtime_error{std::format( |
| 41 | "Unable to read MFR_STATUS for device {}: {}", name, e.what())}; |
| 42 | } |
| 43 | return value; |
| 44 | } |
| 45 | |
| 46 | void UCD90xDevice::storePgoodFaultDebugData( |
| 47 | Services& services, const std::vector<int>& gpioValues, |
| 48 | std::map<std::string, std::string>& additionalData) |
| 49 | { |
| 50 | // Store manufacturer-specific MFR_STATUS command value |
| 51 | try |
| 52 | { |
| 53 | uint64_t value = getMfrStatus(); |
| 54 | services.logInfoMsg( |
| 55 | std::format("Device {} MFR_STATUS: {:#014x}", name, value)); |
| 56 | additionalData.emplace("MFR_STATUS", std::format("{:#014x}", value)); |
| 57 | } |
| 58 | catch (...) |
| 59 | { |
| 60 | // Ignore error; don't interrupt pgood fault handling |
| 61 | } |
| 62 | |
| 63 | // Call parent class method to store standard data |
| 64 | PMBusDriverDevice::storePgoodFaultDebugData(services, gpioValues, |
| 65 | additionalData); |
| 66 | } |
| 67 | |
| 68 | } // namespace phosphor::power::sequencer |