e52f5ed2e303c2d0acdd098f34f4a42a62821665
[deb_dpdk.git] / drivers / bus / fslmc / qbman / qbman_sys_decl.h
1 /*-
2  *   BSD LICENSE
3  *
4  * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *     * Redistributions of source code must retain the above copyright
9  *       notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above copyright
11  *       notice, this list of conditions and the following disclaimer in the
12  *       documentation and/or other materials provided with the distribution.
13  *     * Neither the name of Freescale Semiconductor nor the
14  *       names of its contributors may be used to endorse or promote products
15  *       derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 #include <compat.h>
29 #include <fsl_qbman_base.h>
30
31 /* Sanity check */
32 #if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && \
33         (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
34 #error "Unknown endianness!"
35 #endif
36
37 /* The platform-independent code shouldn't need endianness, except for
38  * weird/fast-path cases like qbman_result_has_token(), which needs to
39  * perform a passive and endianness-specific test on a read-only data structure
40  * very quickly. It's an exception, and this symbol is used for that case.
41  */
42 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
43 #define DQRR_TOK_OFFSET 0
44 #define QBMAN_RESULT_VERB_OFFSET_IN_MEM 24
45 #define SCN_STATE_OFFSET_IN_MEM 8
46 #define SCN_RID_OFFSET_IN_MEM 8
47 #else
48 #define DQRR_TOK_OFFSET 24
49 #define QBMAN_RESULT_VERB_OFFSET_IN_MEM 0
50 #define SCN_STATE_OFFSET_IN_MEM 16
51 #define SCN_RID_OFFSET_IN_MEM 0
52 #endif
53
54 /* Similarly-named functions */
55 #define upper32(a) upper_32_bits(a)
56 #define lower32(a) lower_32_bits(a)
57
58         /****************/
59         /* arch assists */
60         /****************/
61 #define dcbz(p) { asm volatile("dc zva, %0" : : "r" (p) : "memory"); }
62 #define lwsync() { asm volatile("dmb st" : : : "memory"); }
63 #define dcbf(p) { asm volatile("dc cvac, %0" : : "r"(p) : "memory"); }
64 #define dccivac(p) { asm volatile("dc civac, %0" : : "r"(p) : "memory"); }
65 static inline void prefetch_for_load(void *p)
66 {
67         asm volatile("prfm pldl1keep, [%0, #64]" : : "r" (p));
68 }
69
70 static inline void prefetch_for_store(void *p)
71 {
72         asm volatile("prfm pstl1keep, [%0, #64]" : : "r" (p));
73 }