summaryrefslogtreecommitdiffstats
path: root/src/ssx/occhw/occhw_pba.h
blob: 9346d0d9b163bc6265124c20742991b8ed621fdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/ssx/occhw/occhw_pba.h $                                   */
/*                                                                        */
/* OpenPOWER OnChipController Project                                     */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2016                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef __OCCHW_PBA_H__
#define __OCCHW_PBA_H__

/// \file occhw_pba.h
/// \brief PBA unit header.  Local and mechanically generated macros.

/// \todo Add Doxygen grouping to constant groups

#include "pba_register_addresses.h"
#include "pba_firmware_registers.h"

#include "occhw_pba_common.h"

#define POWERBUS_CACHE_LINE_SIZE 128
#define LOG_POWERBUS_CACHE_LINE_SIZE 7

/// The PBA OCI region is always either 0 or 3
#define PBA_OCI_REGION 0

// It is assumed the the PBA BAR sets will be assigned according to the
// following scheme.  There are still many open questions concerning PBA
// setup.

/// The number of PBA Base Address Registers (BARS)
#define PBA_BARS 4

#define PBA_BAR_CHIP    0
#define PBA_BAR_NODE    2
#define PBA_BAR_SYSTEM  3
#define PBA_BAR_CENTAUR 1

#define PBA_BAR_OCC      0    /* OCC image (HOMER) */
#define PBA_BAR_PORE_SLW 2    /* Redundant mapping for SLW offset into HOMER */

// Standard PBA slave assignments, set up by FAPI procedure prior to releasing
// OCC from reset.

/// The number of PBA slaves
#define PBA_SLAVES 4

#define PBA_SLAVE_PORE_GPE 0    /* GPE0/1, but only 1 can access mainstore */
#define PBA_SLAVE_OCC      1    /* 405 I- and D-cache */
#define PBA_SLAVE_PORE_SLW 2
#define PBA_SLAVE_OCB      3

/// The maximum number of bytes a PBA block-copy engine can transfer at once
#define PBA_BCE_SIZE_MAX 4096

/// The base-2 log of the minimum PBA translation window size in bytes
#define PBA_LOG_SIZE_MIN 20

/// The base-2 log of the maximum PBA translation window size in bytes
///
/// Note that windows > 2**27 bytes require the extended address.
#define PBA_LOG_SIZE_MAX 41

/// The number of PBA slaves
#define PBA_SLAVES 4

/// The number of PBA read buffers
#define PBA_READ_BUFFERS 6

/// The number of PBA write buffers
#define PBA_WRITE_BUFFERS 2

// PBASLVCTLn and PBASLVRST macros defined in occhw_pba_common.h

// PBA PowerBus command scope and priority, and PBA defaults

/// Nodal, Local Node
#define POWERBUS_COMMAND_SCOPE_NODAL 0x0

/// Group, Local 4-chip, (aka, node pump)
#define POWERBUS_COMMAND_SCOPE_GROUP 0x1

/// System,  All units in the system
#define POWERBUS_COMMAND_SCOPE_SYSTEM 0x2

/// RGP, All units in the system (aka, system pump)
#define POWERBUS_COMMAND_SCOPE_RGP 0x3

/// Foreign, All units on the local chip, local SMP, and remote chip (pivot
/// nodes), In P8, only 100 and 101 are valid.
#define POWERBUS_COMMAND_SCOPE_FOREIGN0 0x4

/// Foreign, All units on the local chip, local SMP, and remote chip (pivot
/// nodes), In P8, only 100 and 101 are valid.
#define POWERBUS_COMMAND_SCOPE_FOREIGN1 0x5


/// Default command scope for BCDE/BCUE transfers
#define PBA_POWERBUS_COMMAND_SCOPE_DEFAULT POWERBUS_COMMAND_SCOPE_NODAL

// PBA Error/Panic codes

#define PBA_SCOM_ERROR1                    0x00722001
#define PBA_SCOM_ERROR2                    0x00722002
#define PBA_SLVRST_TIMED_OUT1              0x00722003
#define PBA_SLVRST_TIMED_OUT2              0x00722004
#define PBA_INVALID_ARGUMENT_BARSET        0x00779005
#define PBA_INVALID_ARGUMENT_RESET         0x00779006
#define PBAX_INVALID_ARGUMENT_CONFIG       0x00779007
#define PBAX_INVALID_ARGUMENT_TARGET       0x00779008
#define PBAX_INVALID_OBJECT                0x00722009

