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" |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 17 | #include "ext_interface.hpp" |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 18 | #include "p9_cfam.hpp" |
Matt Spinler | d9bdcf7 | 2017-03-09 15:06:23 -0600 | [diff] [blame] | 19 | #include "registration.hpp" |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 20 | #include "targeting.hpp" |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 21 | |
| 22 | #include <phosphor-logging/log.hpp> |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 23 | |
Matt Spinler | f716f32 | 2017-02-28 09:37:38 -0600 | [diff] [blame] | 24 | namespace openpower |
| 25 | { |
| 26 | namespace p9 |
| 27 | { |
| 28 | |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 29 | using namespace phosphor::logging; |
| 30 | using namespace openpower::cfam::access; |
| 31 | using namespace openpower::cfam::p9; |
| 32 | using namespace openpower::targeting; |
| 33 | |
Matt Spinler | 83e3732 | 2017-03-09 11:23:17 -0600 | [diff] [blame] | 34 | /** |
| 35 | * @brief Starts the self boot engine on P9 position 0 to kick off a boot. |
| 36 | * @return void |
| 37 | */ |
Matt Spinler | f716f32 | 2017-02-28 09:37:38 -0600 | [diff] [blame] | 38 | void startHost() |
| 39 | { |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 40 | Targeting targets; |
| 41 | const auto& master = *(targets.begin()); |
Matt Spinler | f716f32 | 2017-02-28 09:37:38 -0600 | [diff] [blame] | 42 | |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 43 | log<level::INFO>("Running P9 procedure startHost", |
| 44 | entry("NUM_PROCS=%d", targets.size())); |
| 45 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 46 | // Ensure asynchronous clock mode is set |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 47 | writeReg(master, P9_LL_MODE_REG, 0x00000001); |
| 48 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 49 | // Clock mux select override |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 50 | for (const auto& t : targets) |
| 51 | { |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 52 | writeRegWithMask(t, P9_ROOT_CTRL8, 0x0000000C, 0x0000000C); |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 53 | } |
| 54 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 55 | // Enable P9 checkstop to be reported to the BMC |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 56 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 57 | // Setup FSI2PIB to report checkstop |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 58 | writeReg(master, P9_FSI_A_SI1S, 0x20000000); |
| 59 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 60 | // Enable Xstop/ATTN interrupt |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 61 | writeReg(master, P9_FSI2PIB_TRUE_MASK, 0x60000000); |
| 62 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 63 | // Arm it |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 64 | writeReg(master, P9_FSI2PIB_INTERRUPT, 0xFFFFFFFF); |
| 65 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 66 | // Kick off the SBE to start the boot |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 67 | |
Andrew Geissler | 2548c7a | 2017-05-18 15:35:40 -0500 | [diff] [blame] | 68 | // Choose seeprom side to boot from |
| 69 | cfam_data_t sbeSide = 0; |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 70 | if (getBootCount() > 0) |
Andrew Geissler | 2548c7a | 2017-05-18 15:35:40 -0500 | [diff] [blame] | 71 | { |
| 72 | sbeSide = 0; |
| 73 | log<level::INFO>("Setting SBE seeprom side to 0", |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 74 | entry("SBE_SIDE_SELECT=%d", 0)); |
Andrew Geissler | 2548c7a | 2017-05-18 15:35:40 -0500 | [diff] [blame] | 75 | } |
| 76 | else |
| 77 | { |
| 78 | sbeSide = 0x00004000; |
| 79 | log<level::INFO>("Setting SBE seeprom side to 1", |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 80 | entry("SBE_SIDE_SELECT=%d", 1)); |
Andrew Geissler | 2548c7a | 2017-05-18 15:35:40 -0500 | [diff] [blame] | 81 | } |
| 82 | // Bit 17 of the ctrl status reg indicates sbe seeprom boot side |
| 83 | // 0 -> Side 0, 1 -> Side 1 |
| 84 | writeRegWithMask(master, P9_SBE_CTRL_STATUS, sbeSide, 0x00004000); |
| 85 | |
Andrew Geissler | ed212d5 | 2020-01-31 11:02:35 -0600 | [diff] [blame^] | 86 | // Ensure SBE start bit is 0 to handle warm reboot scenarios |
| 87 | writeRegWithMask(master, P9_CBS_CS, 0x00000000, 0x80000000); |
| 88 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 89 | // Start the SBE |
Matt Spinler | 6419b63 | 2017-02-28 10:10:50 -0600 | [diff] [blame] | 90 | writeRegWithMask(master, P9_CBS_CS, 0x80000000, 0x80000000); |
Matt Spinler | f716f32 | 2017-02-28 09:37:38 -0600 | [diff] [blame] | 91 | } |
| 92 | |
Matt Spinler | d9bdcf7 | 2017-03-09 15:06:23 -0600 | [diff] [blame] | 93 | REGISTER_PROCEDURE("startHost", startHost); |
Matt Spinler | f716f32 | 2017-02-28 09:37:38 -0600 | [diff] [blame] | 94 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 95 | } // namespace p9 |
| 96 | } // namespace openpower |