1164426Ssam/*	$NetBSD: ixp425_a4x_io.S,v 1.2 2005/12/11 12:16:51 christos Exp $	*/
2164426Ssam
3164426Ssam/*
4164426Ssam * Copyright 2003 Wasabi Systems, Inc.
5164426Ssam * All rights reserved.
6164426Ssam *
7164426Ssam * Written by Steve C. Woodford for Wasabi Systems, Inc.
8164426Ssam *
9164426Ssam * Redistribution and use in source and binary forms, with or without
10164426Ssam * modification, are permitted provided that the following conditions
11164426Ssam * are met:
12164426Ssam * 1. Redistributions of source code must retain the above copyright
13164426Ssam *    notice, this list of conditions and the following disclaimer.
14164426Ssam * 2. Redistributions in binary form must reproduce the above copyright
15164426Ssam *    notice, this list of conditions and the following disclaimer in the
16164426Ssam *    documentation and/or other materials provided with the distribution.
17164426Ssam * 3. All advertising materials mentioning features or use of this software
18164426Ssam *    must display the following acknowledgement:
19164426Ssam *      This product includes software developed for the NetBSD Project by
20164426Ssam *      Wasabi Systems, Inc.
21164426Ssam * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22164426Ssam *    or promote products derived from this software without specific prior
23164426Ssam *    written permission.
24164426Ssam *
25164426Ssam * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26164426Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27164426Ssam * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28164426Ssam * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29164426Ssam * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30164426Ssam * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31164426Ssam * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32164426Ssam * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33164426Ssam * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34164426Ssam * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35164426Ssam * POSSIBILITY OF SUCH DAMAGE.
36164426Ssam */
37164426Ssam
38164426Ssam/*
39164426Ssam * There are simple bus space functions for IO registers mapped at
40164426Ssam * 32-bit aligned positions.  offset is multiplied by 4.
41164426Ssam *
42164426Ssam * Based loosely on pxa2x0_a2x_io.S
43164426Ssam */
44164426Ssam
45164426Ssam#include <machine/asm.h>
46164426Ssam__FBSDID("$FreeBSD$");
47164426Ssam
48164426Ssam/*
49164426Ssam * bus_space I/O functions with offset*4
50164426Ssam */
51164426Ssam
52164426Ssam/*
53164426Ssam * Read single
54164426Ssam */
55164426SsamENTRY(a4x_bs_r_1)
56164426Ssam	ldr	r0, [r1, r2, LSL #2]
57164426Ssam	and	r0, r0, #0xff
58164426Ssam	mov	pc, lr
59275519SandrewEND(a4x_bs_r_1)
60164426Ssam
61164426SsamENTRY(a4x_bs_r_2)
62164426Ssam	ldr	r0, [r1, r2, LSL #2]
63164426Ssam	mov	r1, #0xff
64164426Ssam	orr	r1, r1, r1, lsl #8
65164426Ssam	and	r0, r0, r1
66164426Ssam	mov	pc, lr
67275519SandrewEND(a4x_bs_r_2)
68164426Ssam
69164426SsamENTRY(a4x_bs_r_4)
70164426Ssam	ldr	r0, [r1, r2, LSL #2]
71164426Ssam	mov	pc, lr
72275519SandrewEND(a4x_bs_r_4)
73164426Ssam
74164426Ssam/*
75164426Ssam * Write single
76164426Ssam */
77164426SsamENTRY(a4x_bs_w_1)
78164426Ssam	and	r3, r3, #0xff
79164426Ssam	str	r3, [r1, r2, LSL #2]
80164426Ssam	mov	pc, lr
81275519SandrewEND(a4x_bs_w_1)
82164426Ssam
83164426SsamENTRY(a4x_bs_w_2)
84164426Ssam	mov	r0, #0xff
85164426Ssam	orr	r0, r0, r0, lsl #8
86164426Ssam	and	r3, r3, r0
87164426Ssam	str	r3, [r1, r2, LSL #2]
88164426Ssam	mov	pc, lr
89275519SandrewEND(a4x_bs_w_2)
90164426Ssam
91164426SsamENTRY(a4x_bs_w_4)
92164426Ssam	str	r3, [r1, r2, LSL #2]
93164426Ssam	mov	pc, lr
94275519SandrewEND(a4x_bs_w_4)
95164426Ssam
96164426Ssam/*
97164426Ssam * Read multiple
98164426Ssam */
99164426SsamENTRY(a4x_bs_rm_1)
100164426Ssam	add	r0, r1, r2, lsl #2
101164426Ssam	ldr	r2, [sp, #0]
102164426Ssam	mov	r1, r3
103164426Ssam	teq	r2, #0
104164426Ssam	moveq	pc, lr
105164426Ssam1:	ldr	r3, [r0]
106164426Ssam	subs	r2, r2, #1
107164426Ssam	strb	r3, [r1], #1
108164426Ssam	bne	1b
109164426Ssam	mov	pc, lr
110275519SandrewEND(a4x_bs_rm_1)
111164426Ssam
112164426SsamENTRY(a4x_bs_rm_2)
113164426Ssam	add	r0, r1, r2, lsl #2
114164426Ssam	ldr	r2, [sp, #0]
115164426Ssam	mov	r1, r3
116164426Ssam	teq	r2, #0
117164426Ssam	moveq	pc, lr
118164426Ssam1:	ldr	r3, [r0]
119164426Ssam	subs	r2, r2, #1
120164426Ssam	strh	r3, [r1], #2
121164426Ssam	bne	1b
122164426Ssam	mov	pc, lr
123275519SandrewEND(a4x_bs_rm_2)
124164426Ssam
125164426Ssam/*
126164426Ssam * Write multiple
127164426Ssam */
128164426SsamENTRY(a4x_bs_wm_1)
129164426Ssam	add	r0, r1, r2, lsl #2
130164426Ssam	ldr	r2, [sp, #0]
131164426Ssam	mov	r1, r3
132164426Ssam	teq	r2, #0
133164426Ssam	moveq	pc, lr
134164426Ssam1:	ldrb	r3, [r1], #1
135164426Ssam	subs	r2, r2, #1
136164426Ssam	str	r3, [r0]
137164426Ssam	bne	1b
138164426Ssam	mov	pc, lr
139275519SandrewEND(a4x_bs_wm_1)
140164426Ssam
141164426SsamENTRY(a4x_bs_wm_2)
142164426Ssam	add	r0, r1, r2, lsl #2
143164426Ssam	ldr	r2, [sp, #0]
144164426Ssam	mov	r1, r3
145164426Ssam	teq	r2, #0
146164426Ssam	moveq	pc, lr
147164426Ssam1:	ldrh	r3, [r1], #2
148164426Ssam	subs	r2, r2, #1
149164426Ssam	str	r3, [r0]
150164426Ssam	bne	1b
151164426Ssam	mov	pc, lr
152275519SandrewEND(a4x_bs_wm_2)
153