blob: 2625888aea5fa922dc35aabd92c26636ad32b815 [file] [log] [blame]
Matt Spinlerf716f322017-02-28 09:37:38 -06001/**
Patrick Venturee84b4dd2018-11-01 16:06:31 -07002 * Copyright (C) 2017 IBM Corporation
Matt Spinlerf716f322017-02-28 09:37:38 -06003 *
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 Spinler6419b632017-02-28 10:10:50 -060016#include "cfam_access.hpp"
Patrick Venturef78d9042018-11-01 15:39:53 -070017#include "ext_interface.hpp"
Matt Spinler6419b632017-02-28 10:10:50 -060018#include "p9_cfam.hpp"
Matt Spinlerd9bdcf72017-03-09 15:06:23 -060019#include "registration.hpp"
Matt Spinler6419b632017-02-28 10:10:50 -060020#include "targeting.hpp"
Patrick Venturef78d9042018-11-01 15:39:53 -070021
22#include <phosphor-logging/log.hpp>
Matt Spinler6419b632017-02-28 10:10:50 -060023
Matt Spinlerf716f322017-02-28 09:37:38 -060024namespace openpower
25{
26namespace p9
27{
28
Matt Spinler6419b632017-02-28 10:10:50 -060029using namespace phosphor::logging;
30using namespace openpower::cfam::access;
31using namespace openpower::cfam::p9;
32using namespace openpower::targeting;
33
Matt Spinler83e37322017-03-09 11:23:17 -060034/**
35 * @brief Starts the self boot engine on P9 position 0 to kick off a boot.
36 * @return void
37 */
Matt Spinlerf716f322017-02-28 09:37:38 -060038void startHost()
39{
Matt Spinler6419b632017-02-28 10:10:50 -060040 Targeting targets;
41 const auto& master = *(targets.begin());
Matt Spinlerf716f322017-02-28 09:37:38 -060042
Matt Spinler6419b632017-02-28 10:10:50 -060043 log<level::INFO>("Running P9 procedure startHost",
44 entry("NUM_PROCS=%d", targets.size()));
45
Patrick Venturef78d9042018-11-01 15:39:53 -070046 // Ensure asynchronous clock mode is set
Matt Spinler6419b632017-02-28 10:10:50 -060047 writeReg(master, P9_LL_MODE_REG, 0x00000001);
48
Patrick Venturef78d9042018-11-01 15:39:53 -070049 // Clock mux select override
Matt Spinler6419b632017-02-28 10:10:50 -060050 for (const auto& t : targets)
51 {
Patrick Venturef78d9042018-11-01 15:39:53 -070052 writeRegWithMask(t, P9_ROOT_CTRL8, 0x0000000C, 0x0000000C);
Matt Spinler6419b632017-02-28 10:10:50 -060053 }
54
Patrick Venturef78d9042018-11-01 15:39:53 -070055 // Enable P9 checkstop to be reported to the BMC
Matt Spinler6419b632017-02-28 10:10:50 -060056
Patrick Venturef78d9042018-11-01 15:39:53 -070057 // Setup FSI2PIB to report checkstop
Matt Spinler6419b632017-02-28 10:10:50 -060058 writeReg(master, P9_FSI_A_SI1S, 0x20000000);
59
Patrick Venturef78d9042018-11-01 15:39:53 -070060 // Enable Xstop/ATTN interrupt
Matt Spinler6419b632017-02-28 10:10:50 -060061 writeReg(master, P9_FSI2PIB_TRUE_MASK, 0x60000000);
62
Patrick Venturef78d9042018-11-01 15:39:53 -070063 // Arm it
Matt Spinler6419b632017-02-28 10:10:50 -060064 writeReg(master, P9_FSI2PIB_INTERRUPT, 0xFFFFFFFF);
65
Patrick Venturef78d9042018-11-01 15:39:53 -070066 // Kick off the SBE to start the boot
Matt Spinler6419b632017-02-28 10:10:50 -060067
Andrew Geissler2548c7a2017-05-18 15:35:40 -050068 // Choose seeprom side to boot from
69 cfam_data_t sbeSide = 0;
Patrick Venturef78d9042018-11-01 15:39:53 -070070 if (getBootCount() > 0)
Andrew Geissler2548c7a2017-05-18 15:35:40 -050071 {
72 sbeSide = 0;
73 log<level::INFO>("Setting SBE seeprom side to 0",
Patrick Venturef78d9042018-11-01 15:39:53 -070074 entry("SBE_SIDE_SELECT=%d", 0));
Andrew Geissler2548c7a2017-05-18 15:35:40 -050075 }
76 else
77 {
78 sbeSide = 0x00004000;
79 log<level::INFO>("Setting SBE seeprom side to 1",
Patrick Venturef78d9042018-11-01 15:39:53 -070080 entry("SBE_SIDE_SELECT=%d", 1));
Andrew Geissler2548c7a2017-05-18 15:35:40 -050081 }
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 Geisslered212d52020-01-31 11:02:35 -060086 // Ensure SBE start bit is 0 to handle warm reboot scenarios
87 writeRegWithMask(master, P9_CBS_CS, 0x00000000, 0x80000000);
88
Patrick Venturef78d9042018-11-01 15:39:53 -070089 // Start the SBE
Matt Spinler6419b632017-02-28 10:10:50 -060090 writeRegWithMask(master, P9_CBS_CS, 0x80000000, 0x80000000);
Matt Spinlerf716f322017-02-28 09:37:38 -060091}
92
Matt Spinlerd9bdcf72017-03-09 15:06:23 -060093REGISTER_PROCEDURE("startHost", startHost);
Matt Spinlerf716f322017-02-28 09:37:38 -060094
Patrick Venturef78d9042018-11-01 15:39:53 -070095} // namespace p9
96} // namespace openpower