sm_obio_space_asm.S revision 1.4.128.1 1 /* $NetBSD: sm_obio_space_asm.S,v 1.4.128.1 2013/08/28 23:59:14 rmind Exp $ */
2
3 /*
4 * Copyright (c) 2002, 2003 Genetec Corporation. All rights reserved.
5 * Written by Hiroyuki Bessho for Genetec Corporation.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of Genetec Corporation may not be used to endorse or
16 * promote products derived from this software without specific prior
17 * written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /*
33 * These are special bus space functions for Lubbock's on-board I/O.
34 * Especially for SMC91c96 chip in 8-bit mode.
35 */
36
37 #include <machine/asm.h>
38
39 RCSID("$NetBSD: sm_obio_space_asm.S,v 1.4.128.1 2013/08/28 23:59:14 rmind Exp $")
40
41 /*
42 * bus_space I/O functions with offset*4, 8-bit access.
43 */
44
45 /*
46 * read single
47 */
48
49 ENTRY(smobio8_bs_r_2)
50 add r1, r1, r2, LSL #2
51 ldrb r0, [r1], #4
52 ldrb r2, [r1]
53 orr r0, r0, r2, LSL #8
54 RET
55 END(smobio8_bs_r_2)
56
57 /*
58 * write single
59 */
60
61 ENTRY(smobio8_bs_w_2)
62 add r1, r1, r2, LSL #2
63 strb r3, [r1], #4
64 mov r3, r3, LSR #8
65 strb r3, [r1]
66 RET
67 END(smobio8_bs_w_2)
68
69 /*
70 * read multiple
71 */
72 ENTRY(smobio8_bs_rm_2)
73 add r0, r1, r2, LSL #2
74 ldr r2, [sp, #0]
75 cmp r2, #0x00000000
76 RETc(le)
77
78 Lbs_rm_2_loop:
79 ldrb r1, [r0]
80 ldrb lr, [r0, #4]
81 subs r2, r2, #0x00000001
82 orr r1, r1, lr, LSL #8
83 strh r1, [r3], #0x0002
84 bgt Lbs_rm_2_loop
85
86 RET
87 END(smobio8_bs_rm_2)
88
89
90
91 /*
92 * write multiple
93 */
94 ENTRY(smobio8_bs_wm_2)
95 add r0, r1, r2, LSL #2
96 ldr r2, [sp, #0]
97 cmp r2, #0x00000000
98 RETc(le)
99
100 Lbs_wm_2_loop:
101 ldrh r1, [r3], #0x0002
102 subs r2, r2, #0x00000001
103 strb r1, [r0]
104 mov r1, r1, LSR #8
105 strb r1, [r0,#4]
106 bgt Lbs_wm_2_loop
107
108 RET
109 END(smobio8_bs_wm_2)
110
111
112 /*
113 * For 16-bit mode
114 */
115
116 /*
117 * read single
118 */
119
120 ENTRY(smobio16_bs_r_1)
121 tst r2, #1 /* Even/Odd ? */
122 ldrbeq r0, [r1, r2, LSL #2]
123 RETc(eq)
124
125 /* Odd byte. read 16bits and get high byte */
126 bic r2, r2, #1
127 add r1, r1, r2, LSL #2
128 ldrh r0, [r1]
129 mov r0, r0, LSR #8
130 RET
131 END(smobio16_bs_r_1)
132
133
134 /*
135 * write single
136 */
137
138 ENTRY(smobio16_bs_w_1)
139 tst r2, #1 /* Even/Odd ? */
140 strbeq r3, [r1, r2, LSL #2]
141 RETc(eq)
142
143 /* Odd byte. write 16bit with low byte is 0. */
144 bic r2, r2, #1
145 mov r3, r3, LSL #8
146 add r1, r1, r2, LSL #2
147 strh r3, [r1]
148 RET
149 END(smobio16_bs_w_1)
150