Anthony Wilson | 7052f71 | 2018-11-07 22:53:11 -0600 | [diff] [blame] | 1 | /** |
| 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 Wilson | aa2030c | 2019-03-26 17:05:50 -0500 | [diff] [blame^] | 22 | #include <xyz/openbmc_project/Common/File/error.hpp> |
Anthony Wilson | 7052f71 | 2018-11-07 22:53:11 -0600 | [diff] [blame] | 23 | |
| 24 | namespace openpower |
| 25 | { |
| 26 | namespace p9 |
| 27 | { |
| 28 | |
| 29 | using namespace phosphor::logging; |
| 30 | using namespace openpower::cfam::access; |
| 31 | using namespace openpower::cfam::p9; |
| 32 | using namespace openpower::targeting; |
Anthony Wilson | aa2030c | 2019-03-26 17:05:50 -0500 | [diff] [blame^] | 33 | namespace file_error = sdbusplus::xyz::openbmc_project::Common::File::Error; |
Anthony Wilson | 7052f71 | 2018-11-07 22:53:11 -0600 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * @brief Disables PCIE drivers and receiver in the PCIE root ctrl 1 register |
| 37 | * @return void |
| 38 | */ |
| 39 | void cleanupPcie() |
| 40 | { |
Anthony Wilson | aa2030c | 2019-03-26 17:05:50 -0500 | [diff] [blame^] | 41 | try |
Anthony Wilson | 5970484 | 2018-11-07 23:00:21 -0600 | [diff] [blame] | 42 | { |
Anthony Wilson | aa2030c | 2019-03-26 17:05:50 -0500 | [diff] [blame^] | 43 | 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 Spinler | a27263d | 2019-02-05 10:20:19 -0600 | [diff] [blame] | 49 | { |
Anthony Wilson | aa2030c | 2019-03-26 17:05:50 -0500 | [diff] [blame^] | 50 | 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 Spinler | a27263d | 2019-02-05 10:20:19 -0600 | [diff] [blame] | 60 | } |
Anthony Wilson | aa2030c | 2019-03-26 17:05:50 -0500 | [diff] [blame^] | 61 | } |
| 62 | catch (file_error::Open& e) |
| 63 | { |
| 64 | // For this procedure we can ignore the ::Open error |
Anthony Wilson | 5970484 | 2018-11-07 23:00:21 -0600 | [diff] [blame] | 65 | } |
Anthony Wilson | 7052f71 | 2018-11-07 22:53:11 -0600 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | REGISTER_PROCEDURE("cleanupPcie", cleanupPcie); |
| 69 | |
| 70 | } // namespace p9 |
| 71 | } // namespace openpower |