#ifndef __ASSEMBLER__

/// The PBA extended address in the form of a 'firmware register'
///
/// The extended address covers only bits 23:36 of the 50-bit PowerBus address.

typedef union pba_extended_address
{

    uint64_t value;
    uint32_t word[2];
    struct
    {
        uint64_t reserved0        : 23;
        uint64_t extended_address : 14;
        uint64_t reserved1        : 27;
    } fields;
} pba_extended_address_t;


int
pba_barset_initialize(int idx, uint64_t base, int log_size);

int
_pba_slave_reset(int id, SsxInterval timeout, SsxInterval sleep);

int
pba_slave_reset(int id);


////////////////////////////////////////////////////////////////////////////
// PBAX
////////////////////////////////////////////////////////////////////////////

// PBAX error/panic codes

#define PBAX_SEND_TIMEOUT  0x00722901
#define PBAX_SEND_ERROR    0x00722902
#define PBAX_RECEIVE_ERROR 0x00722903

/// The number of receive queues implemented by PBAX
#define PBAX_QUEUES 2

/// The number of PBAX Node Ids
#define PBAX_GROUPS 16

/// The number of PBAX Chip Ids (and group Ids)
#define PBAX_CHIPS 8

/// The maximum legal PBAX group mask
#define PBAX_GROUP_MASK_MAX 0xff

// PBAX Send Message Scope

#define PBAX_GROUP  3
#define PBAX_SYSTEM 5

// PBAX Send Type

#define PBAX_UNICAST   0
#define PBAX_BROADCAST 1

// Default timeout for pbax_send()

#ifndef PBAX_SEND_DEFAULT_TIMEOUT
    #define PBAX_SEND_DEFAULT_TIMEOUT SSX_MICROSECONDS(30)
#endif

/// An abstract target for PBAX send operations
///
/// This structure contains an abstraction of a communication target for PBAX
/// send operations.  An application using PBAX to transmit data first creates
/// an instance of the PbaxTarget for each abstract target using
/// pbax_target_create(), then calls pbax_send() or _pbax_send() with a
/// PbaxTarget and an 8-byte data packet to effect a transmission.
///
/// For applications that use GPE programs to implement PBAX sends, a pointer
/// to this object could also be passed to the GPE program.

typedef struct
{

    /// The abstract target
    ///
    /// pbax_target_create() condenses the target parameters into a copy of
    /// the PBAXSNDTX register used to configure the transmission.
    pba_xsndtx_t target;

} PbaxTarget;


int
pbax_target_create(PbaxTarget* target,
                   int type, int scope, int queue,
                   int node, int chip_or_group, int cnt);

int
pbax_configure(int master, int node, int chip, int group_mask);

int
_pbax_send(PbaxTarget* target, uint64_t data, SsxInterval timeout);

int
pbax_send(PbaxTarget* target, uint64_t data);

/// Enable the PBAX send mechanism

static inline void
pbax_send_enable(void)
{
    pba_xcfg_t pxc;

    pxc.words.high_order = in32(PBA_XCFG);
    pxc.fields.pbax_en = 1;
    out32(PBA_XCFG, pxc.words.high_order);

}


/// Disable the PBAX send mechanism

static inline void
pbax_send_disable(void)
{
    pba_xcfg_t pxc;

    pxc.words.high_order = in32(PBA_XCFG);
    pxc.fields.pbax_en = 0;
    out32(PBA_XCFG, pxc.words.high_order);

}


/// Clear the PBAX send error condition

static inline void
pbax_clear_send_error(void)
{
    pba_xcfg_t pxc;

    pxc.words.high_order = in32(PBA_XCFG);
    pxc.fields.snd_reset = 1;
    out32(PBA_XCFG, pxc.words.high_order);
}


/// Clear the PBAX receive error condition

static inline void
pbax_clear_receive_error(void)
{
    pba_xcfg_t pxc;

    pxc.words.high_order = in32(PBA_XCFG);
    pxc.fields.rcv_reset = 1;
    out32(PBA_XCFG, pxc.words.high_order);
}

#endif /* __ASSEMBLER__ */

#endif  /* __OCCHW_PBA_H__ */
OpenPOWER on IntegriCloud