2 * SBE 2T3E3 synchronous serial card driver for Linux
4 * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License
8 * as published by the Free Software Foundation.
10 * This code is based on a driver written by SBE Inc.
16 void exar7250_init(struct channel
*sc
)
18 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_OPERATING_MODE
,
19 SBE_2T3E3_FRAMER_VAL_T3_CBIT
|
20 SBE_2T3E3_FRAMER_VAL_INTERRUPT_ENABLE_RESET
|
21 SBE_2T3E3_FRAMER_VAL_TIMING_ASYNCH_TXINCLK
);
23 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_IO_CONTROL
,
24 SBE_2T3E3_FRAMER_VAL_DISABLE_TX_LOSS_OF_CLOCK
|
25 SBE_2T3E3_FRAMER_VAL_DISABLE_RX_LOSS_OF_CLOCK
|
26 SBE_2T3E3_FRAMER_VAL_AMI_LINE_CODE
|
27 SBE_2T3E3_FRAMER_VAL_RX_LINE_CLOCK_INVERT
);
29 exar7250_set_frame_type(sc
, SBE_2T3E3_FRAME_TYPE_T3_CBIT
);
32 void exar7250_set_frame_type(struct channel
*sc
, u32 type
)
37 case SBE_2T3E3_FRAME_TYPE_E3_G751
:
38 case SBE_2T3E3_FRAME_TYPE_E3_G832
:
39 case SBE_2T3E3_FRAME_TYPE_T3_CBIT
:
40 case SBE_2T3E3_FRAME_TYPE_T3_M13
:
46 exar7250_stop_intr(sc
, type
);
48 val
= exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_OPERATING_MODE
);
49 val
&= ~(SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE
|
50 SBE_2T3E3_FRAMER_VAL_T3_E3_SELECT
|
51 SBE_2T3E3_FRAMER_VAL_FRAME_FORMAT_SELECT
);
53 case SBE_2T3E3_FRAME_TYPE_E3_G751
:
54 val
|= SBE_2T3E3_FRAMER_VAL_E3_G751
;
56 case SBE_2T3E3_FRAME_TYPE_E3_G832
:
57 val
|= SBE_2T3E3_FRAMER_VAL_E3_G832
;
59 case SBE_2T3E3_FRAME_TYPE_T3_CBIT
:
60 val
|= SBE_2T3E3_FRAMER_VAL_T3_CBIT
;
62 case SBE_2T3E3_FRAME_TYPE_T3_M13
:
63 val
|= SBE_2T3E3_FRAMER_VAL_T3_M13
;
68 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_OPERATING_MODE
, val
);
69 exar7250_start_intr(sc
, type
);
73 void exar7250_start_intr(struct channel
*sc
, u32 type
)
78 case SBE_2T3E3_FRAME_TYPE_E3_G751
:
79 case SBE_2T3E3_FRAME_TYPE_E3_G832
:
80 val
= exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2
);
82 sc
->s
.LOS
= val
& SBE_2T3E3_FRAMER_VAL_E3_RX_LOS
? 1 : 0;
86 sc
->s
.OOF
= val
& SBE_2T3E3_FRAMER_VAL_E3_RX_OOF
? 1 : 0;
87 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1
);
88 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1
,
89 SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE
|
90 SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE
);
92 /*SBE_2T3E3_FRAMER_VAL_E3_RX_COFA_INTERRUPT_ENABLE |
93 SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
94 SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_INTERRUPT_ENABLE |
95 SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE |
96 SBE_2T3E3_FRAMER_VAL_E3_RX_AIS_INTERRUPT_ENABLE);*/
99 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2
);
101 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2
,
102 SBE_2T3E3_FRAMER_VAL_E3_RX_FEBE_INTERRUPT_ENABLE
|
103 SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_INTERRUPT_ENABLE
|
104 SBE_2T3E3_FRAMER_VAL_E3_RX_FRAMING_BYTE_ERROR_INTERRUPT_ENABLE
);
108 case SBE_2T3E3_FRAME_TYPE_T3_CBIT
:
109 case SBE_2T3E3_FRAME_TYPE_T3_M13
:
110 val
= exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS
);
112 sc
->s
.LOS
= val
& SBE_2T3E3_FRAMER_VAL_T3_RX_LOS
? 1 : 0;
116 sc
->s
.OOF
= val
& SBE_2T3E3_FRAMER_VAL_T3_RX_OOF
? 1 : 0;
118 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS
);
119 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE
,
120 SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE
|
121 SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE
);
123 /* SBE_2T3E3_FRAMER_VAL_T3_RX_CP_BIT_ERROR_INTERRUPT_ENABLE |
124 SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
125 SBE_2T3E3_FRAMER_VAL_T3_RX_AIS_INTERRUPT_ENABLE |
126 SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE_INTERRUPT_ENABLE |
127 SBE_2T3E3_FRAMER_VAL_T3_RX_FERF_INTERRUPT_ENABLE |
128 SBE_2T3E3_FRAMER_VAL_T3_RX_AIC_INTERRUPT_ENABLE |
129 SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE |
130 SBE_2T3E3_FRAMER_VAL_T3_RX_P_BIT_INTERRUPT_ENABLE);*/
133 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS
);
135 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS
,
136 SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_REMOVE_INTERRUPT_ENABLE
|
137 SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID_INTERRUPT_ENABLE
);
140 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL
, 0);
147 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS
);
148 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE
,
149 SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_ENABLE
|
150 SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_ENABLE
);
154 void exar7250_stop_intr(struct channel
*sc
, u32 type
)
156 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE
, 0);
157 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS
);
160 case SBE_2T3E3_FRAME_TYPE_E3_G751
:
161 case SBE_2T3E3_FRAME_TYPE_E3_G832
:
162 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1
, 0);
163 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1
);
164 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2
, 0);
165 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2
);
166 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_CONTROL
, 0);
167 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_CONTROL
);
168 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS
, 0);
169 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS
);
172 case SBE_2T3E3_FRAME_TYPE_T3_CBIT
:
173 case SBE_2T3E3_FRAME_TYPE_T3_M13
:
174 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE
, 0);
175 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS
);
176 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS
, 0);
177 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS
);
178 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL
, 0);
179 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL
);
180 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS
, 0);
181 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS
);
182 exar7250_write(sc
, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS
, 0);
183 exar7250_read(sc
, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS
);
191 void exar7250_unipolar_onoff(struct channel
*sc
, u32 mode
)
195 exar7300_clear_bit(sc
, SBE_2T3E3_FRAMER_REG_IO_CONTROL
,
196 SBE_2T3E3_FRAMER_VAL_UNIPOLAR
);
199 exar7300_set_bit(sc
, SBE_2T3E3_FRAMER_REG_IO_CONTROL
,
200 SBE_2T3E3_FRAMER_VAL_UNIPOLAR
);
205 void exar7250_set_loopback(struct channel
*sc
, u32 mode
)
208 case SBE_2T3E3_FRAMER_VAL_LOOPBACK_OFF
:
209 exar7300_clear_bit(sc
, SBE_2T3E3_FRAMER_REG_OPERATING_MODE
,
210 SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE
);
212 case SBE_2T3E3_FRAMER_VAL_LOOPBACK_ON
:
213 exar7300_set_bit(sc
, SBE_2T3E3_FRAMER_REG_OPERATING_MODE
,
214 SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE
);