1/* SPDX-License-Identifier: GPL-2.0-only */
2/* linux/drivers/spi/spi_s3c24xx_fiq.S
3 *
4 * Copyright 2009 Simtec Electronics
5 *	Ben Dooks <ben@simtec.co.uk>
6 *
7 * S3C24XX SPI - FIQ pseudo-DMA transfer code
8*/
9
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12
13#include "map.h"
14#include "regs-irq.h"
15
16#include <linux/spi/s3c24xx-fiq.h>
17
18#define S3C2410_SPTDAT           (0x10)
19#define S3C2410_SPRDAT           (0x14)
20
21	.text
22
23	@ entry to these routines is as follows, with the register names
24	@ defined in fiq.h so that they can be shared with the C files which
25	@ setup the calling registers.
26	@
27	@ fiq_rirq	The base of the IRQ registers to find S3C2410_SRCPND
28	@ fiq_rtmp	Temporary register to hold tx/rx data
29	@ fiq_rspi	The base of the SPI register block
30	@ fiq_rtx	The tx buffer pointer
31	@ fiq_rrx	The rx buffer pointer
32	@ fiq_rcount	The number of bytes to move
33
34	@ each entry starts with a word entry of how long it is
35	@ and an offset to the irq acknowledgment word
36
37ENTRY(s3c24xx_spi_fiq_rx)
38s3c24xx_spi_fix_rx:
39	.word	fiq_rx_end - fiq_rx_start
40	.word	fiq_rx_irq_ack - fiq_rx_start
41fiq_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	subnes	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
59fiq_rx_irq_ack:
60	.word	0
61fiq_rx_end:
62
63ENTRY(s3c24xx_spi_fiq_txrx)
64s3c24xx_spi_fiq_txrx:
65	.word	fiq_txrx_end - fiq_txrx_start
66	.word	fiq_txrx_irq_ack - fiq_txrx_start
67fiq_txrx_start:
68
69	ldrb	fiq_rtmp, [ fiq_rspi, #  S3C2410_SPRDAT ]
70	strb	fiq_rtmp, [ fiq_rrx ], #1
71
72	ldr	fiq_rtmp, fiq_txrx_irq_ack
73	str	fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ]
74
75	ldrb	fiq_rtmp, [ fiq_rtx ], #1
76	strb	fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ]
77
78	subs	fiq_rcount, fiq_rcount, #1
79	subnes	pc, lr, #4		@@ return, still have work to do
80
81	mov	fiq_rtmp, #0
82	str	fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD  - S3C24XX_VA_IRQ ]
83	subs	pc, lr, #4
84
85fiq_txrx_irq_ack:
86	.word	0
87
88fiq_txrx_end:
89
90ENTRY(s3c24xx_spi_fiq_tx)
91s3c24xx_spi_fix_tx:
92	.word	fiq_tx_end - fiq_tx_start
93	.word	fiq_tx_irq_ack - fiq_tx_start
94fiq_tx_start:
95	ldrb	fiq_rtmp, [ fiq_rspi, #  S3C2410_SPRDAT ]
96
97	ldr	fiq_rtmp, fiq_tx_irq_ack
98	str	fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ]
99
100	ldrb	fiq_rtmp, [ fiq_rtx ], #1
101	strb	fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ]
102
103	subs	fiq_rcount, fiq_rcount, #1
104	subnes	pc, lr, #4		@@ return, still have work to do
105
106	mov	fiq_rtmp, #0
107	str	fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD  - S3C24XX_VA_IRQ ]
108	subs	pc, lr, #4
109
110fiq_tx_irq_ack:
111	.word	0
112
113fiq_tx_end:
114
115	.end
116