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
59164426Ssam
60164426SsamENTRY(a4x_bs_r_2)
61164426Ssam	ldr	r0, [r1, r2, LSL #2]
62164426Ssam	mov	r1, #0xff
63164426Ssam	orr	r1, r1, r1, lsl #8
64164426Ssam	and	r0, r0, r1
65164426Ssam	mov	pc, lr
66164426Ssam
67164426SsamENTRY(a4x_bs_r_4)
68164426Ssam	ldr	r0, [r1, r2, LSL #2]
69164426Ssam	mov	pc, lr
70164426Ssam
71164426Ssam/*
72164426Ssam * Write single
73164426Ssam */
74164426SsamENTRY(a4x_bs_w_1)
75164426Ssam	and	r3, r3, #0xff
76164426Ssam	str	r3, [r1, r2, LSL #2]
77164426Ssam	mov	pc, lr
78164426Ssam
79164426SsamENTRY(a4x_bs_w_2)
80164426Ssam	mov	r0, #0xff
81164426Ssam	orr	r0, r0, r0, lsl #8
82164426Ssam	and	r3, r3, r0
83164426Ssam	str	r3, [r1, r2, LSL #2]
84164426Ssam	mov	pc, lr
85164426Ssam
86164426SsamENTRY(a4x_bs_w_4)
87164426Ssam	str	r3, [r1, r2, LSL #2]
88164426Ssam	mov	pc, lr
89164426Ssam
90164426Ssam/*
91164426Ssam * Read multiple
92164426Ssam */
93164426SsamENTRY(a4x_bs_rm_1)
94164426Ssam	add	r0, r1, r2, lsl #2
95164426Ssam	ldr	r2, [sp, #0]
96164426Ssam	mov	r1, r3
97164426Ssam	teq	r2, #0
98164426Ssam	moveq	pc, lr
99164426Ssam1:	ldr	r3, [r0]
100164426Ssam	subs	r2, r2, #1
101164426Ssam	strb	r3, [r1], #1
102164426Ssam	bne	1b
103164426Ssam	mov	pc, lr
104164426Ssam
105164426SsamENTRY(a4x_bs_rm_2)
106164426Ssam	add	r0, r1, r2, lsl #2
107164426Ssam	ldr	r2, [sp, #0]
108164426Ssam	mov	r1, r3
109164426Ssam	teq	r2, #0
110164426Ssam	moveq	pc, lr
111164426Ssam1:	ldr	r3, [r0]
112164426Ssam	subs	r2, r2, #1
113164426Ssam	strh	r3, [r1], #2
114164426Ssam	bne	1b
115164426Ssam	mov	pc, lr
116164426Ssam
117164426Ssam/*
118164426Ssam * Write multiple
119164426Ssam */
120164426SsamENTRY(a4x_bs_wm_1)
121164426Ssam	add	r0, r1, r2, lsl #2
122164426Ssam	ldr	r2, [sp, #0]
123164426Ssam	mov	r1, r3
124164426Ssam	teq	r2, #0
125164426Ssam	moveq	pc, lr
126164426Ssam1:	ldrb	r3, [r1], #1
127164426Ssam	subs	r2, r2, #1
128164426Ssam	str	r3, [r0]
129164426Ssam	bne	1b
130164426Ssam	mov	pc, lr
131164426Ssam
132164426SsamENTRY(a4x_bs_wm_2)
133164426Ssam	add	r0, r1, r2, lsl #2
134164426Ssam	ldr	r2, [sp, #0]
135164426Ssam	mov	r1, r3
136164426Ssam	teq	r2, #0
137164426Ssam	moveq	pc, lr
138164426Ssam1:	ldrh	r3, [r1], #2
139164426Ssam	subs	r2, r2, #1
140164426Ssam	str	r3, [r0]
141164426Ssam	bne	1b
142164426Ssam	mov	pc, lr
143