New upstream version 18.02
[deb_dpdk.git] / drivers / bus / fslmc / mc / fsl_mc_sys.h
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  *
3  * Copyright 2013-2015 Freescale Semiconductor Inc.
4  * Copyright 2017 NXP
5  *
6  */
7 #ifndef _FSL_MC_SYS_H
8 #define _FSL_MC_SYS_H
9
10 #ifdef __linux_driver__
11
12 #include <linux/errno.h>
13 #include <asm/io.h>
14 #include <linux/slab.h>
15
16 struct fsl_mc_io {
17         void *regs;
18 };
19
20 #ifndef ENOTSUP
21 #define ENOTSUP         95
22 #endif
23
24 #define ioread64(_p)        readq(_p)
25 #define iowrite64(_v, _p)   writeq(_v, _p)
26
27 #else /* __linux_driver__ */
28
29 #include <stdio.h>
30 #include <stdint.h>
31 #include <errno.h>
32 #include <sys/uio.h>
33 #include <linux/byteorder/little_endian.h>
34
35 #ifndef dmb
36 #define dmb() {__asm__ __volatile__("" : : : "memory"); }
37 #endif
38 #define __iormb()       dmb()
39 #define __iowmb()       dmb()
40 #define __arch_getq(a)          (*(volatile uint64_t *)(a))
41 #define __arch_putq(v, a)       (*(volatile uint64_t *)(a) = (v))
42 #define __arch_putq32(v, a)     (*(volatile uint32_t *)(a) = (v))
43 #define readq(c) \
44         ({ uint64_t __v = __arch_getq(c); __iormb(); __v; })
45 #define writeq(v, c) \
46         ({ uint64_t __v = v; __iowmb(); __arch_putq(__v, c); __v; })
47 #define writeq32(v, c) \
48         ({ uint32_t __v = v; __iowmb(); __arch_putq32(__v, c); __v; })
49 #define ioread64(_p)            readq(_p)
50 #define iowrite64(_v, _p)       writeq(_v, _p)
51 #define iowrite32(_v, _p)       writeq32(_v, _p)
52 #define __iomem
53
54 /*GPP is supposed to use MC commands with low priority*/
55 #define CMD_PRI_LOW          0 /*!< Low Priority command indication */
56
57 struct fsl_mc_io {
58         void *regs;
59 };
60
61 #endif /* __linux_driver__ */
62
63 #endif /* _FSL_MC_SYS_H */