Matt Spinler | f716f32 | 2017-02-28 09:37:38 -0600 | [diff] [blame] | 1 | /** |
Patrick Venture | e84b4dd | 2018-11-01 16:06:31 -0700 | [diff] [blame] | 2 | * Copyright (C) 2017 IBM Corporation |
Matt Spinler | f716f32 | 2017-02-28 09:37:38 -0600 | [diff] [blame] | 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 | */ |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 16 | #include "cfam_access.hpp" |
| 17 | #include "p9_cfam.hpp" |
Matt Spinler | d9bdcf7 | 2017-03-09 15:06:23 -0600 | [diff] [blame] | 18 | #include "registration.hpp" |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 19 | #include "targeting.hpp" |
| 20 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 21 | #include <phosphor-logging/log.hpp> |
| 22 | |
Matt Spinler | f716f32 | 2017-02-28 09:37:38 -0600 | [diff] [blame] | 23 | namespace openpower |
| 24 | { |
| 25 | namespace p9 |
| 26 | { |
| 27 | |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 28 | using namespace phosphor::logging; |
| 29 | using namespace openpower::cfam::access; |
| 30 | using namespace openpower::cfam::p9; |
| 31 | using namespace openpower::targeting; |
| 32 | |
Matt Spinler | 83e3732 | 2017-03-09 11:23:17 -0600 | [diff] [blame] | 33 | /** |
| 34 | * @brief Performs the 'VCS Workaround' on all P9s in the system. |
| 35 | * @return void |
| 36 | */ |
Matt Spinler | f716f32 | 2017-02-28 09:37:38 -0600 | [diff] [blame] | 37 | void vcsWorkaround() |
| 38 | { |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 39 | Targeting targets; |
| 40 | const auto& master = *(targets.begin()); |
Matt Spinler | f716f32 | 2017-02-28 09:37:38 -0600 | [diff] [blame] | 41 | |
Andrew Geissler | 16e099a | 2017-06-08 15:36:09 -0500 | [diff] [blame] | 42 | // First determine if we need to run this workaround (not needed on chips |
| 43 | // which are not DD1.0) |
| 44 | // Mixing DD1.0 parts with other levels is not allowed so just look |
| 45 | // at the first chip |
| 46 | auto chipID = readReg(master, P9_FSI2PIB_CHIPID); |
| 47 | if (chipID != P9_DD10_CHIPID) |
| 48 | { |
| 49 | log<level::INFO>("P9 procedure vcsWorkaround not needed", |
| 50 | entry("CHIPID=0x%08X", chipID)); |
| 51 | return; |
| 52 | } |
| 53 | |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 54 | log<level::INFO>("Running P9 procedure vcsWorkaround", |
| 55 | entry("NUM_PROCS=%d", targets.size())); |
| 56 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 57 | // Set asynchronous clock mode |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 58 | writeReg(master, P9_LL_MODE_REG, 0x00000001); |
| 59 | |
| 60 | for (const auto& t : targets) |
| 61 | { |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 62 | // Unfence PLL controls |
| 63 | writeRegWithMask(t, P9_ROOT_CTRL0, 0x00000000, 0x00010000); |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 64 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 65 | // Assert Perv chiplet endpoint reset |
| 66 | writeRegWithMask(t, P9_PERV_CTRL0, 0x40000000, 0x40000000); |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 67 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 68 | // Enable Nest PLL |
| 69 | writeRegWithMask(t, P9_PERV_CTRL0, 0x00000001, 0x00000001); |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 70 | } |
Matt Spinler | f716f32 | 2017-02-28 09:37:38 -0600 | [diff] [blame] | 71 | } |
| 72 | |
Matt Spinler | d9bdcf7 | 2017-03-09 15:06:23 -0600 | [diff] [blame] | 73 | REGISTER_PROCEDURE("vcsWorkaround", vcsWorkaround); |
| 74 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 75 | } // namespace p9 |
| 76 | } // namespace openpower |