blob: 188fec052356ada4c07eaf189e82782378aa4883 [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"
19#include "targeting.hpp"
20
Matt Spinlerf716f322017-02-28 09:37:38 -060021namespace openpower
22{
23namespace p9
24{
25
Matt Spinler6419b632017-02-28 10:10:50 -060026using namespace phosphor::logging;
27using namespace openpower::cfam::access;
28using namespace openpower::cfam::p9;
29using namespace openpower::targeting;
30
Matt Spinlerf716f322017-02-28 09:37:38 -060031void startHost()
32{
Matt Spinler6419b632017-02-28 10:10:50 -060033 Targeting targets;
34 const auto& master = *(targets.begin());
Matt Spinlerf716f322017-02-28 09:37:38 -060035
Matt Spinler6419b632017-02-28 10:10:50 -060036 log<level::INFO>("Running P9 procedure startHost",
37 entry("NUM_PROCS=%d", targets.size()));
38
39
40 //Ensure asynchronous clock mode is set
41 writeReg(master, P9_LL_MODE_REG, 0x00000001);
42
43 //Clock mux select override
44 for (const auto& t : targets)
45 {
46 writeRegWithMask(t, P9_ROOT_CTRL8,
47 0x0000000C, 0x0000000C);
48 }
49
50 //Enable P9 checkstop to be reported to the BMC
51
52 //Setup FSI2PIB to report checkstop
53 writeReg(master, P9_FSI_A_SI1S, 0x20000000);
54
55 //Enable Xstop/ATTN interrupt
56 writeReg(master, P9_FSI2PIB_TRUE_MASK, 0x60000000);
57
58 //Arm it
59 writeReg(master, P9_FSI2PIB_INTERRUPT, 0xFFFFFFFF);
60
61 //Kick off the SBE to start the boot
62
63 //First ensure ISTEP stepping isn't enabled
64 writeReg(master, P9_SCRATCH_REGISTER_8, 0x20000000);
65
66 //Start the SBE
67 writeRegWithMask(master, P9_CBS_CS, 0x80000000, 0x80000000);
Matt Spinlerf716f322017-02-28 09:37:38 -060068}
69
70
71void vcsWorkaround()
72{
Matt Spinler6419b632017-02-28 10:10:50 -060073 Targeting targets;
74 const auto& master = *(targets.begin());
Matt Spinlerf716f322017-02-28 09:37:38 -060075
Matt Spinler6419b632017-02-28 10:10:50 -060076 log<level::INFO>("Running P9 procedure vcsWorkaround",
77 entry("NUM_PROCS=%d", targets.size()));
78
79 //Set asynchronous clock mode
80 writeReg(master, P9_LL_MODE_REG, 0x00000001);
81
82 for (const auto& t : targets)
83 {
84 //Unfence PLL controls
85 writeRegWithMask(t, P9_ROOT_CTRL0,
86 0x00000000, 0x00010000);
87
88 //Assert Perv chiplet endpoint reset
89 writeRegWithMask(t, P9_PERV_CTRL0,
90 0x40000000, 0x40000000);
91
92 //Enable Nest PLL
93 writeRegWithMask(t, P9_PERV_CTRL0,
94 0x00000001, 0x00000001);
95 }
Matt Spinlerf716f322017-02-28 09:37:38 -060096}
97
98}
99}