blob: 425c20e634b334f91e588c62c08fd5e7a92dda63 [file] [log] [blame]
Shawn McCarneydb0b8332020-04-06 14:13:04 -05001/**
2 * Copyright © 2020 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 "chassis.hpp"
18
Shawn McCarney525e20c2020-04-14 11:05:39 -050019#include "system.hpp"
20
Shawn McCarneydb0b8332020-04-06 14:13:04 -050021namespace phosphor::power::regulators
22{
23
24void Chassis::addToIDMap(IDMap& idMap)
25{
26 // Add devices and their rails to the map
27 for (std::unique_ptr<Device>& device : devices)
28 {
29 device->addToIDMap(idMap);
30 }
31}
32
Shawn McCarney9bd94d32021-01-25 19:40:42 -060033void Chassis::clearCache()
34{
35 // Clear any cached data in each device
36 for (std::unique_ptr<Device>& device : devices)
37 {
38 device->clearCache();
39 }
40}
41
Shawn McCarney9f3e54e2021-05-14 14:56:13 -050042void Chassis::clearErrorHistory()
43{
44 // Clear error history in each device
45 for (std::unique_ptr<Device>& device : devices)
46 {
47 device->clearErrorHistory();
48 }
49}
50
Bob Kingd692d6d2020-09-14 13:42:57 +080051void Chassis::closeDevices(Services& services)
Shawn McCarney050531f2020-06-02 14:17:12 -050052{
53 // Log debug message in journal
Bob Kingd692d6d2020-09-14 13:42:57 +080054 services.getJournal().logDebug("Closing devices in chassis " +
55 std::to_string(number));
Shawn McCarney050531f2020-06-02 14:17:12 -050056
57 // Close devices
58 for (std::unique_ptr<Device>& device : devices)
59 {
Bob Kingd692d6d2020-09-14 13:42:57 +080060 device->close(services);
Shawn McCarney050531f2020-06-02 14:17:12 -050061 }
62}
63
Bob King23243f82020-07-29 10:38:57 +080064void Chassis::configure(Services& services, System& system)
Shawn McCarney525e20c2020-04-14 11:05:39 -050065{
66 // Log info message in journal; important for verifying success of boot
Bob King5cfe5102020-07-30 16:26:18 +080067 services.getJournal().logInfo("Configuring chassis " +
68 std::to_string(number));
Shawn McCarney525e20c2020-04-14 11:05:39 -050069
70 // Configure devices
71 for (std::unique_ptr<Device>& device : devices)
72 {
Bob King23243f82020-07-29 10:38:57 +080073 device->configure(services, system, *this);
Shawn McCarney525e20c2020-04-14 11:05:39 -050074 }
75}
76
Bob King8a552922020-08-05 17:02:31 +080077void Chassis::monitorSensors(Services& services, System& system)
Bob Kinga2c81a62020-07-08 13:31:16 +080078{
79 // Monitor sensors in each device
80 for (std::unique_ptr<Device>& device : devices)
81 {
Bob King8a552922020-08-05 17:02:31 +080082 device->monitorSensors(services, system, *this);
Bob Kinga2c81a62020-07-08 13:31:16 +080083 }
84}
85
Shawn McCarneydb0b8332020-04-06 14:13:04 -050086} // namespace phosphor::power::regulators