summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/freescale/sdk_fman/inc/cores/e500v2_ext.h
blob: e79b1ddff1213a03e4e5fd5aa54a116014c937c1 (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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
/*
 * Copyright 2008-2012 Freescale Semiconductor Inc.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of Freescale Semiconductor nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 *
 * ALTERNATIVELY, this software may be distributed under the terms of the
 * GNU General Public License ("GPL") as published by the Free Software
 * Foundation, either version 2 of that License or (at your option) any
 * later version.
 *
 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


/**************************************************************************//**
 @File          e500v2_ext.h

 @Description   E500 external definitions prototypes
                This file is not included by the E500
                source file as it is an assembly file. It is used
                only for prototypes exposure, for inclusion
                by user and other modules.
*//***************************************************************************/

#ifndef __E500V2_EXT_H
#define __E500V2_EXT_H

#include "std_ext.h"


/* Layer 1 Cache Manipulations
 *==============================
 * Should not be called directly by the user.
 */
void        L1DCache_Invalidate (void);
void        L1ICache_Invalidate(void);
void        L1DCache_Enable(void);
void        L1ICache_Enable(void);
void        L1DCache_Disable(void);
void        L1ICache_Disable(void);
void        L1DCache_Flush(void);
void        L1ICache_Flush(void);
uint32_t    L1ICache_IsEnabled(void);
uint32_t    L1DCache_IsEnabled(void);
/*
 *
 */
uint32_t    L1DCache_LineLock(uint32_t addr);
uint32_t    L1ICache_LineLock(uint32_t addr);
void        L1Cache_BroadCastEnable(void);
void        L1Cache_BroadCastDisable(void);


#define CORE_DCacheEnable       E500_DCacheEnable
#define CORE_ICacheEnable       E500_ICacheEnable
#define CORE_DCacheDisable      E500_DCacheDisable
#define CORE_ICacheDisable      E500_ICacheDisable
#define CORE_GetId              E500_GetId
#define CORE_TestAndSet         E500_TestAndSet
#define CORE_MemoryBarrier      E500_MemoryBarrier
#define CORE_InstructionSync    E500_InstructionSync

#define CORE_SetDozeMode        E500_SetDozeMode
#define CORE_SetNapMode         E500_SetNapMode
#define CORE_SetSleepMode       E500_SetSleepMode
#define CORE_SetJogMode         E500_SetJogMode
#define CORE_SetDeepSleepMode   E500_SetDeepSleepMode

#define CORE_RecoverDozeMode    E500_RecoverDozeMode
#define CORE_RecoverNapMode     E500_RecoverNapMode
#define CORE_RecoverSleepMode   E500_RecoverSleepMode
#define CORE_RecoverJogMode     E500_RecoverJogMode

void E500_SetDozeMode(void);
void E500_SetNapMode(void);
void E500_SetSleepMode(void);
void E500_SetJogMode(void);
t_Error E500_SetDeepSleepMode(uint32_t bptrAddress);

void E500_RecoverDozeMode(void);
void E500_RecoverNapMode(void);
void E500_RecoverSleepMode(void);
void E500_RecoverJogMode(void);


/**************************************************************************//**
 @Group         E500_id E500 Application Programming Interface

 @Description   E500 API functions, definitions and enums

 @{
*//***************************************************************************/

/**************************************************************************//**
 @Group         E500_init_grp E500 Initialization Unit

 @Description   E500 initialization unit API functions, definitions and enums

 @{
*//***************************************************************************/


/**************************************************************************//**
 @Function      E500_DCacheEnable

 @Description   Enables the data cache for memory pages that are
                not cache inhibited.

 @Return        None.
*//***************************************************************************/
void E500_DCacheEnable(void);

/**************************************************************************//**
 @Function      E500_ICacheEnable

 @Description   Enables the instruction cache for memory pages that are
                not cache inhibited.

 @Return        None.
*//***************************************************************************/
void E500_ICacheEnable(void);

/**************************************************************************//**
 @Function      E500_DCacheDisable

 @Description   Disables the data cache.

 @Return        None.
*//***************************************************************************/
void E500_DCacheDisable(void);

/**************************************************************************//**
 @Function      E500_ICacheDisable

 @Description   Disables the instruction cache.

 @Return        None.
*//***************************************************************************/
void E500_ICacheDisable(void);

/**************************************************************************//**
 @Function      E500_DCacheFlush

 @Description   Flushes the data cache

 @Return        None.
*//***************************************************************************/
void E500_DCacheFlush(void);

/**************************************************************************//**
 @Function      E500_ICacheFlush

 @Description   Flushes the instruction cache.

 @Return        None.
*//***************************************************************************/
void E500_ICacheFlush(void);

/**************************************************************************//**
 @Function      E500_DCacheSetStashId

 @Description   Set Stash Id for data cache

 @Param[in]     stashId     the stash id to be set.

 @Return        None.
*//***************************************************************************/
void E500_DCacheSetStashId(uint8_t stashId);

/**************************************************************************//**
 @Description   E500mc L2 Cache Operation Mode
*//***************************************************************************/
typedef enum e_E500mcL2CacheMode
{
    e_L2_CACHE_MODE_DATA_ONLY      = 0x00000001,   /**< Cache data only */
    e_L2_CACHE_MODE_INST_ONLY      = 0x00000002,   /**< Cache instructions only */
    e_L2_CACHE_MODE_DATA_AND_INST  = 0x00000003    /**< Cache data and instructions */
} e_E500mcL2CacheMode;

#if defined(CORE_E500MC) || defined(CORE_E5500)
/**************************************************************************//**
 @Function      E500_L2CacheEnable

 @Description   Enables the cache for memory pages that are not cache inhibited.

 @param[in]     mode - L2 cache mode: data only, instruction only or instruction and data.

 @Return        None.

 @Cautions      This routine must be call only ONCE for both caches. I.e. it is
                not possible to call this routine for i-cache and than to call
                again for d-cache; The second call will override the first one.
*//***************************************************************************/
void E500_L2CacheEnable(e_E500mcL2CacheMode mode);

/**************************************************************************//**
 @Function      E500_L2CacheDisable

 @Description   Disables the cache (data instruction or both).

 @Return        None.

*//***************************************************************************/
void E500_L2CacheDisable(void);

/**************************************************************************//**
 @Function      E500_L2CacheFlush

 @Description   Flushes the cache.

 @Return        None.
*//***************************************************************************/
void E500_L2CacheFlush(void);

/**************************************************************************//**
 @Function      E500_L2SetStashId

 @Description   Set Stash Id

 @Param[in]     stashId     the stash id to be set.

 @Return        None.
*//***************************************************************************/
void E500_L2SetStashId(uint8_t stashId);
#endif /* defined(CORE_E500MC) || defined(CORE_E5500) */

#ifdef CORE_E6500
/**************************************************************************//**
 @Function      E6500_L2CacheEnable

 @Description   Enables the cache for memory pages that are not cache inhibited.

 @param[in]     mode - L2 cache mode: support data & instruction only.

 @Return        None.

 @Cautions      This routine must be call only ONCE for both caches. I.e. it is
                not possible to call this routine for i-cache and than to call
                again for d-cache; The second call will override the first one.
*//***************************************************************************/
void E6500_L2CacheEnable(uintptr_t clusterBase);

/**************************************************************************//**
 @Function      E6500_L2CacheDisable

 @Description   Disables the cache (data instruction or both).

 @Return        None.

*//***************************************************************************/
void E6500_L2CacheDisable(uintptr_t clusterBase);

/**************************************************************************//**
 @Function      E6500_L2CacheFlush

 @Description   Flushes the cache.

 @Return        None.
*//***************************************************************************/
void E6500_L2CacheFlush(uintptr_t clusterBase);

/**************************************************************************//**
 @Function      E6500_L2SetStashId

 @Description   Set Stash Id

 @Param[in]     stashId     the stash id to be set.

 @Return        None.
*//***************************************************************************/
void E6500_L2SetStashId(uintptr_t clusterBase, uint8_t stashId);

/**************************************************************************//**
 @Function      E6500_GetCcsrBase

 @Description   Obtain SoC CCSR base address

 @Param[in]     None.

 @Return        Physical CCSR base address.
*//***************************************************************************/
physAddress_t E6500_GetCcsrBase(void);
#endif /* CORE_E6500 */

/**************************************************************************//**
 @Function      E500_AddressBusStreamingEnable

 @Description   Enables address bus streaming on the CCB.

                This setting, along with the ECM streaming configuration
                parameters, enables address bus streaming on the CCB.

 @Return        None.
*//***************************************************************************/
void E500_AddressBusStreamingEnable(void);

/**************************************************************************//**
 @Function      E500_AddressBusStreamingDisable

 @Description   Disables address bus streaming on the CCB.

 @Return        None.
*//***************************************************************************/
void E500_AddressBusStreamingDisable(void);

/**************************************************************************//**
 @Function      E500_AddressBroadcastEnable

 @Description   Enables address broadcast.

                The e500 broadcasts cache management instructions (dcbst, dcblc
                (CT = 1), icblc (CT = 1), dcbf, dcbi, mbar, msync, tlbsync, icbi)
                based on ABE. ABE must be set to allow management of external
                L2 caches.

 @Return        None.
*//***************************************************************************/
void E500_AddressBroadcastEnable(void);

/**************************************************************************//**
 @Function      E500_AddressBroadcastDisable

 @Description   Disables address broadcast.

                The e500 broadcasts cache management instructions (dcbst, dcblc
                (CT = 1), icblc (CT = 1), dcbf, dcbi, mbar, msync, tlbsync, icbi)
                based on ABE. ABE must be set to allow management of external
                L2 caches.

 @Return        None.
*//***************************************************************************/
void E500_AddressBroadcastDisable(void);

/**************************************************************************//**
 @Function      E500_IsTaskletSupported

 @Description   Checks if tasklets are supported by the e500 interrupt handler.

 @Retval        TRUE    - Tasklets are supported.
 @Retval        FALSE   - Tasklets are not supported.
*//***************************************************************************/
bool E500_IsTaskletSupported(void);

void E500_EnableTimeBase(void);
void E500_DisableTimeBase(void);

uint64_t E500_GetTimeBaseTime(void);

void E500_GenericIntrInit(void);

t_Error E500_SetIntr(int        ppcIntrSrc,
                     void       (* Isr)(t_Handle handle),
                     t_Handle   handle);

t_Error E500_ClearIntr(int ppcIntrSrc);

/**************************************************************************//**
 @Function      E500_GenericIntrHandler

 @Description   This is the general e500 interrupt handler.

                It is called by the main assembly interrupt handler
                when an exception occurs and no other function has been
                assigned to this exception.

 @Param         intrEntry   - (In) The exception interrupt vector entry.
*//***************************************************************************/
void E500_GenericIntrHandler(uint32_t intrEntry);

/**************************************************************************//**
 @Function      CriticalIntr

 @Description   This is the specific critical e500 interrupt handler.

                It is called by the main assembly interrupt handler
                when an critical interrupt.

 @Param         intrEntry   - (In) The exception interrupt vector entry.
*//***************************************************************************/
void CriticalIntr(uint32_t intrEntry);


/**************************************************************************//**
 @Function      E500_GetId

 @Description   Returns the core ID in the system.

 @Return        Core ID.
*//***************************************************************************/
uint32_t E500_GetId(void);

/**************************************************************************//**
 @Function      E500_TestAndSet

 @Description   This routine tries to atomically test-and-set an integer
                in memory to a non-zero value.

                The memory will be set only if it is tested as zero, in which
                case the routine returns the new non-zero value; otherwise the
                routine returns zero.

 @Param[in]     p - pointer to a volatile int in memory, on which test-and-set
                    operation should be made.

 @Retval        Zero        - Operation failed - memory was already set.
 @Retval        Non-zero    - Operation succeeded - memory has been set.
*//***************************************************************************/
int E500_TestAndSet(volatile int *p);

/**************************************************************************//**
 @Function      E500_MemoryBarrier

 @Description   This routine will cause the core to stop executing any commands
                until all previous memory read/write commands are completely out
                of the core's pipeline.

 @Return        None.
*//***************************************************************************/
static __inline__ void E500_MemoryBarrier(void)
{
#ifndef CORE_E500V2
    __asm__ ("mbar 1");
#else  /* CORE_E500V2 */
    /**** ERRATA WORK AROUND START ****/
    /* ERRATA num:  CPU1 */
    /* Description: "mbar MO = 1" instruction fails to order caching-inhibited
                    guarded loads and stores. */

    /* "msync" instruction is used instead */

    __asm__ ("msync");

    /**** ERRATA WORK AROUND END ****/
#endif /* CORE_E500V2 */
}

/**************************************************************************//**
 @Function      E500_InstructionSync

 @Description   This routine will cause the core to wait for previous instructions
                (including any interrupts they generate) to complete before the
                synchronization command executes, which purges all instructions
                from the processor's pipeline and refetches the next instruction.

 @Return        None.
*//***************************************************************************/
static __inline__ void E500_InstructionSync(void)
{
    __asm__ ("isync");
}


/** @} */ /* end of E500_init_grp group */
/** @} */ /* end of E500_grp group */


#endif /* __E500V2_EXT_H */