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 /* 20 * For data in "device-endian" byte order (device endianness is model 21 * dependent). Analogous to __leXX or __beXX. 22 */ 23 typedef __u32 __bitwise __dev32; 24 typedef __u16 __bitwise __dev16; 25 26 enum { 27 ENDIANNESS_MIN = 0, 28 ENDIANNESS_UNKNOWN, 29 ENDIANNESS_LITTLE, 30 ENDIANNESS_BIG, 31 ENDIANNESS_MIDDLE, 32 ENDIANNESS_MAX 33 }; 34 35 struct gdm_endian { 36 u8 dev_ed; 37 }; 38 39 void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian); 40 __dev16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x); 41 u16 gdm_dev16_to_cpu(struct gdm_endian *ed, __dev16 x); 42 __dev32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x); 43 u32 gdm_dev32_to_cpu(struct gdm_endian *ed, __dev32 x); 44 45 #endif /*__GDM_ENDIAN_H__*/ 46