blob: a8b93c5f29b5321a3b0ef341cfb07d601218a2d2 [file] [log] [blame]
Sascha Hauer83802222009-11-25 16:41:04 +01001/*
2 * Copyright (C) 2009 Sascha Hauer <s.hauer@pengutronix.de>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/linkage.h>
10#include <asm/assembler.h>
11
12/*
13 * r8 = bit 0-15: tx offset, bit 16-31: tx buffer size
14 * r9 = bit 0-15: rx offset, bit 16-31: rx buffer size
15 */
16
17#define SSI_STX0 0x00
18#define SSI_SRX0 0x08
19#define SSI_SISR 0x14
20#define SSI_SIER 0x18
21#define SSI_SACNT 0x38
22
23#define SSI_SACNT_AC97EN (1 << 0)
24
25#define SSI_SIER_TFE0_EN (1 << 0)
26#define SSI_SISR_TFE0 (1 << 0)
27#define SSI_SISR_RFF0 (1 << 2)
28#define SSI_SIER_RFF0_EN (1 << 2)
29
30 .text
31 .global imx_ssi_fiq_start
32 .global imx_ssi_fiq_end
33 .global imx_ssi_fiq_base
34 .global imx_ssi_fiq_rx_buffer
35 .global imx_ssi_fiq_tx_buffer
36
Dave Martin7095b952012-08-10 12:53:24 +010037/*
38 * imx_ssi_fiq_start is _intentionally_ not marked as a function symbol
39 * using ENDPROC(). imx_ssi_fiq_start and imx_ssi_fiq_end are used to
40 * mark the function body so that it can be copied to the FIQ vector in
41 * the vectors page. imx_ssi_fiq_start should only be called as the result
42 * of an FIQ: calling it directly will not work.
43 */
Sascha Hauer83802222009-11-25 16:41:04 +010044imx_ssi_fiq_start:
Dave Martin7095b952012-08-10 12:53:24 +010045 ldr r12, .L_imx_ssi_fiq_base
Sascha Hauer83802222009-11-25 16:41:04 +010046
47 /* TX */
Dave Martin7095b952012-08-10 12:53:24 +010048 ldr r13, .L_imx_ssi_fiq_tx_buffer
Sascha Hauer83802222009-11-25 16:41:04 +010049
50 /* shall we send? */
Dave Martin7095b952012-08-10 12:53:24 +010051 ldr r11, [r12, #SSI_SIER]
52 tst r11, #SSI_SIER_TFE0_EN
Sascha Hauer83802222009-11-25 16:41:04 +010053 beq 1f
54
55 /* TX FIFO empty? */
Dave Martin7095b952012-08-10 12:53:24 +010056 ldr r11, [r12, #SSI_SISR]
57 tst r11, #SSI_SISR_TFE0
Sascha Hauer83802222009-11-25 16:41:04 +010058 beq 1f
59
60 mov r10, #0x10000
61 sub r10, #1
62 and r10, r10, r8 /* r10: current buffer offset */
63
Dave Martin7095b952012-08-10 12:53:24 +010064 add r13, r13, r10
Sascha Hauer83802222009-11-25 16:41:04 +010065
Dave Martin7095b952012-08-10 12:53:24 +010066 ldrh r11, [r13]
67 strh r11, [r12, #SSI_STX0]
Sascha Hauer83802222009-11-25 16:41:04 +010068
Dave Martin7095b952012-08-10 12:53:24 +010069 ldrh r11, [r13, #2]
70 strh r11, [r12, #SSI_STX0]
Sascha Hauer83802222009-11-25 16:41:04 +010071
Dave Martin7095b952012-08-10 12:53:24 +010072 ldrh r11, [r13, #4]
73 strh r11, [r12, #SSI_STX0]
Sascha Hauer83802222009-11-25 16:41:04 +010074
Dave Martin7095b952012-08-10 12:53:24 +010075 ldrh r11, [r13, #6]
76 strh r11, [r12, #SSI_STX0]
Sascha Hauer83802222009-11-25 16:41:04 +010077
78 add r10, #8
Dave Martin7095b952012-08-10 12:53:24 +010079 lsr r11, r8, #16 /* r11: buffer size */
80 cmp r10, r11
81 lslgt r8, r11, #16
Sascha Hauer83802222009-11-25 16:41:04 +010082 addle r8, #8
831:
84 /* RX */
85
86 /* shall we receive? */
Dave Martin7095b952012-08-10 12:53:24 +010087 ldr r11, [r12, #SSI_SIER]
88 tst r11, #SSI_SIER_RFF0_EN
Sascha Hauer83802222009-11-25 16:41:04 +010089 beq 1f
90
91 /* RX FIFO full? */
Dave Martin7095b952012-08-10 12:53:24 +010092 ldr r11, [r12, #SSI_SISR]
93 tst r11, #SSI_SISR_RFF0
Sascha Hauer83802222009-11-25 16:41:04 +010094 beq 1f
95
Dave Martin7095b952012-08-10 12:53:24 +010096 ldr r13, .L_imx_ssi_fiq_rx_buffer
Sascha Hauer83802222009-11-25 16:41:04 +010097
98 mov r10, #0x10000
99 sub r10, #1
100 and r10, r10, r9 /* r10: current buffer offset */
101
Dave Martin7095b952012-08-10 12:53:24 +0100102 add r13, r13, r10
Sascha Hauer83802222009-11-25 16:41:04 +0100103
Dave Martin7095b952012-08-10 12:53:24 +0100104 ldr r11, [r12, #SSI_SACNT]
105 tst r11, #SSI_SACNT_AC97EN
Sascha Hauer83802222009-11-25 16:41:04 +0100106
Dave Martin7095b952012-08-10 12:53:24 +0100107 ldr r11, [r12, #SSI_SRX0]
108 strh r11, [r13]
Sascha Hauer83802222009-11-25 16:41:04 +0100109
Dave Martin7095b952012-08-10 12:53:24 +0100110 ldr r11, [r12, #SSI_SRX0]
111 strh r11, [r13, #2]
Sascha Hauer83802222009-11-25 16:41:04 +0100112
113 /* dummy read to skip slot 12 */
Dave Martin7095b952012-08-10 12:53:24 +0100114 ldrne r11, [r12, #SSI_SRX0]
Sascha Hauer83802222009-11-25 16:41:04 +0100115
Dave Martin7095b952012-08-10 12:53:24 +0100116 ldr r11, [r12, #SSI_SRX0]
117 strh r11, [r13, #4]
Sascha Hauer83802222009-11-25 16:41:04 +0100118
Dave Martin7095b952012-08-10 12:53:24 +0100119 ldr r11, [r12, #SSI_SRX0]
120 strh r11, [r13, #6]
Sascha Hauer83802222009-11-25 16:41:04 +0100121
122 /* dummy read to skip slot 12 */
Dave Martin7095b952012-08-10 12:53:24 +0100123 ldrne r11, [r12, #SSI_SRX0]
Sascha Hauer83802222009-11-25 16:41:04 +0100124
125 add r10, #8
Dave Martin7095b952012-08-10 12:53:24 +0100126 lsr r11, r9, #16 /* r11: buffer size */
127 cmp r10, r11
128 lslgt r9, r11, #16
Sascha Hauer83802222009-11-25 16:41:04 +0100129 addle r9, #8
130
1311:
132 @ return from FIQ
133 subs pc, lr, #4
Dave Martin0575b4b2010-11-16 13:13:37 +0000134
135 .align
Dave Martin7095b952012-08-10 12:53:24 +0100136.L_imx_ssi_fiq_base:
Sascha Hauer83802222009-11-25 16:41:04 +0100137imx_ssi_fiq_base:
138 .word 0x0
Dave Martin7095b952012-08-10 12:53:24 +0100139.L_imx_ssi_fiq_rx_buffer:
Sascha Hauer83802222009-11-25 16:41:04 +0100140imx_ssi_fiq_rx_buffer:
141 .word 0x0
Dave Martin7095b952012-08-10 12:53:24 +0100142.L_imx_ssi_fiq_tx_buffer:
Sascha Hauer83802222009-11-25 16:41:04 +0100143imx_ssi_fiq_tx_buffer:
144 .word 0x0
Dave Martin7095b952012-08-10 12:53:24 +0100145.L_imx_ssi_fiq_end:
Sascha Hauer83802222009-11-25 16:41:04 +0100146imx_ssi_fiq_end:
147