aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include/uapi
diff options
context:
space:
mode:
authorChen Jie <chenj@lemote.com>2014-08-15 04:56:58 -0400
committerRalf Baechle <ralf@linux-mips.org>2014-09-22 07:35:46 -0400
commit3c09bae43ba92a07a6a7b7d42360deb32d289cc0 (patch)
tree7648425d5b309e76a60612ca46ba4b88bfdf729b /arch/mips/include/uapi
parent0f33be009b89d2268e94194dc4fd01a7851b6d51 (diff)
MIPS: Use WSBH/DSBH/DSHD on Loongson 3A
Signed-off-by: chenj <chenj@lemote.com> Cc: linux-mips@linux-mips.org Cc: chenhc@lemote.com Patchwork: https://patchwork.linux-mips.org/patch/7542/ Patchwork: https://patchwork.linux-mips.org/patch/7550/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/include/uapi')
-rw-r--r--arch/mips/include/uapi/asm/swab.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/arch/mips/include/uapi/asm/swab.h b/arch/mips/include/uapi/asm/swab.h
index ac9a8f9cd1fb..8f2d184dbe9f 100644
--- a/arch/mips/include/uapi/asm/swab.h
+++ b/arch/mips/include/uapi/asm/swab.h
@@ -13,12 +13,16 @@
13 13
14#define __SWAB_64_THRU_32__ 14#define __SWAB_64_THRU_32__
15 15
16#if defined(__mips_isa_rev) && (__mips_isa_rev >= 2) 16#if (defined(__mips_isa_rev) && (__mips_isa_rev >= 2)) || \
17 defined(_MIPS_ARCH_LOONGSON3A)
17 18
18static inline __attribute_const__ __u16 __arch_swab16(__u16 x) 19static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
19{ 20{
20 __asm__( 21 __asm__(
22 " .set push \n"
23 " .set arch=mips32r2 \n"
21 " wsbh %0, %1 \n" 24 " wsbh %0, %1 \n"
25 " .set pop \n"
22 : "=r" (x) 26 : "=r" (x)
23 : "r" (x)); 27 : "r" (x));
24 28
@@ -29,8 +33,11 @@ static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
29static inline __attribute_const__ __u32 __arch_swab32(__u32 x) 33static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
30{ 34{
31 __asm__( 35 __asm__(
36 " .set push \n"
37 " .set arch=mips32r2 \n"
32 " wsbh %0, %1 \n" 38 " wsbh %0, %1 \n"
33 " rotr %0, %0, 16 \n" 39 " rotr %0, %0, 16 \n"
40 " .set pop \n"
34 : "=r" (x) 41 : "=r" (x)
35 : "r" (x)); 42 : "r" (x));
36 43
@@ -46,8 +53,11 @@ static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
46static inline __attribute_const__ __u64 __arch_swab64(__u64 x) 53static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
47{ 54{
48 __asm__( 55 __asm__(
49 " dsbh %0, %1\n" 56 " .set push \n"
50 " dshd %0, %0" 57 " .set arch=mips64r2 \n"
58 " dsbh %0, %1 \n"
59 " dshd %0, %0 \n"
60 " .set pop \n"
51 : "=r" (x) 61 : "=r" (x)
52 : "r" (x)); 62 : "r" (x));
53 63
@@ -55,5 +65,5 @@ static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
55} 65}
56#define __arch_swab64 __arch_swab64 66#define __arch_swab64 __arch_swab64
57#endif /* __mips64 */ 67#endif /* __mips64 */
58#endif /* MIPS R2 or newer */ 68#endif /* MIPS R2 or newer or Loongson 3A */
59#endif /* _ASM_SWAB_H */ 69#endif /* _ASM_SWAB_H */