blob: 3049eac2fd64185fbbbbc78fe5d308f73e953f2d [file] [log] [blame]
Matt Spinlerf716f322017-02-28 09:37:38 -06001/**
2 * Copyright © 2017 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 */
Matt Spinler6419b632017-02-28 10:10:50 -060016#include <phosphor-logging/log.hpp>
17#include "cfam_access.hpp"
18#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"
Andrew Geissler2548c7a2017-05-18 15:35:40 -050021#include "ext_interface.hpp"
Matt Spinler6419b632017-02-28 10:10:50 -060022
Matt Spinlerf716f322017-02-28 09:37:38 -060023namespace openpower
24{
25namespace p9
26{
27
Matt Spinler6419b632017-02-28 10:10:50 -060028using namespace phosphor::logging;
29using namespace openpower::cfam::access;
30using namespace openpower::cfam::p9;
31using namespace openpower::targeting;
32
Matt Spinler83e37322017-03-09 11:23:17 -060033
34/**
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
Matt Spinler6419b632017-02-28 10:10:50 -060046 //Ensure asynchronous clock mode is set
47 writeReg(master, P9_LL_MODE_REG, 0x00000001);
48
49 //Clock mux select override
50 for (const auto& t : targets)
51 {
52 writeRegWithMask(t, P9_ROOT_CTRL8,
53 0x0000000C, 0x0000000C);
54 }
55
56 //Enable P9 checkstop to be reported to the BMC
57
58 //Setup FSI2PIB to report checkstop
59 writeReg(master, P9_FSI_A_SI1S, 0x20000000);
60
61 //Enable Xstop/ATTN interrupt
62 writeReg(master, P9_FSI2PIB_TRUE_MASK, 0x60000000);
63
64 //Arm it
65 writeReg(master, P9_FSI2PIB_INTERRUPT, 0xFFFFFFFF);
66
67 //Kick off the SBE to start the boot
68
Andrew Geissler2548c7a2017-05-18 15:35:40 -050069 // Choose seeprom side to boot from
70 cfam_data_t sbeSide = 0;
71 if(getBootCount() > 1)
72 {
73 sbeSide = 0;
74 log<level::INFO>("Setting SBE seeprom side to 0",
75 entry("SBE_SIDE_SELECT=%d", 0));
76 }
77 else
78 {
79 sbeSide = 0x00004000;
80 log<level::INFO>("Setting SBE seeprom side to 1",
81 entry("SBE_SIDE_SELECT=%d", 1));
82 }
83 // Bit 17 of the ctrl status reg indicates sbe seeprom boot side
84 // 0 -> Side 0, 1 -> Side 1
85 writeRegWithMask(master, P9_SBE_CTRL_STATUS, sbeSide, 0x00004000);
86
87 //Ensure ISTEP stepping isn't enabled
Michael Tritzbe407162017-03-30 16:52:24 -050088 writeRegWithMask(master, P9_SCRATCH_REGISTER_8, 0x20000000, 0x20000000);
Matt Spinler6419b632017-02-28 10:10:50 -060089
90 //Start the SBE
91 writeRegWithMask(master, P9_CBS_CS, 0x80000000, 0x80000000);
Matt Spinlerf716f322017-02-28 09:37:38 -060092}
93
Matt Spinlerd9bdcf72017-03-09 15:06:23 -060094REGISTER_PROCEDURE("startHost", startHost);
Matt Spinlerf716f322017-02-28 09:37:38 -060095
Matt Spinlerf716f322017-02-28 09:37:38 -060096}
97}