Jim Wright | 1553cd9 | 2021-03-31 16:11:59 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2021 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 | |
Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 17 | #include "ucd90320_monitor.hpp" |
| 18 | |
Jim Wright | 56ae78e | 2021-12-01 14:46:15 -0600 | [diff] [blame] | 19 | #include <fmt/format.h> |
| 20 | #include <fmt/ranges.h> |
| 21 | |
| 22 | #include <phosphor-logging/log.hpp> |
Jim Wright | 56ae78e | 2021-12-01 14:46:15 -0600 | [diff] [blame] | 23 | |
Jim Wright | 213ffe9 | 2022-06-03 08:54:30 -0500 | [diff] [blame] | 24 | #include <span> |
Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 25 | |
| 26 | namespace phosphor::power::sequencer |
Jim Wright | 1553cd9 | 2021-03-31 16:11:59 -0500 | [diff] [blame] | 27 | { |
Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 28 | |
Jim Wright | 56ae78e | 2021-12-01 14:46:15 -0600 | [diff] [blame] | 29 | using namespace phosphor::logging; |
Jim Wright | 71a1413 | 2022-01-28 09:46:46 -0600 | [diff] [blame] | 30 | |
Patrick Williams | 7354ce6 | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 31 | UCD90320Monitor::UCD90320Monitor(sdbusplus::bus_t& bus, std::uint8_t i2cBus, |
Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 32 | std::uint16_t i2cAddress) : |
Jim Wright | c48551a | 2022-12-22 15:43:14 -0600 | [diff] [blame] | 33 | UCD90xMonitor(bus, i2cBus, i2cAddress, "UCD90320", 32) |
| 34 | {} |
Jim Wright | 56ae78e | 2021-12-01 14:46:15 -0600 | [diff] [blame] | 35 | |
Jim Wright | c48551a | 2022-12-22 15:43:14 -0600 | [diff] [blame] | 36 | void UCD90320Monitor::formatGpioValues( |
| 37 | const std::vector<int>& values, unsigned int numberLines, |
| 38 | std::map<std::string, std::string>& additionalData) const |
Jim Wright | 56ae78e | 2021-12-01 14:46:15 -0600 | [diff] [blame] | 39 | { |
Jim Wright | c48551a | 2022-12-22 15:43:14 -0600 | [diff] [blame] | 40 | // Device has 84 GPIO pins so that value is expected |
Jim Wright | c91eed0 | 2022-07-22 11:27:06 -0500 | [diff] [blame] | 41 | if (numberLines == 84 && values.size() >= 84) |
Jim Wright | 213ffe9 | 2022-06-03 08:54:30 -0500 | [diff] [blame] | 42 | { |
| 43 | log<level::INFO>(fmt::format("MAR01-24 GPIO values: {}", |
| 44 | std::span{values}.subspan(0, 24)) |
| 45 | .c_str()); |
| 46 | additionalData.emplace( |
| 47 | "MAR01_24_GPIO_VALUES", |
| 48 | fmt::format("{}", std::span{values}.subspan(0, 24))); |
| 49 | log<level::INFO>(fmt::format("EN1-32 GPIO values: {}", |
| 50 | std::span{values}.subspan(24, 32)) |
| 51 | .c_str()); |
| 52 | additionalData.emplace( |
| 53 | "EN1_32_GPIO_VALUES", |
| 54 | fmt::format("{}", std::span{values}.subspan(24, 32))); |
| 55 | log<level::INFO>(fmt::format("LGP01-16 GPIO values: {}", |
| 56 | std::span{values}.subspan(56, 16)) |
| 57 | .c_str()); |
| 58 | additionalData.emplace( |
| 59 | "LGP01_16_GPIO_VALUES", |
| 60 | fmt::format("{}", std::span{values}.subspan(56, 16))); |
| 61 | log<level::INFO>(fmt::format("DMON1-8 GPIO values: {}", |
| 62 | std::span{values}.subspan(72, 8)) |
| 63 | .c_str()); |
| 64 | additionalData.emplace( |
| 65 | "DMON1_8_GPIO_VALUES", |
| 66 | fmt::format("{}", std::span{values}.subspan(72, 8))); |
| 67 | log<level::INFO>(fmt::format("GPIO1-4 GPIO values: {}", |
| 68 | std::span{values}.subspan(80, 4)) |
| 69 | .c_str()); |
| 70 | additionalData.emplace( |
| 71 | "GPIO1_4_GPIO_VALUES", |
| 72 | fmt::format("{}", std::span{values}.subspan(80, 4))); |
| 73 | } |
| 74 | else |
| 75 | { |
| 76 | log<level::INFO>(fmt::format("GPIO values: {}", values).c_str()); |
| 77 | additionalData.emplace("GPIO_VALUES", fmt::format("{}", values)); |
| 78 | } |
Jim Wright | 71a1413 | 2022-01-28 09:46:46 -0600 | [diff] [blame] | 79 | } |
| 80 | |
Jim Wright | 7945dd2 | 2021-04-06 16:55:15 -0500 | [diff] [blame] | 81 | } // namespace phosphor::power::sequencer |