mfd: wm8350-i2c: Make sure the i2c regmap functions are compiled
[linux/fpc-iii.git] / drivers / staging / sbe-2t3e3 / exar7250.c
blobe3ddd140207e215e17ed6ec58b7b0e72fa138ceb
1 /*
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.
13 #include "2t3e3.h"
14 #include "ctrl.h"
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)
34 u32 val;
36 switch (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:
41 break;
42 default:
43 return;
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);
52 switch (type) {
53 case SBE_2T3E3_FRAME_TYPE_E3_G751:
54 val |= SBE_2T3E3_FRAMER_VAL_E3_G751;
55 break;
56 case SBE_2T3E3_FRAME_TYPE_E3_G832:
57 val |= SBE_2T3E3_FRAMER_VAL_E3_G832;
58 break;
59 case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
60 val |= SBE_2T3E3_FRAMER_VAL_T3_CBIT;
61 break;
62 case SBE_2T3E3_FRAME_TYPE_T3_M13:
63 val |= SBE_2T3E3_FRAMER_VAL_T3_M13;
64 break;
65 default:
66 return;
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)
75 u32 val;
77 switch (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 cpld_LOS_update(sc);
84 sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
85 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1);
86 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1,
87 SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
88 SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE);
90 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2);
91 break;
93 case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
94 case SBE_2T3E3_FRAME_TYPE_T3_M13:
95 val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
97 cpld_LOS_update(sc);
99 sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
101 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS);
102 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE,
103 SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
104 SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE);
106 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS);
108 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL, 0);
109 break;
111 default:
112 return;
115 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS);
116 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE,
117 SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_ENABLE |
118 SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_ENABLE);
122 void exar7250_stop_intr(struct channel *sc, u32 type)
124 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE, 0);
125 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS);
127 switch (type) {
128 case SBE_2T3E3_FRAME_TYPE_E3_G751:
129 case SBE_2T3E3_FRAME_TYPE_E3_G832:
130 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1, 0);
131 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1);
132 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2, 0);
133 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2);
134 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_CONTROL, 0);
135 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_CONTROL);
136 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS, 0);
137 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS);
138 break;
140 case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
141 case SBE_2T3E3_FRAME_TYPE_T3_M13:
142 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE, 0);
143 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS);
144 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS, 0);
145 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS);
146 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL, 0);
147 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL);
148 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS, 0);
149 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS);
150 exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS, 0);
151 exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS);
152 break;
159 void exar7250_unipolar_onoff(struct channel *sc, u32 mode)
161 switch (mode) {
162 case SBE_2T3E3_OFF:
163 exar7300_clear_bit(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL,
164 SBE_2T3E3_FRAMER_VAL_UNIPOLAR);
165 break;
166 case SBE_2T3E3_ON:
167 exar7300_set_bit(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL,
168 SBE_2T3E3_FRAMER_VAL_UNIPOLAR);
169 break;
173 void exar7250_set_loopback(struct channel *sc, u32 mode)
175 switch (mode) {
176 case SBE_2T3E3_FRAMER_VAL_LOOPBACK_OFF:
177 exar7300_clear_bit(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE,
178 SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE);
179 break;
180 case SBE_2T3E3_FRAMER_VAL_LOOPBACK_ON:
181 exar7300_set_bit(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE,
182 SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE);
183 break;