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 29enum { 30 ENDIANNESS_MIN = 0, 31 ENDIANNESS_UNKNOWN, 32 ENDIANNESS_LITTLE, 33 ENDIANNESS_BIG, 34 ENDIANNESS_MIDDLE, 35 ENDIANNESS_MAX 36}; 37 38struct gdm_endian { 39 u8 dev_ed; 40 u8 host_ed; 41}; 42 43void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian); 44u16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x); 45u16 gdm_dev16_to_cpu(struct gdm_endian *ed, u16 x); 46u32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x); 47u32 gdm_dev32_to_cpu(struct gdm_endian *ed, u32 x); 48 49#endif /*__GDM_ENDIAN_H__*/ 50