Merge tag 'gpio-v3.13-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw...
[linux-2.6.git] / drivers / staging / gdm724x / gdm_endian.h
blob9b2531ff908e2f11faba8db0c81adeace9dbaccc
1 /*
2 * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
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.
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.
14 #ifndef __GDM_ENDIAN_H__
15 #define __GDM_ENDIAN_H__
17 #include <linux/types.h>
19 #define Endian16_Swap(value) \
20 ((((u16)((value) & 0x00FF)) << 8) | \
21 (((u16)((value) & 0xFF00)) >> 8))
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))
29 enum {
30 ENDIANNESS_MIN = 0,
31 ENDIANNESS_UNKNOWN,
32 ENDIANNESS_LITTLE,
33 ENDIANNESS_BIG,
34 ENDIANNESS_MIDDLE,
35 ENDIANNESS_MAX
38 struct gdm_endian {
39 u8 dev_ed;
40 u8 host_ed;
43 void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian);
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);
49 #endif /*__GDM_ENDIAN_H__*/