xref: /openbmc/linux/arch/arm/lib/io-writesb.S (revision b593bce5)
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 *  linux/arch/arm/lib/io-writesb.S
4 *
5 *  Copyright (C) 1995-2000 Russell King
6 */
7#include <linux/linkage.h>
8#include <asm/assembler.h>
9
10		.macro	outword, rd
11#ifndef __ARMEB__
12		strb	\rd, [r0]
13		mov	\rd, \rd, lsr #8
14		strb	\rd, [r0]
15		mov	\rd, \rd, lsr #8
16		strb	\rd, [r0]
17		mov	\rd, \rd, lsr #8
18		strb	\rd, [r0]
19#else
20		mov	lr, \rd, lsr #24
21		strb	lr, [r0]
22		mov	lr, \rd, lsr #16
23		strb	lr, [r0]
24		mov	lr, \rd, lsr #8
25		strb	lr, [r0]
26		strb	\rd, [r0]
27#endif
28		.endm
29
30.Loutsb_align:	rsb	ip, ip, #4
31		cmp	ip, r2
32		movgt	ip, r2
33		cmp	ip, #2
34		ldrb	r3, [r1], #1
35		strb	r3, [r0]
36		ldrbge	r3, [r1], #1
37		strbge	r3, [r0]
38		ldrbgt	r3, [r1], #1
39		strbgt	r3, [r0]
40		subs	r2, r2, ip
41		bne	.Loutsb_aligned
42
43ENTRY(__raw_writesb)
44		teq	r2, #0		@ do we have to check for the zero len?
45		reteq	lr
46		ands	ip, r1, #3
47		bne	.Loutsb_align
48
49.Loutsb_aligned:
50		stmfd	sp!, {r4, r5, lr}
51
52		subs	r2, r2, #16
53		bmi	.Loutsb_no_16
54
55.Loutsb_16_lp:	ldmia	r1!, {r3, r4, r5, ip}
56		outword	r3
57		outword	r4
58		outword	r5
59		outword	ip
60		subs	r2, r2, #16
61		bpl	.Loutsb_16_lp
62
63		tst	r2, #15
64		ldmfdeq	sp!, {r4, r5, pc}
65
66.Loutsb_no_16:	tst	r2, #8
67		beq	.Loutsb_no_8
68
69		ldmia	r1!, {r3, r4}
70		outword	r3
71		outword	r4
72
73.Loutsb_no_8:	tst	r2, #4
74		beq	.Loutsb_no_4
75
76		ldr	r3, [r1], #4
77		outword	r3
78
79.Loutsb_no_4:	ands	r2, r2, #3
80		ldmfdeq	sp!, {r4, r5, pc}
81
82		cmp	r2, #2
83		ldrb	r3, [r1], #1
84		strb	r3, [r0]
85		ldrbge	r3, [r1], #1
86		strbge	r3, [r0]
87		ldrbgt	r3, [r1]
88		strbgt	r3, [r0]
89
90		ldmfd	sp!, {r4, r5, pc}
91ENDPROC(__raw_writesb)
92