blob: 68b6649f5845a96025db2d7cb09da3b86b524667 [file] [log] [blame]
Anthony Wilson7052f712018-11-07 22:53:11 -06001/**
2 * Copyright (C) 2018 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 "cfam_access.hpp"
17#include "p9_cfam.hpp"
18#include "registration.hpp"
19#include "targeting.hpp"
20
21#include <phosphor-logging/log.hpp>
Anthony Wilsonaa2030c2019-03-26 17:05:50 -050022#include <xyz/openbmc_project/Common/File/error.hpp>
Anthony Wilson7052f712018-11-07 22:53:11 -060023
24namespace openpower
25{
26namespace p9
27{
28
29using namespace phosphor::logging;
30using namespace openpower::cfam::access;
31using namespace openpower::cfam::p9;
32using namespace openpower::targeting;
Anthony Wilsonaa2030c2019-03-26 17:05:50 -050033namespace file_error = sdbusplus::xyz::openbmc_project::Common::File::Error;
Anthony Wilson7052f712018-11-07 22:53:11 -060034
35/**
36 * @brief Disables PCIE drivers and receiver in the PCIE root ctrl 1 register
37 * @return void
38 */
39void cleanupPcie()
40{
Anthony Wilsonaa2030c2019-03-26 17:05:50 -050041 try
Anthony Wilson59704842018-11-07 23:00:21 -060042 {
Anthony Wilsonaa2030c2019-03-26 17:05:50 -050043 Targeting targets;
44
45 log<level::INFO>("Running P9 procedure cleanupPcie");
46
47 // Disable the PCIE drivers and receiver on all CPUs
48 for (const auto& target : targets)
Matt Spinlera27263d2019-02-05 10:20:19 -060049 {
Anthony Wilsonaa2030c2019-03-26 17:05:50 -050050 try
51 {
52 writeReg(target, P9_ROOT_CTRL1_CLEAR, 0x00001C00);
53 }
54 catch (std::exception& e)
55 {
56 // Don't need an error log coming from the power off
57 // path, just keep trying on the other processors.
58 continue;
59 }
Matt Spinlera27263d2019-02-05 10:20:19 -060060 }
Anthony Wilsonaa2030c2019-03-26 17:05:50 -050061 }
62 catch (file_error::Open& e)
63 {
64 // For this procedure we can ignore the ::Open error
Anthony Wilson59704842018-11-07 23:00:21 -060065 }
Anthony Wilson7052f712018-11-07 22:53:11 -060066}
67
68REGISTER_PROCEDURE("cleanupPcie", cleanupPcie);
69
70} // namespace p9
71} // namespace openpower