Lei YU | 0bf1b78 | 2019-08-29 16:02:30 +0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2019 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 | #pragma once |
| 17 | |
Faisal Awada | 5dce1a7 | 2024-08-19 15:51:44 -0500 | [diff] [blame] | 18 | #include "pmbus.hpp" |
| 19 | |
| 20 | #include <sdbusplus/bus.hpp> |
| 21 | |
Lei YU | 0bf1b78 | 2019-08-29 16:02:30 +0800 | [diff] [blame] | 22 | #include <string> |
Faisal Awada | 5dce1a7 | 2024-08-19 15:51:44 -0500 | [diff] [blame] | 23 | #include <tuple> |
Lei YU | 093b591 | 2019-10-22 15:28:51 +0800 | [diff] [blame] | 24 | #include <vector> |
Lei YU | 0bf1b78 | 2019-08-29 16:02:30 +0800 | [diff] [blame] | 25 | |
| 26 | namespace version |
| 27 | { |
Shawn McCarney | 14572cf | 2024-11-06 12:17:57 -0600 | [diff] [blame] | 28 | namespace internal |
Faisal Awada | 5dce1a7 | 2024-08-19 15:51:44 -0500 | [diff] [blame] | 29 | { |
| 30 | // PsuInfo contains the device path, pmbus read type, and the version string |
| 31 | using PsuVersionInfo = |
| 32 | std::tuple<std::string, phosphor::pmbus::Type, std::string>; |
| 33 | |
Lei YU | 0bf1b78 | 2019-08-29 16:02:30 +0800 | [diff] [blame] | 34 | /** |
Faisal Awada | 5dce1a7 | 2024-08-19 15:51:44 -0500 | [diff] [blame] | 35 | * @brief Get PSU version information |
| 36 | * |
| 37 | * @param[in] psuInventoryPath - The PSU inventory path. |
| 38 | * |
| 39 | * @return tuple - device path, pmbus read type and PSU version |
| 40 | */ |
| 41 | PsuVersionInfo getVersionInfo(const std::string& psuInventoryPath); |
| 42 | |
| 43 | /** |
| 44 | * @brief Get firmware latest version |
| 45 | * |
| 46 | * @param[in] versions - String of versions |
| 47 | * |
| 48 | * @return version - latest firmware level |
| 49 | */ |
| 50 | std::string getLatestDefault(const std::vector<std::string>& versions); |
| 51 | |
Shawn McCarney | 14572cf | 2024-11-06 12:17:57 -0600 | [diff] [blame] | 52 | } // namespace internal |
Faisal Awada | 5dce1a7 | 2024-08-19 15:51:44 -0500 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * Get the software version of the PSU using sysfs |
| 56 | * |
| 57 | * @param[in] bus - Systemd bus connection |
| 58 | * @param[in] psuInventoryPath - The inventory path of the PSU |
| 59 | * |
| 60 | * @return The version of the PSU |
| 61 | */ |
| 62 | std::string getVersion(sdbusplus::bus_t& bus, |
| 63 | const std::string& psuInventoryPath); |
| 64 | |
| 65 | /** |
| 66 | * Get the software version of the PSU using psu.json |
Lei YU | 0bf1b78 | 2019-08-29 16:02:30 +0800 | [diff] [blame] | 67 | * |
| 68 | * @param[in] psuInventoryPath - The inventory path of the PSU |
Lei YU | 093b591 | 2019-10-22 15:28:51 +0800 | [diff] [blame] | 69 | * |
| 70 | * @return The version of the PSU |
Lei YU | 0bf1b78 | 2019-08-29 16:02:30 +0800 | [diff] [blame] | 71 | */ |
| 72 | std::string getVersion(const std::string& psuInventoryPath); |
| 73 | |
Lei YU | 093b591 | 2019-10-22 15:28:51 +0800 | [diff] [blame] | 74 | /** |
| 75 | * Get the latest version from a list of versions |
| 76 | * |
| 77 | * @param[in] versions - The list of PSU version strings |
| 78 | * |
| 79 | * @return The latest version |
| 80 | */ |
| 81 | std::string getLatest(const std::vector<std::string>& versions); |
| 82 | |
Lei YU | 0bf1b78 | 2019-08-29 16:02:30 +0800 | [diff] [blame] | 83 | } // namespace version |