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> 22 #include <xyz/openbmc_project/Common/File/error.hpp> 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; 33 namespace file_error = sdbusplus::xyz::openbmc_project::Common::File::Error; 34 35 /** 36 * @brief Disables PCIE drivers and receiver in the PCIE root ctrl 1 register 37 * @return void 38 */ 39 void cleanupPcie() 40 { 41 try 42 { 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) 49 { 50 try 51 { 52 writeReg(target, P9_ROOT_CTRL1_CLEAR, 0x00001C00); 53 } 54 catch (const 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 } 60 } 61 } 62 catch (const file_error::Open& e) 63 { 64 // For this procedure we can ignore the ::Open error 65 } 66 } 67 68 REGISTER_PROCEDURE("cleanupPcie", cleanupPcie) 69 70 } // namespace p9 71 } // namespace openpower 72