Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 1 | /* |
| 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 Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 37 | /* |
| 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 Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 44 | imx_ssi_fiq_start: |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 45 | ldr r12, .L_imx_ssi_fiq_base |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 46 | |
| 47 | /* TX */ |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 48 | ldr r13, .L_imx_ssi_fiq_tx_buffer |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 49 | |
| 50 | /* shall we send? */ |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 51 | ldr r11, [r12, #SSI_SIER] |
| 52 | tst r11, #SSI_SIER_TFE0_EN |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 53 | beq 1f |
| 54 | |
| 55 | /* TX FIFO empty? */ |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 56 | ldr r11, [r12, #SSI_SISR] |
| 57 | tst r11, #SSI_SISR_TFE0 |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 58 | beq 1f |
| 59 | |
| 60 | mov r10, #0x10000 |
| 61 | sub r10, #1 |
| 62 | and r10, r10, r8 /* r10: current buffer offset */ |
| 63 | |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 64 | add r13, r13, r10 |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 65 | |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 66 | ldrh r11, [r13] |
| 67 | strh r11, [r12, #SSI_STX0] |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 68 | |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 69 | ldrh r11, [r13, #2] |
| 70 | strh r11, [r12, #SSI_STX0] |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 71 | |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 72 | ldrh r11, [r13, #4] |
| 73 | strh r11, [r12, #SSI_STX0] |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 74 | |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 75 | ldrh r11, [r13, #6] |
| 76 | strh r11, [r12, #SSI_STX0] |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 77 | |
| 78 | add r10, #8 |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 79 | lsr r11, r8, #16 /* r11: buffer size */ |
| 80 | cmp r10, r11 |
| 81 | lslgt r8, r11, #16 |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 82 | addle r8, #8 |
| 83 | 1: |
| 84 | /* RX */ |
| 85 | |
| 86 | /* shall we receive? */ |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 87 | ldr r11, [r12, #SSI_SIER] |
| 88 | tst r11, #SSI_SIER_RFF0_EN |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 89 | beq 1f |
| 90 | |
| 91 | /* RX FIFO full? */ |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 92 | ldr r11, [r12, #SSI_SISR] |
| 93 | tst r11, #SSI_SISR_RFF0 |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 94 | beq 1f |
| 95 | |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 96 | ldr r13, .L_imx_ssi_fiq_rx_buffer |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 97 | |
| 98 | mov r10, #0x10000 |
| 99 | sub r10, #1 |
| 100 | and r10, r10, r9 /* r10: current buffer offset */ |
| 101 | |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 102 | add r13, r13, r10 |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 103 | |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 104 | ldr r11, [r12, #SSI_SACNT] |
| 105 | tst r11, #SSI_SACNT_AC97EN |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 106 | |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 107 | ldr r11, [r12, #SSI_SRX0] |
| 108 | strh r11, [r13] |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 109 | |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 110 | ldr r11, [r12, #SSI_SRX0] |
| 111 | strh r11, [r13, #2] |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 112 | |
| 113 | /* dummy read to skip slot 12 */ |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 114 | ldrne r11, [r12, #SSI_SRX0] |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 115 | |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 116 | ldr r11, [r12, #SSI_SRX0] |
| 117 | strh r11, [r13, #4] |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 118 | |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 119 | ldr r11, [r12, #SSI_SRX0] |
| 120 | strh r11, [r13, #6] |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 121 | |
| 122 | /* dummy read to skip slot 12 */ |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 123 | ldrne r11, [r12, #SSI_SRX0] |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 124 | |
| 125 | add r10, #8 |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 126 | lsr r11, r9, #16 /* r11: buffer size */ |
| 127 | cmp r10, r11 |
| 128 | lslgt r9, r11, #16 |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 129 | addle r9, #8 |
| 130 | |
| 131 | 1: |
| 132 | @ return from FIQ |
| 133 | subs pc, lr, #4 |
Dave Martin | 0575b4b | 2010-11-16 13:13:37 +0000 | [diff] [blame] | 134 | |
| 135 | .align |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 136 | .L_imx_ssi_fiq_base: |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 137 | imx_ssi_fiq_base: |
| 138 | .word 0x0 |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 139 | .L_imx_ssi_fiq_rx_buffer: |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 140 | imx_ssi_fiq_rx_buffer: |
| 141 | .word 0x0 |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 142 | .L_imx_ssi_fiq_tx_buffer: |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 143 | imx_ssi_fiq_tx_buffer: |
| 144 | .word 0x0 |
Dave Martin | 7095b95 | 2012-08-10 12:53:24 +0100 | [diff] [blame] | 145 | .L_imx_ssi_fiq_end: |
Sascha Hauer | 8380222 | 2009-11-25 16:41:04 +0100 | [diff] [blame] | 146 | imx_ssi_fiq_end: |
| 147 | |