Commit | Line | Data |
---|---|---|
61e12104 WK |
1 | /* |
2 | * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. | |
3 | * | |
4 | * This software is licensed under the terms of the GNU General Public | |
5 | * License version 2, as published by the Free Software Foundation, and | |
6 | * may be copied, distributed, and modified under those terms. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | */ | |
13 | ||
14 | #ifndef __GDM_ENDIAN_H__ | |
15 | #define __GDM_ENDIAN_H__ | |
16 | ||
17 | #include <linux/types.h> | |
18 | ||
19 | #define Endian16_Swap(value) \ | |
20 | ((((u16)((value) & 0x00FF)) << 8) | \ | |
21 | (((u16)((value) & 0xFF00)) >> 8)) | |
22 | ||
23 | #define Endian32_Swap(value) \ | |
24 | ((((u32)((value) & 0x000000FF)) << 24) | \ | |
25 | (((u32)((value) & 0x0000FF00)) << 8) | \ | |
26 | (((u32)((value) & 0x00FF0000)) >> 8) | \ | |
27 | (((u32)((value) & 0xFF000000)) >> 24)) | |
28 | ||
29 | enum { | |
30 | ENDIANNESS_MIN = 0, | |
31 | ENDIANNESS_UNKNOWN, | |
32 | ENDIANNESS_LITTLE, | |
33 | ENDIANNESS_BIG, | |
34 | ENDIANNESS_MIDDLE, | |
35 | ENDIANNESS_MAX | |
36 | }; | |
37 | ||
38 | struct gdm_endian { | |
39 | u8 dev_ed; | |
40 | u8 host_ed; | |
41 | }; | |
42 | ||
9c02d0db | 43 | void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian); |
61e12104 WK |
44 | u16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x); |
45 | u16 gdm_dev16_to_cpu(struct gdm_endian *ed, u16 x); | |
46 | u32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x); | |
47 | u32 gdm_dev32_to_cpu(struct gdm_endian *ed, u32 x); | |
48 | ||
49 | #endif /*__GDM_ENDIAN_H__*/ |