]>
Commit | Line | Data |
---|---|---|
9f95a23c | 1 | /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) |
11fdf7f2 TL |
2 | * |
3 | * Copyright 2013-2015 Freescale Semiconductor Inc. | |
9f95a23c | 4 | * Copyright 2017 NXP |
11fdf7f2 | 5 | * |
11fdf7f2 TL |
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> | |
11fdf7f2 TL |
30 | #include <stdint.h> |
31 | #include <errno.h> | |
32 | #include <sys/uio.h> | |
33 | #include <linux/byteorder/little_endian.h> | |
34 | ||
11fdf7f2 TL |
35 | #ifndef dmb |
36 | #define dmb() {__asm__ __volatile__("" : : : "memory"); } | |
37 | #endif | |
9f95a23c TL |
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) \ | |
11fdf7f2 | 44 | ({ uint64_t __v = __arch_getq(c); __iormb(); __v; }) |
9f95a23c | 45 | #define writeq(v, c) \ |
11fdf7f2 TL |
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; }) | |
9f95a23c TL |
49 | #define ioread64(_p) readq(_p) |
50 | #define iowrite64(_v, _p) writeq(_v, _p) | |
51 | #define iowrite32(_v, _p) writeq32(_v, _p) | |
11fdf7f2 TL |
52 | #define __iomem |
53 | ||
11fdf7f2 TL |
54 | /*GPP is supposed to use MC commands with low priority*/ |
55 | #define CMD_PRI_LOW 0 /*!< Low Priority command indication */ | |
56 | ||
9f95a23c TL |
57 | struct fsl_mc_io { |
58 | void *regs; | |
59 | }; | |
11fdf7f2 TL |
60 | |
61 | #endif /* __linux_driver__ */ | |
62 | ||
63 | #endif /* _FSL_MC_SYS_H */ |