treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
[linux-2.6-block.git] / arch / arm / mach-imx / ssi-fiq.S
CommitLineData
d2912cb1 1/* SPDX-License-Identifier: GPL-2.0-only */
8380222e
SH
2/*
3 * Copyright (C) 2009 Sascha Hauer <s.hauer@pengutronix.de>
8380222e
SH
4 */
5
6#include <linux/linkage.h>
7#include <asm/assembler.h>
8
9/*
10 * r8 = bit 0-15: tx offset, bit 16-31: tx buffer size
11 * r9 = bit 0-15: rx offset, bit 16-31: rx buffer size
12 */
13
14#define SSI_STX0 0x00
15#define SSI_SRX0 0x08
16#define SSI_SISR 0x14
17#define SSI_SIER 0x18
18#define SSI_SACNT 0x38
19
20#define SSI_SACNT_AC97EN (1 << 0)
21
22#define SSI_SIER_TFE0_EN (1 << 0)
23#define SSI_SISR_TFE0 (1 << 0)
24#define SSI_SISR_RFF0 (1 << 2)
25#define SSI_SIER_RFF0_EN (1 << 2)
26
27 .text
28 .global imx_ssi_fiq_start
29 .global imx_ssi_fiq_end
30 .global imx_ssi_fiq_base
31 .global imx_ssi_fiq_rx_buffer
32 .global imx_ssi_fiq_tx_buffer
33
7095b956
DM
34/*
35 * imx_ssi_fiq_start is _intentionally_ not marked as a function symbol
36 * using ENDPROC(). imx_ssi_fiq_start and imx_ssi_fiq_end are used to
37 * mark the function body so that it can be copied to the FIQ vector in
38 * the vectors page. imx_ssi_fiq_start should only be called as the result
39 * of an FIQ: calling it directly will not work.
40 */
8380222e 41imx_ssi_fiq_start:
7095b956 42 ldr r12, .L_imx_ssi_fiq_base
8380222e
SH
43
44 /* TX */
7095b956 45 ldr r13, .L_imx_ssi_fiq_tx_buffer
8380222e
SH
46
47 /* shall we send? */
7095b956
DM
48 ldr r11, [r12, #SSI_SIER]
49 tst r11, #SSI_SIER_TFE0_EN
8380222e
SH
50 beq 1f
51
52 /* TX FIFO empty? */
7095b956
DM
53 ldr r11, [r12, #SSI_SISR]
54 tst r11, #SSI_SISR_TFE0
8380222e
SH
55 beq 1f
56
57 mov r10, #0x10000
58 sub r10, #1
59 and r10, r10, r8 /* r10: current buffer offset */
60
7095b956 61 add r13, r13, r10
8380222e 62
7095b956
DM
63 ldrh r11, [r13]
64 strh r11, [r12, #SSI_STX0]
8380222e 65
7095b956
DM
66 ldrh r11, [r13, #2]
67 strh r11, [r12, #SSI_STX0]
8380222e 68
7095b956
DM
69 ldrh r11, [r13, #4]
70 strh r11, [r12, #SSI_STX0]
8380222e 71
7095b956
DM
72 ldrh r11, [r13, #6]
73 strh r11, [r12, #SSI_STX0]
8380222e
SH
74
75 add r10, #8
7095b956
DM
76 lsr r11, r8, #16 /* r11: buffer size */
77 cmp r10, r11
78 lslgt r8, r11, #16
8380222e
SH
79 addle r8, #8
801:
81 /* RX */
82
83 /* shall we receive? */
7095b956
DM
84 ldr r11, [r12, #SSI_SIER]
85 tst r11, #SSI_SIER_RFF0_EN
8380222e
SH
86 beq 1f
87
88 /* RX FIFO full? */
7095b956
DM
89 ldr r11, [r12, #SSI_SISR]
90 tst r11, #SSI_SISR_RFF0
8380222e
SH
91 beq 1f
92
7095b956 93 ldr r13, .L_imx_ssi_fiq_rx_buffer
8380222e
SH
94
95 mov r10, #0x10000
96 sub r10, #1
97 and r10, r10, r9 /* r10: current buffer offset */
98
7095b956 99 add r13, r13, r10
8380222e 100
7095b956
DM
101 ldr r11, [r12, #SSI_SACNT]
102 tst r11, #SSI_SACNT_AC97EN
8380222e 103
7095b956
DM
104 ldr r11, [r12, #SSI_SRX0]
105 strh r11, [r13]
8380222e 106
7095b956
DM
107 ldr r11, [r12, #SSI_SRX0]
108 strh r11, [r13, #2]
8380222e
SH
109
110 /* dummy read to skip slot 12 */
7095b956 111 ldrne r11, [r12, #SSI_SRX0]
8380222e 112
7095b956
DM
113 ldr r11, [r12, #SSI_SRX0]
114 strh r11, [r13, #4]
8380222e 115
7095b956
DM
116 ldr r11, [r12, #SSI_SRX0]
117 strh r11, [r13, #6]
8380222e
SH
118
119 /* dummy read to skip slot 12 */
7095b956 120 ldrne r11, [r12, #SSI_SRX0]
8380222e
SH
121
122 add r10, #8
7095b956
DM
123 lsr r11, r9, #16 /* r11: buffer size */
124 cmp r10, r11
125 lslgt r9, r11, #16
8380222e
SH
126 addle r9, #8
127
1281:
129 @ return from FIQ
130 subs pc, lr, #4
0575b4b8
DM
131
132 .align
7095b956 133.L_imx_ssi_fiq_base:
8380222e
SH
134imx_ssi_fiq_base:
135 .word 0x0
7095b956 136.L_imx_ssi_fiq_rx_buffer:
8380222e
SH
137imx_ssi_fiq_rx_buffer:
138 .word 0x0
7095b956 139.L_imx_ssi_fiq_tx_buffer:
8380222e
SH
140imx_ssi_fiq_tx_buffer:
141 .word 0x0
7095b956 142.L_imx_ssi_fiq_end:
8380222e 143imx_ssi_fiq_end:
8478132a 144