Home | History | Annotate | Line # | Download | only in lubbock
sm_obio_space_asm.S revision 1.4
      1 /*	$NetBSD: sm_obio_space_asm.S,v 1.4 2005/12/11 12:17:09 christos 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 2005/12/11 12:17:09 christos 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 	mov	pc, lr
     55 
     56 /*
     57  * write single
     58  */
     59 
     60 ENTRY(smobio8_bs_w_2)
     61 	add	r1, r1, r2, LSL #2
     62 	strb	r3, [r1], #4
     63 	mov	r3, r3, LSR #8
     64 	strb	r3, [r1]
     65 	mov	pc, lr
     66 
     67 /*
     68  * read multiple
     69  */
     70 ENTRY(smobio8_bs_rm_2)
     71 	add	r0, r1, r2, LSL #2
     72 	ldr	r2, [sp, #0]
     73 	cmp     r2, #0x00000000
     74 	movle   pc, lr
     75 
     76 	stmfd	sp!, {lr}
     77 Lbs_rm_2_loop:
     78 	ldrb	r1, [r0]
     79 	ldrb	lr, [r0, #4]
     80 	subs	r2, r2, #0x00000001
     81 	orr	r1, r1, lr, LSL #8
     82 	strh	r1, [r3], #0x0002
     83 	bgt	Lbs_rm_2_loop
     84 
     85 	ldmfd	sp!, {pc}
     86 
     87 
     88 
     89 /*
     90  * write multiple
     91  */
     92 ENTRY(smobio8_bs_wm_2)
     93 	add	r0, r1, r2, LSL #2
     94 	ldr	r2, [sp, #0]
     95 	cmp     r2, #0x00000000
     96 	movle   pc, lr
     97 
     98 Lbs_wm_2_loop:
     99 	ldrh	r1, [r3], #0x0002
    100 	subs	r2, r2, #0x00000001
    101 	strb	r1, [r0]
    102 	mov	r1, r1, LSR #8
    103 	strb	r1, [r0,#4]
    104 	bgt	Lbs_wm_2_loop
    105 
    106 	mov	pc, lr
    107 
    108 
    109 /*
    110  * For 16-bit mode
    111  */
    112 
    113 /*
    114  * read single
    115  */
    116 
    117 ENTRY(smobio16_bs_r_1)
    118 	tst	r2, #1    /* Even/Odd ? */
    119 	ldreqb	r0, [r1, r2, LSL #2]
    120 	moveq	pc,lr
    121 
    122 	/* Odd byte.  read 16bits and get high byte */
    123 	bic	r2, r2, #1
    124 	add	r1, r1, r2, LSL #2
    125 	ldrh	r0, [r1]
    126 	mov	r0, r0, LSR #8
    127 	mov	pc, lr
    128 
    129 
    130 /*
    131  * write single
    132  */
    133 
    134 ENTRY(smobio16_bs_w_1)
    135 	tst	r2, #1    /* Even/Odd ? */
    136 	streqb	r3, [r1, r2, LSL #2]
    137 	moveq	pc,lr
    138 
    139 	/* Odd byte.  write 16bit with low byte is 0. */
    140 	bic	r2, r2, #1
    141 	mov	r3, r3, LSL #8
    142 	add	r1, r1, r2, LSL #2
    143 	strh	r3, [r1]
    144 	mov	pc, lr
    145