GNU Linux-libre 4.4.284-gnu1
[releases.git] / drivers / spi / spi-s3c24xx-fiq.S
1 /* linux/drivers/spi/spi_s3c24xx_fiq.S
2  *
3  * Copyright 2009 Simtec Electronics
4  *      Ben Dooks <ben@simtec.co.uk>
5  *
6  * S3C24XX SPI - FIQ pseudo-DMA transfer code
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11 */
12
13 #include <linux/linkage.h>
14 #include <asm/assembler.h>
15
16 #include <mach/map.h>
17 #include <mach/regs-irq.h>
18 #include <plat/regs-spi.h>
19
20 #include "spi-s3c24xx-fiq.h"
21
22         .text
23
24         @ entry to these routines is as follows, with the register names
25         @ defined in fiq.h so that they can be shared with the C files which
26         @ setup the calling registers.
27         @
28         @ fiq_rirq      The base of the IRQ registers to find S3C2410_SRCPND
29         @ fiq_rtmp      Temporary register to hold tx/rx data
30         @ fiq_rspi      The base of the SPI register block
31         @ fiq_rtx       The tx buffer pointer
32         @ fiq_rrx       The rx buffer pointer
33         @ fiq_rcount    The number of bytes to move
34
35         @ each entry starts with a word entry of how long it is
36         @ and an offset to the irq acknowledgment word
37
38 ENTRY(s3c24xx_spi_fiq_rx)
39         .word   fiq_rx_end - fiq_rx_start
40         .word   fiq_rx_irq_ack - fiq_rx_start
41 fiq_rx_start:
42         ldr     fiq_rtmp, fiq_rx_irq_ack
43         str     fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ]
44
45         ldrb    fiq_rtmp, [ fiq_rspi, #  S3C2410_SPRDAT ]
46         strb    fiq_rtmp, [ fiq_rrx ], #1
47
48         mov     fiq_rtmp, #0xff
49         strb    fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ]
50
51         subs    fiq_rcount, fiq_rcount, #1
52         subsne  pc, lr, #4              @@ return, still have work to do
53
54         @@ set IRQ controller so that next op will trigger IRQ
55         mov     fiq_rtmp, #0
56         str     fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD  - S3C24XX_VA_IRQ ]
57         subs    pc, lr, #4
58
59 fiq_rx_irq_ack:
60         .word   0
61 fiq_rx_end:
62
63 ENTRY(s3c24xx_spi_fiq_txrx)
64         .word   fiq_txrx_end - fiq_txrx_start
65         .word   fiq_txrx_irq_ack - fiq_txrx_start
66 fiq_txrx_start:
67
68         ldrb    fiq_rtmp, [ fiq_rspi, #  S3C2410_SPRDAT ]
69         strb    fiq_rtmp, [ fiq_rrx ], #1
70
71         ldr     fiq_rtmp, fiq_txrx_irq_ack
72         str     fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ]
73
74         ldrb    fiq_rtmp, [ fiq_rtx ], #1
75         strb    fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ]
76
77         subs    fiq_rcount, fiq_rcount, #1
78         subsne  pc, lr, #4              @@ return, still have work to do
79
80         mov     fiq_rtmp, #0
81         str     fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD  - S3C24XX_VA_IRQ ]
82         subs    pc, lr, #4
83
84 fiq_txrx_irq_ack:
85         .word   0
86
87 fiq_txrx_end:
88
89 ENTRY(s3c24xx_spi_fiq_tx)
90         .word   fiq_tx_end - fiq_tx_start
91         .word   fiq_tx_irq_ack - fiq_tx_start
92 fiq_tx_start:
93         ldrb    fiq_rtmp, [ fiq_rspi, #  S3C2410_SPRDAT ]
94
95         ldr     fiq_rtmp, fiq_tx_irq_ack
96         str     fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ]
97
98         ldrb    fiq_rtmp, [ fiq_rtx ], #1
99         strb    fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ]
100
101         subs    fiq_rcount, fiq_rcount, #1
102         subsne  pc, lr, #4              @@ return, still have work to do
103
104         mov     fiq_rtmp, #0
105         str     fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD  - S3C24XX_VA_IRQ ]
106         subs    pc, lr, #4
107
108 fiq_tx_irq_ack:
109         .word   0
110
111 fiq_tx_end:
112
113         .end